File: fractalmodel.h

package info (click to toggle)
fraqtive 0.4.3-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 988 kB
  • ctags: 1,249
  • sloc: cpp: 8,387; sh: 103; makefile: 45
file content (188 lines) | stat: -rw-r--r-- 5,122 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/**************************************************************************
* This file is part of the Fraqtive program
* Copyright (C) 2004-2008 Michał Męciński
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
**************************************************************************/

#ifndef FRACTALMODEL_H
#define FRACTALMODEL_H

#include <QObject>
#include <QColor>
#include <QTime>

#include "datastructures.h"

class QTimer;

class FractalPresenter;

enum ViewMode
{
    NoViewMode,
    ImageViewMode,
    MeshViewMode
};

class FractalModel : public QObject
{
    Q_OBJECT
public:
    FractalModel( QObject* parent );
    ~FractalModel();

public:
    FractalPresenter* presenter() const { return m_presenter; }

    void setPreviewPresenter( FractalPresenter* presenter );
    FractalPresenter* previewPresenter() const { return m_previewPresenter; }

    void setEnabled( bool enabled );
    bool isEnabled() const { return m_enabled; }

    void setParameters( const FractalType& type, const Position& position );

    void setFractalType( const FractalType& type );
    FractalType fractalType() const { return m_fractalType; }

    void setPosition( const Position& position );
    Position position() const { return m_position; }

    void setDefaultPosition();
    bool hasDefaultPosition() const;

    void setTrackingPosition( const Position& position );
    void clearTracking();

    bool isTracking() const { return m_tracking; }
    Position trackingPosition() const { return m_trackingPosition; }

    void setHoveringParameters( const FractalType& type, const Position& position );
    void clearHovering();

    bool isHovering() const { return m_hovering; }
    FractalType hoveringFractalType() const { return m_hoveringFractalType; }
    Position hoveringPosition() const { return m_hoveringPosition; }

    void setNavigationEnabled( bool enable );
    bool isNavigationEnabled() const { return m_navigation; }

    bool canNavigateBackward() const;
    bool canNavigateForward() const;

    void navigateBackward();
    void navigateForward();

    void setColorSettings( const Gradient& gradient, const QColor& backround, const ColorMapping& mapping );

    void setGradient( const Gradient& gradient );
    Gradient gradient() const { return m_gradient; }

    void setBackgroundColor( const QColor& color );
    QColor backgroundColor() const { return m_backgroundColor; }

    void setColorMapping( const ColorMapping& mapping );
    ColorMapping colorMapping() const { return m_colorMapping; }

    bool hasDefaultColorSettings() const;
    void saveDefaultColorSettings() const;
    void loadDefaultColorSettings();

    void setGeneratorSettings( const GeneratorSettings& settings );
    GeneratorSettings generatorSettings() const { return m_generatorSettings; }

    bool hasDefaultGeneratorSettings() const;
    void saveDefaultGeneratorSettings() const;
    void loadDefaultGeneratorSettings();

    void setViewSettings( const ViewSettings& settings );
    ViewSettings viewSettings() const { return m_viewSettings; }

    bool hasDefaultViewSettings() const;
    void saveDefaultViewSettings() const;
    void loadDefaultViewSettings();

    void setViewMode( ViewMode mode );
    ViewMode viewMode() const { return m_viewMode; }

    void setAnimationSettings( const AnimationSettings& settings );
    AnimationSettings animationSettings() const { return m_animationSettings; }

    AnimationState animationState() const { return m_animationState; }

signals:
    void fractalTypeChanged();
    void positionChanged();

    void trackingChanged();
    void hoveringChanged();
    void navigationChanged();

    void gradientChanged();
    void backgroundColorChanged();
    void colorMappingChanged();

    void generatorSettingsChanged();
    void viewSettingsChanged();

    void viewModeChanged();

    void animationSettingsChanged();

private slots:
    void animate();

private:
    void storeParameters();
    void setParametersInternal( const FractalType& type, const Position& position );

    void updateTimer();

private:
    struct Navigation
    {
        FractalType m_type;
        Position m_position;
    };

private:
    FractalPresenter* m_presenter;
    FractalPresenter* m_previewPresenter;

    bool m_enabled;

    FractalType m_fractalType;
    Position m_position;

    bool m_tracking;
    Position m_trackingPosition;

    bool m_hovering;
    FractalType m_hoveringFractalType;
    Position m_hoveringPosition;

    bool m_navigation;
    QList<Navigation> m_navigationBackward;
    QList<Navigation> m_navigationForward;

    Gradient m_gradient;
    QColor m_backgroundColor;
    ColorMapping m_colorMapping;

    GeneratorSettings m_generatorSettings;
    ViewSettings m_viewSettings;

    ViewMode m_viewMode;

    AnimationSettings m_animationSettings;
    AnimationState m_animationState;

    QTimer* m_timer;
    QTime m_time;
};

#endif