Refractor stretch panel

This commit is contained in:
2022-04-09 10:28:36 +02:00
parent 5da85e53ec
commit 68fbcfbb59
4 changed files with 140 additions and 12 deletions
+119
View File
@@ -0,0 +1,119 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="32mm"
height="32mm"
viewBox="0 0 32 32"
version="1.1"
id="svg5"
inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)"
sodipodi:docname="nuke.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview7"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:document-units="mm"
showgrid="false"
width="32mm"
inkscape:zoom="3.7543719"
inkscape:cx="37.423037"
inkscape:cy="62.194158"
inkscape:window-width="1868"
inkscape:window-height="1136"
inkscape:window-x="52"
inkscape:window-y="27"
inkscape:window-maximized="1"
inkscape:current-layer="layer1" />
<defs
id="defs2">
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath2897">
<circle
style="opacity:1;fill:#ffff00;fill-opacity:0.677435;stroke:#00000d;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="circle2899"
cx="16"
cy="16"
r="15.999999" />
</clipPath>
</defs>
<g
inkscape:label="Vrstva 1"
inkscape:groupmode="layer"
id="layer1">
<circle
style="opacity:1;fill:#ffff00;fill-opacity:0.677435;stroke:#00000d;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path75"
cx="16"
cy="16"
r="15.999999" />
<g
id="g2793"
clip-path="url(#clipPath2897)"
transform="rotate(-15,16,16)">
<path
sodipodi:type="star"
style="opacity:1;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path2538"
inkscape:flatsided="true"
sodipodi:sides="3"
sodipodi:cx="0.019383565"
sodipodi:cy="0.022225825"
sodipodi:r1="21.288982"
sodipodi:r2="10.644491"
sodipodi:arg1="0.78539816"
sodipodi:arg2="1.8325957"
inkscape:rounded="1.42247e-16"
inkscape:randomized="0"
d="M 15.072967,15.07581 -20.544194,5.53222 5.5293776,-20.541352 Z"
transform="matrix(0.5300977,0,0,0.53009772,8.0098541,8.0083476)"
inkscape:transform-center-x="1.4604177"
inkscape:transform-center-y="-1.4604177" />
<path
sodipodi:type="star"
style="opacity:1;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path2784"
inkscape:flatsided="true"
sodipodi:sides="3"
sodipodi:cx="0.019383565"
sodipodi:cy="0.022225825"
sodipodi:r1="21.288982"
sodipodi:r2="10.644491"
sodipodi:arg1="0.78539816"
sodipodi:arg2="1.8325957"
inkscape:rounded="1.42247e-16"
inkscape:randomized="0"
d="M 15.072967,15.07581 -20.544194,5.53222 5.5293776,-20.541352 Z"
transform="matrix(0.5300977,0,0,0.53009772,26.89043,13.067383)"
inkscape:transform-center-x="1.4604177"
inkscape:transform-center-y="-1.4604177" />
<path
sodipodi:type="star"
style="opacity:1;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path2786"
inkscape:flatsided="true"
sodipodi:sides="3"
sodipodi:cx="0.019383565"
sodipodi:cy="0.022225825"
sodipodi:r1="21.288982"
sodipodi:r2="10.644491"
sodipodi:arg1="0.78539816"
sodipodi:arg2="1.8325957"
inkscape:rounded="1.42247e-16"
inkscape:randomized="0"
d="M 15.072967,15.07581 -20.544194,5.53222 5.5293776,-20.541352 Z"
transform="matrix(0.5300977,0,0,0.53009772,13.068889,26.888924)"
inkscape:transform-center-x="1.4604177"
inkscape:transform-center-y="-1.4604177" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.4 KiB

