fractorium/Source/Fractorium/VariationTreeWidgetItem.h

91 lines
2.9 KiB
C
Raw Normal View History

#pragma once
#include "FractoriumPch.h"
#include "DoubleSpinBox.h"
/// <summary>
0.4.1.3 Beta 10/14/2014 --User Changes Size is no longer fixed to the window size. Size scaling is done differently in the final render dialog. This fixes several bugs. Remove Xml saving size from settings and options dialog, it no longer applies. Final render can be broken into strips. Set default save path to the desktop if none is found in the settings file. Set default output size to 1920x1080 if none is found in the settings file. --Bug Fixes Better memory size reporting in final render dialog. --Code Changes Migrate to C++11, Qt 5.3.1, and Visual Studio 2013. Change most instances of unsigned int to size_t, and int to intmax_t. Add m_OrigPixPerUnit and m_ScaleType to Ember for scaling purposes. Replace some sprintf_s() calls in XmlToEmber with ostringstream. Move more non-templated members into RendererBase. Add CopyVec() overload that takes a per element function pointer. Add vector Memset(). Replace '&' with '+' instead of "&amp;" in XmlToEmber for much faster parsing. Break strips rendering out into EmberCommon and call from EmberRender and Fractorium. Make AddAndWriteBuffer() just call WriteBuffer(). Make AddAndWriteImage() delete the existing image first before replacing it. Add SetOutputTexture() to RendererCL to support making new textures in response to resize events. Remove multiple return statements in RendererCL, and replace with a bool that tracks results. Add ToDouble(), MakeEnd(), ToString() and Exists() wrappers in Fractorium. Add Size() wrapper in EmberFile. Make QString function arguments const QString&, and string with const string&. Make ShowCritical() wrapper for invoking a message box from another thread. Add combo box to TwoButtonWidget and rename.
2014-10-14 11:53:15 -04:00
/// VariationTreeWidgetItem class.
/// </summary>
/// <summary>
/// A derivation of QTreeWidgetItem which helps us with sorting.
/// This is used when the user chooses to sort the variations tree
/// by index or by weight. It supports weights less than, equal to, or
/// greater than zero.
/// </summary>
class VariationTreeWidgetItem : public QTreeWidgetItem
{
public:
/// <summary>
/// Constructor that takes a pointer to a QTreeWidget as the parent
/// and passes it to the base.
/// </summary>
/// <param name="id">The ID of the variation this widget will represent</param>
2014-12-11 00:50:15 -05:00
/// <param name="p">The parent widget</param>
--User changes -Remove the option --intpalette to format the palette in the xml as ints. If they are not hex formatted, then they should always be float. This option was pointless. -Cleanup some options text for the command line programs. -Allow for dragging around flames in the library tab. This is useful for setting up the order of an animation. -Make the opening of large files in Fractorium much more efficient when not-appending. -Make the opening of large files in all EmberRender and EmberAnimate more efficient. -Better error reporting when opening files. --Bug fixes -Get rid of leftover artifacts that would appear on preview thumbnails when either switching SP/DP or re-rendering previews. -Filename extension was not being appended on Linux when saving as Xml, thus making it impossible to drag that file back in becase drop is filtered on extension. --Code changes -Move GCC compiler spec to C++14. Building with 5.3 now on linux. -Use inline member data initializers. -Make a #define for static for use in Utils.h to make things a little cleaner. -Make various functions able to take arbitrary collections as their parameters rather than just vectors. -Make library collection a list rather than vector. This alleviates the need to re-sync pointers whenever the collection changes. -Subclass QTreeWidget for the library tree. Two new files added for this. -Remove all usage of #ifdef ROW_ONLY_DE in DEOpenCLKernelCreator, it was never used. -Add move constructor and assignment operator to EmberFile. -Add the ability to use a pointer to outside memory in the renderer for the vector of Ember<T>. -Make a lot more functions const where they should be.
2016-04-03 21:55:12 -04:00
VariationTreeWidgetItem(eVariationId id, QTreeWidget* p = nullptr)
2014-12-11 00:50:15 -05:00
: QTreeWidgetItem(p)
{
m_Id = id;
}
/// <summary>
/// Constructor that takes a pointer to a QTreeWidgetItem as the parent
/// and passes it to the base.
/// This is used for making sub items for parametric variation parameters.
/// </summary>
/// <param name="id">The ID of the variation this widget will represent</param>
2014-12-11 00:50:15 -05:00
/// <param name="p">The parent widget</param>
VariationTreeWidgetItem(eVariationId id, QTreeWidgetItem* p = 0)
: QTreeWidgetItem(p)
{
m_Id = id;
}
virtual ~VariationTreeWidgetItem() { }
eVariationId Id() { return m_Id; }
private:
/// <summary>
/// Less than operator used for sorting.
/// </summary>
/// <param name="other">The QTreeWidgetItem to compare against for sorting</param>
/// <returns>True if this is less than other, else false.</returns>
bool operator < (const QTreeWidgetItem& other) const
{
int column = treeWidget()->sortColumn();
auto itemWidget1 = treeWidget()->itemWidget(const_cast<VariationTreeWidgetItem*>(this), 1);//Get the widget for the second column.
if (auto spinBox1 = dynamic_cast<VariationTreeDoubleSpinBox*>(itemWidget1))//Cast the widget to the VariationTreeDoubleSpinBox type.
{
auto itemWidget2 = treeWidget()->itemWidget(const_cast<QTreeWidgetItem*>(&other), 1);//Get the widget for the second column of the widget item passed in.
if (auto spinBox2 = dynamic_cast<VariationTreeDoubleSpinBox*>(itemWidget2))//Cast the widget to the VariationTreeDoubleSpinBox type.
{
if (spinBox1->IsParam() || spinBox2->IsParam())//Do not sort params, their order will always remain the same.
return false;
auto weight1 = spinBox1->value();
auto weight2 = spinBox2->value();
auto index1 = spinBox1->GetVariationId();
auto index2 = spinBox2->GetVariationId();
if (column == 0)//First column clicked, sort by variation index.
{
return index1 < index2;
}
else if (column == 1)//Second column clicked, sort by weight.
{
if (IsNearZero(weight1) && IsNearZero(weight2))
return index1 > index2;
else
return std::abs(weight1) < fabs(weight2);
}
}
}
return false;
}
eVariationId m_Id;
2014-12-11 00:50:15 -05:00
};