~ubuntu-branches/ubuntu/raring/fyre/raring

« back to all changes in this revision

Viewing changes to src/iterative-map.h

  • Committer: Bazaar Package Importer
  • Author(s): Christoph Haas
  • Date: 2005-05-25 21:59:19 UTC
  • Revision ID: james.westby@ubuntu.com-20050525215919-jawtso5ic23qb401
Tags: upstream-1.0.0
ImportĀ upstreamĀ versionĀ 1.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- mode: c; c-basic-offset: 4; -*-
 
2
 *
 
3
 * iterative-map.h - The IterativeMap object builds on the ParameterHolder and
 
4
 *                   HistogramRender objects to provide a rendering of a chaotic
 
5
 *                   map into a histogram image.
 
6
 *
 
7
 * Fyre - rendering and interactive exploration of chaotic functions
 
8
 * Copyright (C) 2004-2005 David Trowbridge and Micah Dowty
 
9
 *
 
10
 * This program is free software; you can redistribute it and/or
 
11
 * modify it under the terms of the GNU General Public License
 
12
 * as published by the Free Software Foundation; either version 2
 
13
 * of the License, or (at your option) any later version.
 
14
 *
 
15
 * This program is distributed in the hope that it will be useful,
 
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
18
 * GNU General Public License for more details.
 
19
 *
 
20
 * You should have received a copy of the GNU General Public License
 
21
 * along with this program; if not, write to the Free Software
 
22
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
23
 *
 
24
 */
 
25
 
 
26
#ifndef __ITERATIVE_MAP_H__
 
27
#define __ITERATIVE_MAP_H__
 
28
 
 
29
#include <gtk/gtk.h>
 
30
#include "histogram-imager.h"
 
31
 
 
32
G_BEGIN_DECLS
 
33
 
 
34
#define ITERATIVE_MAP_TYPE            (iterative_map_get_type ())
 
35
#define ITERATIVE_MAP(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), ITERATIVE_MAP_TYPE, IterativeMap))
 
36
#define ITERATIVE_MAP_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), ITERATIVE_MAP_TYPE, IterativeMapClass))
 
37
#define IS_ITERATIVE_MAP(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ITERATIVE_MAP_TYPE))
 
38
#define IS_ITERATIVE_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ITERATIVE_MAP_TYPE))
 
39
 
 
40
typedef struct _IterativeMap      IterativeMap;
 
41
typedef struct _IterativeMapClass IterativeMapClass;
 
42
 
 
43
struct _IterativeMap {
 
44
    HistogramImager parent;
 
45
 
 
46
    /* Current calculation state */
 
47
    gdouble iterations;
 
48
 
 
49
    /* Estimated iterations per second, for calculate_timed and friends */
 
50
    gdouble iter_speed_estimate;
 
51
 
 
52
    /* For background rendering in the idle handler */
 
53
    guint idle_handler;
 
54
    double render_time;
 
55
};
 
56
 
 
57
struct _IterativeMapClass {
 
58
    HistogramImagerClass parent_class;
 
59
 
 
60
    void (*iterative_map) (IterativeMap *self);
 
61
 
 
62
    /* Overrideable methods */
 
63
    void (*calculate)        (IterativeMap          *self,
 
64
                              guint                  iterations);
 
65
    void (*calculate_motion) (IterativeMap          *self,
 
66
                              guint                  iterations,
 
67
                              gboolean               continuation,
 
68
                              ParameterInterpolator *interp,
 
69
                              gpointer               interp_data);
 
70
};
 
71
 
 
72
/************************************************************************************/
 
73
/******************************************************************* Public Methods */
 
74
/************************************************************************************/
 
75
 
 
76
GType         iterative_map_get_type               ();
 
77
 
 
78
/* Simple calculation functions, implemented by subclasses.
 
79
 * They calculate a fixed number of iterations.
 
80
 */
 
81
void          iterative_map_calculate              (IterativeMap          *self,
 
82
                                                    guint                  iterations);
 
83
void          iterative_map_calculate_motion       (IterativeMap          *self,
 
84
                                                    guint                  iterations,
 
85
                                                    gboolean               continuation,
 
86
                                                    ParameterInterpolator *interp,
 
87
                                                    gpointer               interp_data);
 
88
 
 
89
/* Calculation functions implemented by this base class,
 
90
 * that stop after an estimated amount of time rather
 
91
 * than a number of iterations. Each time this runs,
 
92
 * it uses the actual time elapsed to update an estimate
 
93
 * of the calculation speed used to come up with a
 
94
 * number of iterations to pass the actual rendering
 
95
 * functions.
 
96
 */
 
97
void          iterative_map_calculate_timed        (IterativeMap          *self,
 
98
                                                    double                 seconds);
 
99
void          iterative_map_calculate_motion_timed (IterativeMap          *self,
 
100
                                                    double                 seconds,
 
101
                                                    gboolean               continuation,
 
102
                                                    ParameterInterpolator *interp,
 
103
                                                    gpointer               interp_data);
 
104
 
 
105
/* Start or stop running calculation from a main loop
 
106
 * idle handler. The current 'render_time' is the number
 
107
 * of seconds that we nominally calculate for during
 
108
 * each main loop iteration. The default of 15ms is
 
109
 * fine for most interactive use.
 
110
 */
 
111
void          iterative_map_start_calculation      (IterativeMap          *self);
 
112
void          iterative_map_stop_calculation       (IterativeMap          *self);
 
113
gboolean      iterative_map_is_calculation_running (IterativeMap          *self);
 
114
 
 
115
G_END_DECLS
 
116
 
 
117
#endif /* __ITERATIVE_MAP_H__ */
 
118
 
 
119
/* The End */