+1
View File
@@ -5,5 +5,6 @@
</qresource> </qresource>
<qresource prefix="/"> <qresource prefix="/">
<file>icon.png</file> <file>icon.png</file>
<file>nuke.svg</file>
</qresource> </qresource>
</RCC> </RCC>
+7 -3
View File
@@ -3,6 +3,7 @@
#include <QPainter> #include <QPainter>
#include <QPaintEvent> #include <QPaintEvent>
#include <QPainterPath> #include <QPainterPath>
#include <QToolTip>
static float clamp(float x) static float clamp(float x)
{ {
@@ -94,16 +95,19 @@ void STFSlider::mouseMoveEvent(QMouseEvent *event)
switch(m_grabbed) switch(m_grabbed)
{ {
case 0: case 0:
m_blackPoint = (qreal)event->x()/width(); m_blackPoint = clamp((qreal)event->x()/width());
m_whitePoint = std::max(m_whitePoint, m_blackPoint); m_whitePoint = std::max(m_whitePoint, m_blackPoint);
QToolTip::showText(event->globalPos(), QString::number(m_blackPoint), this);
break; break;
case 1: case 1:
m_midPoint = ((qreal)event->x()/width() - m_blackPoint) / (m_whitePoint - m_blackPoint); m_midPoint = ((qreal)event->x()/width() - m_blackPoint) / (m_whitePoint - m_blackPoint);
m_midPoint = std::max(std::min(m_midPoint, 1.0f), 0.0f); m_midPoint = clamp(m_midPoint);
QToolTip::showText(event->globalPos(), QString::number(m_midPoint), this);
break; break;
case 2: case 2:
m_whitePoint = (qreal)event->x()/width(); m_whitePoint = clamp((qreal)event->x()/width());
m_blackPoint = std::min(m_blackPoint, m_whitePoint); m_blackPoint = std::min(m_blackPoint, m_whitePoint);
QToolTip::showText(event->globalPos(), QString::number(m_whitePoint), this);
break; break;
} }
if(m_grabbed >= 0) if(m_grabbed >= 0)
+13 -9
View File
@@ -1,7 +1,7 @@
#include "stretchpanel.h" #include "stretchpanel.h"
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QDebug> #include <QDebug>
#include <QPushButton> #include <QToolButton>
#include "imageringlist.h" #include "imageringlist.h"
const float BLACK_POINT_SIGMA = -2.8f; const float BLACK_POINT_SIGMA = -2.8f;
@@ -21,18 +21,22 @@ StretchPanel::StretchPanel(QWidget *parent) : QWidget(parent)
setLayout(layout); setLayout(layout);
m_stfSlider = new STFSlider(this); m_stfSlider = new STFSlider(this);
layout->addWidget(m_stfSlider); layout->addWidget(m_stfSlider, 0, 0);
connect(m_stfSlider, SIGNAL(paramChanged(float, float, float)), this, SIGNAL(paramChanged(float,float,float))); connect(m_stfSlider, SIGNAL(paramChanged(float, float, float)), this, SIGNAL(paramChanged(float,float,float)));
QPushButton *resetButton = new QPushButton(tr("Reset STF"), this); QToolButton *autoStretchButton = new QToolButton(this);
resetButton->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); autoStretchButton->setIcon(QIcon(":/nuke.svg"));
layout->addWidget(resetButton); autoStretchButton->setToolTip(tr("Auto Stretch F12"));
connect(resetButton, SIGNAL(pressed()), this, SLOT(resetMTF())); autoStretchButton->setShortcut(Qt::Key_F12);
QPushButton *autoStretchButton = new QPushButton(tr("Autostretch"), this);
autoStretchButton->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
layout->addWidget(autoStretchButton); layout->addWidget(autoStretchButton);
connect(autoStretchButton, SIGNAL(pressed()), this, SIGNAL(autoStretch())); connect(autoStretchButton, SIGNAL(pressed()), this, SIGNAL(autoStretch()));
QToolButton *resetButton = new QToolButton(this);
resetButton->setIcon(style()->standardIcon(QStyle::SP_DialogResetButton));
resetButton->setToolTip(tr("Reset Screen Transfer Function F11"));
resetButton->setShortcut(Qt::Key_F11);
layout->addWidget(resetButton);
connect(resetButton, SIGNAL(pressed()), this, SLOT(resetMTF()));
} }
void StretchPanel::stretchImage(Image *img) void StretchPanel::stretchImage(Image *img)