Start playing with the visualiser design.

This commit is contained in:
David Given
2024-01-16 22:18:12 +01:00
parent be33d31c92
commit ce7ddf858b
5 changed files with 316 additions and 158 deletions

View File

@@ -36,6 +36,7 @@ cxxlibrary(
"userinterface.h": ".+userinterface_h",
"driveConfigurationForm.h": ".+driveConfigurationForm_h",
"fluxConfigurationForm.h": ".+fluxConfigurationForm_h",
"fluxvisualiserwidget.h": "./fluxvisualiserwidget.h",
},
)
@@ -46,6 +47,7 @@ cxxprogram(
"./mainwindow.cc",
"./drivecomponent.cc",
"./formatcomponent.cc",
"./fluxvisualiserwidget.cc",
"./globals.h",
"./mainwindow.h",
"./drivecomponent.h",

View File

@@ -0,0 +1,92 @@
#include "lib/globals.h"
#include "lib/config.h"
#include "lib/fluxmap.h"
#include "lib/flux.h"
#include "lib/layout.h"
#include "globals.h"
#include "fluxvisualiserwidget.h"
#include <QWheelEvent>
#include <QFrame>
W_OBJECT_IMPL(FluxVisualiserWidget)
class DiskFlux;
class TrackFlux;
static const int TRACKS = 82;
static const float VBORDER = 1.0;
static const float VOUTER_RADIUS = 50.0;
static const float VINNER_RADIUS = 10.0;
class FluxVisualiserWidgetImpl : public FluxVisualiserWidget
{
public:
FluxVisualiserWidgetImpl(): _scene(new QGraphicsScene())
{
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setFrameShape(QFrame::NoFrame);
setScene(_scene);
}
public:
void resizeEvent(QResizeEvent* event) override
{
fitInView(sceneRect(), Qt::KeepAspectRatio);
}
public:
void setTrackData(std::shared_ptr<const TrackFlux> track)
{
key_t key = {
track->trackInfo->physicalTrack, track->trackInfo->physicalSide};
_tracks[key] = track;
}
void setDiskData(std::shared_ptr<const DiskFlux> disk)
{
for (const auto& track : disk->tracks)
{
key_t key = {track->trackInfo->physicalTrack,
track->trackInfo->physicalSide};
_tracks[key] = track;
}
}
public:
void refresh() override
{
_scene->clear();
drawSide(VOUTER_RADIUS, VOUTER_RADIUS);
drawSide(VOUTER_RADIUS, VOUTER_RADIUS*3 + VBORDER);
_scene->setSceneRect(0.0, 0.0, VOUTER_RADIUS*2, VOUTER_RADIUS*4 + VBORDER);
}
private:
void drawSide(float x, float y)
{
QPen black(QColorConstants::Black);
black.setWidth(0);
float step = (VOUTER_RADIUS - VINNER_RADIUS) / TRACKS;
for (int track = 0; track<82; track++)
{
float r = VOUTER_RADIUS - track * step;
_scene->addEllipse(x-r, y-r, r*2, r*2, black);
}
}
private:
typedef std::pair<unsigned, unsigned> key_t;
QGraphicsScene* _scene;
std::map<key_t, std::shared_ptr<const TrackFlux>> _tracks;
};
FluxVisualiserWidget* FluxVisualiserWidget::create()
{
return new FluxVisualiserWidgetImpl();
}

View File

@@ -0,0 +1,18 @@
#pragma once
#include <QGraphicsView>
class FluxVisualiserWidget : public QGraphicsView
{
W_OBJECT(FluxVisualiserWidget)
public:
virtual void refresh() = 0;
W_SLOT(refresh)
virtual void setTrackData(std::shared_ptr<const TrackFlux> track) = 0;
virtual void setDiskData(std::shared_ptr<const DiskFlux> disk) = 0;
public:
static FluxVisualiserWidget* create();
};

View File

@@ -1,9 +1,11 @@
#include "lib/globals.h"
#include "lib/config.h"
#include "lib/readerwriter.h"
#include "globals.h"
#include "mainwindow.h"
#include "drivecomponent.h"
#include "formatcomponent.h"
#include "fluxvisualiserwidget.h"
class MainWindowImpl : public MainWindow
{
@@ -30,6 +32,10 @@ public:
stopWidget->setText("Stop");
statusbar->addPermanentWidget(stopWidget);
_fluxVisualiserWidget = FluxVisualiserWidget::create();
fluxViewContainer->layout()->addWidget(_fluxVisualiserWidget);
_fluxVisualiserWidget->refresh();
connect(readDiskButton,
&QAbstractButton::clicked,
this,
@@ -130,6 +136,7 @@ private:
DriveComponent* _driveComponent;
FormatComponent* _formatComponent;
QProgressBar* _progressWidget;
FluxVisualiserWidget* _fluxVisualiserWidget;
};
W_OBJECT_IMPL(MainWindowImpl)

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1679</width>
<height>1017</height>
<width>1644</width>
<height>892</height>
</rect>
</property>
<property name="windowTitle">
@@ -64,64 +64,6 @@
</property>
</spacer>
</item>
<item row="7" column="1">
<widget class="QLabel" name="label_14">
<property name="text">
<string>Configure drive and format before use.</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="6" column="0">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="6" column="4">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1" colspan="3">
<widget class="QLabel" name="label">
<property name="minimumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="resources.qrc">:/ui/extras/icon.png</pixmap>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="6" column="3">
<widget class="QGroupBox" name="groupBox_2">
<property name="sizePolicy">
@@ -181,27 +123,6 @@
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QWidget" name="widget_2" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
</layout>
</widget>
</item>
<item row="7" column="3">
<widget class="QLabel" name="label_15">
<property name="text">
@@ -212,29 +133,6 @@
</property>
</widget>
</item>
<item row="2" column="1" colspan="3">
<widget class="QLabel" name="label_2">
<property name="text">
<string>FluxEngine</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="4" column="1" colspan="3">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="6" column="1">
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
@@ -283,6 +181,108 @@
</layout>
</widget>
</item>
<item row="4" column="1" colspan="3">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="7" column="1">
<widget class="QLabel" name="label_14">
<property name="text">
<string>Configure drive and format before use.</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QWidget" name="widget_2" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
</layout>
</widget>
</item>
<item row="1" column="1" colspan="3">
<widget class="QLabel" name="label">
<property name="minimumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="resources.qrc">:/ui/extras/icon.png</pixmap>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="2" column="1" colspan="3">
<widget class="QLabel" name="label_2">
<property name="text">
<string>FluxEngine</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="6" column="0">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="6" column="4">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
@@ -290,7 +290,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>1679</width>
<width>1644</width>
<height>29</height>
</rect>
</property>
@@ -337,33 +337,113 @@
<bool>false</bool>
</property>
<widget class="QWidget" name="tab">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<attribute name="title">
<string>Flux view</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_3" columnstretch="0,0,0,0">
<layout class="QFormLayout" name="formLayout">
<item row="1" column="1">
<widget class="QRadioButton" name="radioButton_7">
<property name="text">
<string>By index pulse</string>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
</widget>
<item>
<widget class="QRadioButton" name="radioButton_7">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>By index pulse</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_8">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>By sector number</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<item row="4" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Revolution:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="leftMargin">
<number>0</number>
</property>
<item>
<widget class="QSlider" name="revolutionsSlider">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksAbove</enum>
</property>
<property name="tickInterval">
<number>1</number>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="revolutionsSpinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_11">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Alignment:</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="4">
<widget class="QFrame" name="frame">
<item row="0" column="0" colspan="2">
<widget class="QFrame" name="fluxViewContainer">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">QFrame {
background: white;
@@ -376,48 +456,7 @@ background: white;
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QGraphicsView" name="leftFluxView">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QGraphicsView" name="rightFluxView">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="2">
<widget class="QRadioButton" name="radioButton_8">
<property name="text">
<string>By sector number</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QSpinBox" name="revolutionsSpinBox"/>
</item>
<item row="2" column="1" colspan="2">
<widget class="QSlider" name="revolutionsSlider">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksAbove</enum>
</property>
<property name="tickInterval">
<number>1</number>
</property>
<layout class="QVBoxLayout" name="verticalLayout_12"/>
</widget>
</item>
</layout>
@@ -484,8 +523,8 @@ background: white;
<rect>
<x>0</x>
<y>0</y>
<width>360</width>
<height>189</height>
<width>337</width>
<height>171</height>
</rect>
</property>
<property name="sizePolicy">
@@ -600,7 +639,7 @@ background: white;
<x>0</x>
<y>0</y>
<width>348</width>
<height>461</height>
<height>354</height>
</rect>
</property>
<property name="sizePolicy">