mirror of
https://bitbucket.org/mfeemster/fractorium.git
synced 2025-04-19 09:21:42 -04:00
Allow for multiple palette files rather than hard coding to flam3-palettes.xml.
Make xaos display a matrix rather than a single column. This will be moved out into its own tab since it's no longer xform dependent, but that will be in a future commit. Remove xaos from/to button since it's no longer applicable. Add test function to Isaac to return just one random byte. Might be used in the future.
This commit is contained in:
parent
4067422075
commit
053a9fcf95
@ -46,8 +46,8 @@ template<> unique_ptr<QTIsaac<ISAAC_SIZE, ISAAC_INT>> QTIsaac<ISAAC_SIZE, ISAAC_
|
|||||||
template EMBER_API class Post##varName##Variation<T>;
|
template EMBER_API class Post##varName##Variation<T>;
|
||||||
|
|
||||||
#define EXPORT_SINGLE_TYPE_EMBER(T) \
|
#define EXPORT_SINGLE_TYPE_EMBER(T) \
|
||||||
template<> bool PaletteList<T>::m_Init = false; \
|
template<> const char* PaletteList<T>::m_DefaultFilename = "flam3-palettes.xml"; \
|
||||||
template<> vector<Palette<T>> PaletteList<T>::m_Palettes = vector<Palette<T>>(); \
|
template<> map<string, vector<Palette<T>>> PaletteList<T>::m_Palettes = map<string, vector<Palette<T>>>(); \
|
||||||
template<> bool XmlToEmber<T>::m_Init = false; \
|
template<> bool XmlToEmber<T>::m_Init = false; \
|
||||||
template<> vector<string> XmlToEmber<T>::m_FlattenNames = vector<string>(); \
|
template<> vector<string> XmlToEmber<T>::m_FlattenNames = vector<string>(); \
|
||||||
template<> vector<pair<string, string>> XmlToEmber<T>::m_BadParamNames = vector<pair<string, string>>(); \
|
template<> vector<pair<string, string>> XmlToEmber<T>::m_BadParamNames = vector<pair<string, string>>(); \
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
#else
|
#else
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <map>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
|
@ -41,6 +41,13 @@
|
|||||||
|
|
||||||
namespace EmberNs
|
namespace EmberNs
|
||||||
{
|
{
|
||||||
|
|
||||||
|
union UintBytes
|
||||||
|
{
|
||||||
|
unsigned char Bytes[4];
|
||||||
|
uint Uint;
|
||||||
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// QTIsaac class which allows using ISAAC in an OOP manner.
|
/// QTIsaac class which allows using ISAAC in an OOP manner.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -49,6 +56,8 @@ class EMBER_API QTIsaac
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum { N = (1 << ALPHA) };
|
enum { N = (1 << ALPHA) };
|
||||||
|
UintBytes m_Cache;
|
||||||
|
int m_LastIndex;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Global ISAAC RNG to be used from anywhere. This is not thread safe, so take caution to only
|
/// Global ISAAC RNG to be used from anywhere. This is not thread safe, so take caution to only
|
||||||
@ -83,6 +92,28 @@ public:
|
|||||||
QTIsaac(T a = 0, T b = 0, T c = 0, T* s = nullptr)
|
QTIsaac(T a = 0, T b = 0, T c = 0, T* s = nullptr)
|
||||||
{
|
{
|
||||||
Srand(a, b, c, s);
|
Srand(a, b, c, s);
|
||||||
|
m_LastIndex = 0;
|
||||||
|
m_Cache.Uint = Rand();
|
||||||
|
T temp = RandByte();//Need to call at least once so other libraries can link.
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Return the next random integer in the range of 0-255.
|
||||||
|
/// If only a byte is needed, this is a more efficient way because
|
||||||
|
/// it only calls rand 1/4 of the time.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The next random integer in the range of 0-255</returns>
|
||||||
|
inline T RandByte()
|
||||||
|
{
|
||||||
|
T ret = m_Cache.Bytes[m_LastIndex++];
|
||||||
|
|
||||||
|
if (m_LastIndex == 4)
|
||||||
|
{
|
||||||
|
m_LastIndex = 0;
|
||||||
|
m_Cache.Uint = Rand();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -261,7 +292,7 @@ public:
|
|||||||
if (s == nullptr)//Default to using time plus index as the seed if s was nullptr.
|
if (s == nullptr)//Default to using time plus index as the seed if s was nullptr.
|
||||||
{
|
{
|
||||||
for (int i = 0; i < N; i++)
|
for (int i = 0; i < N; i++)
|
||||||
m_Rc.randrsl[i] = static_cast<T>(time(nullptr)) + i;
|
m_Rc.randrsl[i] = static_cast<T>(NowMs()) + i;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -272,9 +303,9 @@ public:
|
|||||||
#ifndef ISAAC_FLAM3_DEBUG
|
#ifndef ISAAC_FLAM3_DEBUG
|
||||||
if (a == 0 && b == 0 && c == 0)
|
if (a == 0 && b == 0 && c == 0)
|
||||||
{
|
{
|
||||||
m_Rc.randa = static_cast<T>(time(nullptr));
|
m_Rc.randa = static_cast<T>(NowMs());
|
||||||
m_Rc.randb = static_cast<T>(time(nullptr)) * static_cast<T>(time(nullptr));
|
m_Rc.randb = static_cast<T>(NowMs()) * static_cast<T>(NowMs());
|
||||||
m_Rc.randc = static_cast<T>(time(nullptr)) * static_cast<T>(time(nullptr)) * static_cast<T>(time(nullptr));
|
m_Rc.randc = static_cast<T>(NowMs()) * static_cast<T>(NowMs()) * static_cast<T>(NowMs());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
@ -18,11 +18,14 @@ template <typename T>
|
|||||||
class EMBER_API PaletteList : public EmberReport
|
class EMBER_API PaletteList : public EmberReport
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
static const char* m_DefaultFilename;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Empty constructor which does nothing.
|
/// Empty constructor which initializes the palette map with the default palette file.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
PaletteList()
|
PaletteList()
|
||||||
{
|
{
|
||||||
|
Add(string(m_DefaultFilename));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -31,17 +34,16 @@ public:
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filename">The full path to the file to read</param>
|
/// <param name="filename">The full path to the file to read</param>
|
||||||
/// <param name="force">If true, override the initialization state and force a read, else observe the initialization state.</param>
|
/// <param name="force">If true, override the initialization state and force a read, else observe the initialization state.</param>
|
||||||
/// <returns>The initialization state</returns>
|
/// <returns>Whether anything was read</returns>
|
||||||
bool Init(const string& filename, bool force = false)
|
bool Add(const string& filename, bool force = false)
|
||||||
{
|
{
|
||||||
if (!m_Init || force)
|
bool added = false;
|
||||||
{
|
auto& palettes = m_Palettes[filename];
|
||||||
const char* loc = __FUNCTION__;
|
|
||||||
|
|
||||||
m_Init = false;
|
if (palettes.empty() || force)
|
||||||
m_Palettes.clear();
|
{
|
||||||
m_ErrorReport.clear();
|
|
||||||
string buf;
|
string buf;
|
||||||
|
const char* loc = __FUNCTION__;
|
||||||
|
|
||||||
if (ReadFile(filename.c_str(), buf))
|
if (ReadFile(filename.c_str(), buf))
|
||||||
{
|
{
|
||||||
@ -51,10 +53,11 @@ public:
|
|||||||
{
|
{
|
||||||
xmlNode* rootNode = xmlDocGetRootElement(doc);
|
xmlNode* rootNode = xmlDocGetRootElement(doc);
|
||||||
|
|
||||||
m_Palettes.reserve(buf.size() / 2048);//Roughly what it takes per palette.
|
palettes.clear();
|
||||||
ParsePalettes(rootNode);
|
palettes.reserve(buf.size() / 2048);//Roughly what it takes per palette.
|
||||||
|
ParsePalettes(rootNode, palettes);
|
||||||
xmlFreeDoc(doc);
|
xmlFreeDoc(doc);
|
||||||
m_Init = m_ErrorReport.empty();
|
added = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -67,54 +70,81 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_Init;
|
return added;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the palette at a specified index.
|
/// Get the palette at a random index in a random file in the map.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="i">The index of the palette to read. A value of -1 indicates a random palette.</param>
|
Palette<T>* GetRandomPalette()
|
||||||
/// <returns>A pointer to the requested palette if the index was in range, else nullptr.</returns>
|
|
||||||
Palette<T>* GetPalette(int i)
|
|
||||||
{
|
{
|
||||||
if (!m_Palettes.empty())
|
auto p = m_Palettes.begin();
|
||||||
|
int i = 0, paletteFileIndex = QTIsaac<ISAAC_SIZE, ISAAC_INT>::GlobalRand->Rand() % Size();
|
||||||
|
|
||||||
|
while (i < paletteFileIndex && p != m_Palettes.end())
|
||||||
{
|
{
|
||||||
if (i == -1)
|
++i;
|
||||||
return &m_Palettes[QTIsaac<ISAAC_SIZE, ISAAC_INT>::GlobalRand->Rand() % Size()];
|
++p;
|
||||||
else if (i < int(m_Palettes.size()))
|
}
|
||||||
return &m_Palettes[i];
|
|
||||||
|
if (i < Size())
|
||||||
|
{
|
||||||
|
int paletteIndex = QTIsaac<ISAAC_SIZE, ISAAC_INT>::GlobalRand->Rand() % p->second.size();
|
||||||
|
|
||||||
|
if (paletteIndex < p->second.size())
|
||||||
|
return &p->second[paletteIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a pointer to a palette with a specified name.
|
/// Get the palette at a specified index in the specified file in the map.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="name">The name of the palette to retrieve</param>
|
/// <param name="filename">The filename of the palette to retrieve</param>
|
||||||
/// <returns>A pointer to the palette if found, else nullptr</returns>
|
/// <param name="i">The index of the palette to read. A value of -1 indicates a random palette.</param>
|
||||||
Palette<T>* GetPaletteByName(const string&& name)
|
/// <returns>A pointer to the requested palette if the index was in range, else nullptr.</returns>
|
||||||
|
Palette<T>* GetPalette(const string& filename, int i)
|
||||||
{
|
{
|
||||||
for (uint i = 0; i < Size(); i++)
|
auto& palettes = m_Palettes[filename];
|
||||||
if (m_Palettes[i].m_Name == name)
|
|
||||||
return &m_Palettes[i];
|
if (!palettes.empty() && i < int(palettes.size()))
|
||||||
|
return &palettes[i];
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a copy of the palette at a specified index with its hue adjusted by the specified amount.
|
/// Get a pointer to a palette with a specified name in the specified file in the map.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="i">The index of the palette to read. A value of -1 indicates a random palette.</param>
|
/// <param name="filename">The filename of the palette to retrieve</param>
|
||||||
|
/// <param name="name">The name of the palette to retrieve</param>
|
||||||
|
/// <returns>A pointer to the palette if found, else nullptr</returns>
|
||||||
|
Palette<T>* GetPaletteByName(const string& filename, const string& name)
|
||||||
|
{
|
||||||
|
for (auto& palettes : m_Palettes)
|
||||||
|
if (palettes.first == filename)
|
||||||
|
for (auto& palette : palettes.second)
|
||||||
|
if (palette.m_Name == name)
|
||||||
|
return &palette;
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get a copy of the palette at a specified index in the specified file in the map
|
||||||
|
/// with its hue adjusted by the specified amount.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filename">The filename of the palette to retrieve</param>
|
||||||
|
/// <param name="i">The index of the palette to read.</param>
|
||||||
/// <param name="hue">The hue adjustment to apply</param>
|
/// <param name="hue">The hue adjustment to apply</param>
|
||||||
/// <param name="palette">The palette to store the output</param>
|
/// <param name="palette">The palette to store the output</param>
|
||||||
/// <returns>True if successful, else false.</returns>
|
/// <returns>True if successful, else false.</returns>
|
||||||
bool GetHueAdjustedPalette(int i, T hue, Palette<T>& palette)
|
bool GetHueAdjustedPalette(const string& filename, int i, T hue, Palette<T>& palette)
|
||||||
{
|
{
|
||||||
bool b = false;
|
bool b = false;
|
||||||
Palette<T>* unadjustedPal = GetPalette(i);
|
|
||||||
|
|
||||||
if (unadjustedPal)
|
if (Palette<T>* unadjustedPal = GetPalette(filename, i))
|
||||||
{
|
{
|
||||||
unadjustedPal->MakeHueAdjustedPalette(palette, hue);
|
unadjustedPal->MakeHueAdjustedPalette(palette, hue);
|
||||||
b = true;
|
b = true;
|
||||||
@ -129,23 +159,72 @@ public:
|
|||||||
void Clear()
|
void Clear()
|
||||||
{
|
{
|
||||||
m_Palettes.clear();
|
m_Palettes.clear();
|
||||||
m_Init = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Accessors.
|
/// Get the size of the palettes map.
|
||||||
|
/// This will be the number of files read.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
bool Init() { return m_Init; }
|
/// <returns>The size of the palettes map</returns>
|
||||||
size_t Size() { return m_Palettes.size(); }
|
size_t Size() { return m_Palettes.size(); }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the size of specified palette vector in the palettes map.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="index">The index of the palette in the map to retrieve</param>
|
||||||
|
/// <returns>The size of the palette vector at the specified index in the palettes map</returns>
|
||||||
|
size_t Size(size_t index)
|
||||||
|
{
|
||||||
|
size_t i = 0;
|
||||||
|
auto p = m_Palettes.begin();
|
||||||
|
|
||||||
|
while (i < index && p != m_Palettes.end())
|
||||||
|
{
|
||||||
|
++i;
|
||||||
|
++p;
|
||||||
|
}
|
||||||
|
|
||||||
|
return p->second.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the size of specified palette vector in the palettes map.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="s">The filename of the palette in the map to retrieve</param>
|
||||||
|
/// <returns>The size of the palette vector at the specified index in the palettes map</returns>
|
||||||
|
size_t Size(const string& s)
|
||||||
|
{
|
||||||
|
return m_Palettes[s].size();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the name of specified palette in the palettes map.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="index">The index of the palette in the map to retrieve</param>
|
||||||
|
/// <returns>The name of the palette vector at the specified index in the palettes map</returns>
|
||||||
|
const string& Name(size_t index)
|
||||||
|
{
|
||||||
|
size_t i = 0;
|
||||||
|
auto p = m_Palettes.begin();
|
||||||
|
|
||||||
|
while (i < index && p != m_Palettes.end())
|
||||||
|
{
|
||||||
|
++i;
|
||||||
|
++p;
|
||||||
|
}
|
||||||
|
|
||||||
|
return p->first;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Parses an Xml node for all palettes present and stores in the palette list.
|
/// Parses an Xml node for all palettes present and store in the passed in palette vector.
|
||||||
/// Note that although the Xml color values are expected to be 0-255, they are converted and
|
/// Note that although the Xml color values are expected to be 0-255, they are converted and
|
||||||
/// stored as normalized colors, with values from 0-1.
|
/// stored as normalized colors, with values from 0-1.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="node">The parent note of all palettes in the Xml file.</param>
|
/// <param name="node">The parent note of all palettes in the Xml file.</param>
|
||||||
void ParsePalettes(xmlNode* node)
|
/// <param name="palettes">The vector to store the paresed palettes associated with this file in.</param>
|
||||||
|
void ParsePalettes(xmlNode* node, vector<Palette<T>>& palettes)
|
||||||
{
|
{
|
||||||
bool hexError = false;
|
bool hexError = false;
|
||||||
char* val;
|
char* val;
|
||||||
@ -208,19 +287,18 @@ private:
|
|||||||
|
|
||||||
if (!hexError)
|
if (!hexError)
|
||||||
{
|
{
|
||||||
m_Palettes.push_back(palette);
|
palettes.push_back(palette);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ParsePalettes(node->children);
|
ParsePalettes(node->children, palettes);
|
||||||
}
|
}
|
||||||
|
|
||||||
node = node->next;
|
node = node->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool m_Init;//Initialized to false in Ember.cpp, and will be set to true upon successful reading of an Xml palette file.
|
static map<string, vector<Palette<T>>> m_Palettes;//The map of filenames to vectors that store the palettes.
|
||||||
static vector<Palette<T>> m_Palettes;//The vector that stores the palettes.
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ public:
|
|||||||
m_OffsetX = 0;
|
m_OffsetX = 0;
|
||||||
m_OffsetY = 0;
|
m_OffsetY = 0;
|
||||||
|
|
||||||
m_PaletteList.Init(palettePath);
|
m_PaletteList.Add(palettePath);
|
||||||
m_StandardIterator = unique_ptr<StandardIterator<T>>(new StandardIterator<T>());
|
m_StandardIterator = unique_ptr<StandardIterator<T>>(new StandardIterator<T>());
|
||||||
m_XaosIterator = unique_ptr<XaosIterator<T>>(new XaosIterator<T>());
|
m_XaosIterator = unique_ptr<XaosIterator<T>>(new XaosIterator<T>());
|
||||||
m_Renderer = unique_ptr<Renderer<T, bucketT>>(renderer);
|
m_Renderer = unique_ptr<Renderer<T, bucketT>>(renderer);
|
||||||
@ -99,8 +99,8 @@ public:
|
|||||||
ember.AddXform(xform2);
|
ember.AddXform(xform2);
|
||||||
ember.AddXform(xform3);
|
ember.AddXform(xform3);
|
||||||
|
|
||||||
if (m_PaletteList.Init())
|
if (m_PaletteList.Size())
|
||||||
ember.m_Palette = *m_PaletteList.GetPalette(-1);
|
ember.m_Palette = *m_PaletteList.GetRandomPalette();
|
||||||
|
|
||||||
return ember;
|
return ember;
|
||||||
}
|
}
|
||||||
@ -386,8 +386,8 @@ public:
|
|||||||
{
|
{
|
||||||
Palette<T> palette;
|
Palette<T> palette;
|
||||||
|
|
||||||
if (m_PaletteList.Init())
|
if (m_PaletteList.Size())
|
||||||
palette = *m_PaletteList.GetPalette(-1);
|
palette = *m_PaletteList.GetRandomPalette();
|
||||||
|
|
||||||
palette.MakeHueAdjustedPalette(ember.m_Palette, ember.m_Hue);
|
palette.MakeHueAdjustedPalette(ember.m_Palette, ember.m_Hue);
|
||||||
|
|
||||||
@ -640,8 +640,8 @@ public:
|
|||||||
ember.Clear();
|
ember.Clear();
|
||||||
ember.m_Hue = (m_Rand.Rand() & 7) ? 0 : m_Rand.Frand01<T>();
|
ember.m_Hue = (m_Rand.Rand() & 7) ? 0 : m_Rand.Frand01<T>();
|
||||||
|
|
||||||
if (m_PaletteList.Init())
|
if (m_PaletteList.Size())
|
||||||
palette = *m_PaletteList.GetPalette(-1);
|
palette = *m_PaletteList.GetRandomPalette();
|
||||||
|
|
||||||
palette.MakeHueAdjustedPalette(ember.m_Palette, ember.m_Hue);
|
palette.MakeHueAdjustedPalette(ember.m_Palette, ember.m_Hue);
|
||||||
ember.m_Time = 0;
|
ember.m_Time = 0;
|
||||||
@ -926,8 +926,8 @@ public:
|
|||||||
|
|
||||||
ember.m_Hue = 0.0;
|
ember.m_Hue = 0.0;
|
||||||
|
|
||||||
if (m_PaletteList.Init())
|
if (m_PaletteList.Size())
|
||||||
palette = m_PaletteList.GetPalette(-1);
|
palette = m_PaletteList.GetRandomPalette();
|
||||||
|
|
||||||
if (palette)
|
if (palette)
|
||||||
{
|
{
|
||||||
|
@ -44,6 +44,13 @@ static inline size_t SizeOf(vector<T>& vec)
|
|||||||
return sizeof(vec[0]) * vec.size();
|
return sizeof(vec[0]) * vec.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Thin wrapper around getting the current time in milliseconds.
|
||||||
|
/// </summary>
|
||||||
|
static inline size_t NowMs()
|
||||||
|
{
|
||||||
|
return duration_cast<milliseconds>(Clock::now().time_since_epoch()).count();
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// After a run completes, information about what was run can be saved as strings to the comments
|
/// After a run completes, information about what was run can be saved as strings to the comments
|
||||||
/// section of a jpg or png file. This class is just a container for those values.
|
/// section of a jpg or png file. This class is just a container for those values.
|
||||||
|
@ -344,7 +344,7 @@ public:
|
|||||||
string buf;
|
string buf;
|
||||||
|
|
||||||
//Ensure palette list is setup first.
|
//Ensure palette list is setup first.
|
||||||
if (!m_PaletteList.Init())
|
if (!m_PaletteList.Size())
|
||||||
{
|
{
|
||||||
m_ErrorReport.push_back(string(loc) + " : Palette list must be initialized before parsing embers.");
|
m_ErrorReport.push_back(string(loc) + " : Palette list must be initialized before parsing embers.");
|
||||||
return false;
|
return false;
|
||||||
@ -515,7 +515,7 @@ private:
|
|||||||
|
|
||||||
if (currentEmber.PaletteIndex() != -1)
|
if (currentEmber.PaletteIndex() != -1)
|
||||||
{
|
{
|
||||||
if (!m_PaletteList.GetHueAdjustedPalette(currentEmber.PaletteIndex(), currentEmber.m_Hue, currentEmber.m_Palette))
|
if (!m_PaletteList.GetHueAdjustedPalette(PaletteList<T>::m_DefaultFilename, currentEmber.PaletteIndex(), currentEmber.m_Hue, currentEmber.m_Palette))
|
||||||
{
|
{
|
||||||
m_ErrorReport.push_back(string(loc) + " : Error assigning palette with index " + Itos(currentEmber.PaletteIndex()));
|
m_ErrorReport.push_back(string(loc) + " : Error assigning palette with index " + Itos(currentEmber.PaletteIndex()));
|
||||||
}
|
}
|
||||||
@ -834,8 +834,6 @@ private:
|
|||||||
//Make sure BOTH are not specified, otherwise either are ok.
|
//Make sure BOTH are not specified, otherwise either are ok.
|
||||||
int numColors = 0;
|
int numColors = 0;
|
||||||
int numBytes = 0;
|
int numBytes = 0;
|
||||||
bool oldFormat = false;
|
|
||||||
bool newFormat = false;
|
|
||||||
int index0, index1;
|
int index0, index1;
|
||||||
T hue0, hue1;
|
T hue0, hue1;
|
||||||
T blend = 0.5;
|
T blend = 0.5;
|
||||||
@ -855,40 +853,12 @@ private:
|
|||||||
{
|
{
|
||||||
attStr = reinterpret_cast<char*>(xmlGetProp(childNode, curAtt->name));
|
attStr = reinterpret_cast<char*>(xmlGetProp(childNode, curAtt->name));
|
||||||
|
|
||||||
if (!Compare(curAtt->name, "index0"))
|
if (!Compare(curAtt->name, "count"))
|
||||||
{
|
{
|
||||||
oldFormat = true;
|
|
||||||
Atoi(attStr, index0);
|
|
||||||
}
|
|
||||||
else if (!Compare(curAtt->name, "index1"))
|
|
||||||
{
|
|
||||||
oldFormat = true;
|
|
||||||
Atoi(attStr, index1);
|
|
||||||
}
|
|
||||||
else if (!Compare(curAtt->name, "hue0"))
|
|
||||||
{
|
|
||||||
oldFormat = true;
|
|
||||||
Atof(attStr, hue0);
|
|
||||||
}
|
|
||||||
else if (!Compare(curAtt->name, "hue1"))
|
|
||||||
{
|
|
||||||
oldFormat = true;
|
|
||||||
Atof(attStr, hue1);
|
|
||||||
}
|
|
||||||
else if (!Compare(curAtt->name, "blend"))
|
|
||||||
{
|
|
||||||
oldFormat = true;
|
|
||||||
Atof(attStr, blend);
|
|
||||||
}
|
|
||||||
else if (!Compare(curAtt->name, "count"))
|
|
||||||
{
|
|
||||||
newFormat = true;
|
|
||||||
Atoi(attStr, numColors);
|
Atoi(attStr, numColors);
|
||||||
}
|
}
|
||||||
else if (!Compare(curAtt->name, "format"))
|
else if (!Compare(curAtt->name, "format"))
|
||||||
{
|
{
|
||||||
newFormat = true;
|
|
||||||
|
|
||||||
if (!_stricmp(attStr, "RGB"))
|
if (!_stricmp(attStr, "RGB"))
|
||||||
numBytes = 3;
|
numBytes = 3;
|
||||||
else if (!_stricmp(attStr, "RGBA"))
|
else if (!_stricmp(attStr, "RGBA"))
|
||||||
@ -907,29 +877,16 @@ private:
|
|||||||
xmlFree(attStr);
|
xmlFree(attStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Old or new format?
|
//Removing support for whatever "old format" was in flam3.
|
||||||
if (newFormat && oldFormat)
|
//Read formatted string from contents of tag.
|
||||||
|
char* palStr = CX(xmlNodeGetContent(childNode));
|
||||||
|
|
||||||
|
if (!ParseHexColors(palStr, currentEmber, numColors, numBytes))
|
||||||
{
|
{
|
||||||
oldFormat = false;
|
m_ErrorReport.push_back(string(loc) + " : Problem reading hexadecimal color data in palette");
|
||||||
m_ErrorReport.push_back(string(loc) + " : Mixing of old and new palette tag syntax not allowed, defaulting to new");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldFormat)
|
xmlFree(palStr);
|
||||||
{
|
|
||||||
InterpolateCmap(currentEmber.m_Palette, blend, index0, hue0, index1, hue1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//Read formatted string from contents of tag.
|
|
||||||
char* palStr = CX(xmlNodeGetContent(childNode));
|
|
||||||
|
|
||||||
if (!ParseHexColors(palStr, currentEmber, numColors, numBytes))
|
|
||||||
{
|
|
||||||
m_ErrorReport.push_back(string(loc) + " : Problem reading hexadecimal color data in palette");
|
|
||||||
}
|
|
||||||
|
|
||||||
xmlFree(palStr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (!Compare(childNode->name, "symmetry"))
|
else if (!Compare(childNode->name, "symmetry"))
|
||||||
{
|
{
|
||||||
@ -1436,51 +1393,6 @@ private:
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Interpolate the palette.
|
|
||||||
/// Used with older formats, deprecated.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="palette">The palette to interpolate</param>
|
|
||||||
/// <param name="blend">The blend</param>
|
|
||||||
/// <param name="index0">The first index</param>
|
|
||||||
/// <param name="hue0">The first hue</param>
|
|
||||||
/// <param name="index1">The second index</param>
|
|
||||||
/// <param name="hue1">The second hue/param>
|
|
||||||
void InterpolateCmap(Palette<T>& palette, T blend, int index0, T hue0, int index1, T hue1)
|
|
||||||
{
|
|
||||||
int i, j;
|
|
||||||
const char* loc = __FUNCTION__;
|
|
||||||
Palette<T> adjustedPal0, adjustedPal1;
|
|
||||||
|
|
||||||
if (m_PaletteList.GetHueAdjustedPalette(index0, hue0, adjustedPal0) &&
|
|
||||||
m_PaletteList.GetHueAdjustedPalette(index1, hue1, adjustedPal1))
|
|
||||||
{
|
|
||||||
v4T* hueAdjusted0 = adjustedPal0.m_Entries.data();
|
|
||||||
v4T* hueAdjusted1 = adjustedPal1.m_Entries.data();
|
|
||||||
|
|
||||||
for (i = 0; i < 256; i++)
|
|
||||||
{
|
|
||||||
T t[4], s[4];
|
|
||||||
|
|
||||||
Palette<T>::RgbToHsv(glm::value_ptr(hueAdjusted0[i]), s);
|
|
||||||
Palette<T>::RgbToHsv(glm::value_ptr(hueAdjusted1[i]), t);
|
|
||||||
|
|
||||||
s[3] = hueAdjusted0[i][3];
|
|
||||||
t[3] = hueAdjusted1[i][3];
|
|
||||||
|
|
||||||
for (j = 0; j < 4; j++)
|
|
||||||
t[j] = ((1 - blend) * s[j]) + (blend * t[j]);
|
|
||||||
|
|
||||||
Palette<T>::HsvToRgb(t, glm::value_ptr(palette.m_Entries[i]));
|
|
||||||
palette.m_Entries[i][3] = t[3];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_ErrorReport.push_back(string(loc) + " : Unable to retrieve palettes");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Wrapper to parse a floating point Xml value and convert it to float.
|
/// Wrapper to parse a floating point Xml value and convert it to float.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -112,7 +112,9 @@ static bool InitPaletteList(const string& filename)
|
|||||||
{
|
{
|
||||||
PaletteList<T> paletteList;//Even though this is local, the members are static so they will remain.
|
PaletteList<T> paletteList;//Even though this is local, the members are static so they will remain.
|
||||||
|
|
||||||
if (!paletteList.Init(filename))
|
paletteList.Add(filename);
|
||||||
|
|
||||||
|
if (!paletteList.Size())
|
||||||
{
|
{
|
||||||
cout << "Error parsing palette file " << filename << ". Reason: " << endl;
|
cout << "Error parsing palette file " << filename << ". Reason: " << endl;
|
||||||
cout << paletteList.ErrorReportString() << endl << "Returning without executing." << endl;
|
cout << paletteList.ErrorReportString() << endl << "Returning without executing." << endl;
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
#include <random>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -102,7 +102,7 @@ void MakeTestAllVarsRegPrePost(vector<Ember<T>>& embers)
|
|||||||
PaletteList<T> paletteList;
|
PaletteList<T> paletteList;
|
||||||
QTIsaac<ISAAC_SIZE, ISAAC_INT> rand;
|
QTIsaac<ISAAC_SIZE, ISAAC_INT> rand;
|
||||||
|
|
||||||
paletteList.Init("flam3-palettes.xml");
|
paletteList.Add("flam3-palettes.xml");
|
||||||
|
|
||||||
Timing t;
|
Timing t;
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ void MakeTestAllVarsRegPrePost(vector<Ember<T>>& embers)
|
|||||||
ss << "NoVars";
|
ss << "NoVars";
|
||||||
emberNoVars.m_Name = ss.str();
|
emberNoVars.m_Name = ss.str();
|
||||||
ss.str("");
|
ss.str("");
|
||||||
emberNoVars.m_Palette = *paletteList.GetPalette(0);
|
emberNoVars.m_Palette = *paletteList.GetPalette(paletteList.m_DefaultFilename, 0);
|
||||||
embers.push_back(emberNoVars);
|
embers.push_back(emberNoVars);
|
||||||
|
|
||||||
while (index < varList.RegSize())
|
while (index < varList.RegSize())
|
||||||
@ -196,7 +196,7 @@ void MakeTestAllVarsRegPrePost(vector<Ember<T>>& embers)
|
|||||||
ss << index << "_" << regVar->Name();
|
ss << index << "_" << regVar->Name();
|
||||||
ember1.m_Name = ss.str();
|
ember1.m_Name = ss.str();
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ember1.m_Palette = *paletteList.GetPalette(index % paletteList.Size());
|
ember1.m_Palette = *paletteList.GetRandomPalette();
|
||||||
index++;
|
index++;
|
||||||
embers.push_back(ember1);
|
embers.push_back(ember1);
|
||||||
}
|
}
|
||||||
@ -1142,7 +1142,7 @@ void TestXformsInOutPoints()
|
|||||||
PaletteList<float> paletteList;
|
PaletteList<float> paletteList;
|
||||||
QTIsaac<ISAAC_SIZE, ISAAC_INT> rand;
|
QTIsaac<ISAAC_SIZE, ISAAC_INT> rand;
|
||||||
|
|
||||||
paletteList.Init("flam3-palettes.xml");
|
paletteList.Add("flam3-palettes.xml");
|
||||||
|
|
||||||
while (index < varList.RegSize())
|
while (index < varList.RegSize())
|
||||||
{
|
{
|
||||||
@ -1882,8 +1882,15 @@ int _tmain(int argc, _TCHAR* argv[])
|
|||||||
{
|
{
|
||||||
//int i;
|
//int i;
|
||||||
Timing t(4);
|
Timing t(4);
|
||||||
QTIsaac<ISAAC_SIZE, ISAAC_INT> rand;
|
QTIsaac<ISAAC_SIZE, ISAAC_INT> rand(1, 2, 3);
|
||||||
double d = 1;
|
mt19937 meow(1729);
|
||||||
|
|
||||||
|
PaletteList<float> palf;
|
||||||
|
Palette<float>* pal = palf.GetRandomPalette();
|
||||||
|
|
||||||
|
cout << pal->Size() << endl;
|
||||||
|
|
||||||
|
/*double d = 1;
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++)
|
for (int i = 0; i < 10; i++)
|
||||||
{
|
{
|
||||||
@ -1891,7 +1898,32 @@ int _tmain(int argc, _TCHAR* argv[])
|
|||||||
d *= 10;
|
d *= 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;*/
|
||||||
|
/*
|
||||||
|
uint i, iters = (uint)10e7;
|
||||||
|
size_t total = 0;
|
||||||
|
|
||||||
|
t.Tic();
|
||||||
|
for (i = 0; i < iters; i++)
|
||||||
|
{
|
||||||
|
total += rand.RandByte();
|
||||||
|
total += rand.Rand();
|
||||||
|
}
|
||||||
|
t.Toc("Isaac sum");
|
||||||
|
|
||||||
|
cout << "Isaac total = " << total << " for " << i << " iters." << endl;
|
||||||
|
|
||||||
|
total = 0;
|
||||||
|
|
||||||
|
t.Tic();
|
||||||
|
for (i = 0; i < iters; i++)
|
||||||
|
{
|
||||||
|
total += meow();
|
||||||
|
}
|
||||||
|
t.Toc("Mt sum");
|
||||||
|
|
||||||
|
cout << "Mt total = " << total << " for " << i << " iters." << endl;
|
||||||
|
*/
|
||||||
//glm::vec2 solution, src[4];
|
//glm::vec2 solution, src[4];
|
||||||
//double bezT = 1, w[4];
|
//double bezT = 1, w[4];
|
||||||
//BezierPoints curvePoints[4];
|
//BezierPoints curvePoints[4];
|
||||||
|
@ -243,11 +243,11 @@ public slots:
|
|||||||
|
|
||||||
//Xforms Xaos.
|
//Xforms Xaos.
|
||||||
void OnXaosChanged(double d);
|
void OnXaosChanged(double d);
|
||||||
void OnXaosFromToToggled(bool checked);
|
|
||||||
void OnClearXaosButtonClicked(bool checked);
|
void OnClearXaosButtonClicked(bool checked);
|
||||||
void OnRandomXaosButtonClicked(bool checked);
|
void OnRandomXaosButtonClicked(bool checked);
|
||||||
|
|
||||||
//Palette.
|
//Palette.
|
||||||
|
void OnPaletteFilenameComboChanged(const QString& text);
|
||||||
void OnPaletteAdjust(int d);
|
void OnPaletteAdjust(int d);
|
||||||
void OnPaletteCellClicked(int row, int col);
|
void OnPaletteCellClicked(int row, int col);
|
||||||
void OnPaletteCellDoubleClicked(int row, int col);
|
void OnPaletteCellDoubleClicked(int row, int col);
|
||||||
|
@ -2953,8 +2953,8 @@ SpinBox
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>118</width>
|
<width>245</width>
|
||||||
<height>618</height>
|
<height>747</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="autoFillBackground">
|
<property name="autoFillBackground">
|
||||||
@ -4561,7 +4561,10 @@ SpinBox
|
|||||||
<enum>Qt::ScrollBarAsNeeded</enum>
|
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="horizontalScrollBarPolicy">
|
<property name="horizontalScrollBarPolicy">
|
||||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeAdjustPolicy">
|
||||||
|
<enum>QAbstractScrollArea::AdjustToContents</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="autoScroll">
|
<property name="autoScroll">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
@ -4603,29 +4606,32 @@ SpinBox
|
|||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="columnCount">
|
<property name="columnCount">
|
||||||
<number>2</number>
|
<number>3</number>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="horizontalHeaderVisible">
|
<attribute name="horizontalHeaderVisible">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="horizontalHeaderCascadingSectionResizes">
|
<attribute name="horizontalHeaderCascadingSectionResizes">
|
||||||
<bool>false</bool>
|
<bool>true</bool>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="horizontalHeaderDefaultSectionSize">
|
<attribute name="horizontalHeaderDefaultSectionSize">
|
||||||
<number>110</number>
|
<number>40</number>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="horizontalHeaderHighlightSections">
|
<attribute name="horizontalHeaderHighlightSections">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="horizontalHeaderMinimumSectionSize">
|
<attribute name="horizontalHeaderMinimumSectionSize">
|
||||||
<number>27</number>
|
<number>15</number>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="horizontalHeaderStretchLastSection">
|
<attribute name="horizontalHeaderStretchLastSection">
|
||||||
<bool>true</bool>
|
<bool>false</bool>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="verticalHeaderVisible">
|
<attribute name="verticalHeaderVisible">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
<attribute name="verticalHeaderCascadingSectionResizes">
|
||||||
|
<bool>true</bool>
|
||||||
|
</attribute>
|
||||||
<attribute name="verticalHeaderDefaultSectionSize">
|
<attribute name="verticalHeaderDefaultSectionSize">
|
||||||
<number>22</number>
|
<number>22</number>
|
||||||
</attribute>
|
</attribute>
|
||||||
@ -4640,17 +4646,22 @@ SpinBox
|
|||||||
</attribute>
|
</attribute>
|
||||||
<row>
|
<row>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Default Row</string>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
</row>
|
</row>
|
||||||
<column>
|
<column>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Field</string>
|
<string>F1</string>
|
||||||
</property>
|
</property>
|
||||||
</column>
|
</column>
|
||||||
<column>
|
<column>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string>F2</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>F3</string>
|
||||||
</property>
|
</property>
|
||||||
</column>
|
</column>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
@ -4663,56 +4674,11 @@ SpinBox
|
|||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
</item>
|
</item>
|
||||||
</widget>
|
<item row="0" column="2">
|
||||||
</item>
|
<property name="text">
|
||||||
<item>
|
<string/>
|
||||||
<widget class="QGroupBox" name="XaosFromToGroupBox">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="title">
|
|
||||||
<string>Direction</string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
|
||||||
</property>
|
|
||||||
<property name="flat">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
|
||||||
<property name="leftMargin">
|
|
||||||
<number>6</number>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="topMargin">
|
</item>
|
||||||
<number>2</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>6</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>6</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<widget class="QRadioButton" name="XaosToRadio">
|
|
||||||
<property name="text">
|
|
||||||
<string>To</string>
|
|
||||||
</property>
|
|
||||||
<property name="checked">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QRadioButton" name="XaosFromRadio">
|
|
||||||
<property name="text">
|
|
||||||
<string>From</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@ -4752,7 +4718,7 @@ SpinBox
|
|||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Palette</string>
|
<string>Palette</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QGridLayout" name="gridLayout_16" rowstretch="0,0,0,0" columnstretch="0">
|
<layout class="QGridLayout" name="gridLayout_16" rowstretch="0,0,0,0,0" columnstretch="0">
|
||||||
<property name="sizeConstraint">
|
<property name="sizeConstraint">
|
||||||
<enum>QLayout::SetDefaultConstraint</enum>
|
<enum>QLayout::SetDefaultConstraint</enum>
|
||||||
</property>
|
</property>
|
||||||
@ -4771,7 +4737,7 @@ SpinBox
|
|||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="2" column="0">
|
<item row="3" column="0">
|
||||||
<widget class="TableWidget" name="PalettePreviewTable">
|
<widget class="TableWidget" name="PalettePreviewTable">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
|
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
|
||||||
@ -4853,7 +4819,7 @@ SpinBox
|
|||||||
<column/>
|
<column/>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="TableWidget" name="PaletteAdjustTable">
|
<widget class="TableWidget" name="PaletteAdjustTable">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
|
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
|
||||||
@ -4986,7 +4952,7 @@ SpinBox
|
|||||||
</item>
|
</item>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="4" column="0">
|
||||||
<widget class="QTableWidget" name="PaletteListTable">
|
<widget class="QTableWidget" name="PaletteListTable">
|
||||||
<property name="focusPolicy">
|
<property name="focusPolicy">
|
||||||
<enum>Qt::StrongFocus</enum>
|
<enum>Qt::StrongFocus</enum>
|
||||||
@ -5060,7 +5026,7 @@ SpinBox
|
|||||||
</column>
|
</column>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="2" column="0">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>4</number>
|
<number>4</number>
|
||||||
@ -5117,6 +5083,9 @@ SpinBox
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QComboBox" name="PaletteFilenameCombo"/>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="InfoTab">
|
<widget class="QWidget" name="InfoTab">
|
||||||
@ -6064,8 +6033,6 @@ SpinBox
|
|||||||
<tabstop>PreAffineGroupBox</tabstop>
|
<tabstop>PreAffineGroupBox</tabstop>
|
||||||
<tabstop>scrollArea_4</tabstop>
|
<tabstop>scrollArea_4</tabstop>
|
||||||
<tabstop>InfoBoundsGroupBox</tabstop>
|
<tabstop>InfoBoundsGroupBox</tabstop>
|
||||||
<tabstop>XaosFromRadio</tabstop>
|
|
||||||
<tabstop>XaosToRadio</tabstop>
|
|
||||||
</tabstops>
|
</tabstops>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="Fractorium.qrc"/>
|
<include location="Fractorium.qrc"/>
|
||||||
|
@ -76,7 +76,11 @@ FractoriumEmberController<T>::FractoriumEmberController(Fractorium* fractorium)
|
|||||||
m_GLController = unique_ptr<GLEmberController<T>>(new GLEmberController<T>(fractorium, fractorium->ui.GLDisplay, this));
|
m_GLController = unique_ptr<GLEmberController<T>>(new GLEmberController<T>(fractorium, fractorium->ui.GLDisplay, this));
|
||||||
m_PreviewRenderer = unique_ptr<EmberNs::Renderer<T, T>>(new EmberNs::Renderer<T, T>());
|
m_PreviewRenderer = unique_ptr<EmberNs::Renderer<T, T>>(new EmberNs::Renderer<T, T>());
|
||||||
SetupVariationTree();
|
SetupVariationTree();
|
||||||
InitPaletteTable("flam3-palettes.xml");
|
|
||||||
|
//Initial combo change event to fill the palette table will be called automatically later.
|
||||||
|
if (!InitPaletteList("./"))
|
||||||
|
throw "No palettes found, exiting.";
|
||||||
|
|
||||||
BackgroundChanged(QColor(0, 0, 0));//Default to black.
|
BackgroundChanged(QColor(0, 0, 0));//Default to black.
|
||||||
ClearUndo();
|
ClearUndo();
|
||||||
|
|
||||||
|
@ -177,14 +177,15 @@ public:
|
|||||||
virtual void VariationSpinBoxValueChanged(double d) { }
|
virtual void VariationSpinBoxValueChanged(double d) { }
|
||||||
|
|
||||||
//Xforms Xaos.
|
//Xforms Xaos.
|
||||||
virtual void FillXaosWithCurrentXform() { }
|
virtual void FillXaos() { }
|
||||||
virtual QString MakeXaosNameString(uint i) { return ""; }
|
virtual QString MakeXaosNameString(uint i) { return ""; }
|
||||||
virtual void XaosChanged(DoubleSpinBox* sender) { }
|
virtual void XaosChanged(DoubleSpinBox* sender) { }
|
||||||
virtual void ClearXaos() { }
|
virtual void ClearXaos() { }
|
||||||
virtual void RandomXaos() { }
|
virtual void RandomXaos() { }
|
||||||
|
|
||||||
//Palette.
|
//Palette.
|
||||||
virtual bool InitPaletteTable(const string& s) { return false; }
|
virtual int InitPaletteList(const string& s) { return 0; }
|
||||||
|
virtual bool FillPaletteTable(const string& s) { return false; }
|
||||||
virtual void ApplyPaletteToEmber() { }
|
virtual void ApplyPaletteToEmber() { }
|
||||||
virtual void PaletteAdjust() { }
|
virtual void PaletteAdjust() { }
|
||||||
virtual QRgb GetQRgbFromPaletteIndex(uint i) { return QRgb(); }
|
virtual QRgb GetQRgbFromPaletteIndex(uint i) { return QRgb(); }
|
||||||
@ -235,6 +236,7 @@ protected:
|
|||||||
QImage m_FinalPaletteImage;
|
QImage m_FinalPaletteImage;
|
||||||
QString m_LastSaveAll;
|
QString m_LastSaveAll;
|
||||||
QString m_LastSaveCurrent;
|
QString m_LastSaveCurrent;
|
||||||
|
string m_CurrentPaletteFilePath;
|
||||||
CriticalSection m_Cs;
|
CriticalSection m_Cs;
|
||||||
std::thread m_WriteThread;
|
std::thread m_WriteThread;
|
||||||
vector<byte> m_FinalImage[2];
|
vector<byte> m_FinalImage[2];
|
||||||
@ -405,14 +407,15 @@ public:
|
|||||||
void FillVariationTreeWithXform(Xform<T>* xform);
|
void FillVariationTreeWithXform(Xform<T>* xform);
|
||||||
|
|
||||||
//Xforms Xaos.
|
//Xforms Xaos.
|
||||||
virtual void FillXaosWithCurrentXform() override;
|
virtual void FillXaos() override;
|
||||||
virtual QString MakeXaosNameString(uint i) override;
|
virtual QString MakeXaosNameString(uint i) override;
|
||||||
virtual void XaosChanged(DoubleSpinBox* sender) override;
|
virtual void XaosChanged(DoubleSpinBox* sender) override;
|
||||||
virtual void ClearXaos() override;
|
virtual void ClearXaos() override;
|
||||||
virtual void RandomXaos() override;
|
virtual void RandomXaos() override;
|
||||||
|
|
||||||
//Palette.
|
//Palette.
|
||||||
virtual bool InitPaletteTable(const string& s) override;
|
virtual int InitPaletteList(const string& s) override;
|
||||||
|
virtual bool FillPaletteTable(const string& s) override;
|
||||||
virtual void ApplyPaletteToEmber() override;
|
virtual void ApplyPaletteToEmber() override;
|
||||||
virtual void PaletteAdjust() override;
|
virtual void PaletteAdjust() override;
|
||||||
virtual QRgb GetQRgbFromPaletteIndex(uint i) override { return QRgb(); }
|
virtual QRgb GetQRgbFromPaletteIndex(uint i) override { return QRgb(); }
|
||||||
|
@ -98,7 +98,7 @@ void FractoriumEmberController<T>::NewEmptyFlameInCurrentFile()
|
|||||||
xform.m_Weight = T(0.25);
|
xform.m_Weight = T(0.25);
|
||||||
xform.m_ColorX = m_Rand.Frand01<T>();
|
xform.m_ColorX = m_Rand.Frand01<T>();
|
||||||
ember.AddXform(xform);
|
ember.AddXform(xform);
|
||||||
ember.m_Palette = *m_PaletteList.GetPalette(-1);
|
ember.m_Palette = *m_PaletteList.GetRandomPalette();
|
||||||
ember.m_Name = EmberFile<T>::DefaultEmberName(m_EmberFile.Size() + 1).toStdString();
|
ember.m_Name = EmberFile<T>::DefaultEmberName(m_EmberFile.Size() + 1).toStdString();
|
||||||
ember.m_Index = m_EmberFile.Size();
|
ember.m_Index = m_EmberFile.Size();
|
||||||
m_EmberFile.m_Embers.push_back(ember);//Will invalidate the pointers contained in the EmberTreeWidgetItems, UpdateLibraryTree() will resync.
|
m_EmberFile.m_Embers.push_back(ember);//Will invalidate the pointers contained in the EmberTreeWidgetItems, UpdateLibraryTree() will resync.
|
||||||
|
@ -12,6 +12,8 @@ void Fractorium::InitPaletteUI()
|
|||||||
QTableWidget* paletteTable = ui.PaletteListTable;
|
QTableWidget* paletteTable = ui.PaletteListTable;
|
||||||
QTableWidget* palettePreviewTable = ui.PalettePreviewTable;
|
QTableWidget* palettePreviewTable = ui.PalettePreviewTable;
|
||||||
|
|
||||||
|
connect(ui.PaletteFilenameCombo, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(OnPaletteFilenameComboChanged(const QString&)), Qt::QueuedConnection);
|
||||||
|
|
||||||
connect(paletteTable, SIGNAL(cellClicked(int, int)), this, SLOT(OnPaletteCellClicked(int, int)), Qt::QueuedConnection);
|
connect(paletteTable, SIGNAL(cellClicked(int, int)), this, SLOT(OnPaletteCellClicked(int, int)), Qt::QueuedConnection);
|
||||||
connect(paletteTable, SIGNAL(cellDoubleClicked(int, int)), this, SLOT(OnPaletteCellDoubleClicked(int, int)), Qt::QueuedConnection);
|
connect(paletteTable, SIGNAL(cellDoubleClicked(int, int)), this, SLOT(OnPaletteCellDoubleClicked(int, int)), Qt::QueuedConnection);
|
||||||
|
|
||||||
@ -30,52 +32,83 @@ void Fractorium::InitPaletteUI()
|
|||||||
|
|
||||||
connect(ui.PaletteRandomSelect, SIGNAL(clicked(bool)), this, SLOT(OnPaletteRandomSelectButtonClicked(bool)), Qt::QueuedConnection);
|
connect(ui.PaletteRandomSelect, SIGNAL(clicked(bool)), this, SLOT(OnPaletteRandomSelectButtonClicked(bool)), Qt::QueuedConnection);
|
||||||
connect(ui.PaletteRandomAdjust, SIGNAL(clicked(bool)), this, SLOT(OnPaletteRandomAdjustButtonClicked(bool)), Qt::QueuedConnection);
|
connect(ui.PaletteRandomAdjust, SIGNAL(clicked(bool)), this, SLOT(OnPaletteRandomAdjustButtonClicked(bool)), Qt::QueuedConnection);
|
||||||
|
|
||||||
|
//Preview table.
|
||||||
|
palettePreviewTable->setRowCount(1);
|
||||||
|
palettePreviewTable->setColumnWidth(1, 260);//256 plus small margin on each side.
|
||||||
|
QTableWidgetItem* previewNameCol = new QTableWidgetItem("");
|
||||||
|
palettePreviewTable->setItem(0, 0, previewNameCol);
|
||||||
|
QTableWidgetItem* previewPaletteItem = new QTableWidgetItem();
|
||||||
|
palettePreviewTable->setItem(0, 1, previewPaletteItem);
|
||||||
|
|
||||||
|
paletteTable->setColumnWidth(1, 260);//256 plus small margin on each side.
|
||||||
|
paletteTable->horizontalHeader()->setSectionsClickable(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Read all palette Xml files in the specified folder and populate the palette list with the contents.
|
||||||
|
/// This will clear any previous contents.
|
||||||
|
/// Called upon initialization, or controller type change.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="s">The full path to the palette files folder</param>
|
||||||
|
/// <returns>The number of palettes successfully added</returns>
|
||||||
|
template <typename T>
|
||||||
|
int FractoriumEmberController<T>::InitPaletteList(const string& s)
|
||||||
|
{
|
||||||
|
QDirIterator it(s.c_str(), QStringList() << "*.xml", QDir::Files, QDirIterator::FollowSymlinks);
|
||||||
|
|
||||||
|
m_PaletteList.Clear();
|
||||||
|
m_Fractorium->ui.PaletteFilenameCombo->clear();
|
||||||
|
m_Fractorium->ui.PaletteFilenameCombo->setProperty("path", QString::fromStdString(s));
|
||||||
|
|
||||||
|
while (it.hasNext())
|
||||||
|
{
|
||||||
|
auto path = it.next().toStdString();
|
||||||
|
auto qfilename = it.fileName();
|
||||||
|
|
||||||
|
if (m_PaletteList.Add(path))
|
||||||
|
m_Fractorium->ui.PaletteFilenameCombo->addItem(qfilename);
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_PaletteList.Size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Read a palette Xml file and populate the palette table with the contents.
|
/// Read a palette Xml file and populate the palette table with the contents.
|
||||||
/// This will clear any previous contents.
|
/// This will clear any previous contents.
|
||||||
/// Called upon initialization, or controller type change.
|
/// Called upon initialization, palette combo index change, and controller type change.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="s">The full path to the palette file</param>
|
/// <param name="s">The name to the palette file without the path</param>
|
||||||
/// <returns>True if successful, else false.</returns>
|
/// <returns>True if successful, else false.</returns>
|
||||||
template <typename T>
|
template <typename T>
|
||||||
bool FractoriumEmberController<T>::InitPaletteTable(const string& s)
|
bool FractoriumEmberController<T>::FillPaletteTable(const string& s)
|
||||||
{
|
{
|
||||||
QTableWidget* paletteTable = m_Fractorium->ui.PaletteListTable;
|
QTableWidget* paletteTable = m_Fractorium->ui.PaletteListTable;
|
||||||
QTableWidget* palettePreviewTable = m_Fractorium->ui.PalettePreviewTable;
|
QTableWidget* palettePreviewTable = m_Fractorium->ui.PalettePreviewTable;
|
||||||
|
|
||||||
paletteTable->clear();
|
m_CurrentPaletteFilePath = m_Fractorium->ui.PaletteFilenameCombo->property("path").toString().toStdString() + s;
|
||||||
|
size_t paletteSize = m_PaletteList.Size(m_CurrentPaletteFilePath);
|
||||||
|
|
||||||
if (m_PaletteList.Init(s))//Default to this, but add an option later.//TODO
|
if (paletteSize)
|
||||||
{
|
{
|
||||||
//Preview table.
|
paletteTable->clear();
|
||||||
palettePreviewTable->setRowCount(1);
|
paletteTable->blockSignals(true);
|
||||||
palettePreviewTable->setColumnWidth(1, 260);//256 plus small margin on each side.
|
paletteTable->setRowCount(paletteSize);
|
||||||
QTableWidgetItem* previewNameCol = new QTableWidgetItem("");
|
|
||||||
palettePreviewTable->setItem(0, 0, previewNameCol);
|
|
||||||
QTableWidgetItem* previewPaletteItem = new QTableWidgetItem();
|
|
||||||
palettePreviewTable->setItem(0, 1, previewPaletteItem);
|
|
||||||
|
|
||||||
//Palette list table.
|
|
||||||
paletteTable->setRowCount(m_PaletteList.Size());
|
|
||||||
paletteTable->setColumnWidth(1, 260);//256 plus small margin on each side.
|
|
||||||
paletteTable->horizontalHeader()->setSectionsClickable(false);
|
|
||||||
|
|
||||||
//Headers get removed when clearing, so must re-create here.
|
//Headers get removed when clearing, so must re-create here.
|
||||||
QTableWidgetItem* nameHeader = new QTableWidgetItem("Name");
|
QTableWidgetItem* nameHeader = new QTableWidgetItem("Name");
|
||||||
QTableWidgetItem* paletteHeader = new QTableWidgetItem("Palette");
|
QTableWidgetItem* paletteHeader = new QTableWidgetItem("Palette");
|
||||||
|
|
||||||
nameHeader->setTextAlignment(Qt::AlignLeft|Qt::AlignVCenter);
|
nameHeader->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
||||||
paletteHeader->setTextAlignment(Qt::AlignLeft|Qt::AlignVCenter);
|
paletteHeader->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
||||||
|
|
||||||
paletteTable->setHorizontalHeaderItem(0, nameHeader);
|
paletteTable->setHorizontalHeaderItem(0, nameHeader);
|
||||||
paletteTable->setHorizontalHeaderItem(1, paletteHeader);
|
paletteTable->setHorizontalHeaderItem(1, paletteHeader);
|
||||||
|
|
||||||
//Palette list table.
|
//Palette list table.
|
||||||
for (size_t i = 0; i < m_PaletteList.Size(); i++)
|
for (size_t i = 0; i < paletteSize; i++)
|
||||||
{
|
{
|
||||||
Palette<T>* p = m_PaletteList.GetPalette(i);
|
Palette<T>* p = m_PaletteList.GetPalette(m_CurrentPaletteFilePath, i);
|
||||||
vector<byte> v = p->MakeRgbPaletteBlock(PALETTE_CELL_HEIGHT);
|
vector<byte> v = p->MakeRgbPaletteBlock(PALETTE_CELL_HEIGHT);
|
||||||
QTableWidgetItem* nameCol = new QTableWidgetItem(p->m_Name.c_str());
|
QTableWidgetItem* nameCol = new QTableWidgetItem(p->m_Name.c_str());
|
||||||
|
|
||||||
@ -89,6 +122,8 @@ bool FractoriumEmberController<T>::InitPaletteTable(const string& s)
|
|||||||
paletteTable->setItem(i, 1, paletteItem);
|
paletteTable->setItem(i, 1, paletteItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
paletteTable->blockSignals(false);
|
||||||
|
m_Fractorium->OnPaletteRandomSelectButtonClicked(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -102,6 +137,8 @@ bool FractoriumEmberController<T>::InitPaletteTable(const string& s)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Fractorium::OnPaletteFilenameComboChanged(const QString& text) { m_Controller->FillPaletteTable(text.toStdString()); }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Apply adjustments to the current ember's palette.
|
/// Apply adjustments to the current ember's palette.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -188,7 +225,7 @@ void Fractorium::OnPaletteAdjust(int d) { m_Controller->PaletteAdjust(); }
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
void FractoriumEmberController<T>::PaletteCellClicked(int row, int col)
|
void FractoriumEmberController<T>::PaletteCellClicked(int row, int col)
|
||||||
{
|
{
|
||||||
Palette<T>* palette = m_PaletteList.GetPalette(row);
|
Palette<T>* palette = m_PaletteList.GetPalette(m_CurrentPaletteFilePath, row);
|
||||||
QTableWidgetItem* nameItem = m_Fractorium->ui.PaletteListTable->item(row, 0);
|
QTableWidgetItem* nameItem = m_Fractorium->ui.PaletteListTable->item(row, 0);
|
||||||
|
|
||||||
if (palette)
|
if (palette)
|
||||||
@ -225,11 +262,11 @@ void Fractorium::OnPaletteCellDoubleClicked(int row, int col)
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set the selected palette to a randomly selected one,
|
/// Set the selected palette to a randomly selected one,
|
||||||
/// applying any adjustments previously specified.
|
/// applying any adjustments previously specified if the checked parameter is true.
|
||||||
/// Called when the Random Palette button is clicked.
|
/// Called when the Random Palette button is clicked.
|
||||||
/// Resets the rendering process.
|
/// Resets the rendering process.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="row">The current row selected</param>
|
/// <param name="checked">True to clear the current adjustments, else leave current adjustments.</param>
|
||||||
void Fractorium::OnPaletteRandomSelectButtonClicked(bool checked)
|
void Fractorium::OnPaletteRandomSelectButtonClicked(bool checked)
|
||||||
{
|
{
|
||||||
uint i = 0;
|
uint i = 0;
|
||||||
@ -237,7 +274,10 @@ void Fractorium::OnPaletteRandomSelectButtonClicked(bool checked)
|
|||||||
|
|
||||||
while ((i = QTIsaac<ISAAC_SIZE, ISAAC_INT>::GlobalRand->Rand(rowCount)) == uint(m_PreviousPaletteRow));
|
while ((i = QTIsaac<ISAAC_SIZE, ISAAC_INT>::GlobalRand->Rand(rowCount)) == uint(m_PreviousPaletteRow));
|
||||||
|
|
||||||
OnPaletteCellClicked(i, 1);
|
if (checked)
|
||||||
|
OnPaletteCellDoubleClicked(i, 1);//Will clear the adjustments.
|
||||||
|
else
|
||||||
|
OnPaletteCellClicked(i, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -568,6 +568,9 @@ void FractoriumEmberController<T>::FillParamTablesAndPalette()
|
|||||||
m_TempPalette = m_Ember.m_Palette;
|
m_TempPalette = m_Ember.m_Palette;
|
||||||
UpdateAdjustedPaletteGUI(m_Ember.m_Palette);//Will clear name string since embedded palettes have no name. This will trigger a full render.
|
UpdateAdjustedPaletteGUI(m_Ember.m_Palette);//Will clear name string since embedded palettes have no name. This will trigger a full render.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Xaos.
|
||||||
|
FillXaos();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -267,11 +267,11 @@ void FractoriumEmberController<T>::XformNameChanged(int row, int col)
|
|||||||
|
|
||||||
xform->m_Name = m_Fractorium->ui.XformWeightNameTable->item(row, col)->text().toStdString();
|
xform->m_Name = m_Fractorium->ui.XformWeightNameTable->item(row, col)->text().toStdString();
|
||||||
|
|
||||||
if (index != -1)
|
//if (index != -1)
|
||||||
{
|
//{
|
||||||
if (QTableWidgetItem* xformNameItem = m_Fractorium->ui.XaosTable->item(index, 0))
|
// if (QTableWidgetItem* xformNameItem = m_Fractorium->ui.XaosTable->item(index, 0))
|
||||||
xformNameItem->setText(MakeXaosNameString(index));
|
// xformNameItem->setText(MakeXaosNameString(index));
|
||||||
}
|
//}
|
||||||
}, false);
|
}, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -298,7 +298,6 @@ void FractoriumEmberController<T>::FillWithXform(Xform<T>* xform)
|
|||||||
FillColorWithXform(xform);
|
FillColorWithXform(xform);
|
||||||
FillAffineWithXform(xform, true);
|
FillAffineWithXform(xform, true);
|
||||||
FillAffineWithXform(xform, false);
|
FillAffineWithXform(xform, false);
|
||||||
FillXaosWithCurrentXform();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -6,42 +6,24 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
void Fractorium::InitXformsXaosUI()
|
void Fractorium::InitXformsXaosUI()
|
||||||
{
|
{
|
||||||
connect(ui.XaosToRadio, SIGNAL(toggled(bool)), this, SLOT(OnXaosFromToToggled(bool)), Qt::QueuedConnection);
|
|
||||||
connect(ui.ClearXaosButton, SIGNAL(clicked(bool)), this, SLOT(OnClearXaosButtonClicked(bool)), Qt::QueuedConnection);
|
connect(ui.ClearXaosButton, SIGNAL(clicked(bool)), this, SLOT(OnClearXaosButtonClicked(bool)), Qt::QueuedConnection);
|
||||||
connect(ui.RandomXaosButton, SIGNAL(clicked(bool)), this, SLOT(OnRandomXaosButtonClicked(bool)), Qt::QueuedConnection);
|
connect(ui.RandomXaosButton, SIGNAL(clicked(bool)), this, SLOT(OnRandomXaosButtonClicked(bool)), Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fill the xaos table with the values from the current xform.
|
/// Fill the xaos table with the values from the ember.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void FractoriumEmberController<T>::FillXaosWithCurrentXform()
|
void FractoriumEmberController<T>::FillXaos()
|
||||||
{
|
{
|
||||||
Xform<T>* currXform = CurrentXform();
|
for (int i = 0, count = int(XformCount()); i < count; i++)
|
||||||
|
|
||||||
if (!IsFinal(currXform))
|
|
||||||
{
|
{
|
||||||
for (int i = 0; i < m_Ember.XformCount(); i++)
|
auto* xform = m_Ember.GetXform(i);
|
||||||
{
|
|
||||||
DoubleSpinBox* spinBox = dynamic_cast<DoubleSpinBox*>(m_Fractorium->ui.XaosTable->cellWidget(i, 1));
|
|
||||||
|
|
||||||
//Fill in values column.
|
for (int j = 0; j < count; j++)
|
||||||
if (m_Fractorium->ui.XaosToRadio->isChecked())//"To": Single xform, advance index.
|
if (auto* spinBox = dynamic_cast<DoubleSpinBox*>(m_Fractorium->ui.XaosTable->cellWidget(i, j)))
|
||||||
spinBox->SetValueStealth(currXform->Xaos(i));
|
spinBox->SetValueStealth(xform->Xaos(j));
|
||||||
else//"From": Advance xforms, single index.
|
|
||||||
if ((currXform = m_Ember.GetXform(i)))
|
|
||||||
spinBox->SetValueStealth(currXform->Xaos(m_Fractorium->ui.CurrentXformCombo->currentIndex()));
|
|
||||||
|
|
||||||
//Fill in name column.
|
|
||||||
Xform<T>* xform = m_Ember.GetXform(i);
|
|
||||||
QTableWidgetItem* xformNameItem = m_Fractorium->ui.XaosTable->item(i, 0);
|
|
||||||
|
|
||||||
if (xform && xformNameItem)
|
|
||||||
xformNameItem->setText(MakeXaosNameString(i));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Fractorium->ui.XaosTable->setEnabled(!IsFinal(currXform));//Disable if final, else enable.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -55,22 +37,22 @@ QString FractoriumEmberController<T>::MakeXaosNameString(uint i)
|
|||||||
Xform<T>* xform = m_Ember.GetXform(i);
|
Xform<T>* xform = m_Ember.GetXform(i);
|
||||||
QString name;
|
QString name;
|
||||||
|
|
||||||
if (xform)
|
//if (xform)
|
||||||
{
|
//{
|
||||||
int indexPlus1 = m_Ember.GetXformIndex(xform) + 1;//GUI is 1 indexed to avoid confusing the user.
|
// int indexPlus1 = m_Ember.GetXformIndex(xform) + 1;//GUI is 1 indexed to avoid confusing the user.
|
||||||
int curr = m_Fractorium->ui.CurrentXformCombo->currentIndex() + 1;
|
// int curr = m_Fractorium->ui.CurrentXformCombo->currentIndex() + 1;
|
||||||
|
//
|
||||||
if (indexPlus1 != -1)
|
// if (indexPlus1 != -1)
|
||||||
{
|
// {
|
||||||
if (m_Fractorium->ui.XaosToRadio->isChecked())
|
// if (m_Fractorium->ui.XaosToRadio->isChecked())
|
||||||
name = QString("From ") + ToString(curr) + QString(" To ") + ToString(indexPlus1);
|
// name = QString("From ") + ToString(curr) + QString(" To ") + ToString(indexPlus1);
|
||||||
else
|
// else
|
||||||
name = QString("From ") + ToString(indexPlus1) + QString(" To ") + ToString(curr);
|
// name = QString("From ") + ToString(indexPlus1) + QString(" To ") + ToString(curr);
|
||||||
|
//
|
||||||
//if (xform->m_Name != "")
|
// //if (xform->m_Name != "")
|
||||||
// name = name + " (" + QString::fromStdString(xform->m_Name) + ")";
|
// // name = name + " (" + QString::fromStdString(xform->m_Name) + ")";
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
@ -78,109 +60,93 @@ QString FractoriumEmberController<T>::MakeXaosNameString(uint i)
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set the xaos value.
|
/// Set the xaos value.
|
||||||
/// Called when any xaos spinner is changed.
|
/// Called when any xaos spinner is changed.
|
||||||
/// Different action taken based on the state of to/from radio button.
|
|
||||||
/// Resets the rendering process.
|
/// Resets the rendering process.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sender">The DoubleSpinBox that triggered this event</param>
|
/// <param name="sender">The DoubleSpinBox that triggered this event</param>
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void FractoriumEmberController<T>::XaosChanged(DoubleSpinBox* sender)
|
void FractoriumEmberController<T>::XaosChanged(DoubleSpinBox* sender)
|
||||||
{
|
{
|
||||||
UpdateCurrentXform([&] (Xform<T>* xform)
|
auto p = sender->property("tableindex").toPoint();
|
||||||
{
|
|
||||||
QTableWidget* xaosTable = m_Fractorium->ui.XaosTable;
|
|
||||||
|
|
||||||
if (!IsFinal(xform))//This should never get called for the final xform because the table will be disabled, but check just to be safe.
|
if (auto* xform = m_Ember.GetXform(p.x()))
|
||||||
{
|
Update([&] { xform->SetXaos(p.y(), sender->value()); });
|
||||||
for (int i = 0; i < xaosTable->rowCount(); i++)//Find the spin box that triggered the event.
|
|
||||||
{
|
|
||||||
DoubleSpinBox* spinBox = dynamic_cast<DoubleSpinBox*>(xaosTable->cellWidget(i, 1));
|
|
||||||
|
|
||||||
if (spinBox == sender)
|
|
||||||
{
|
|
||||||
if (m_Fractorium->ui.XaosToRadio->isChecked())//"To": Single xform, advance index.
|
|
||||||
{
|
|
||||||
xform->SetXaos(i, spinBox->value());
|
|
||||||
}
|
|
||||||
else//"From": Advance xforms, single index.
|
|
||||||
{
|
|
||||||
if ((xform = m_Ember.GetXform(i)))//Single = is intentional.
|
|
||||||
xform->SetXaos(m_Fractorium->ui.CurrentXformCombo->currentIndex(), spinBox->value());
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fractorium::OnXaosChanged(double d)
|
void Fractorium::OnXaosChanged(double d)
|
||||||
{
|
{
|
||||||
if (DoubleSpinBox* senderSpinBox = dynamic_cast<DoubleSpinBox*>(this->sender()))
|
if (auto* senderSpinBox = dynamic_cast<DoubleSpinBox*>(this->sender()))
|
||||||
m_Controller->XaosChanged(senderSpinBox);
|
m_Controller->XaosChanged(senderSpinBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Update xaos display to use either "to" or "from" logic.
|
/// Clear xaos table, recreate all spinners based on the xaos used in the current ember.
|
||||||
/// Called when xaos to/from radio buttons checked.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="checked">Ignored</param>
|
|
||||||
void Fractorium::OnXaosFromToToggled(bool checked)
|
|
||||||
{
|
|
||||||
m_Controller->FillXaosWithCurrentXform();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clear xaos table, recreate all spinners based on the xaos used by the current xform in the current ember.
|
|
||||||
/// Called every time the current xform changes.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void Fractorium::FillXaosTable()
|
void Fractorium::FillXaosTable()
|
||||||
{
|
{
|
||||||
int spinHeight = 20;
|
int spinHeight = 20;
|
||||||
|
int count = int(m_Controller->XformCount());
|
||||||
QWidget* w = nullptr;
|
QWidget* w = nullptr;
|
||||||
ui.XaosTable->setRowCount(m_Controller->XformCount());//This will grow or shrink the number of rows and call the destructor for previous DoubleSpinBoxes.
|
QString lbl("lbl");
|
||||||
|
|
||||||
for (int i = 0; i < int(m_Controller->XformCount()); i++)
|
ui.XaosTable->setRowCount(count);//This will grow or shrink the number of rows and call the destructor for previous DoubleSpinBoxes.
|
||||||
|
ui.XaosTable->setColumnCount(count);
|
||||||
|
|
||||||
|
ui.XaosTable->verticalHeader()->setVisible(true);
|
||||||
|
ui.XaosTable->horizontalHeader()->setVisible(true);
|
||||||
|
ui.XaosTable->verticalHeader()->setSectionsClickable(false);
|
||||||
|
ui.XaosTable->horizontalHeader()->setSectionsClickable(false);
|
||||||
|
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
DoubleSpinBox* spinBox = new DoubleSpinBox(ui.XaosTable, spinHeight, 0.1);
|
for (int j = 0; j < count; j++)
|
||||||
QTableWidgetItem* xformNameItem = new QTableWidgetItem(m_Controller->MakeXaosNameString(i));
|
{
|
||||||
|
QPoint p(i, j);
|
||||||
|
DoubleSpinBox* spinBox = new DoubleSpinBox(ui.XaosTable, spinHeight, 0.1);
|
||||||
|
|
||||||
spinBox->DoubleClick(true);
|
spinBox->setFixedWidth(35);
|
||||||
spinBox->DoubleClickZero(1);
|
spinBox->DoubleClick(true);
|
||||||
spinBox->DoubleClickNonZero(0);
|
spinBox->DoubleClickZero(1);
|
||||||
ui.XaosTable->setItem(i, 0, xformNameItem);
|
spinBox->DoubleClickNonZero(0);
|
||||||
ui.XaosTable->setCellWidget(i, 1, spinBox);
|
spinBox->setProperty("tableindex", p);
|
||||||
connect(spinBox, SIGNAL(valueChanged(double)), this, SLOT(OnXaosChanged(double)), Qt::QueuedConnection);
|
ui.XaosTable->setCellWidget(i, j, spinBox);
|
||||||
|
|
||||||
if (i > 0)
|
auto wp = ui.XaosTable->item(i, j);
|
||||||
w = SetTabOrder(this, w, spinBox);
|
|
||||||
else
|
if (wp)
|
||||||
w = spinBox;
|
wp->setTextAlignment(Qt::AlignCenter);
|
||||||
|
|
||||||
|
connect(spinBox, SIGNAL(valueChanged(double)), this, SLOT(OnXaosChanged(double)), Qt::QueuedConnection);
|
||||||
|
|
||||||
|
if (i == 0 && j == 0)
|
||||||
|
w = spinBox;
|
||||||
|
else
|
||||||
|
w = SetTabOrder(this, w, spinBox);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
w = SetTabOrder(this, w, ui.XaosToRadio);
|
for (int i = 0; i < count; i++)
|
||||||
w = SetTabOrder(this, w, ui.XaosFromRadio);
|
{
|
||||||
|
ui.XaosTable->setHorizontalHeaderItem(i, new QTableWidgetItem("F" + QString::number(i + 1)));
|
||||||
|
ui.XaosTable->setVerticalHeaderItem(i, new QTableWidgetItem("T" + QString::number(i + 1)));
|
||||||
|
ui.XaosTable->horizontalHeader()->setSectionResizeMode(i, QHeaderView::ResizeToContents);
|
||||||
|
ui.XaosTable->verticalHeader()->setSectionResizeMode(i, QHeaderView::ResizeToContents);
|
||||||
|
}
|
||||||
|
|
||||||
|
ui.XaosTable->resizeRowsToContents();
|
||||||
|
ui.XaosTable->resizeColumnsToContents();
|
||||||
|
|
||||||
w = SetTabOrder(this, w, ui.ClearXaosButton);
|
w = SetTabOrder(this, w, ui.ClearXaosButton);
|
||||||
w = SetTabOrder(this, w, ui.RandomXaosButton);
|
w = SetTabOrder(this, w, ui.RandomXaosButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Clear all xaos from the current ember.
|
/// Clear all xaos from the current ember.
|
||||||
/// Called when xaos to/from radio buttons checked.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="checked">Ignored</param>
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void FractoriumEmberController<T>::ClearXaos()
|
void FractoriumEmberController<T>::ClearXaos()
|
||||||
{
|
{
|
||||||
UpdateCurrentXform([&] (Xform<T>* xform)
|
Update([&] { m_Ember.ClearXaos(); });
|
||||||
{
|
FillXaos();
|
||||||
m_Ember.ClearXaos();
|
|
||||||
});
|
|
||||||
|
|
||||||
//Can't just call FillXaosWithCurrentXform() because the current xform might the final.
|
|
||||||
for (int i = 0; i < m_Ember.XformCount(); i++)
|
|
||||||
if (DoubleSpinBox* spinBox = dynamic_cast<DoubleSpinBox*>(m_Fractorium->ui.XaosTable->cellWidget(i, 1)))
|
|
||||||
spinBox->SetValueStealth(1.0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fractorium::OnClearXaosButtonClicked(bool checked) { m_Controller->ClearXaos(); }
|
void Fractorium::OnClearXaosButtonClicked(bool checked) { m_Controller->ClearXaos(); }
|
||||||
@ -195,25 +161,24 @@ void Fractorium::OnClearXaosButtonClicked(bool checked) { m_Controller->ClearXao
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
void FractoriumEmberController<T>::RandomXaos()
|
void FractoriumEmberController<T>::RandomXaos()
|
||||||
{
|
{
|
||||||
UpdateCurrentXform([&](Xform<T>* xform)
|
Update([&]
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < m_Ember.XformCount(); i++)
|
for (size_t i = 0; i < m_Ember.XformCount(); i++)
|
||||||
{
|
{
|
||||||
if (Xform<T>* localXform = m_Ember.GetXform(i))
|
if (auto* xform = m_Ember.GetXform(i))
|
||||||
{
|
{
|
||||||
for (size_t j = 0; j < m_Ember.XformCount(); j++)
|
for (size_t j = 0; j < m_Ember.XformCount(); j++)
|
||||||
{
|
{
|
||||||
if (m_Rand.RandBit())
|
if (m_Rand.RandBit())
|
||||||
localXform->SetXaos(j, T(m_Rand.RandBit()));
|
xform->SetXaos(j, T(m_Rand.RandBit()));
|
||||||
else
|
else
|
||||||
localXform->SetXaos(j, m_Rand.Frand<T>(0, 3));
|
xform->SetXaos(j, m_Rand.Frand<T>(0, 3));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//If current is final, it will update when they change to a non-final xform.
|
FillXaos();
|
||||||
FillXaosWithCurrentXform();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fractorium::OnRandomXaosButtonClicked(bool checked) { m_Controller->RandomXaos(); }
|
void Fractorium::OnRandomXaosButtonClicked(bool checked) { m_Controller->RandomXaos(); }
|
||||||
|
Loading…
Reference in New Issue
Block a user