changes
This commit is contained in:
@@ -28,6 +28,8 @@ set(PROJECT_SOURCES
|
|||||||
patternWidget.h
|
patternWidget.h
|
||||||
renderthread.cpp
|
renderthread.cpp
|
||||||
renderthread.h
|
renderthread.h
|
||||||
|
Cmplx.cpp
|
||||||
|
cmplx.h
|
||||||
framelesswindow.ui
|
framelesswindow.ui
|
||||||
mainfrm.ui
|
mainfrm.ui
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE QtCreatorProject>
|
<!DOCTYPE QtCreatorProject>
|
||||||
<!-- Written by QtCreator 7.0.2, 2022-06-27T01:09:59. -->
|
<!-- Written by QtCreator 7.0.2, 2022-07-02T17:54:45. -->
|
||||||
<qtcreator>
|
<qtcreator>
|
||||||
<data>
|
<data>
|
||||||
<variable>EnvironmentId</variable>
|
<variable>EnvironmentId</variable>
|
||||||
|
|||||||
@@ -0,0 +1,267 @@
|
|||||||
|
/*
|
||||||
|
Complex C++ Utilities
|
||||||
|
|
||||||
|
from C Mathematical Function Handbook by Louis Baker
|
||||||
|
Copyright 1991 by Louis Baker. All rights reserved.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
#include "cmplx.h"
|
||||||
|
|
||||||
|
cmplx::cmplx(double xx, double yy) // constructor
|
||||||
|
{
|
||||||
|
x = xx;
|
||||||
|
y = yy;
|
||||||
|
}
|
||||||
|
|
||||||
|
cmplx::cmplx() // constructor
|
||||||
|
{
|
||||||
|
x = 0.;
|
||||||
|
y = 0.;
|
||||||
|
bio = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// double cmplx::sum_of_sqrs()
|
||||||
|
// { return (x*x+y*y);}
|
||||||
|
|
||||||
|
// double cmplx::abs()
|
||||||
|
// { return sqrt(x*x+y*y);}
|
||||||
|
|
||||||
|
// double cmplx::real()
|
||||||
|
// { return x; }
|
||||||
|
|
||||||
|
// double cmplx::imag()
|
||||||
|
// { return y; }
|
||||||
|
|
||||||
|
// double cmplx::imaginary()
|
||||||
|
// { return y; }
|
||||||
|
|
||||||
|
double cmplx::squares()
|
||||||
|
{
|
||||||
|
if (bio)
|
||||||
|
{
|
||||||
|
if (bio == 1)
|
||||||
|
{
|
||||||
|
if (fabs(x) > fabs(y))
|
||||||
|
return sqrt(2 * x * x);
|
||||||
|
else
|
||||||
|
return sqrt(2 * y * y);
|
||||||
|
}
|
||||||
|
else if (bio == 2)
|
||||||
|
return sqrt(2 * x * y);
|
||||||
|
else if (bio == 3)
|
||||||
|
{
|
||||||
|
if (fabs(x) > fabs(y))
|
||||||
|
return sqrt(2 * y * y);
|
||||||
|
else
|
||||||
|
return sqrt(2 * x * x);
|
||||||
|
}
|
||||||
|
else if (bio == 4)
|
||||||
|
{
|
||||||
|
if (fabs(x) > fabs(y))
|
||||||
|
return 2 * x * x;
|
||||||
|
else
|
||||||
|
return 2 * y * y;
|
||||||
|
}
|
||||||
|
else if (bio == 5)
|
||||||
|
return 2 * x * y;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (fabs(x) > fabs(y))
|
||||||
|
return 2 * y * y;
|
||||||
|
else
|
||||||
|
return 2 * x * x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return (x * x + y * y);
|
||||||
|
}
|
||||||
|
|
||||||
|
double cmplx::magnitude()
|
||||||
|
{
|
||||||
|
if (bio)
|
||||||
|
{
|
||||||
|
if (bio == 1)
|
||||||
|
{
|
||||||
|
if (fabs(x) > fabs(y))
|
||||||
|
return sqrt(2 * x * x);
|
||||||
|
else
|
||||||
|
return sqrt(2 * y * y);
|
||||||
|
}
|
||||||
|
else if (bio == 2)
|
||||||
|
return sqrt(2 * x * y);
|
||||||
|
else if (bio == 3)
|
||||||
|
{
|
||||||
|
if (fabs(x) > fabs(y))
|
||||||
|
return sqrt(2 * y * y);
|
||||||
|
else
|
||||||
|
return sqrt(2 * x * x);
|
||||||
|
}
|
||||||
|
else if (bio == 4)
|
||||||
|
{
|
||||||
|
if (fabs(x) > fabs(y))
|
||||||
|
return 2 * x * x;
|
||||||
|
else
|
||||||
|
return 2 * y * y;
|
||||||
|
}
|
||||||
|
else if (bio == 5)
|
||||||
|
return 2 * x * y;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (fabs(x) > fabs(y))
|
||||||
|
return 2 * y * y;
|
||||||
|
else
|
||||||
|
return 2 * x * x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return sqrt(x * x + y * y);
|
||||||
|
}
|
||||||
|
|
||||||
|
double cmplx::biotest()
|
||||||
|
{
|
||||||
|
return (bio * x * y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmplx::set_biomorph(double dBiomorph)
|
||||||
|
{
|
||||||
|
bio = dBiomorph;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmplx::set_real(double set_x)
|
||||||
|
{
|
||||||
|
x = set_x;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmplx::set_imag(double set_y)
|
||||||
|
{
|
||||||
|
y = set_y;
|
||||||
|
}
|
||||||
|
|
||||||
|
// cmplx cmplx::cexp()
|
||||||
|
//{
|
||||||
|
// static double scale;
|
||||||
|
// scale= x;
|
||||||
|
|
||||||
|
// if( x > topexp)
|
||||||
|
// return cmplx( errorcode,0.);
|
||||||
|
// if( x<-topexp)
|
||||||
|
// return cmplx( 0.,0.);
|
||||||
|
|
||||||
|
// scale= exp((scale));
|
||||||
|
// return cmplx(scale*cos(y),scale*sin(y));
|
||||||
|
|
||||||
|
// return cmplx(exp(x)*cos(y),exp(x)*sin(y));
|
||||||
|
|
||||||
|
//}
|
||||||
|
|
||||||
|
// cmplx cmplx::clog()
|
||||||
|
//{
|
||||||
|
// static double mant,arg,mag;mag=(*this).abs();
|
||||||
|
|
||||||
|
// mag=fabs(mag); // ??
|
||||||
|
|
||||||
|
// if( mag < zerotol )
|
||||||
|
// return cmplx(errorcode,0.);
|
||||||
|
|
||||||
|
// mant = log(mag);
|
||||||
|
// arg= atan2(y,x);
|
||||||
|
// return cmplx(mant,arg);
|
||||||
|
|
||||||
|
// return cmplx(log(fabs((*this).abs())),atan2(y,x));
|
||||||
|
//}
|
||||||
|
|
||||||
|
// cmplx cmplx::operator^(double expon)
|
||||||
|
//{
|
||||||
|
// static cmplx z;
|
||||||
|
// z= (*this).clog( ) * expon;
|
||||||
|
// return z.cexp();
|
||||||
|
|
||||||
|
// return ((*this).clog( ) * expon).cexp();
|
||||||
|
//}
|
||||||
|
|
||||||
|
// cmplx cmplx::operator^(cmplx expon)
|
||||||
|
//{
|
||||||
|
// static cmplx z;
|
||||||
|
// z= (*this).clog( ) * expon;
|
||||||
|
// return z.cexp();
|
||||||
|
|
||||||
|
// return ((*this).clog( ) * expon).cexp();
|
||||||
|
//}
|
||||||
|
|
||||||
|
cmplx cmplx::csin()
|
||||||
|
{
|
||||||
|
return cmplx(.5 * (exp(y) + 1. / exp(y)) * sin(x), cos(x) * .5 * (exp(y) - 1. / exp(y)));
|
||||||
|
}
|
||||||
|
|
||||||
|
cmplx cmplx::ccos()
|
||||||
|
{
|
||||||
|
// static double z,zi,sinh,cosh,real;
|
||||||
|
// static double z,zi;
|
||||||
|
// real=x;
|
||||||
|
|
||||||
|
// if( y> topexp)
|
||||||
|
// return cmplx( errorcode,0.);
|
||||||
|
// if( y<-topexp)
|
||||||
|
// return cmplx( 0.,0.);
|
||||||
|
|
||||||
|
// z=exp(y);
|
||||||
|
// zi=1./z;
|
||||||
|
// cosh=.5*(z+zi);
|
||||||
|
// sinh=.5*(z-zi);
|
||||||
|
|
||||||
|
// return cmplx(cosh*cos(x),-sin(x)*sinh);
|
||||||
|
return cmplx(.5 * (exp(y) + 1. / exp(y)) * cos(x), -sin(x) * .5 * (exp(y) - 1. / exp(y)));
|
||||||
|
}
|
||||||
|
|
||||||
|
cmplx cmplx::csin_error()
|
||||||
|
{
|
||||||
|
if (y > topexp)
|
||||||
|
return cmplx(errorcode, 0.);
|
||||||
|
if (y < -topexp)
|
||||||
|
return cmplx(0., 0.);
|
||||||
|
return cmplx(.5 * (exp(y) + 1. / exp(y)) * sin(x), cos(x) * .5 * (exp(y) - 1. / exp(y)));
|
||||||
|
}
|
||||||
|
|
||||||
|
cmplx tangent(cmplx &x)
|
||||||
|
{
|
||||||
|
return x.csin() / x.ccos();
|
||||||
|
}
|
||||||
|
|
||||||
|
cmplx sinh(cmplx &x)
|
||||||
|
{
|
||||||
|
static cmplx i(0., 1.);
|
||||||
|
return -i * (x * i).csin();
|
||||||
|
}
|
||||||
|
|
||||||
|
// cmplx tanh(cmplx& x)
|
||||||
|
//{
|
||||||
|
// cmplx i(0.,1.);
|
||||||
|
// return -i * tangent( x*i);
|
||||||
|
// }
|
||||||
|
|
||||||
|
cmplx asin(cmplx &x)
|
||||||
|
{
|
||||||
|
// static cmplx i(0.,1.);
|
||||||
|
// return -i * (i*x+ ((1.-x*x)^.5)).clog();
|
||||||
|
|
||||||
|
return -cmplx(0., 1.) * (cmplx(0., 1.) * x + ((1. - x * x) ^ .5)).clog();
|
||||||
|
}
|
||||||
|
|
||||||
|
cmplx acos(cmplx &x)
|
||||||
|
{
|
||||||
|
// static cmplx i(0.,1.);
|
||||||
|
// return -i * (x+ i*((1.-x*x)^.5)).clog();
|
||||||
|
|
||||||
|
return -cmplx(0., 1.) * (x + cmplx(0., 1.) * ((1. - x * x) ^ .5)).clog();
|
||||||
|
}
|
||||||
|
|
||||||
|
cmplx arctan(cmplx &x)
|
||||||
|
{
|
||||||
|
// static cmplx i(0.,1.),a;
|
||||||
|
// a= ( i+x )/(i-x);
|
||||||
|
// return .5 * i * a.clog();
|
||||||
|
|
||||||
|
return .5 * cmplx(0., 1.) * (cmplx(0., 1.) + x) / (cmplx(0., 1.) - x).clog();
|
||||||
|
}
|
||||||
@@ -0,0 +1,170 @@
|
|||||||
|
// cmplx.h
|
||||||
|
#include "math.h"
|
||||||
|
|
||||||
|
#define maxterm 100
|
||||||
|
#define abstol 1.e-10
|
||||||
|
#define reltol 1.e-5
|
||||||
|
#define zerotol 1.e-50 // 1.e-14
|
||||||
|
#define errorcode -1.e60
|
||||||
|
#define pi 3.141592653589793238462643383279
|
||||||
|
#define rad 57.2958
|
||||||
|
#define lim 15.
|
||||||
|
// #define max(a,b) ((a)>(b)?(a):(b))
|
||||||
|
#define infinite_loop for(;;)
|
||||||
|
#define rabs(x) ((x)<0.? -(x):(x))
|
||||||
|
#define ABS(X) rabs(X)
|
||||||
|
#define topexp 350.
|
||||||
|
#define expo 2.7183
|
||||||
|
|
||||||
|
class cmplx
|
||||||
|
{
|
||||||
|
// Attributes
|
||||||
|
public:
|
||||||
|
double x,y;
|
||||||
|
double bio;
|
||||||
|
|
||||||
|
// Operations
|
||||||
|
public:
|
||||||
|
cmplx( double xx , double yy); //create
|
||||||
|
cmplx(); //create
|
||||||
|
|
||||||
|
inline void operator=(cmplx rvalue)
|
||||||
|
{x=rvalue.x;y=rvalue.y;}
|
||||||
|
inline void operator-=(cmplx rvalue)
|
||||||
|
{x-=rvalue.x;y-=rvalue.y;}
|
||||||
|
inline void operator+=(cmplx rvalue)
|
||||||
|
{x+=rvalue.x;y+=rvalue.y;}
|
||||||
|
inline void operator*=(cmplx rvalue)
|
||||||
|
{
|
||||||
|
*this=cmplx(rvalue.x*x-rvalue.y*y,
|
||||||
|
rvalue.x*y+rvalue.y*x);
|
||||||
|
}
|
||||||
|
inline void operator*=(double rvalue)
|
||||||
|
{
|
||||||
|
*this=cmplx(rvalue*x, rvalue*y);//return *this;
|
||||||
|
}
|
||||||
|
inline cmplx& operator+(cmplx& rvalue)
|
||||||
|
{return cmplx(x+rvalue.x,y+rvalue.y);}
|
||||||
|
inline cmplx& operator-(cmplx& rvalue)
|
||||||
|
{return cmplx(x-rvalue.x,y-rvalue.y);}
|
||||||
|
inline cmplx& operator-() //unary minus
|
||||||
|
{return cmplx(-x,-y);}
|
||||||
|
inline cmplx& operator*(cmplx rvalue)
|
||||||
|
{return cmplx(
|
||||||
|
rvalue.x*x-rvalue.y*y,
|
||||||
|
rvalue.x*y+rvalue.y*x);}
|
||||||
|
inline friend cmplx operator/(double dividend,cmplx divisor)
|
||||||
|
{
|
||||||
|
return cmplx((dividend*divisor.x)/(divisor.x*divisor.x+divisor.y*divisor.y),
|
||||||
|
(-dividend*divisor.y)/(divisor.x*divisor.x+divisor.y*divisor.y));
|
||||||
|
}
|
||||||
|
inline cmplx operator/(cmplx divisor)
|
||||||
|
{
|
||||||
|
return cmplx((divisor.x*x+divisor.y*y)/(divisor.x*divisor.x+divisor.y*divisor.y),
|
||||||
|
(divisor.x*y-divisor.y*x)/(divisor.x*divisor.x+divisor.y*divisor.y));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int operator==(cmplx rvalue)
|
||||||
|
{return (x==rvalue.x && y==rvalue.y);}
|
||||||
|
|
||||||
|
inline cmplx operator^(double expon)
|
||||||
|
{
|
||||||
|
return ((*this).clog( ) * expon).cexp();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline cmplx operator^(cmplx expon)
|
||||||
|
{
|
||||||
|
return ((*this).clog( ) * expon).cexp();
|
||||||
|
}
|
||||||
|
|
||||||
|
friend cmplx operator^(double base, cmplx expon);
|
||||||
|
|
||||||
|
inline double real() {return x;}
|
||||||
|
inline double imaginary() {return y;}
|
||||||
|
inline double imag() {return y;}
|
||||||
|
inline double abs() {return (x*x+y*y);}
|
||||||
|
inline double magnitude1() {return sqrt(x*x+y*y);}
|
||||||
|
|
||||||
|
inline cmplx Real() {
|
||||||
|
return cmplx (x, 0); }
|
||||||
|
|
||||||
|
inline cmplx Imag() {
|
||||||
|
return cmplx (y, 0); }
|
||||||
|
|
||||||
|
inline cmplx cexp() {
|
||||||
|
return cmplx(exp(x)*cos(y),exp(x)*sin(y));}
|
||||||
|
|
||||||
|
inline cmplx clog() {
|
||||||
|
return cmplx(log(fabs((*this).magnitude1())),atan2(y,x));}
|
||||||
|
|
||||||
|
inline cmplx unknown() { // suppose to be sine
|
||||||
|
return cmplx(.5*(exp(y)+1./exp(y))*sin(x),cos(x)*.5*(exp(y)-1./exp(y)));}
|
||||||
|
|
||||||
|
inline cmplx conjugate()
|
||||||
|
{return cmplx(x,-y);}
|
||||||
|
inline friend cmplx operator*(cmplx& num,double real)
|
||||||
|
{return cmplx(num.x*real,num.y*real);}
|
||||||
|
inline friend cmplx operator*(double real,cmplx num)
|
||||||
|
{return cmplx(num.x*real,num.y*real);}
|
||||||
|
inline friend cmplx operator+(cmplx num,double real)
|
||||||
|
{return cmplx(num.x+real,num.y);}
|
||||||
|
inline friend cmplx operator+(double real,cmplx num)
|
||||||
|
{return cmplx(num.x+real,num.y);}
|
||||||
|
inline cmplx operator+=(double real)
|
||||||
|
{return cmplx(x+=real,y);}
|
||||||
|
inline cmplx operator-=(double real)
|
||||||
|
{
|
||||||
|
return cmplx(x-=real,y);}
|
||||||
|
inline cmplx operator++()
|
||||||
|
{x+=1.;return *this;}
|
||||||
|
inline friend cmplx operator/(cmplx num,double real)
|
||||||
|
{return cmplx(num.x/real,num.y/real);}
|
||||||
|
inline friend cmplx operator-(cmplx num,double real)
|
||||||
|
{return cmplx(num.x-real,num.y);}
|
||||||
|
inline friend cmplx operator-(double real,cmplx num)
|
||||||
|
{return cmplx(real-num.x,-num.y);}
|
||||||
|
|
||||||
|
void set_biomorph(double dBiomorph);
|
||||||
|
void set_real(double set_x);
|
||||||
|
void set_imag(double set_y);
|
||||||
|
|
||||||
|
double squares();
|
||||||
|
double magnitude();
|
||||||
|
double biotest();
|
||||||
|
|
||||||
|
cmplx csin();
|
||||||
|
cmplx csin_error(); // used for alden's ray method
|
||||||
|
cmplx ccos();
|
||||||
|
cmplx csqrt();
|
||||||
|
|
||||||
|
//void print( char *ahead="",char *behind="");
|
||||||
|
cmplx hurwitz(cmplx );
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#define _cmplx_DEFINED
|
||||||
|
|
||||||
|
//double cmplx::abs();
|
||||||
|
//double cmplx::sum_of_sqrs();
|
||||||
|
//cmplx cmplx::cexp();
|
||||||
|
//cmplx cmplx::clog();
|
||||||
|
//double cmplx::squares();
|
||||||
|
|
||||||
|
//cmplx cmplx::operator^(double expon);
|
||||||
|
//cmplx cmplx::operator^(cmplx expon);
|
||||||
|
|
||||||
|
//cmplx cmplx::csin(); // TODO commented these 3 lines
|
||||||
|
//cmplx cmplx::ccos();
|
||||||
|
//cmplx cmplx::csin_error();
|
||||||
|
|
||||||
|
cmplx tangent ( cmplx& x);
|
||||||
|
cmplx sinh(cmplx& x);
|
||||||
|
cmplx asin(cmplx&x);
|
||||||
|
cmplx acos(cmplx&x);
|
||||||
|
cmplx arctan( cmplx& x);
|
||||||
|
cmplx cpow( cmplx& x, int nPower);
|
||||||
|
cmplx cpow( cmplx& x, cmplx& nPower);
|
||||||
|
double loggam(double x);
|
||||||
|
double gamma(double x);
|
||||||
|
double bernoulli(int n); /* n even 0<=n*/
|
||||||
|
double expon(double x);
|
||||||
+148
-42
@@ -5,47 +5,161 @@
|
|||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
//! [0]
|
//constructor
|
||||||
const double DefaultCenterX = -0.637011;
|
|
||||||
const double DefaultCenterY = -0.0395159;
|
|
||||||
const double DefaultScale = 0.00403897;
|
|
||||||
|
|
||||||
const double ZoomInFactor = 0.8;
|
|
||||||
const double ZoomOutFactor = 1 / ZoomInFactor;
|
|
||||||
const int ScrollStep = 20;
|
|
||||||
//! [0]
|
|
||||||
|
|
||||||
//! [1]
|
|
||||||
PatternWidget::PatternWidget(QWidget *parent) :
|
PatternWidget::PatternWidget(QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent)
|
||||||
centerX(DefaultCenterX),
|
|
||||||
centerY(DefaultCenterY),
|
|
||||||
pixmapScale(DefaultScale),
|
|
||||||
curScale(DefaultScale)
|
|
||||||
{
|
{
|
||||||
connect(&thread, &RenderThread::renderedImage,
|
connect(&thread, &RenderThread::renderedImage,
|
||||||
this, &PatternWidget::updatePixmap);
|
this, &PatternWidget::updatePixmap);
|
||||||
|
|
||||||
setWindowTitle(tr("Mandelbrot"));
|
nImageSize = 0;
|
||||||
|
|
||||||
|
// nRedStart = 0;
|
||||||
|
// nGrnStart = 40;
|
||||||
|
// nBluStart = 30;
|
||||||
|
|
||||||
|
nRedStart = 143;
|
||||||
|
nGrnStart = 58;
|
||||||
|
nBluStart = 27;
|
||||||
|
|
||||||
|
nColorOrder = 4;
|
||||||
|
nColorMethod = 0;
|
||||||
|
nColorMode = 0;
|
||||||
|
nColorMethodSave = 0;
|
||||||
|
nFilterSave = 0;
|
||||||
|
nDistortionSave = 0;
|
||||||
|
nFDOptionSave = 0;
|
||||||
|
|
||||||
|
min = 0;
|
||||||
|
max = 64;
|
||||||
|
|
||||||
|
nRed = 2;
|
||||||
|
nGrn = 2;
|
||||||
|
nBlu = 2;
|
||||||
|
|
||||||
|
bEdgeDetect = false;
|
||||||
|
bEmboss = false;
|
||||||
|
bSharpen = false;
|
||||||
|
bBlur = false;
|
||||||
|
bAverage = false;
|
||||||
|
bReduceSize = false;
|
||||||
|
|
||||||
|
nMatrix = 0;
|
||||||
|
|
||||||
|
bTraceContour = false;
|
||||||
|
|
||||||
|
iIter_Data = NULL;
|
||||||
|
rIter_Data = NULL;
|
||||||
|
gIter_Data = NULL;
|
||||||
|
bIter_Data = NULL;
|
||||||
|
|
||||||
|
pXTemp = NULL; // pointer to x temp array
|
||||||
|
pYTemp = NULL; // pointer to y temp array
|
||||||
|
|
||||||
|
rjData = NULL;
|
||||||
|
gjData = NULL;
|
||||||
|
bjData = NULL;
|
||||||
|
|
||||||
|
pXSave = NULL;
|
||||||
|
pYSave = NULL;
|
||||||
|
|
||||||
|
bDraw = false;
|
||||||
|
bLaunch = false;
|
||||||
|
bAbort = false;
|
||||||
|
|
||||||
|
CRMIN = -2; //-2.0; // // left
|
||||||
|
CIMIN = -2; //-1.33333; // // top
|
||||||
|
CRMAX = 2; // 1.0; // // right
|
||||||
|
CIMAX = 2; // 1.33333; // // bottom
|
||||||
|
|
||||||
|
dMagnification = 1;
|
||||||
|
|
||||||
|
|
||||||
|
dMIN = 1e-11;
|
||||||
|
|
||||||
|
CRMID = CRMID_Start = CRMID_Finish = ((CRMAX - CRMIN) / 2.0) + CRMIN;
|
||||||
|
CIMID = CIMID_Start = CIMID_Finish = ((CIMAX - CIMIN) / 2.0) + CIMIN;
|
||||||
|
|
||||||
|
|
||||||
|
CRMIN_JUL = -1.5;
|
||||||
|
CIMIN_JUL = -1.5;
|
||||||
|
CRMAX_JUL = 1.5;
|
||||||
|
CIMAX_JUL = 1.5;
|
||||||
|
|
||||||
|
CRMIN_NEW = 0;
|
||||||
|
CIMIN_NEW = 0;
|
||||||
|
CRMAX_NEW = 0;
|
||||||
|
CIMAX_NEW = 0;
|
||||||
|
|
||||||
|
CRMIN_OLD = 0;
|
||||||
|
CIMIN_OLD = 0;
|
||||||
|
CRMAX_OLD = 0;
|
||||||
|
CIMAX_OLD = 0;
|
||||||
|
|
||||||
|
NMAX = 128;
|
||||||
|
NMAX_Save = 0;
|
||||||
|
dBailout = 4;
|
||||||
|
|
||||||
|
dLower = 0;
|
||||||
|
dUpper = 256;
|
||||||
|
|
||||||
|
jul = 0;
|
||||||
|
jul_save = 1;
|
||||||
|
|
||||||
|
|
||||||
|
nDistortion = 1;
|
||||||
|
nFilter = 0;
|
||||||
|
|
||||||
|
bColorize = true;
|
||||||
|
|
||||||
|
dStrands = .08;
|
||||||
|
dBiomorph = 0;
|
||||||
|
dBay100 = 1;
|
||||||
|
dBay1000 = 1;
|
||||||
|
|
||||||
|
nFormulaType = 0;
|
||||||
|
|
||||||
|
nFDOption = 0;
|
||||||
|
bDimensionVariant = 0;
|
||||||
|
|
||||||
|
cOrient.set_real(1);
|
||||||
|
cOrient.set_imag(0);
|
||||||
|
|
||||||
|
// Formulae Parser Variables
|
||||||
|
u_real = 0;
|
||||||
|
v_real = 0;
|
||||||
|
w_real = 0;
|
||||||
|
z_real = 0;
|
||||||
|
|
||||||
|
u_imag = 0;
|
||||||
|
v_imag = 0;
|
||||||
|
w_imag = 0;
|
||||||
|
z_imag = 0;
|
||||||
|
|
||||||
|
strFormulae = "z*z+c";
|
||||||
|
|
||||||
|
// DLL initialization TODO
|
||||||
|
//szTemp = "rsx_fv25.dll";
|
||||||
|
//Load_DLL();
|
||||||
|
|
||||||
|
nDistortion_sav = nDistortion;
|
||||||
|
nFilter_sav = nFilter;
|
||||||
|
nColorMethod_sav = nColorMethod;
|
||||||
|
nFDOption_sav = nFDOption;
|
||||||
|
|
||||||
|
|
||||||
#if QT_CONFIG(cursor)
|
#if QT_CONFIG(cursor)
|
||||||
setCursor(Qt::CrossCursor);
|
setCursor(Qt::CrossCursor);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
//! [1]
|
|
||||||
|
|
||||||
//! [2]
|
|
||||||
void PatternWidget::paintEvent(QPaintEvent * /* event */)
|
void PatternWidget::paintEvent(QPaintEvent * /* event */)
|
||||||
{
|
{
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
painter.fillRect(rect(), Qt::black);
|
painter.fillRect(rect(), Qt::black);
|
||||||
|
|
||||||
if (pixmap.isNull()) {
|
|
||||||
painter.setPen(Qt::white);
|
|
||||||
painter.drawText(rect(), Qt::AlignCenter, tr("Rendering initial image, please wait..."));
|
|
||||||
//! [2] //! [3]
|
|
||||||
return;
|
|
||||||
//! [3] //! [4]
|
|
||||||
}
|
|
||||||
//! [4]
|
//! [4]
|
||||||
|
|
||||||
//! [5]
|
//! [5]
|
||||||
@@ -75,14 +189,14 @@ void PatternWidget::paintEvent(QPaintEvent * /* event */)
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
//! [9]
|
|
||||||
|
|
||||||
//! [10]
|
//! [10]
|
||||||
void PatternWidget::resizeEvent(QResizeEvent * /* event */)
|
void PatternWidget::resizeEvent(QResizeEvent * /* event */)
|
||||||
{
|
{
|
||||||
thread.render(centerX, centerY, curScale, size(), devicePixelRatio());
|
thread.render(centerX, centerY, size(), devicePixelRatio());
|
||||||
}
|
}
|
||||||
//! [10]
|
|
||||||
|
|
||||||
/*void PatternWidget::keyPressEvent(QKeyEvent *event)
|
/*void PatternWidget::keyPressEvent(QKeyEvent *event)
|
||||||
{
|
{
|
||||||
@@ -115,28 +229,20 @@ void PatternWidget::resizeEvent(QResizeEvent * /* event */)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
//! [16]
|
//
|
||||||
void PatternWidget::updatePixmap(const QImage &image, double scaleFactor)
|
void PatternWidget::updatePixmap(const QImage &image)
|
||||||
{
|
{
|
||||||
if (!lastDragPos.isNull())
|
|
||||||
return;
|
|
||||||
|
|
||||||
//info = image.text(RenderThread::infoKey());
|
|
||||||
|
|
||||||
pixmap = QPixmap::fromImage(image);
|
pixmap = QPixmap::fromImage(image);
|
||||||
pixmapOffset = QPoint();
|
pixmapOffset = QPoint();
|
||||||
lastDragPos = QPoint();
|
|
||||||
pixmapScale = scaleFactor;
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
//! [16]
|
|
||||||
|
|
||||||
//! [17]
|
//TODO
|
||||||
void PatternWidget::zoom(double zoomFactor)
|
void PatternWidget::zoom(double zoomFactor)
|
||||||
{
|
{
|
||||||
curScale *= zoomFactor;
|
curScale *= zoomFactor;
|
||||||
update();
|
update();
|
||||||
thread.render(centerX, centerY, curScale, size(), devicePixelRatio());
|
thread.render(centerX, centerY, size(), devicePixelRatio());
|
||||||
}
|
}
|
||||||
//! [17]
|
//
|
||||||
|
|
||||||
|
|||||||
+239
-4
@@ -4,6 +4,8 @@
|
|||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include "renderthread.h"
|
#include "renderthread.h"
|
||||||
|
#include "cmplx.h"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
class PatternWidget : public QWidget
|
class PatternWidget : public QWidget
|
||||||
@@ -12,27 +14,260 @@ class PatternWidget : public QWidget
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
PatternWidget(QWidget *parent = nullptr);
|
PatternWidget(QWidget *parent = nullptr);
|
||||||
|
void updateBuffer();
|
||||||
|
|
||||||
|
// Fractal dimension variables
|
||||||
|
int i2, jrw, bDimensionVariant;
|
||||||
|
double x_std, y_std, dm, da;
|
||||||
|
double denominator, x_rmin, x_rmax, y_rmin, y_rmax;
|
||||||
|
|
||||||
|
// Data array pointers
|
||||||
|
double *pXTemp;
|
||||||
|
double *pYTemp;
|
||||||
|
|
||||||
|
double *rjData;
|
||||||
|
double *gjData;
|
||||||
|
double *bjData;
|
||||||
|
|
||||||
|
double *pXSave;
|
||||||
|
double *pYSave;
|
||||||
|
|
||||||
|
cmplx cx_std;
|
||||||
|
cmplx cy_std;
|
||||||
|
cmplx cFDx;
|
||||||
|
cmplx cFDy;
|
||||||
|
cmplx cRng_x;
|
||||||
|
cmplx cRng_y;
|
||||||
|
cmplx cNMAX;
|
||||||
|
|
||||||
|
double dFDx; // Fractal Dimension x
|
||||||
|
double dFDy; // Fractal Dimension y
|
||||||
|
|
||||||
|
double dFDx_0; // Initial F Dimension x
|
||||||
|
double dFDy_0; // Initial F Dimension y
|
||||||
|
|
||||||
|
int nDIter_x;
|
||||||
|
int nDIter_y;
|
||||||
|
int nFDOption;
|
||||||
|
int NMAX_Save;
|
||||||
|
int nColorMethod;
|
||||||
|
int nColorMode;
|
||||||
|
int nColorMethodSave;
|
||||||
|
int min, max;
|
||||||
|
int ntemp;
|
||||||
|
|
||||||
|
int nFormulaType;
|
||||||
|
|
||||||
|
int nFilterSave;
|
||||||
|
int nDistortionSave;
|
||||||
|
int nFDOptionSave;
|
||||||
|
|
||||||
|
// Average variables
|
||||||
|
double x_mean;
|
||||||
|
double y_mean;
|
||||||
|
|
||||||
|
// misc
|
||||||
|
bool bEdgeDetect;
|
||||||
|
bool bEmboss;
|
||||||
|
bool bSharpen;
|
||||||
|
bool bBlur;
|
||||||
|
bool bAverage;
|
||||||
|
bool bTraceContour;
|
||||||
|
bool bReduceSize;
|
||||||
|
bool bColorize;
|
||||||
|
|
||||||
|
double rj, gj, bj;
|
||||||
|
int xi, yi, ii;
|
||||||
|
int red, grn, blu;
|
||||||
|
int nRed, nGrn, nBlu;
|
||||||
|
int nRedStart, nGrnStart, nBluStart;
|
||||||
|
|
||||||
|
double PrtScale;
|
||||||
|
double CrtScale;
|
||||||
|
double dMIN;
|
||||||
|
double dzx, dzy;
|
||||||
|
double dzx_save, dzy_save;
|
||||||
|
double temp, temp1, temp2;
|
||||||
|
double x_temp, y_temp, length;
|
||||||
|
double x_temp1, y_temp1;
|
||||||
|
double dUpper, dLower;
|
||||||
|
double rr, rn;
|
||||||
|
double deg;
|
||||||
|
|
||||||
|
int *iIter_Data;
|
||||||
|
int *rIter_Data;
|
||||||
|
int *gIter_Data;
|
||||||
|
int *bIter_Data;
|
||||||
|
|
||||||
|
int rb_avg;
|
||||||
|
int cxDIB;
|
||||||
|
int cyDIB;
|
||||||
|
int nImageSize;
|
||||||
|
int nXpix, nYpix;
|
||||||
|
int rb_width;
|
||||||
|
int rb_height;
|
||||||
|
int rb_center_x;
|
||||||
|
int rb_center_y;
|
||||||
|
int dim_avg;
|
||||||
|
int nFilter;
|
||||||
|
int nColorOrder;
|
||||||
|
int kr, kc;
|
||||||
|
int UBANDS;
|
||||||
|
int nMatrix;
|
||||||
|
int n_color_sav;
|
||||||
|
|
||||||
|
// Constants used for mandelbrot pattern
|
||||||
|
// define Mandelbrot set constants:
|
||||||
|
double CIMAX; // 1.2
|
||||||
|
double CIMIN; // -1.2
|
||||||
|
double CRMAX; // 1.0
|
||||||
|
double CRMIN; // -2.0
|
||||||
|
|
||||||
|
double CIMAX_JUL; // 1.5
|
||||||
|
double CIMIN_JUL; // -1.5
|
||||||
|
double CRMAX_JUL; // 1.5
|
||||||
|
double CRMIN_JUL; // -1.5
|
||||||
|
|
||||||
|
double CIMAX_OLD; // 1.2
|
||||||
|
double CIMIN_OLD; // -1.2
|
||||||
|
double CRMAX_OLD; // 1.0
|
||||||
|
double CRMIN_OLD; // -2.0
|
||||||
|
|
||||||
|
double CRMID; // rubber band x mid point
|
||||||
|
double CIMID; // rubber band y mid point
|
||||||
|
double CRMID_Start; // rubber band x mid point finish
|
||||||
|
double CIMID_Start; // rubber band y mid point finish
|
||||||
|
double CRMID_Finish; // rubber band x mid point finish
|
||||||
|
double CIMID_Finish; // rubber band y mid point finish
|
||||||
|
|
||||||
|
double CIMAX_NEW; // 1.2
|
||||||
|
double CIMIN_NEW; // -1.2
|
||||||
|
double CRMAX_NEW; // 1.0
|
||||||
|
double CRMIN_NEW; // -2.0
|
||||||
|
|
||||||
|
double CRMID_OLD;
|
||||||
|
double CIMID_OLD;
|
||||||
|
|
||||||
|
double CRMID_JUL;
|
||||||
|
double CIMID_JUL;
|
||||||
|
|
||||||
|
double dMag_new;
|
||||||
|
double dMagnification;
|
||||||
|
double Radius_x;
|
||||||
|
double Radius_y;
|
||||||
|
|
||||||
|
int dBiomorph;
|
||||||
|
double rorder_r;
|
||||||
|
double rorder_i;
|
||||||
|
double dBay100, dBay1000;
|
||||||
|
double dStrands, dStrands_HI, dStrands_LO;
|
||||||
|
double limit;
|
||||||
|
|
||||||
|
double rx_ratio, ry_ratio;
|
||||||
|
double dx_length, dy_length;
|
||||||
|
|
||||||
|
double zx, zy;
|
||||||
|
|
||||||
|
|
||||||
|
// Variables for the Mandelbrot fractal
|
||||||
|
bool bDraw;
|
||||||
|
bool bLaunch;
|
||||||
|
bool bAbort;
|
||||||
|
bool bGeometry;
|
||||||
|
|
||||||
|
int RowMax;
|
||||||
|
int Row;
|
||||||
|
int Col;
|
||||||
|
int ColMax;
|
||||||
|
|
||||||
|
int size_x, size_y;
|
||||||
|
|
||||||
|
double CR;
|
||||||
|
double DCI;
|
||||||
|
double DCR;
|
||||||
|
int NMAX;
|
||||||
|
int temp_max;
|
||||||
|
int Orig_X, Orig_Y;
|
||||||
|
int dBailout;
|
||||||
|
double cxx, cyy;
|
||||||
|
int nDistortion;
|
||||||
|
|
||||||
|
int nDistortion_sav;
|
||||||
|
int nFilter_sav;
|
||||||
|
int nColorMethod_sav;
|
||||||
|
int nFDOption_sav;
|
||||||
|
|
||||||
|
int niter, /* maximum number of iterations */
|
||||||
|
px, py, /* current pixel */
|
||||||
|
nx, ny, /* number of pixels */
|
||||||
|
nc, /* number of colors to use */
|
||||||
|
i, j, /* counters for miscellaneous use */
|
||||||
|
jul, /* 1 = Julia Set, 0 = Mandelbrot */
|
||||||
|
jul_save;
|
||||||
|
|
||||||
|
double ri;
|
||||||
|
|
||||||
|
double x, y, /* last point on orbit */
|
||||||
|
xsquared, ysquared, /* used to speed up computations */
|
||||||
|
ldx, ldy, /* theoretical size of pixels */
|
||||||
|
cx, cy, /* number to add each iteration */
|
||||||
|
xO, yO, /* starting x,y */
|
||||||
|
xI, yI; /* ending x,y */
|
||||||
|
|
||||||
|
cmplx c;
|
||||||
|
cmplx cn;
|
||||||
|
cmplx z;
|
||||||
|
cmplx z1;
|
||||||
|
cmplx z2;
|
||||||
|
cmplx cOrient;
|
||||||
|
cmplx uu;
|
||||||
|
cmplx vv;
|
||||||
|
cmplx ww;
|
||||||
|
|
||||||
|
QRect rubberBand, rubberBandSave;
|
||||||
|
|
||||||
|
double rb_left;
|
||||||
|
double rb_top;
|
||||||
|
double rb_right;
|
||||||
|
double rb_bottom;
|
||||||
|
|
||||||
|
double sxmin;
|
||||||
|
double symin;
|
||||||
|
double sxmax;
|
||||||
|
double symax;
|
||||||
|
double x_size;
|
||||||
|
double y_size;
|
||||||
|
|
||||||
|
// Formulae parser variables
|
||||||
|
double u_real, v_real, w_real, z_real;
|
||||||
|
double u_imag, v_imag, w_imag, z_imag;
|
||||||
|
QString strFormulae;
|
||||||
|
|
||||||
|
//#include "Expression.h"
|
||||||
|
// MExpression *ParsedExpr;
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *event) override;
|
void paintEvent(QPaintEvent *event) override;
|
||||||
void resizeEvent(QResizeEvent *event) override;
|
void resizeEvent(QResizeEvent *event) override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updatePixmap(const QImage &image, double scaleFactor);
|
void updatePixmap(const QImage &image); //pixmap is updated with buffer after rendering
|
||||||
void zoom(double zoomFactor);
|
void zoom(double zoomFactor);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
RenderThread thread;
|
RenderThread thread;
|
||||||
QPixmap pixmap;
|
QPixmap pixmap;
|
||||||
|
QImage wbuffer; // the buffer of the widget
|
||||||
QPoint pixmapOffset;
|
QPoint pixmapOffset;
|
||||||
QPoint lastDragPos;
|
|
||||||
//QString help;
|
// old (maybe not in use)
|
||||||
QString info;
|
|
||||||
double centerX;
|
double centerX;
|
||||||
double centerY;
|
double centerY;
|
||||||
double pixmapScale;
|
double pixmapScale;
|
||||||
double curScale;
|
double curScale;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PATTERNWIDGET_H
|
#endif // PATTERNWIDGET_H
|
||||||
|
|||||||
@@ -31,14 +31,13 @@ RenderThread::~RenderThread()
|
|||||||
//! [1]
|
//! [1]
|
||||||
|
|
||||||
//! [2]
|
//! [2]
|
||||||
void RenderThread::render(double centerX, double centerY, double scaleFactor,
|
void RenderThread::render(double centerX, double centerY,
|
||||||
QSize resultSize, double devicePixelRatio)
|
QSize resultSize, double devicePixelRatio)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&mutex);
|
QMutexLocker locker(&mutex);
|
||||||
|
|
||||||
this->centerX = centerX;
|
this->centerX = centerX;
|
||||||
this->centerY = centerY;
|
this->centerY = centerY;
|
||||||
this->scaleFactor = scaleFactor;
|
|
||||||
this->devicePixelRatio = devicePixelRatio;
|
this->devicePixelRatio = devicePixelRatio;
|
||||||
this->resultSize = resultSize;
|
this->resultSize = resultSize;
|
||||||
|
|
||||||
@@ -59,8 +58,6 @@ void RenderThread::run()
|
|||||||
mutex.lock();
|
mutex.lock();
|
||||||
const double devicePixelRatio = this->devicePixelRatio;
|
const double devicePixelRatio = this->devicePixelRatio;
|
||||||
const QSize resultSize = this->resultSize * devicePixelRatio;
|
const QSize resultSize = this->resultSize * devicePixelRatio;
|
||||||
const double requestedScaleFactor = this->scaleFactor;
|
|
||||||
const double scaleFactor = requestedScaleFactor / devicePixelRatio;
|
|
||||||
const double centerX = this->centerX;
|
const double centerX = this->centerX;
|
||||||
const double centerY = this->centerY;
|
const double centerY = this->centerY;
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
@@ -89,10 +86,10 @@ void RenderThread::run()
|
|||||||
|
|
||||||
auto scanLine =
|
auto scanLine =
|
||||||
reinterpret_cast<uint *>(image.scanLine(y + halfHeight));
|
reinterpret_cast<uint *>(image.scanLine(y + halfHeight));
|
||||||
const double ay = centerY + (y * scaleFactor);
|
const double ay = centerY + (y);
|
||||||
|
|
||||||
for (int x = -halfWidth; x < halfWidth; ++x) {
|
for (int x = -halfWidth; x < halfWidth; ++x) {
|
||||||
const double ax = centerX + (x * scaleFactor);
|
const double ax = centerX + (x );
|
||||||
double a1 = ax;
|
double a1 = ax;
|
||||||
double b1 = ay;
|
double b1 = ay;
|
||||||
int numIterations = 0;
|
int numIterations = 0;
|
||||||
@@ -135,7 +132,7 @@ void RenderThread::run()
|
|||||||
str << elapsed << "ms";
|
str << elapsed << "ms";
|
||||||
image.setText(infoKey(), message);
|
image.setText(infoKey(), message);
|
||||||
|
|
||||||
emit renderedImage(image, requestedScaleFactor);
|
emit renderedImage(image);
|
||||||
}
|
}
|
||||||
//! [5] //! [6]
|
//! [5] //! [6]
|
||||||
++pass;
|
++pass;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public:
|
|||||||
RenderThread(QObject *parent = nullptr);
|
RenderThread(QObject *parent = nullptr);
|
||||||
~RenderThread();
|
~RenderThread();
|
||||||
|
|
||||||
void render(double centerX, double centerY, double scaleFactor, QSize resultSize,
|
void render(double centerX, double centerY, QSize resultSize,
|
||||||
double devicePixelRatio);
|
double devicePixelRatio);
|
||||||
|
|
||||||
static void setNumPasses(int n) { numPasses = n; }
|
static void setNumPasses(int n) { numPasses = n; }
|
||||||
@@ -27,7 +27,7 @@ public:
|
|||||||
static QString infoKey() { return QStringLiteral("info"); }
|
static QString infoKey() { return QStringLiteral("info"); }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void renderedImage(const QImage &image, double scaleFactor);
|
void renderedImage(const QImage &image);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void run() override;
|
void run() override;
|
||||||
@@ -39,7 +39,6 @@ private:
|
|||||||
QWaitCondition condition;
|
QWaitCondition condition;
|
||||||
double centerX;
|
double centerX;
|
||||||
double centerY;
|
double centerY;
|
||||||
double scaleFactor;
|
|
||||||
double devicePixelRatio;
|
double devicePixelRatio;
|
||||||
QSize resultSize;
|
QSize resultSize;
|
||||||
static int numPasses;
|
static int numPasses;
|
||||||
|
|||||||
Reference in New Issue
Block a user