mandelbrot.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2008 Benoit Jacob <jacob.benoit.1@gmail.com>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #ifndef MANDELBROT_H
11 #define MANDELBROT_H
12 
13 #include <Eigen/Core>
14 #include <QtGui/QApplication>
15 #include <QtGui/QWidget>
16 #include <QtCore/QThread>
17 
18 class MandelbrotWidget;
19 
20 class MandelbrotThread : public QThread
21 {
22  friend class MandelbrotWidget;
24  long long total_iter;
25  int id, max_iter;
27 
28  public:
29  MandelbrotThread(MandelbrotWidget *w, int i) : widget(w), id(i) {}
30  void run();
31  template<typename Real> void render(int img_width, int img_height);
32 };
33 
34 class MandelbrotWidget : public QWidget
35 {
36  Q_OBJECT
37 
38  friend class MandelbrotThread;
39  Eigen::Vector2d center;
40  double xradius;
41  int size;
42  unsigned char *buffer;
43  QPoint lastpos;
44  int draft;
47 
48  protected:
49  void resizeEvent(QResizeEvent *);
50  void paintEvent(QPaintEvent *);
51  void mousePressEvent(QMouseEvent *event);
52  void mouseMoveEvent(QMouseEvent *event);
53 
54  public:
55  MandelbrotWidget() : QWidget(), center(0,0), xradius(2),
56  size(0), buffer(0), draft(16)
57  {
58  setAutoFillBackground(false);
59  threadcount = QThread::idealThreadCount();
60  threads = new MandelbrotThread*[threadcount];
61  for(int th = 0; th < threadcount; th++) threads[th] = new MandelbrotThread(this, th);
62  }
64  {
65  if(buffer) delete[]buffer;
66  for(int th = 0; th < threadcount; th++) delete threads[th];
67  delete[] threads;
68  }
69 };
70 
71 #endif // MANDELBROT_H
bool single_precision
Definition: mandelbrot.h:26
Eigen::Vector2d center
Definition: mandelbrot.h:39
MandelbrotThread(MandelbrotWidget *w, int i)
Definition: mandelbrot.h:29
long long total_iter
Definition: mandelbrot.h:24
RowVector3d w
unsigned char * buffer
Definition: mandelbrot.h:42
void render(int img_width, int img_height)
Definition: mandelbrot.cpp:31
MandelbrotThread ** threads
Definition: mandelbrot.h:45
MandelbrotWidget * widget
Definition: mandelbrot.h:23


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:34:35