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
|
|
|
|
2021-03-09 19:37:12 +00:00
|
|
|
ScrollView {
|
2020-12-22 15:47:48 +00:00
|
|
|
id: settings
|
2020-12-22 00:01:36 +00:00
|
|
|
|
|
|
|
signal changed()
|
|
|
|
|
2020-12-23 23:06:52 +00:00
|
|
|
property int settingWidth: settings.width
|
2020-12-22 00:01:36 +00:00
|
|
|
|
|
|
|
property int xzoom: 100
|
|
|
|
property int yzoom: 10
|
|
|
|
property double xmin: 5/10
|
|
|
|
property double ymax: 25
|
2020-12-25 18:55:47 +00:00
|
|
|
property string xaxisstep: "4"
|
2020-12-23 23:06:52 +00:00
|
|
|
property string yaxisstep: "4"
|
|
|
|
property string xaxislabel: ""
|
|
|
|
property string yaxislabel: ""
|
2021-03-31 22:29:05 +00:00
|
|
|
property double linewidth: 1
|
|
|
|
property double textsize: 14
|
2020-12-25 15:44:53 +00:00
|
|
|
property bool logscalex: true
|
2020-12-22 00:01:36 +00:00
|
|
|
property string saveFilename: ""
|
2021-01-26 17:36:21 +00:00
|
|
|
property bool showxgrad: true
|
|
|
|
property bool showygrad: true
|
2020-12-22 00:01:36 +00:00
|
|
|
|
2021-03-09 19:37:12 +00:00
|
|
|
Column {
|
2021-03-31 22:29:05 +00:00
|
|
|
//height: 30*12 //30*Math.max(1, Math.ceil(7 / columns))
|
2021-03-09 19:37:12 +00:00
|
|
|
//columns: Math.floor(width / settingWidth)
|
|
|
|
spacing: 10
|
2021-03-31 22:29:05 +00:00
|
|
|
|
2021-03-09 19:37:12 +00:00
|
|
|
FileDialog {
|
|
|
|
id: fdiag
|
|
|
|
onAccepted: {
|
|
|
|
var filePath = fileUrl.toString().substr(7)
|
|
|
|
settings.saveFilename = filePath
|
|
|
|
if(exportMode) {
|
|
|
|
root.saveDiagram(filePath)
|
|
|
|
} else {
|
|
|
|
root.loadDiagram(filePath)
|
|
|
|
if(xAxisLabel.find(settings.xaxislabel) == -1) xAxisLabel.model.append({text: settings.xaxislabel})
|
|
|
|
xAxisLabel.editText = settings.xaxislabel
|
|
|
|
if(yAxisLabel.find(settings.yaxislabel) == -1) yAxisLabel.model.append({text: settings.yaxislabel})
|
|
|
|
yAxisLabel.editText = settings.yaxislabel
|
|
|
|
}
|
2020-12-22 00:01:36 +00:00
|
|
|
}
|
|
|
|
}
|
2021-03-09 19:37:12 +00:00
|
|
|
|
|
|
|
// Zoom
|
|
|
|
TextSetting {
|
|
|
|
id: zoomX
|
|
|
|
height: 30
|
|
|
|
isInt: true
|
|
|
|
label: "X Zoom"
|
|
|
|
min: 1
|
|
|
|
width: settings.settingWidth
|
|
|
|
defValue: settings.xzoom
|
|
|
|
onChanged: function(newValue) {
|
|
|
|
settings.xzoom = newValue
|
|
|
|
settings.changed()
|
|
|
|
}
|
2020-12-22 00:01:36 +00:00
|
|
|
}
|
2021-03-31 13:58:21 +00:00
|
|
|
|
2021-03-09 19:37:12 +00:00
|
|
|
TextSetting {
|
|
|
|
id: zoomY
|
|
|
|
height: 30
|
|
|
|
isInt: true
|
|
|
|
label: "Y Zoom"
|
|
|
|
width: settings.settingWidth
|
|
|
|
defValue: settings.yzoom
|
|
|
|
onChanged: function(newValue) {
|
|
|
|
settings.yzoom = newValue
|
|
|
|
settings.changed()
|
|
|
|
}
|
2020-12-22 00:01:36 +00:00
|
|
|
}
|
2021-03-31 13:58:21 +00:00
|
|
|
|
2021-03-09 19:37:12 +00:00
|
|
|
// Positioning the graph
|
|
|
|
TextSetting {
|
|
|
|
id: minX
|
|
|
|
height: 30
|
|
|
|
isDouble: true
|
|
|
|
min: -Infinity
|
|
|
|
label: "Min X"
|
2021-03-31 13:58:21 +00:00
|
|
|
icon: "icons/settings/xmin.svg"
|
2021-03-09 19:37:12 +00:00
|
|
|
width: settings.settingWidth
|
|
|
|
defValue: settings.xmin
|
|
|
|
onChanged: function(newValue) {
|
|
|
|
settings.xmin = newValue
|
|
|
|
settings.changed()
|
|
|
|
}
|
2020-12-22 00:01:36 +00:00
|
|
|
}
|
2021-03-31 13:58:21 +00:00
|
|
|
|
2021-03-09 19:37:12 +00:00
|
|
|
TextSetting {
|
|
|
|
id: maxY
|
|
|
|
height: 30
|
|
|
|
isDouble: true
|
|
|
|
label: "Max Y"
|
2021-03-31 13:58:21 +00:00
|
|
|
icon: "icons/settings/ymax.svg"
|
2021-03-09 19:37:12 +00:00
|
|
|
width: settings.settingWidth
|
|
|
|
defValue: settings.ymax
|
|
|
|
onChanged: function(newValue) {
|
|
|
|
settings.ymax = newValue
|
|
|
|
settings.changed()
|
|
|
|
}
|
2020-12-22 00:01:36 +00:00
|
|
|
}
|
2021-03-31 13:58:21 +00:00
|
|
|
|
2021-03-31 22:29:05 +00:00
|
|
|
TextSetting {
|
|
|
|
id: xAxisStep
|
|
|
|
height: 30
|
|
|
|
label: "X Axis Step"
|
|
|
|
icon: "icons/settings/xaxisstep.svg"
|
|
|
|
width: settings.settingWidth
|
|
|
|
defValue: settings.xaxisstep
|
|
|
|
visible: !settings.logscalex
|
|
|
|
onChanged: function(newValue) {
|
|
|
|
settings.xaxisstep = newValue
|
|
|
|
settings.changed()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-09 19:37:12 +00:00
|
|
|
TextSetting {
|
|
|
|
id: yAxisStep
|
|
|
|
height: 30
|
|
|
|
label: "Y Axis Step"
|
2021-03-31 13:58:21 +00:00
|
|
|
icon: "icons/settings/yaxisstep.svg"
|
2021-03-09 19:37:12 +00:00
|
|
|
width: settings.settingWidth
|
|
|
|
defValue: settings.yaxisstep
|
|
|
|
onChanged: function(newValue) {
|
|
|
|
settings.yaxisstep = newValue
|
|
|
|
settings.changed()
|
|
|
|
}
|
2020-12-22 00:01:36 +00:00
|
|
|
}
|
2021-03-09 19:37:12 +00:00
|
|
|
|
|
|
|
TextSetting {
|
2021-03-31 22:29:05 +00:00
|
|
|
id: lineWidth
|
2021-03-09 19:37:12 +00:00
|
|
|
height: 30
|
2021-03-31 22:29:05 +00:00
|
|
|
isDouble: true
|
|
|
|
label: "Line width"
|
|
|
|
min: 1
|
|
|
|
icon: "icons/settings/linewidth.svg"
|
2021-03-09 19:37:12 +00:00
|
|
|
width: settings.settingWidth
|
2021-03-31 22:29:05 +00:00
|
|
|
defValue: settings.linewidth
|
2021-03-09 19:37:12 +00:00
|
|
|
onChanged: function(newValue) {
|
2021-03-31 22:29:05 +00:00
|
|
|
settings.linewidth = newValue
|
|
|
|
settings.changed()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TextSetting {
|
|
|
|
id: textSize
|
|
|
|
height: 30
|
|
|
|
isDouble: true
|
|
|
|
label: "Text size (px)"
|
|
|
|
min: 1
|
|
|
|
icon: "icons/settings/textsize.svg"
|
|
|
|
width: settings.settingWidth
|
|
|
|
defValue: settings.textsize
|
|
|
|
onChanged: function(newValue) {
|
|
|
|
settings.textsize = newValue
|
2021-03-09 19:37:12 +00:00
|
|
|
settings.changed()
|
|
|
|
}
|
2020-12-25 18:55:47 +00:00
|
|
|
}
|
2021-03-09 19:37:12 +00:00
|
|
|
|
|
|
|
ComboBoxSetting {
|
|
|
|
id: xAxisLabel
|
|
|
|
height: 30
|
|
|
|
width: settings.settingWidth
|
|
|
|
label: 'X Label'
|
2021-03-31 13:58:21 +00:00
|
|
|
icon: "icons/settings/xlabel.svg"
|
2021-03-09 19:37:12 +00:00
|
|
|
model: ListModel {
|
|
|
|
ListElement { text: "" }
|
|
|
|
ListElement { text: "x" }
|
|
|
|
ListElement { text: "ω (rad/s)" }
|
|
|
|
}
|
|
|
|
currentIndex: find(settings.xaxislabel)
|
|
|
|
editable: true
|
|
|
|
onAccepted: function(){
|
|
|
|
editText = Utils.parseName(editText, false)
|
|
|
|
if (find(editText) === -1) model.append({text: editText})
|
|
|
|
settings.xaxislabel = editText
|
|
|
|
settings.changed()
|
|
|
|
}
|
|
|
|
onActivated: function(selectedId) {
|
|
|
|
settings.xaxislabel = model.get(selectedId).text
|
|
|
|
settings.changed()
|
|
|
|
}
|
|
|
|
Component.onCompleted: editText = settings.xaxislabel
|
2020-12-23 23:06:52 +00:00
|
|
|
}
|
2021-03-09 19:37:12 +00:00
|
|
|
|
|
|
|
ComboBoxSetting {
|
|
|
|
id: yAxisLabel
|
|
|
|
height: 30
|
|
|
|
width: settings.settingWidth
|
|
|
|
label: 'Y Label'
|
2021-03-31 13:58:21 +00:00
|
|
|
icon: "icons/settings/ylabel.svg"
|
2021-03-09 19:37:12 +00:00
|
|
|
model: ListModel {
|
|
|
|
ListElement { text: "" }
|
|
|
|
ListElement { text: "y" }
|
|
|
|
ListElement { text: "G (dB)" }
|
|
|
|
ListElement { text: "φ (°)" }
|
|
|
|
ListElement { text: "φ (deg)" }
|
|
|
|
ListElement { text: "φ (rad)" }
|
|
|
|
}
|
|
|
|
currentIndex: find(settings.yaxislabel)
|
|
|
|
editable: true
|
|
|
|
onAccepted: function(){
|
|
|
|
editText = Utils.parseName(editText, false)
|
|
|
|
if (find(editText) === -1) model.append({text: editText, yaxisstep: root.yaxisstep})
|
|
|
|
settings.yaxislabel = editText
|
|
|
|
settings.changed()
|
|
|
|
}
|
|
|
|
onActivated: function(selectedId) {
|
|
|
|
settings.yaxislabel = model.get(selectedId).text
|
|
|
|
settings.changed()
|
|
|
|
}
|
|
|
|
Component.onCompleted: editText = settings.yaxislabel
|
2020-12-23 23:06:52 +00:00
|
|
|
}
|
2021-03-09 19:37:12 +00:00
|
|
|
|
|
|
|
CheckBox {
|
|
|
|
id: logScaleX
|
|
|
|
checked: settings.logscalex
|
|
|
|
text: 'X Log scale'
|
|
|
|
onClicked: {
|
|
|
|
settings.logscalex = checked
|
|
|
|
settings.changed()
|
|
|
|
}
|
2020-12-22 00:01:36 +00:00
|
|
|
}
|
2021-03-09 19:37:12 +00:00
|
|
|
|
|
|
|
CheckBox {
|
|
|
|
id: showXGrad
|
|
|
|
checked: settings.showxgrad
|
|
|
|
text: 'Show X graduation'
|
|
|
|
onClicked: {
|
|
|
|
settings.showxgrad = checked
|
|
|
|
settings.changed()
|
|
|
|
}
|
2020-12-23 23:06:52 +00:00
|
|
|
}
|
2021-03-09 19:37:12 +00:00
|
|
|
|
|
|
|
CheckBox {
|
|
|
|
id: showYGrad
|
|
|
|
checked: settings.showygrad
|
|
|
|
text: 'Show Y graduation'
|
|
|
|
onClicked: {
|
|
|
|
settings.showygrad = checked
|
|
|
|
settings.changed()
|
|
|
|
}
|
2020-12-22 00:01:36 +00:00
|
|
|
}
|
2021-03-09 19:37:12 +00:00
|
|
|
|
|
|
|
Button {
|
|
|
|
id: copyToClipboard
|
|
|
|
height: 30
|
|
|
|
width: settings.settingWidth
|
|
|
|
text: "Copy to clipboard"
|
|
|
|
icon.name: 'editcopy'
|
|
|
|
onClicked: root.copyDiagramToClipboard()
|
2020-12-23 23:06:52 +00:00
|
|
|
}
|
2021-03-09 19:37:12 +00:00
|
|
|
|
|
|
|
Button {
|
|
|
|
id: saveDiagram
|
|
|
|
height: 30
|
|
|
|
width: settings.settingWidth
|
|
|
|
text: "Save diagram"
|
|
|
|
icon.name: 'filesave'
|
|
|
|
onClicked: save()
|
2020-12-25 15:44:53 +00:00
|
|
|
}
|
2021-03-09 19:37:12 +00:00
|
|
|
|
|
|
|
Button {
|
|
|
|
id: saveDiagramAs
|
|
|
|
height: 30
|
|
|
|
width: settings.settingWidth
|
|
|
|
text: "Save diagram as"
|
|
|
|
icon.name: 'filesaveas'
|
|
|
|
onClicked: saveAs()
|
2021-01-26 17:36:21 +00:00
|
|
|
}
|
2021-03-09 19:37:12 +00:00
|
|
|
|
|
|
|
Button {
|
|
|
|
id: loadDiagram
|
|
|
|
height: 30
|
|
|
|
width: settings.settingWidth
|
|
|
|
text: "Load diagram"
|
|
|
|
icon.name: 'fileopen'
|
|
|
|
onClicked: load()
|
2021-01-26 17:36:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-22 00:01:36 +00:00
|
|
|
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()
|
|
|
|
}
|
|
|
|
}
|