2014-07-08 03:11:14 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "FractoriumPch.h"
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// GLEmberControllerBase and GLEmberController<T> classes.
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Use/draw pre or post affine transform.
|
|
|
|
/// </summary>
|
2016-01-04 19:50:15 -05:00
|
|
|
enum class eAffineType : et { AffinePre, AffinePost };
|
2014-07-08 03:11:14 -04:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Hovering over nothing, the x axis, the y axis or the center.
|
|
|
|
/// </summary>
|
2016-01-04 19:50:15 -05:00
|
|
|
enum class eHoverType : et { HoverNone, HoverXAxis, HoverYAxis, HoverTranslation };
|
2014-07-08 03:11:14 -04:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Dragging an affine transform or panning, rotating or scaling the image.
|
|
|
|
/// </summary>
|
2016-12-05 22:04:33 -05:00
|
|
|
enum class eDragState : et { DragNone, DragSelect, DragPanning, DragDragging, DragRotateScale };
|
2014-07-08 03:11:14 -04:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Dragging with no keys pressed, shift, control or alt.
|
|
|
|
/// </summary>
|
2016-01-04 19:50:15 -05:00
|
|
|
enum class eDragModifier : et { DragModNone = 0x00, DragModShift = 0x01, DragModControl = 0x02, DragModAlt = 0x04 };
|
2014-07-08 03:11:14 -04:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// GLController, FractoriumEmberController, GLWidget and Fractorium need each other, but each can't all include the other.
|
|
|
|
/// So GLWidget includes this file, and GLWidget, FractoriumEmberController and Fractorium are declared as forward declarations here.
|
|
|
|
/// </summary>
|
|
|
|
class GLWidget;
|
|
|
|
class Fractorium;
|
|
|
|
template <typename T> class FractoriumEmberController;
|
|
|
|
|
2018-03-28 00:32:10 -04:00
|
|
|
#define USE_GLSL 1
|
|
|
|
|
2014-07-08 03:11:14 -04:00
|
|
|
/// <summary>
|
|
|
|
/// GLEmberControllerBase serves as a non-templated base class with virtual
|
|
|
|
/// functions which will be overridden in a derived class that takes a template parameter.
|
|
|
|
/// The controller serves as a way to access both the GLWidget and the underlying ember
|
|
|
|
/// objects through an interface that doesn't require template argument, but does allow
|
|
|
|
/// templated objects to be used underneath.
|
|
|
|
/// The functions not implemented in this file can be found in GLWidget.cpp near the area of code which uses them.
|
|
|
|
/// </summary>
|
|
|
|
class GLEmberControllerBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GLEmberControllerBase(Fractorium* fractorium, GLWidget* glWidget);
|
|
|
|
virtual ~GLEmberControllerBase();
|
|
|
|
|
|
|
|
void ClearDrag();
|
|
|
|
bool Allocate(bool force = false);
|
2016-01-04 19:50:15 -05:00
|
|
|
bool GetAlt();
|
|
|
|
bool GetShift();
|
|
|
|
bool GetControl();
|
|
|
|
void SetAlt();
|
|
|
|
void SetShift();
|
|
|
|
void SetControl();
|
|
|
|
void ClearAlt();
|
|
|
|
void ClearShift();
|
|
|
|
void ClearControl();
|
2018-08-10 21:06:04 -04:00
|
|
|
eDragState DragState() { return m_DragState; }
|
2014-07-08 03:11:14 -04:00
|
|
|
virtual void DrawImage() { }
|
|
|
|
virtual void DrawAffines(bool pre, bool post) { }
|
|
|
|
virtual void ClearWindow() { }
|
2014-12-11 00:50:15 -05:00
|
|
|
virtual bool KeyPress_(QKeyEvent* e);
|
|
|
|
virtual bool KeyRelease_(QKeyEvent* e);
|
2014-07-08 03:11:14 -04:00
|
|
|
virtual void MousePress(QMouseEvent* e) { }
|
|
|
|
virtual void MouseRelease(QMouseEvent* e) { }
|
|
|
|
virtual void MouseMove(QMouseEvent* e) { }
|
|
|
|
virtual void Wheel(QWheelEvent* e) { }
|
2014-10-14 11:53:15 -04:00
|
|
|
virtual bool SizesMatch() { return false; }
|
2014-07-08 03:11:14 -04:00
|
|
|
virtual bool CheckForSizeMismatch(int w, int h) { return true; }
|
|
|
|
virtual void QueryMatrices(bool print) { }
|
2015-01-02 18:11:36 -05:00
|
|
|
virtual void ResetMouseState() { }
|
2014-07-08 03:11:14 -04:00
|
|
|
|
|
|
|
protected:
|
2014-12-06 00:05:09 -05:00
|
|
|
uint m_DragModifier;
|
2014-07-08 03:11:14 -04:00
|
|
|
glm::ivec2 m_MousePos;
|
|
|
|
glm::ivec2 m_MouseDownPos;
|
|
|
|
glm::ivec4 m_Viewport;
|
|
|
|
eDragState m_DragState;
|
|
|
|
eHoverType m_HoverType;
|
|
|
|
eAffineType m_AffineType;
|
|
|
|
GLWidget* m_GL;
|
|
|
|
Fractorium* m_Fractorium;
|
|
|
|
};
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Templated derived class which implements all interaction functionality between the embers
|
|
|
|
/// of a specific template type and the GLWidget;
|
|
|
|
/// </summary>
|
|
|
|
template<typename T>
|
|
|
|
class GLEmberController : public GLEmberControllerBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GLEmberController(Fractorium* fractorium, GLWidget* glWidget, FractoriumEmberController<T>* controller);
|
|
|
|
virtual ~GLEmberController();
|
2014-10-14 11:53:15 -04:00
|
|
|
virtual void DrawImage() override;
|
|
|
|
virtual void DrawAffines(bool pre, bool post) override;
|
|
|
|
virtual void ClearWindow() override;
|
|
|
|
virtual void MousePress(QMouseEvent* e) override;
|
|
|
|
virtual void MouseRelease(QMouseEvent* e) override;
|
|
|
|
virtual void MouseMove(QMouseEvent* e) override;
|
|
|
|
virtual void Wheel(QWheelEvent* e) override;
|
|
|
|
virtual void QueryMatrices(bool print) override;
|
|
|
|
virtual bool SizesMatch() override;
|
|
|
|
virtual bool CheckForSizeMismatch(int w, int h) override;
|
2015-01-02 18:11:36 -05:00
|
|
|
virtual void ResetMouseState() override;
|
2014-07-08 03:11:14 -04:00
|
|
|
|
|
|
|
T CalcScale();
|
|
|
|
T CalcRotation();
|
2018-08-10 21:06:04 -04:00
|
|
|
v3T ScrolledCenter(bool toWorld = false);
|
2016-02-12 00:38:21 -05:00
|
|
|
void CalcDragXAxis();
|
|
|
|
void CalcDragYAxis();
|
|
|
|
void CalcDragTranslation();
|
2014-07-08 03:11:14 -04:00
|
|
|
void SetSelectedXform(Xform<T>* xform);
|
--User changes
-Add a palette editor.
-Add support for reading .ugr/.gradient/.gradients palette files.
-Allow toggling on spinners whose minimum value is not zero.
-Allow toggling display of image, affines and grid.
-Add new variations: cylinder2, circlesplit, tile_log, truchet_fill, waves2_radial.
--Bug fixes
-cpow2 was wrong.
-Palettes with rapid changes in color would produce slightly different outputs from Apo/Chaotica. This was due to a long standing bug from flam3.
-Use exec() on Apple and show() on all other OSes for dialog boxes.
-Trying to render a sequence with no frames would crash.
-Selecting multiple xforms and rotating them would produce the wrong rotation.
-Better handling when parsing flames using different encoding, such as unicode and UTF-8.
-Switching between SP/DP didn't reselect the selected flame in the Library tab.
--Code changes
-Make all types concerning palettes be floats, including PaletteTableWidgetItem.
-PaletteTableWidgetItem is no longer templated because all palettes are float.
-Include the source colors for user created gradients.
-Change parallel_for() calls to work with very old versions of TBB which are lingering on some systems.
-Split conditional out of accumulation loop on the CPU for better performance.
-Vectorize summing when doing density filter for better performance.
-Make all usage of palettes be of type float, double is pointless.
-Allow palettes to reside in multiple folders, while ensuring only one of each name is added.
-Refactor some palette path searching code.
-Make ReadFile() throw and catch an exception if the file operation fails.
-A little extra safety in foci and foci3D with a call to Zeps().
-Cast to (real_t) in the OpenCL string for the w variation, which was having trouble compiling on Mac.
-Fixing missing comma between paths in InitPaletteList().
-Move Xml and PaletteList classes into cpp to shorten build times when working on them.
-Remove default param values for IterOpenCLKernelCreator<T>::SharedDataIndexDefines in cpp file.
-Change more NULL to nullptr.
2017-02-26 03:02:21 -05:00
|
|
|
void DrawGrid();
|
2014-07-08 03:11:14 -04:00
|
|
|
void DrawAffine(Xform<T>* xform, bool pre, bool selected);
|
|
|
|
int UpdateHover(v3T& glCoords);
|
|
|
|
bool CheckXformHover(Xform<T>* xform, v3T& glCoords, T& bestDist, bool pre, bool post);
|
|
|
|
|
|
|
|
private:
|
2016-02-12 00:38:21 -05:00
|
|
|
v2T SnapToGrid(v2T& vec);
|
2014-07-08 03:11:14 -04:00
|
|
|
v3T SnapToGrid(v3T& vec);
|
2014-12-06 00:05:09 -05:00
|
|
|
v3T SnapToNormalizedAngle(v3T& vec, uint divisions);
|
2014-07-08 03:11:14 -04:00
|
|
|
v3T WindowToWorld(v3T& v, bool flip);
|
|
|
|
void QueryVMP();
|
2018-03-28 00:32:10 -04:00
|
|
|
#ifndef USE_GLSL
|
2014-07-08 03:11:14 -04:00
|
|
|
void MultMatrix(m4T& mat);
|
2018-03-28 00:32:10 -04:00
|
|
|
#endif
|
2014-07-08 03:11:14 -04:00
|
|
|
|
|
|
|
T m_CenterDownX;
|
|
|
|
T m_CenterDownY;
|
|
|
|
T m_RotationDown;
|
|
|
|
T m_ScaleDown;
|
|
|
|
v4T m_BoundsDown;
|
|
|
|
|
|
|
|
v3T m_MouseWorldPos;
|
|
|
|
v3T m_MouseDownWorldPos;
|
|
|
|
v3T m_DragHandlePos;
|
|
|
|
v3T m_HoverHandlePos;
|
2016-01-04 19:50:15 -05:00
|
|
|
|
2014-07-08 03:11:14 -04:00
|
|
|
m4T m_Modelview;
|
|
|
|
m4T m_Projection;
|
|
|
|
|
|
|
|
Affine2D<T> m_DragSrcTransform;
|
2016-02-02 20:51:58 -05:00
|
|
|
vector<Affine2D<T>> m_DragSrcTransforms;
|
2014-07-08 03:11:14 -04:00
|
|
|
|
|
|
|
Xform<T>* m_HoverXform;
|
|
|
|
Xform<T>* m_SelectedXform;
|
|
|
|
FractoriumEmberController<T>* m_FractoriumEmberController;
|
|
|
|
T GridStep;
|
2018-03-28 00:32:10 -04:00
|
|
|
vector<float> m_Verts;//Can't make this T because GLSL only works with floats.
|
2014-07-08 03:11:14 -04:00
|
|
|
};
|
|
|
|
|