--User changes

-Add gnarly variation.

--Bug fixes
 -Fix reading of post variations in .chaos files.
 -Make selection of points on color curves control apply only to the current selection as specified by the radio buttons below.

--Code changes
 -Use std::complex<T> type in some variations' CPU code.
This commit is contained in:
Person
2019-05-28 20:08:59 -07:00
parent a698edf887
commit c000c67d45
9 changed files with 234 additions and 226 deletions

View File

@ -20,7 +20,6 @@ CurvesGraphicsView::CurvesGraphicsView(QWidget* parent)
m_GPen.setWidth(2);
m_BPen.setWidth(2);
setScene(&m_Scene);
SetTop(CurveIndex::ALL);
//qDebug() << "Original scene rect before setting anything is: " << sceneRect();
m_OriginalRect = sceneRect();
Curves<float> curves(true);
@ -30,16 +29,19 @@ CurvesGraphicsView::CurvesGraphicsView(QWidget* parent)
}
/// <summary>
/// Get the position of a given point within a given curve.
/// Called when an underlying point has had its position changed, so emit a signal so that a listener can take action.
/// </summary>
/// <param name="curveIndex">The curve whose point value will be retrieved, 0-3.</param>
/// <param name="pointIndex">The point within the curve value will be retrieved, 1-2.</param>
/// <param name="curveIndex">The curve whose point value was changed, 0-3.</param>
/// <param name="pointIndex">The point within the curve whose point value was changed.</param>
/// <param name="point">The position of the point. X,Y will each be within 0-1.</param>
void CurvesGraphicsView::PointChanged(int curveIndex, int pointIndex, const QPointF& point)
{
double x = point.x() / width();
double y = (height() - point.y()) / height();
emit PointChangedSignal(curveIndex, pointIndex, QPointF(x, y));
if (curveIndex == m_Index)
{
double x = point.x() / width();
double y = (height() - point.y()) / height();
emit PointChangedSignal(curveIndex, pointIndex, QPointF(x, y));
}
}
/// <summary>
@ -105,6 +107,7 @@ void CurvesGraphicsView::Set(Curves<float>& curves)
createpoints(1, m_RedP, Qt::GlobalColor::red, 1);
createpoints(2, m_GrnP, Qt::GlobalColor::green, 1);
createpoints(3, m_BluP, Qt::GlobalColor::blue, 1);
SetTop(CurveIndex(m_Index));
}
/// <summary>
@ -135,16 +138,10 @@ void CurvesGraphicsView::SetTop(CurveIndex curveIndex)
for (size_t i = 0; i < 4; i++)
{
if (i == m_Index)
{
for (auto& p : m_Points[i])
p->setZValue(2);
}
else
{
for (auto& p : m_Points[i])
p->setZValue(1);
}
bool b = (i == m_Index);
for (auto& p : m_Points[i])
p->SetCurrent(b);
}
}
@ -237,7 +234,7 @@ void CurvesGraphicsView::mousePressEvent(QMouseEvent* e)
return -1;
};
if (e->button() == Qt::RightButton)//Right button does whole image rotation and scaling.
if (e->button() == Qt::RightButton)
{
int i = findpoint(e->pos().x(), e->pos().y());

View File

@ -39,6 +39,7 @@ public:
void Set(int curveIndex, int pointIndex, const QPointF& point);
void Set(Curves<float>& curves);
void SetTop(CurveIndex curveIndex);
size_t SelectedCurveIndex() const { return m_Index; }
Q_SIGNALS:
void PointChangedSignal(int curveIndex, int pointIndex, const QPointF& point);
@ -87,13 +88,23 @@ public:
EllipseItem(const QRectF& rect, int curveIndex, int pointIndex, CurvesGraphicsView* viewParent, QGraphicsItem* parent = nullptr)
: QGraphicsEllipseItem(rect, parent)
{
m_CurveIndex = curveIndex;
m_PointIndex = pointIndex;
m_ViewParent = viewParent;
setFlag(QGraphicsItem::ItemSendsScenePositionChanges);
setFlag(QGraphicsItem::ItemIsSelectable);
setFlag(QGraphicsItem::ItemIsMovable);
setPen(Qt::NoPen);
m_CurveIndex = curveIndex;
m_PointIndex = pointIndex;
m_ViewParent = viewParent;
}
/// <summary>
/// Set whether this item is selectable, which means this curve is the current one.
/// </summary>
/// <param name="b">True if selected, else false.</param>
void SetCurrent(bool b)
{
setFlag(QGraphicsItem::ItemIsMovable, b);
setZValue(b ? 2 : 1);
}
/// <summary>
@ -125,7 +136,7 @@ protected:
/// <returns>The new position</returns>
virtual QVariant itemChange(GraphicsItemChange change, const QVariant& value) override
{
if (change == ItemPositionChange && scene())
if ((change == ItemPositionChange) && scene())
{
//Value is the new position.
QPointF newPos = value.toPointF();