mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
Tidy the visualisation up somewhat.
This commit is contained in:
@@ -4,12 +4,8 @@
|
||||
#include "fluxcomponent.h"
|
||||
#include "mainwindow.h"
|
||||
#include "fluxvisualiserwidget.h"
|
||||
#include "fluxOverlayForm.h"
|
||||
|
||||
class FluxComponentImpl :
|
||||
public FluxComponent,
|
||||
public QObject,
|
||||
public Ui_fluxOverlayForm
|
||||
class FluxComponentImpl : public FluxComponent, public QObject
|
||||
{
|
||||
W_OBJECT(FluxComponentImpl)
|
||||
|
||||
@@ -26,6 +22,14 @@ public:
|
||||
QOverload<int>::of(&QComboBox::activated),
|
||||
_fluxVisualiserWidget,
|
||||
&FluxVisualiserWidget::setVisibleSide);
|
||||
connect(_mainWindow->fluxContrastSlider,
|
||||
&QAbstractSlider::valueChanged,
|
||||
[this](int value)
|
||||
{
|
||||
_fluxVisualiserWidget->setGamma(value / 100.0);
|
||||
});
|
||||
|
||||
_mainWindow->fluxContrastSlider->setValue(500);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@@ -52,12 +52,18 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
void setVisibleSide(int mode)
|
||||
void setVisibleSide(int mode) override
|
||||
{
|
||||
_viewMode = mode;
|
||||
redraw();
|
||||
}
|
||||
|
||||
void setGamma(float gamma) override
|
||||
{
|
||||
_gamma = gamma;
|
||||
recompute();
|
||||
}
|
||||
|
||||
void setTrackData(std::shared_ptr<const TrackFlux> track)
|
||||
{
|
||||
key_t key = {
|
||||
@@ -117,7 +123,7 @@ private:
|
||||
float step = (VOUTER_RADIUS - VINNER_RADIUS) / TRACKS;
|
||||
for (int track = 0; track < 82; track++)
|
||||
{
|
||||
QConicalGradient gradient(x, y, 0);
|
||||
QConicalGradient gradient(x, y, 90.0);
|
||||
gradient.setStops(_viewData[side][track].gradientStops);
|
||||
QBrush brush(gradient);
|
||||
QPen pen(brush, step * 1.15);
|
||||
@@ -125,6 +131,14 @@ private:
|
||||
float r = VOUTER_RADIUS - track * step;
|
||||
_scene->addEllipse(x - r, y - r, r * 2, r * 2, pen);
|
||||
}
|
||||
|
||||
QFont font;
|
||||
font.setPointSizeF(VINNER_RADIUS / 3.0);
|
||||
QGraphicsSimpleTextItem* label = _scene->addSimpleText(
|
||||
QString::fromStdString(fmt::format("Side {}", side)));
|
||||
label->setFont(font);
|
||||
QRectF bounds = label->boundingRect();
|
||||
label->setPos(x - bounds.width() / 2, y - bounds.height() / 2);
|
||||
}
|
||||
|
||||
void recompute()
|
||||
@@ -195,18 +209,6 @@ private:
|
||||
vdata.slot[slotIndex].count++;
|
||||
}
|
||||
|
||||
float maxDensity = 0.0;
|
||||
for (int i = 0; i < SLOTS; i++)
|
||||
{
|
||||
VSlot& slot = vdata.slot[i];
|
||||
if (slot.count != 0)
|
||||
{
|
||||
float factor = (float)slot.pulses / (float)slot.count;
|
||||
maxDensity = std::max(maxDensity, factor);
|
||||
}
|
||||
}
|
||||
maxDensity = 300;
|
||||
|
||||
for (int i = 0; i < SLOTS; i++)
|
||||
{
|
||||
VSlot& slot = vdata.slot[i];
|
||||
@@ -215,10 +217,10 @@ private:
|
||||
QPair((float)i / SLOTS, QColorConstants::LightGray));
|
||||
else
|
||||
{
|
||||
float factor =
|
||||
(float)slot.pulses / (float)slot.count / maxDensity;
|
||||
int c = factor * 255.0;
|
||||
stops.append(QPair((float)i / SLOTS, QColor(c, c, c)));
|
||||
float factor = (float)slot.pulses / (float)slot.count / 300;
|
||||
int c = powf(factor, _gamma) * 255.0;
|
||||
stops.append(
|
||||
QPair(1.0 - ((float)i / SLOTS), QColor(0, c, c)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -251,6 +253,7 @@ private:
|
||||
std::map<key_t, std::shared_ptr<const TrackFlux>> _tracks;
|
||||
int _viewMode = BOTH_SIDES;
|
||||
VData _viewData[SIDES][TRACKS];
|
||||
float _gamma = 1.0;
|
||||
};
|
||||
|
||||
FluxVisualiserWidget* FluxVisualiserWidget::create()
|
||||
|
||||
@@ -10,6 +10,9 @@ public:
|
||||
virtual void setVisibleSide(int mode) = 0;
|
||||
W_SLOT(setVisibleSide)
|
||||
|
||||
virtual void setGamma(float gamma) = 0;
|
||||
W_SLOT(setGamma)
|
||||
|
||||
virtual void setTrackData(std::shared_ptr<const TrackFlux> track) = 0;
|
||||
virtual void setDiskData(std::shared_ptr<const DiskFlux> disk) = 0;
|
||||
|
||||
|
||||
@@ -348,19 +348,32 @@
|
||||
</attribute>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4" stretch="1,0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4" stretch="0,0,0">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Contrast:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSlider" name="fluxContrastSlider">
|
||||
<property name="minimum">
|
||||
<number>50</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>999</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
<property name="invertedAppearance">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</spacer>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="fluxSideComboBox">
|
||||
@@ -409,52 +422,6 @@ background: white;
|
||||
<layout class="QVBoxLayout" name="verticalLayout_12"/>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" 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="2" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<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>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
|
||||
Reference in New Issue
Block a user