Added:
branches/backus_dev/src/SpiralLenz/
branches/backus_dev/src/SpiralLenz/compiled_objects/
branches/backus_dev/src/SpiralLenz/compiled_objects/ignore.me
branches/backus_dev/src/SpiralLenz/man_page/
branches/backus_dev/src/SpiralLenz/man_page/SpiralLenz.1
branches/backus_dev/src/SpiralLenz/msvc/
branches/backus_dev/src/SpiralLenz/msvc/glut_demo/
branches/backus_dev/src/SpiralLenz/msvc/glut_demo/Debug/
branches/backus_dev/src/SpiralLenz/msvc/glut_demo/Debug/ignore.me
branches/backus_dev/src/SpiralLenz/msvc/glut_demo/Release/
branches/backus_dev/src/SpiralLenz/msvc/glut_demo/Release/ignore.me
branches/backus_dev/src/SpiralLenz/msvc/redirector/
branches/backus_dev/src/SpiralLenz/msvc/redirector/Debug/
branches/backus_dev/src/SpiralLenz/msvc/redirector/Debug/ignore.me
branches/backus_dev/src/SpiralLenz/msvc/redirector/Release/
branches/backus_dev/src/SpiralLenz/msvc/redirector/Release/ignore.me
branches/backus_dev/src/SpiralLenz/msvc/redirector/redirector.rc
branches/backus_dev/src/SpiralLenz/msvc/redirector/resource.h
branches/backus_dev/src/SpiralLenz/msvc/scr/
branches/backus_dev/src/SpiralLenz/msvc/scr/Debug/
branches/backus_dev/src/SpiralLenz/msvc/scr/Debug/ignore.me
branches/backus_dev/src/SpiralLenz/msvc/scr/Release/
branches/backus_dev/src/SpiralLenz/msvc/scr/Release/ignore.me
branches/backus_dev/src/SpiralLenz/project_files/
branches/backus_dev/src/SpiralLenz/project_files/SpiralLenz_glut.pro
branches/backus_dev/src/SpiralLenz/project_files/SpiralLenz_scr.pro
branches/backus_dev/src/SpiralLenz/resource_files/
branches/backus_dev/src/SpiralLenz/resource_files/app_icon.ico
(contents, props changed)
branches/backus_dev/src/SpiralLenz/resource_files/app_icon.png
(contents, props changed)
branches/backus_dev/src/SpiralLenz/resource_files/defaults.xml
branches/backus_dev/src/SpiralLenz/resource_files/html/
branches/backus_dev/src/SpiralLenz/resource_files/html/MainDialog.jpg
(contents, props changed)
branches/backus_dev/src/SpiralLenz/resource_files/html/PaletteEditorChooser.jpg
(contents, props changed)
branches/backus_dev/src/SpiralLenz/resource_files/html/ProfileEditDialog.html
branches/backus_dev/src/SpiralLenz/resource_files/html/ProfileEditDialog.jpg
(contents, props changed)
branches/backus_dev/src/SpiralLenz/resource_files/html/index.html
branches/backus_dev/src/SpiralLenz/resource_files/qt_resource.qrc
branches/backus_dev/src/SpiralLenz/resource_files/resource.h
branches/backus_dev/src/SpiralLenz/resource_files/win_resource.rc
branches/backus_dev/src/SpiralLenz/src/
branches/backus_dev/src/SpiralLenz/src/ConfigWidget.cpp
branches/backus_dev/src/SpiralLenz/src/ProfileEditDialog.cpp
branches/backus_dev/src/SpiralLenz/src/ProfileEditDialog.h
branches/backus_dev/src/SpiralLenz/src/SpiralBackground.cpp
branches/backus_dev/src/SpiralLenz/src/SpiralBackground.h
branches/backus_dev/src/SpiralLenz/src/SpiralBackgroundProfile.cpp
branches/backus_dev/src/SpiralLenz/src/SpiralBackgroundProfile.h
branches/backus_dev/src/SpiralLenz/src/project_specific_externs.cpp
branches/backus_dev/src/SpiralLenz/src/redirector_main.cpp
branches/backus_dev/src/common/spirals/
branches/backus_dev/src/common/spirals/RectangularSpiralAlgorithm.cpp
branches/backus_dev/src/common/spirals/RectangularSpiralAlgorithm.h
branches/backus_dev/src/common/spirals/SpiralAlgorithm.cpp
branches/backus_dev/src/common/spirals/SpiralAlgorithm.h
Modified:
branches/backus_dev/src/PlasmaGenerator/resource_files/win_resource.rc
Log:
Fixed the windows resource title for the PlasmaGenerator. Added SpiralLenz
and
have begun working on the spirals. The screen saver part requires a lot of
work yet.
Modified:
branches/backus_dev/src/PlasmaGenerator/resource_files/win_resource.rc
==============================================================================
--- branches/backus_dev/src/PlasmaGenerator/resource_files/win_resource.rc
(original)
+++ branches/backus_dev/src/PlasmaGenerator/resource_files/win_resource.rc
Mon Mar 16 14:29:13 2009
@@ -77,7 +77,7 @@
STRINGTABLE
BEGIN
- IDS_DESCRIPTION "PlasmaLenz"
+ IDS_DESCRIPTION "PlasmaGenerator"
END
#endif // English (U.S.) resources
Added: branches/backus_dev/src/SpiralLenz/compiled_objects/ignore.me
==============================================================================
--- (empty file)
+++ branches/backus_dev/src/SpiralLenz/compiled_objects/ignore.me Mon Mar
16 14:29:13 2009
@@ -0,0 +1 @@
+Ignore this file. It is just to ensure that the directory gets created
during checkout.
\ No newline at end of file
Added: branches/backus_dev/src/SpiralLenz/man_page/SpiralLenz.1
==============================================================================
--- (empty file)
+++ branches/backus_dev/src/SpiralLenz/man_page/SpiralLenz.1 Mon Mar 16
14:29:13 2009
@@ -0,0 +1,35 @@
+.TH "PlasmaLenz" 1 "" "X Version 11"
+.SH NAME
+PlasmaLenz \- plasma fractal screen saver.
+.SH SYNOPSIS
+.B PlasmaLenz
+[\--root]
+[\-c]
+.SH DESCRIPTION
+PlasmaLenz is a screen saver for use with XScreenSaver that generates a
+plasma fractal, then rotates through the palette, reminiscent of the demos
+of days gone by. PlasmaLenz is part of the IdleScreen project
+(\fIhttp://sites.google.com/site/idlescreenproject\fP).
+.SH OPTIONS
+.TP 8
+.B \--root
+Draw on the root window.
+.TP 8
+.B \-c
+Display the configuration dialog.
+.SH "SEE ALSO"
+.BR X (1),
+.BR xscreensaver (1),
+.BR xscreensaver-demo (1),
+.BR Crawlies (1),
+.BR AcidRain (1)
+.SH COPYRIGHT
+Copyright \(co 2008 by Jeff Backus and the IdleScreen Project.
+
+PlasmaLenz is released under the GNU General Public License version 2. It
+is distributed AS IS, without any warranty WHAT SO EVER. A copy of the
+GPLv2 can be obtained from
+\fIhttp://www.gnu.org/licenses/old-licenses/gpl-2.0.html\fP
+.SH AUTHOR
+Jeff Backus
+
Added: branches/backus_dev/src/SpiralLenz/msvc/glut_demo/Debug/ignore.me
==============================================================================
--- (empty file)
+++ branches/backus_dev/src/SpiralLenz/msvc/glut_demo/Debug/ignore.me Mon
Mar 16 14:29:13 2009
@@ -0,0 +1 @@
+Ignore this file. It is just to ensure that the directory gets created
during checkout.
\ No newline at end of file
Added: branches/backus_dev/src/SpiralLenz/msvc/glut_demo/Release/ignore.me
==============================================================================
--- (empty file)
+++ branches/backus_dev/src/SpiralLenz/msvc/glut_demo/Release/ignore.me Mon
Mar 16 14:29:13 2009
@@ -0,0 +1 @@
+Ignore this file. It is just to ensure that the directory gets created
during checkout.
\ No newline at end of file
Added: branches/backus_dev/src/SpiralLenz/msvc/redirector/Debug/ignore.me
==============================================================================
--- (empty file)
+++ branches/backus_dev/src/SpiralLenz/msvc/redirector/Debug/ignore.me Mon
Mar 16 14:29:13 2009
@@ -0,0 +1 @@
+Ignore this file. It is just to ensure that the directory gets created
during checkout.
\ No newline at end of file
Added: branches/backus_dev/src/SpiralLenz/msvc/redirector/Release/ignore.me
==============================================================================
--- (empty file)
+++ branches/backus_dev/src/SpiralLenz/msvc/redirector/Release/ignore.me
Mon Mar 16 14:29:13 2009
@@ -0,0 +1 @@
+Ignore this file. It is just to ensure that the directory gets created
during checkout.
\ No newline at end of file
Added: branches/backus_dev/src/SpiralLenz/msvc/redirector/redirector.rc
==============================================================================
--- (empty file)
+++ branches/backus_dev/src/SpiralLenz/msvc/redirector/redirector.rc Mon
Mar 16 14:29:13 2009
@@ -0,0 +1,65 @@
+// Microsoft Visual C++ generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+#include "../../resource_files/resource.h"
+#include "../../../common/utility/redirector_resource.h"
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE
+BEGIN
+ "#include ""afxres.h""\r\n"
+ "#include ""../../resource_files/resource.h""\r\n"
+ "#include ""../../../common/utility/redirector_resource.h""\0"
+END
+
+3 TEXTINCLUDE
+BEGIN
+ "#include ""../../resource_files/win_resource.rc""\r\n"
+ "#include ""../../../common/utility/redirector_resource.rc""\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+#include "../../resource_files/win_resource.rc"
+#include "../../../common/utility/redirector_resource.rc"
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
Added: branches/backus_dev/src/SpiralLenz/msvc/redirector/resource.h
==============================================================================
--- (empty file)
+++ branches/backus_dev/src/SpiralLenz/msvc/redirector/resource.h Mon Mar
16 14:29:13 2009
@@ -0,0 +1,14 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by redirector.rc
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 101
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1001
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
Added: branches/backus_dev/src/SpiralLenz/msvc/scr/Debug/ignore.me
==============================================================================
--- (empty file)
+++ branches/backus_dev/src/SpiralLenz/msvc/scr/Debug/ignore.me Mon Mar 16
14:29:13 2009
@@ -0,0 +1 @@
+Ignore this file. It is just to ensure that the directory gets created
during checkout.
\ No newline at end of file
Added: branches/backus_dev/src/SpiralLenz/msvc/scr/Release/ignore.me
==============================================================================
--- (empty file)
+++ branches/backus_dev/src/SpiralLenz/msvc/scr/Release/ignore.me Mon Mar
16 14:29:13 2009
@@ -0,0 +1 @@
+Ignore this file. It is just to ensure that the directory gets created
during checkout.
\ No newline at end of file
Added: branches/backus_dev/src/SpiralLenz/project_files/SpiralLenz_glut.pro
==============================================================================
--- (empty file)
+++ branches/backus_dev/src/SpiralLenz/project_files/SpiralLenz_glut.pro
Mon Mar 16 14:29:13 2009
@@ -0,0 +1,98 @@
+TEMPLATE = app
+win32:CONFIG += qt warn_on
+unix:CONFIG += qt x11 warn_on release
+QT += xml
+
+unix:COMMON_PATH = ../../common
+win32:COMMON_PATH = ../../../common
+
+unix:SOURCE_PATH = ../src
+win32:SOURCE_PATH = ../../src
+
+unix:RESOURCE_PATH = ../resource_files
+win32:RESOURCE_PATH = ../../resource_files
+
+INCLUDEPATH = $$COMMON_PATH $$SOURCE_PATH $$RESOURCE_PATH
+
+SOURCES = $$COMMON_PATH/core/glut_demo.cpp
$$COMMON_PATH/core/win_misc_funcs.cpp
+
+SOURCES += $$COMMON_PATH/IndexedPalette/IndexedPalette.cpp
+SOURCES += $$COMMON_PATH/IndexedPalette/IndexedPaletteDialog.cpp
+SOURCES +=
$$COMMON_PATH/IndexedPalette/IndexedPaletteDialogEntryButton.cpp
+SOURCES += $$COMMON_PATH/IndexedPalette/IndexedPaletteEditorWidget.cpp
+SOURCES +=
$$COMMON_PATH/IndexedPalette/IndexedPaletteEditorTableWidget.cpp
+SOURCES +=
$$COMMON_PATH/IndexedPalette/IndexedPaletteEditorTableWidgetItem.cpp
+SOURCES +=
$$COMMON_PATH/IndexedPalette/IndexedPaletteEditorTableWidgetSplitDlg.cpp
+SOURCES += $$COMMON_PATH/IndexedPalette/IndexedPaletteProfile.cpp
+SOURCES += $$COMMON_PATH/utility/misc_funcs.cpp
+SOURCES += $$COMMON_PATH/utility/ImportExportDialog.cpp
+SOURCES += $$COMMON_PATH/utility/HelpDialog.cpp
+SOURCES += $$COMMON_PATH/gpl_related/gpldialog.cpp
+SOURCES += $$COMMON_PATH/plasma/PlasmaAlgorithm.cpp
+
+SOURCES += $$COMMON_PATH/2d_bgnd_w_lens/opengl_main.cpp
+SOURCES += $$COMMON_PATH/2d_bgnd_w_lens/Background.cpp
$$COMMON_PATH/2d_bgnd_w_lens/BackgroundProfile.cpp
+SOURCES += $$COMMON_PATH/2d_bgnd_w_lens/configdlg_main.cpp
$$COMMON_PATH/2d_bgnd_w_lens/ConfigManager.cpp
+SOURCES += $$COMMON_PATH/2d_bgnd_w_lens/IndexedPaletteBackground.cpp
+SOURCES += $$COMMON_PATH/2d_bgnd_w_lens/MasterProfile.cpp
+SOURCES += $$COMMON_PATH/2d_bgnd_w_lens/PaletteEditor.cpp
+SOURCES += $$COMMON_PATH/2d_bgnd_w_lens/PaletteSelectWidget.cpp
+
+SOURCES += $$COMMON_PATH/2d_bgnd_w_lens/lens_engine/LensProfile.cpp
+SOURCES += $$COMMON_PATH/2d_bgnd_w_lens/lens_engine/GenericLensObject.cpp
+SOURCES += $$COMMON_PATH/2d_bgnd_w_lens/lens_engine/LensObject.cpp
+SOURCES += $$COMMON_PATH/2d_bgnd_w_lens/lens_engine/LensManager.cpp
+SOURCES +=
$$COMMON_PATH/2d_bgnd_w_lens/lens_engine/SphericalLensProfile.cpp
+
+SOURCES += $$SOURCE_PATH/ConfigWidget.cpp $$SOURCE_PATH/PlasmaFractal.cpp
+SOURCES += $$SOURCE_PATH/PlasmaFractalBackgroundProfile.cpp
$$SOURCE_PATH/project_specific_externs.cpp
+SOURCES += $$COMMON_PATH/utility/AboutDialog.cpp
+SOURCES += $$SOURCE_PATH/ProfileEditDialog.cpp
+
+HEADERS = $$COMMON_PATH/core/win_misc_funcs.h
+
+HEADERS += $$COMMON_PATH/IndexedPalette/IndexedPalette.h
+HEADERS += $$COMMON_PATH/IndexedPalette/IndexedPaletteDialog.h
+HEADERS += $$COMMON_PATH/IndexedPalette/IndexedPaletteDialogEntryButton.h
+HEADERS += $$COMMON_PATH/IndexedPalette/IndexedPaletteEditorWidget.h
+HEADERS += $$COMMON_PATH/IndexedPalette/IndexedPaletteEditorTableWidget.h
+HEADERS +=
$$COMMON_PATH/IndexedPalette/IndexedPaletteEditorTableWidgetItem.h
+HEADERS +=
$$COMMON_PATH/IndexedPalette/IndexedPaletteEditorTableWidgetSplitDlg.h
+HEADERS += $$COMMON_PATH/IndexedPalette/IndexedPaletteProfile.h
+HEADERS += $$COMMON_PATH/utility/misc_funcs.h
+HEADERS += $$COMMON_PATH/utility/ImportExportDialog.h
+HEADERS += $$COMMON_PATH/utility/HelpDialog.h
+HEADERS += $$COMMON_PATH/gpl_related/gpldialog.h
+HEADERS += $$COMMON_PATH/plasma/PlasmaAlgorithm.h
+HEADERS += $$COMMON_PATH/core/opengl_main.h
+
+HEADERS += $$COMMON_PATH/2d_bgnd_w_lens/Background.h
$$COMMON_PATH/2d_bgnd_w_lens/BackgroundProfile.h
+HEADERS += $$COMMON_PATH/2d_bgnd_w_lens/ConfigManager.h
+HEADERS += $$COMMON_PATH/2d_bgnd_w_lens/IndexedPaletteBackground.h
+HEADERS += $$COMMON_PATH/2d_bgnd_w_lens/MasterProfile.h
+HEADERS += $$COMMON_PATH/2d_bgnd_w_lens/globaldefs.h
+HEADERS += $$COMMON_PATH/2d_bgnd_w_lens/ConfigWidget.h
+HEADERS += $$COMMON_PATH/2d_bgnd_w_lens/project_specific_extern_defs.h
+HEADERS += $$COMMON_PATH/2d_bgnd_w_lens/PaletteEditor.h
+HEADERS += $$COMMON_PATH/2d_bgnd_w_lens/PaletteSelectWidget.h
+
+HEADERS += $$COMMON_PATH/2d_bgnd_w_lens/lens_engine/LensProfile.h
+HEADERS += $$COMMON_PATH/2d_bgnd_w_lens/lens_engine/GenericLensObject.h
+HEADERS += $$COMMON_PATH/2d_bgnd_w_lens/lens_engine/LensObject.h
+HEADERS += $$COMMON_PATH/2d_bgnd_w_lens/lens_engine/LensManager.h
+HEADERS += $$COMMON_PATH/2d_bgnd_w_lens/lens_engine/SphericalLensProfile.h
+
+HEADERS += $$SOURCE_PATH/PlasmaFractalBackgroundProfile.h
$$SOURCE_PATH/PlasmaFractal.h
+HEADERS += $$RESOURCE_PATH/resource.h
+HEADERS += $$COMMON_PATH/utility/AboutDialog.h
+HEADERS += $$SOURCE_PATH/ProfileEditDialog.h
+
+TARGET = SpiralLenz_glut
+RESOURCES = $$RESOURCE_PATH/qt_resource.qrc
+
+win32:LIBS += user32.lib shell32.lib Advapi32.lib gdi32.lib scrnsavw.lib
opengl32.lib glu32.lib comctl32.lib
+
+unix:DESTDIR = ../../../bin
+unix:OBJECTS_DIR = ../compiled_objects
+unix:MOC_DIR = ../compiled_objects
+unix:LIBS += -lglut -lGL -lGLU -lX11 -lXmu -lXi -lm
Added: branches/backus_dev/src/SpiralLenz/project_files/SpiralLenz_scr.pro
==============================================================================
--- (empty file)
+++ branches/backus_dev/src/SpiralLenz/project_files/SpiralLenz_scr.pro Mon
Mar 16 14:29:13 2009
@@ -0,0 +1,101 @@
+TEMPLATE = app
+win32:CONFIG += qt warn_on
+unix:CONFIG += qt x11 warn_on release
+QT += xml
+
+unix:COMMON_PATH = ../../common
+win32:COMMON_PATH = ../../../common
+
+unix:SOURCE_PATH = ../src
+win32:SOURCE_PATH = ../../src
+
+unix:RESOURCE_PATH = ../resource_files
+win32:RESOURCE_PATH = ../../resource_files
+
+INCLUDEPATH = $$COMMON_PATH $$SOURCE_PATH $$RESOURCE_PATH
+
+win32:SOURCES = $$COMMON_PATH/core/win_main.cpp
+unix:SOURCES = $$COMMON_PATH/core/unix_main.cpp
+SOURCES += $$COMMON_PATH/core/win_misc_funcs.cpp
+
+SOURCES += $$COMMON_PATH/IndexedPalette/IndexedPalette.cpp
+SOURCES += $$COMMON_PATH/IndexedPalette/IndexedPaletteDialog.cpp
+SOURCES +=
$$COMMON_PATH/IndexedPalette/IndexedPaletteDialogEntryButton.cpp
+SOURCES += $$COMMON_PATH/IndexedPalette/IndexedPaletteEditorWidget.cpp
+SOURCES +=
$$COMMON_PATH/IndexedPalette/IndexedPaletteEditorTableWidget.cpp
+SOURCES +=
$$COMMON_PATH/IndexedPalette/IndexedPaletteEditorTableWidgetItem.cpp
+SOURCES +=
$$COMMON_PATH/IndexedPalette/IndexedPaletteEditorTableWidgetSplitDlg.cpp
+SOURCES += $$COMMON_PATH/IndexedPalette/IndexedPaletteProfile.cpp
+SOURCES += $$COMMON_PATH/utility/misc_funcs.cpp
+SOURCES += $$COMMON_PATH/utility/ImportExportDialog.cpp
+SOURCES += $$COMMON_PATH/utility/HelpDialog.cpp
+SOURCES += $$COMMON_PATH/gpl_related/gpldialog.cpp
+SOURCES += $$COMMON_PATH/plasma/PlasmaAlgorithm.cpp
+
+SOURCES += $$COMMON_PATH/2d_bgnd_w_lens/opengl_main.cpp
+SOURCES += $$COMMON_PATH/2d_bgnd_w_lens/Background.cpp
$$COMMON_PATH/2d_bgnd_w_lens/BackgroundProfile.cpp
+SOURCES += $$COMMON_PATH/2d_bgnd_w_lens/configdlg_main.cpp
$$COMMON_PATH/2d_bgnd_w_lens/ConfigManager.cpp
+SOURCES += $$COMMON_PATH/2d_bgnd_w_lens/IndexedPaletteBackground.cpp
+SOURCES += $$COMMON_PATH/2d_bgnd_w_lens/MasterProfile.cpp
+SOURCES += $$COMMON_PATH/2d_bgnd_w_lens/PaletteEditor.cpp
+SOURCES += $$COMMON_PATH/2d_bgnd_w_lens/PaletteSelectWidget.cpp
+
+SOURCES += $$COMMON_PATH/2d_bgnd_w_lens/lens_engine/LensProfile.cpp
+SOURCES += $$COMMON_PATH/2d_bgnd_w_lens/lens_engine/GenericLensObject.cpp
+SOURCES += $$COMMON_PATH/2d_bgnd_w_lens/lens_engine/LensObject.cpp
+SOURCES += $$COMMON_PATH/2d_bgnd_w_lens/lens_engine/LensManager.cpp
+SOURCES +=
$$COMMON_PATH/2d_bgnd_w_lens/lens_engine/SphericalLensProfile.cpp
+
+SOURCES += $$SOURCE_PATH/ConfigWidget.cpp $$SOURCE_PATH/PlasmaFractal.cpp
+SOURCES += $$SOURCE_PATH/PlasmaFractalBackgroundProfile.cpp
$$SOURCE_PATH/project_specific_externs.cpp
+SOURCES += $$COMMON_PATH/utility/AboutDialog.cpp
+SOURCES += $$SOURCE_PATH/ProfileEditDialog.cpp
+
+HEADERS = $$COMMON_PATH/core/win_misc_funcs.h
+
+HEADERS += $$COMMON_PATH/IndexedPalette/IndexedPalette.h
+HEADERS += $$COMMON_PATH/IndexedPalette/IndexedPaletteDialog.h
+HEADERS += $$COMMON_PATH/IndexedPalette/IndexedPaletteDialogEntryButton.h
+HEADERS += $$COMMON_PATH/IndexedPalette/IndexedPaletteEditorWidget.h
+HEADERS += $$COMMON_PATH/IndexedPalette/IndexedPaletteEditorTableWidget.h
+HEADERS +=
$$COMMON_PATH/IndexedPalette/IndexedPaletteEditorTableWidgetItem.h
+HEADERS +=
$$COMMON_PATH/IndexedPalette/IndexedPaletteEditorTableWidgetSplitDlg.h
+HEADERS += $$COMMON_PATH/IndexedPalette/IndexedPaletteProfile.h
+HEADERS += $$COMMON_PATH/utility/misc_funcs.h
+HEADERS += $$COMMON_PATH/utility/ImportExportDialog.h
+HEADERS += $$COMMON_PATH/utility/HelpDialog.h
+HEADERS += $$COMMON_PATH/gpl_related/gpldialog.h
+HEADERS += $$COMMON_PATH/plasma/PlasmaAlgorithm.h
+HEADERS += $$COMMON_PATH/core/opengl_main.h
+
+HEADERS += $$COMMON_PATH/2d_bgnd_w_lens/Background.h
$$COMMON_PATH/2d_bgnd_w_lens/BackgroundProfile.h
+HEADERS += $$COMMON_PATH/2d_bgnd_w_lens/ConfigManager.h
+HEADERS += $$COMMON_PATH/2d_bgnd_w_lens/IndexedPaletteBackground.h
+HEADERS += $$COMMON_PATH/2d_bgnd_w_lens/MasterProfile.h
+HEADERS += $$COMMON_PATH/2d_bgnd_w_lens/globaldefs.h
+HEADERS += $$COMMON_PATH/2d_bgnd_w_lens/ConfigWidget.h
+HEADERS += $$COMMON_PATH/2d_bgnd_w_lens/project_specific_extern_defs.h
+HEADERS += $$COMMON_PATH/2d_bgnd_w_lens/PaletteEditor.h
+HEADERS += $$COMMON_PATH/2d_bgnd_w_lens/PaletteSelectWidget.h
+
+HEADERS += $$COMMON_PATH/2d_bgnd_w_lens/lens_engine/LensProfile.h
+HEADERS += $$COMMON_PATH/2d_bgnd_w_lens/lens_engine/GenericLensObject.h
+HEADERS += $$COMMON_PATH/2d_bgnd_w_lens/lens_engine/LensObject.h
+HEADERS += $$COMMON_PATH/2d_bgnd_w_lens/lens_engine/LensManager.h
+HEADERS += $$COMMON_PATH/2d_bgnd_w_lens/lens_engine/SphericalLensProfile.h
+
+HEADERS += $$SOURCE_PATH/PlasmaFractalBackgroundProfile.h
$$SOURCE_PATH/PlasmaFractal.h
+HEADERS += $$RESOURCE_PATH/resource.h
+HEADERS += $$COMMON_PATH/utility/AboutDialog.h
+HEADERS += $$SOURCE_PATH/ProfileEditDialog.h
+unix:HEADERS += $$COMMON_PATH/include/vroot.h
+
+TARGET = SpiralLenz
+RESOURCES = $$RESOURCE_PATH/qt_resource.qrc
+
+win32:LIBS += user32.lib shell32.lib Advapi32.lib gdi32.lib
scrnsavw.lib opengl32.lib glu32.lib comctl32.lib $$IDLSCR_RES_LOC
+
+unix:DESTDIR = ../../../bin
+unix:OBJECTS_DIR = ../compiled_objects
+unix:MOC_DIR = ../compiled_objects
+unix:LIBS += -lGL -lGLU -lX11 -lXmu -lXi -lm
Added: branches/backus_dev/src/SpiralLenz/resource_files/app_icon.ico
==============================================================================
Binary file. No diff available.
Added: branches/backus_dev/src/SpiralLenz/resource_files/app_icon.png
==============================================================================
Binary file. No diff available.
Added: branches/backus_dev/src/SpiralLenz/resource_files/defaults.xml
==============================================================================
--- (empty file)
+++ branches/backus_dev/src/SpiralLenz/resource_files/defaults.xml Mon Mar
16 14:29:13 2009
@@ -0,0 +1,111 @@
+<!DOCTYPE PlasmaLenz_Configuration>
+<PlasmaLenz_Configuration>
+ <BackgroundProfile>
+ <type>PlasmaFractalBackground</type>
+ <name>Classic RGB Profile</name>
+ <coarseness>4.5</coarseness>
+ <steps_per_tick>2048</steps_per_tick>
+ <anmiate_palette>true</anmiate_palette>
+ <palette_x_speed>1</palette_x_speed>
+ <palette_y_speed>1</palette_y_speed>
+ <clamp_color>true</clamp_color>
+ <palette>Classic RGB Palette</palette>
+ </BackgroundProfile>
+ <IndexedPaletteProfile>
+ <name>Classic RGB Palette</name>
+ <width>192</width>
+ <height>1</height>
+ <interpolate_colors>Linear</interpolate_colors>
+ <wrap_colors>true</wrap_colors>
+ <default_color>
+ <red>0</red>
+ <green>0</green>
+ <blue>0</blue>
+ </default_color>
+ <color_list>
+ <color_entry>
+ <red>255</red>
+ <green>0</green>
+ <blue>0</blue>
+ <alpha>255</alpha>
+ <x_coordinate>0</x_coordinate>
+ <y_coordinate>0</y_coordinate>
+ </color_entry>
+ <color_entry>
+ <red>0</red>
+ <green>255</green>
+ <blue>0</blue>
+ <alpha>255</alpha>
+ <x_coordinate>63</x_coordinate>
+ <y_coordinate>0</y_coordinate>
+ </color_entry>
+ <color_entry>
+ <red>0</red>
+ <green>0</green>
+ <blue>255</blue>
+ <alpha>255</alpha>
+ <x_coordinate>127</x_coordinate>
+ <y_coordinate>0</y_coordinate>
+ </color_entry>
+ </color_list>
+ </IndexedPaletteProfile>
+ <LensProfile>
+ <type>SphericalLensProfile</type>
+ <name>Sphere</name>
+ <palette_name>Default Lens Palette</palette_name>
+ <outline_width>2</outline_width>
+ <random_tint>false</random_tint>
+ <use_primary_tint>false</use_primary_tint>
+ <primary_tint_is_complement>false</primary_tint_is_complement>
+ <use_outline_tint>false</use_outline_tint>
+ <outline_tint_is_complement>true</outline_tint_is_complement>
+ <min_speed>2</min_speed>
+ <max_speed>6</max_speed>
+ <random_speed>true</random_speed>
+ <min_angle>0.785398</min_angle>
+ <max_angle>2.35619</max_angle>
+ <random_angle>true</random_angle>
+ <random_side>true</random_side>
+ <side_types>
+ <side_entry>
+ <side>Bottom</side>
+ <location>0</location>
+ </side_entry>
+ <side_entry>
+ <side>Top</side>
+ <location>1</location>
+ </side_entry>
+ <side_entry>
+ <side>Left</side>
+ <location>2</location>
+ </side_entry>
+ <side_entry>
+ <side>Right</side>
+ <location>3</location>
+ </side_entry>
+ </side_types>
+ <min_radius>0.075</min_radius>
+ <max_radius>0.15</max_radius>
+ <distortion_factor>0.75</distortion_factor>
+ <random_size>true</random_size>
+ <instances_max>5</instances_max>
+ </LensProfile>
+ <MasterProfile>
+ <name>Classic RGB</name>
+ <width>1024</width>
+ <height>1024</height>
+ <timer_millis>50</timer_millis>
+ <background_profile>Classic RGB Profile</background_profile>
+ <lens_profile>Sphere</lens_profile>
+ </MasterProfile>
+ <random_master_profiles>false</random_master_profiles>
+ <gpl_accepted>false</gpl_accepted>
+ <master_profile_history_size>3</master_profile_history_size>
+ <selected_master_profile_list>
+ <selected_entry>
+ <name>Classic RGB</name>
+ <location>0</location>
+ </selected_entry>
+ </selected_master_profile_list>
+</PlasmaLenz_Configuration>
+
Added: branches/backus_dev/src/SpiralLenz/resource_files/html/MainDialog.jpg
==============================================================================
Binary file. No diff available.
Added:
branches/backus_dev/src/SpiralLenz/resource_files/html/PaletteEditorChooser.jpg
==============================================================================
Binary file. No diff available.
Added:
branches/backus_dev/src/SpiralLenz/resource_files/html/ProfileEditDialog.html
==============================================================================
--- (empty file)
+++
branches/backus_dev/src/SpiralLenz/resource_files/html/ProfileEditDialog.html
Mon Mar 16 14:29:13 2009
@@ -0,0 +1,105 @@
+<HTML>
+<HEAD>
+<TITLE>Profile Editor</TITLE>
+</HEAD>
+<BODY>
+<H2>Profile Editor</H2><br>
+<img src="ProfileEditDialog.jpg" width="454" height="531" border="0"
alt="" align="middle">
+<h3>The Basics</h3>
+<p>Each profile contains several important options that the
+user is able to adjust. Before discussing these options, however,
+lets take a moment to go over the basics. In order to generate
+a plasma fractal, PlasmaLenz requires a palette of colors to use,
+the dimensions of the fractal to generate, and a factor of
+volatility. All three factor into how varied the fractals look,
+larger fractals with a larger number of different colors, and a
+larger factor of volatility will have more variation than
+smaller fractals with a fewer number of different colors and
+a smaller factor of volatility.</P>
+<p>After generating the plasma
+fractal, PlasmaLenz has the ability to rotate through the
+palette, which causes the fractal to look like its "flowing".
+Additionally, PlasmaLenz has the ability to add lens sprites to
+the screen, which create a nice "bubble" like effect.</p>
+<h3>The Nitty-Gritty</h3>
+<p>Here we will discuss the specifics of each parameter.</p>
+<ul><li><b>Width, Height</b> - These are the dimensions of the
+plasma, and required to be a power of 2, thus the drop-down
+boxes.</li>
+<li><b>Milliseconds Between Frames</b> - This parameter controls
+the number of milliseconds to wait before <i>starting</i> the
+next frame after the current frame is initiated. In other
+words, this is a lower bound on the rendering speed. If it
+takes your machine longer than the value of this parameter to
+render each scene, the result will be dropped frames. Smaller
+values for this parameter can result in smoother animation,
+if the machine can handle it. The
+maximum framerate can be calculated by dividing 1000
+by the value of this parameter. For example, for a value of
+50, the maximum framerate will be 1000 / 50 = 20 frames per
+second.</li>
+<li><b>Palette</b> - this is the palette to use to color the
+plasma fractal. Use the drop-down list to select one of
+the available palettes, or you can add a new palette by
+clicking the "Add" button to the right. Clicking the "Edit"
+button will edit the palette currently selected. For more
+information on palettes and the Palette Editor, please
+click <a href="IndexedPaletteDialog.html">here</a>. For
+more suggestions on designing a palette, please see below.</li>
+<li><b>Animate Palette</b> - When this box is checked,
+PlasmaLenz will rotate through the palette colors, creating
+a fluid-like animation.</li>
+<li><b>X Speed, Y Speed</b> - These parameters control the
+speed at which the palette is rotated through in the X (or
+primary) and Y (or secondary) directions. The larger
+the number, the quicker the rotation. A value of 1.0
+corresponds to stepping one color per frame.</li>
+<li><b>Volatility</b> - This slider controls the amount of
+variation, or volatility, within the plasma field.</li>
+<li><b>Clamp color on overflow</b> - When checked, this
+parameter will cause the plasma fractal to clamp to the endmost
+color when it exceeds an endpoint, as opposed to wrapping
+around to the other side.</li>
+<li><b>Number of Lenses</b> - This parameter controls the
+maximum number of lenses allowed on screen at any given time.
+The number of lenses on screen can be smaller than this
+number, but not larger.</li>
+<li><b>Size</b> - This parameter controls the size of the
+lenses. Size will determine the amount of warping the lens
+will cause.</li>
+<li><b>Variation</b> - This parameter controls how much
+variation there is in the size of the lenses. Moving
+the slider all the way to left to "Min" will result in all
+lenses having the same size.</li></ul>
+<h3>Palette Considerations</h3>
+<p>Palette design is a bit of an artform, but some guidelines
+that I stick to are as follows:</p>
+<ul><li>Stick to a small number of "key" colors, say 3-5.</li>
+<li>Keep a consistent amount of undefined colors between
+each "key" color, say 15 or 31.</li>
+<li>Utilize color interpolation and color wrapping.</li>
+<li>Have fun doing it!</li></ul>
+<h3>Performance</h3>
+<p>The two parameters that affect performance the most are
+the plasma dimensions and the number of milliseconds between
+frames. If the screen saver seems jerky, try increasing the
+number of milliseconds between frames and reducing the plasma
+dimensions. Raw CPU power is part of the equation, but the
+biggest bottleneck is the speed of your computer's front-side
+bus. For slower buses, reducing the dimensions of the
+plasma will have a huge effect. The number and size of the
+lenses will also have an effect on the speed, particularly
+for slower CPUs. Field volatility, the size of the
+palette, and the palette rotation speed won't have an effect
+on the frame rate at all, however
+larger palettes will "flow" more slowly, due to the larger
+number of colors to iterate through. This goes for
+2D palettes, also.</p>
+<h3>Where To Look For More Info</h3>
+<p>For more help, feel free to visit us at
+http://sites.google.com/site/idlescreenproject/, where
+you can take advantage of the FAQS, Wiki, and user lists.</p>
+<hr>
+<a href="index.html">Back To the Main Page</a>
+</BODY>
+</HTML>
\ No newline at end of file
Added:
branches/backus_dev/src/SpiralLenz/resource_files/html/ProfileEditDialog.jpg
==============================================================================
Binary file. No diff available.
Added: branches/backus_dev/src/SpiralLenz/resource_files/html/index.html
==============================================================================
--- (empty file)
+++ branches/backus_dev/src/SpiralLenz/resource_files/html/index.html Mon
Mar 16 14:29:13 2009
@@ -0,0 +1,94 @@
+<html>
+<head>
+<title>PlasmaLenz Help</title>
+</head>
+<body>
+<h2>PlasmaLenz Help</h2><br>
+<img src="MainDialog.jpg" width="683" height="458" border="0" alt=""
align="middle">
+<h3>Profiles</h3>
+<P>PlasmaLenz is capable of maintaining multiple
+configuration profiles, which it will either
+randomly or sequentially select at each invocation.
+The box on the left of the
+dialog box contains the list of available profiles,
+and the box on the right contains the list of
+currently selected profiles. Profiles are added
+to the selected list by selecting them in the box
+on the list, and clicking the ">>" button. Clicking
+the "<<" button will remove any selected profiles
+in the box on the right. Pushing the "Up" button
+will move the currently selected profile in the box
+on the right up in the list, and the "Down" button
+will move the selected profile down in the list.
+Below the list of
+selected profiles is the check box to enable or
+disable random profile selection, as well as the
+field that determines the history size, or
+the number of profiles that must be used before
+a profile can be repeated.</p>
+<h3>Creating, Editing, and Deleting Profiles</h3>
+<p>To create a new profile, simply click the "New"
+button under the list of available profiles on
+the left. This will bring up the
+<a href="ProfileEditDialog.html">Profile Editor</a>
+dialog box with an empty profile.
+ To edit a profile, select the
+profile to edit in the box on the left and click
+the "Edit" button. This will open the
+<a href="ProfileEditDialog.html">Profile Editor</a>
+dialog box for the selected profile.
+Clicking delete will permanently delete the profile
+that is currently selected in the box on the left.
+For more information on the Profile Editor
+and the various profile settings, please
+click <a href="ProfileEditDialog.html">here</a>
+or on "Help" in the Profile Editor dialog box.</p>
+<h3>Palettes and the Palette Editor</h3><br>
+<img src="PaletteEditorChooser.jpg" width="392" height="364" border="0"
alt="" align="middle">
+<p>All configuration profiles contain references
+to a color palette. Palettes are separate entities,
+and multiple configuration profiles can reference
+the same palette. To create/edit/delete palettes
+without opening the
+<a href="ProfileEditDialog.html">Profile Editor</a>,
+simply click
+the "Palette Editor" button below the list of
+available profiles. This brings up a dialog that allows
+you to add new palettes, duplicate an existing
+palette, edit an existing palette, or delete a palette.
+Note that all palettes must have unique names. Clicking
+"Duplicate" will prompt you for a new, unique, name
+for the palette. Clicking on "New" or "Edit" will
+bring up the
+<a href="IndexedPaletteDialog.html">Palette Editor</a>.
+For mor information
+on the Palette Editor and on palettes, please click
+<a href="IndexedPaletteDialog.html">here</a> or
+on "Help" in the Palette Editor dialog box.
+For information on palette design considerations,
+please see refer to the help documentation for
+the <a href="ProfileEditDialog.html">Profile Editor</a>.</p>
+<h3>Importing and Exporting</h3>
+<p>PlasmaLenz allows you to import and export
+some or all of your profiles and palettes to an
+XML file. This allows you to backup, restore, and share
+your favorite settings with ease. To export your
+settings, simply click "Export Settings" on the right
+side of the dialog box, select the settings you wish
+to save, click "Export", then enter the name of
+the file to export to. To import settings, simply
+click on "Import Settings" on the right side of
+the dialog box, navigate to the file you wish to import,
+select the profiles and/or palettes to import, then
+click "Import".</p>
+<h3>Final Notes</h3>
+<p>If you make a mistake, take heart! None of the
+settings are actually saved to disk until you click
+"Ok" or "Apply". Clicking "Cancel" will abandon any and
+all changes you have made since the last save.</p>
+<h3>For More Information</h3>
+For more information, including a wiki, bug tracker, and
+program updates, please visit us at
+http://sites.google.com/site/idlescreenproject!
+</body>
+</html>
Added: branches/backus_dev/src/SpiralLenz/resource_files/qt_resource.qrc
==============================================================================
--- (empty file)
+++ branches/backus_dev/src/SpiralLenz/resource_files/qt_resource.qrc Mon
Mar 16 14:29:13 2009
@@ -0,0 +1,15 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file alias="defaults.xml">defaults.xml</file>
+ <file alias="app_icon.png">app_icon.png</file>
+ <file alias="gplv2.txt">../../common/gpl_related/gplv2.txt</file>
+ <file alias="help/index.html">html/index.html</file>
+ <file alias="help/MainDialog.jpg">html/MainDialog.jpg</file>
+ <file
alias="help/PaletteEditorChooser.jpg">html/PaletteEditorChooser.jpg</file>
+ <file
alias="help/ProfileEditDialog.html">html/ProfileEditDialog.html</file>
+ <file alias="help/ProfileEditDialog.jpg">html/ProfileEditDialog.jpg</file>
+ <file
alias="help/IndexedPaletteDialog.html">../../common/IndexedPalette/resource_files/IndexedPaletteDialog.html</file>
+ <file
alias="help/IndexedPaletteDialog.jpg">../../common/IndexedPalette/resource_files/IndexedPaletteDialog.jpg</file>
+ <file
alias="help/InsertColorDialog.jpg">../../common/IndexedPalette/resource_files/InsertColorDialog.jpg</file>
+</qresource>
+</RCC>
Added: branches/backus_dev/src/SpiralLenz/resource_files/resource.h
==============================================================================
--- (empty file)
+++ branches/backus_dev/src/SpiralLenz/resource_files/resource.h Mon Mar 16
14:29:13 2009
@@ -0,0 +1,18 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by win_resource.rc
+//
+#define IDS_DESCRIPTION 1
+#define ID_APP 100
+#define DLG_SCRNSAVECONFIGURE 2003
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 103
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1001
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
Added: branches/backus_dev/src/SpiralLenz/resource_files/win_resource.rc
==============================================================================
--- (empty file)
+++ branches/backus_dev/src/SpiralLenz/resource_files/win_resource.rc Mon
Mar 16 14:29:13 2009
@@ -0,0 +1,97 @@
+// Microsoft Visual C++ generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE
+BEGIN
+ "#include ""afxres.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+DLG_SCRNSAVECONFIGURE DIALOGEX 0, 0, 195, 127
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION
+CAPTION "Property Page"
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ LTEXT "TODO: layout property page",IDC_STATIC,53,59,90,8
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+ID_APP
ICON "../../resource_files/app_icon.ico"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE
+BEGIN
+ IDS_DESCRIPTION "SpiralLenz"
+END
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
Added: branches/backus_dev/src/SpiralLenz/src/ConfigWidget.cpp
==============================================================================
--- (empty file)
+++ branches/backus_dev/src/SpiralLenz/src/ConfigWidget.cpp Mon Mar 16
14:29:13 2009
@@ -0,0 +1,689 @@
+/**
+ * Copyright (c) 2008 Jeff Backus.
+ *
+ * Licensed under the GNU General Public License, Version 2.0
(the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Additionally, this code makes heavy use of the Qt libraries from
+ * Trolltech. These libraries are released under the GNU
+ * General Public License, Version 2.0, as well. Please contact
+ * Trolltech for more information.
+ *
+ * http://trolltech.com/
+ *
+ */
+
+//begin debug
+//#include <iostream>
+//using namespace std;
+#include "2d_bgnd_w_lens/lens_engine/SphericalLensProfile.h"
+//end debug
+
+#include <QVBoxLayout>
+#include <QHBoxLayout>
+#include <QPushButton>
+#include <QCheckBox>
+#include <QWidget>
+#include <QGroupBox>
+#include <QIcon>
+#include <QLabel>
+#include <QFileDialog>
+#include <QDir>
+
+//temp
+//#include <QMessageBox>
+//end temp
+
+#include "../../common/2d_bgnd_w_lens/ConfigWidget.h"
+#include "../../common/2d_bgnd_w_lens/PaletteEditor.h"
+#include "../../common/utility/ImportExportDialog.h"
+#include "../../common/utility/misc_funcs.h"
+#include "../../common/utility/AboutDialog.h"
+#include "../../common/utility/HelpDialog.h"
+#include "../../common/2d_bgnd_w_lens/project_specific_extern_defs.h"
+#include "ProfileEditDialog.h"
+
+//constructor & destructor
+ConfigWidget::ConfigWidget(QWidget* parent, Qt::WindowFlags f) {
+ QDialog(parent, f);
+
+ _manager = NULL;
+ _gplDialog = NULL;
+ _stackedLayout = NULL;
+ _mpAvailList = NULL;
+ _mpSelList = NULL;
+
+ _windowTitle = tr("PlasmaLenz Configuration");
+
+ setWindowTitle(_windowTitle);
+
+ QIcon icon(":/app_icon.png");
+ setWindowIcon(icon);
+}
+
+ConfigWidget::~ConfigWidget() {
+ _manager = NULL;
+
+ if(_gplDialog != NULL) {
+ delete _gplDialog;
+ _gplDialog = NULL;
+ }
+
+ if(_stackedLayout != NULL) {
+ delete _stackedLayout;
+ _stackedLayout = NULL;
+ }
+
+ if(_mpAvailList != NULL) {
+ delete _mpAvailList;
+ _mpAvailList = NULL;
+ }
+
+ if(_mpSelList != NULL) {
+ delete _mpSelList;
+ _mpSelList = NULL;
+ }
+
+ if(_historyBox != NULL) {
+ delete _historyBox;
+ _historyBox = NULL;
+ }
+}
+
+void ConfigWidget::setup(void) {
+
+ //precaution
+ if(_manager == NULL) {
+ emit dialogFinished();
+ }
+
+ _gplDialog = new GPLDialog(_manager->getGPLAccepted());
+
+ QWidget* tempWidget = NULL;
+ QPushButton* tempButton = NULL;
+ QLabel* tempLabel = NULL;
+ QVBoxLayout* mainLayout = new QVBoxLayout();
+
+ //Master Profile selection lists and related.
+ tempWidget = genMPWidget();
+ mainLayout->addWidget(tempWidget);
+ tempWidget = NULL;
+
+ // import/export/palette editor buttons
+ QHBoxLayout* midButtonsLayout = new QHBoxLayout();
+
+ tempButton = new QPushButton(tr("Palette Editor"));
+ tempButton->setToolTip(tr("Opens the palette editor."));
+ QObject::connect(tempButton, SIGNAL(clicked(bool)), this,
SLOT(paletteEditorClicked(bool)));
+ midButtonsLayout->addWidget(tempButton);
+ tempButton = NULL;
+
+ midButtonsLayout->addStretch(0);
+
+ tempButton = new QPushButton(tr("Import Settings"));
+ tempButton->setToolTip(tr("Imports settings from a file."));
+ QObject::connect(tempButton, SIGNAL(clicked(bool)), this,
SLOT(importClicked(bool)));
+ midButtonsLayout->addWidget(tempButton);
+ tempButton = NULL;
+
+ tempButton = new QPushButton(tr("Export Settings"));
+ tempButton->setToolTip(tr("Exports settings to a file."));
+ QObject::connect(tempButton, SIGNAL(clicked(bool)), this,
SLOT(exportClicked(bool)));
+ midButtonsLayout->addWidget(tempButton);
+ tempButton = NULL;
+
+ tempWidget = new QWidget();
+ tempWidget->setLayout(midButtonsLayout);
+ mainLayout->addWidget(tempWidget);
+ tempWidget = NULL;
+
+ //About, Help, OK, Apply, and Cancel buttons
+ QHBoxLayout* botButtonsLayout = new QHBoxLayout();
+
+ tempButton = new QPushButton(tr("A&bout"));
+ QObject::connect(tempButton, SIGNAL(clicked(bool)), this,
SLOT(aboutClicked(bool)));
+ botButtonsLayout->addWidget(tempButton);
+ tempButton = NULL;
+
+ tempButton = new QPushButton(tr("&Help"));
+ tempButton->setDefault(false);
+ tempButton->setAutoDefault(false);
+ QObject::connect(tempButton, SIGNAL(clicked(bool)), this,
SLOT(helpClicked(bool)));
+ botButtonsLayout->addWidget(tempButton);
+ tempButton = NULL;
+
+ botButtonsLayout->addStretch(0);
+
+ tempButton = new QPushButton(tr("&OK"));
+ QObject::connect(tempButton, SIGNAL(clicked(bool)), this,
SLOT(okClicked(bool)));
+ tempButton->setDefault(true);
+ botButtonsLayout->addWidget(tempButton);
+ tempButton = NULL;
+
+ tempButton = new QPushButton(tr("&Apply"));
+ QObject::connect(tempButton, SIGNAL(clicked(bool)), this,
SLOT(applyClicked(bool)));
+ botButtonsLayout->addWidget(tempButton);
+ tempButton = NULL;
+
+ tempButton = new QPushButton(tr("&Cancel"));
+ QObject::connect(tempButton, SIGNAL(clicked(bool)), this,
SLOT(cancelClicked(bool)));
+ botButtonsLayout->addWidget(tempButton);
+ tempButton = NULL;
+
+ tempWidget = new QWidget();
+ tempWidget->setLayout(botButtonsLayout);
+ mainLayout->addWidget(tempWidget);
+ tempWidget = NULL;
+
+ setLayout(mainLayout);
+
+ populateMPLists();
+
+}
+
+void ConfigWidget::setManager(ConfigManager* manager) {
+ _manager = manager;
+}
+
+void ConfigWidget::addListClicked(bool checked) {
+ if(_mpAvailList == NULL || _mpSelList == NULL)
+ return;
+
+ QList<QListWidgetItem*> itemList = _mpAvailList->selectedItems();
+ for(int i =0; i<itemList.size(); i++) {
+
if(_mpSelList->findItems(itemList.at(i)->text(),Qt::MatchExactly).empty()) {
+ _mpSelList->addItem(itemList.at(i)->text());
+ }
+ }
+}
+
+void ConfigWidget::removeListClicked(bool checked) {
+ if(_mpSelList == NULL)
+ return;
+
+ QList<QListWidgetItem*> list = _mpSelList->selectedItems();
+ for(int i=0;i<list.size(); i++) {
+ QListWidgetItem* tmp = _mpSelList->takeItem(_mpSelList->row(list.at(i)));
+ delete tmp;
+ tmp = NULL;
+ }
+}
+
+void ConfigWidget::upListClicked(bool checked) {
+ if(_mpSelList == NULL)
+ return;
+
+ int row = _mpSelList->currentRow();
+ if(row > 0) {
+ _mpSelList->insertItem(row-1,_mpSelList->takeItem(row));
+ _mpSelList->setCurrentRow(row-1);
+ }
+}
+
+void ConfigWidget::downListClicked(bool checked) {
+ if(_mpSelList == NULL)
+ return;
+
+ int row = _mpSelList->currentRow();
+ if(row < _mpSelList->count()) {
+ _mpSelList->insertItem(row+1,_mpSelList->takeItem(row));
+ if(row+1 == _mpSelList->count()) {
+ _mpSelList->setCurrentRow(_mpSelList->count()-1);
+ } else {
+ _mpSelList->setCurrentRow(row+1);
+ }
+ }
+}
+
+void ConfigWidget::okClicked(bool checked) {
+ saveData();
+
+ emit dialogFinished();
+}
+
+void ConfigWidget::applyClicked(bool checked) {
+ saveData();
+}
+
+void ConfigWidget::cancelClicked(bool checked) {
+ emit dialogFinished();
+}
+
+void ConfigWidget::randomClicked(bool checked) {
+ _manager->setRandomProfile(checked);
+}
+
+void ConfigWidget::aboutClicked(bool checked) {
+ AboutDialog* dlg = new AboutDialog(getAppFullName(), getAppVersion());
+ if(dlg != NULL) {
+ dlg->exec();
+ delete dlg;
+ dlg = NULL;
+ }
+}
+
+//shows the GPL dialog
+void ConfigWidget::showGPLDialog(void) {
+ _gplDialog->exec();
+ _manager->setGPLAccepted(_gplDialog->isAccepted());
+ if(_manager->getGPLAccepted()) {
+ _manager->save();
+ }
+}
+
+void ConfigWidget::addMPClicked(bool checked) {
+
+ ProfileEditDialog* dlg = new ProfileEditDialog("", _manager);
+ QObject::connect(dlg, SIGNAL(profileNameChange(QString, QString)), this,
SLOT(profileNameChange(QString, QString)));
+ dlg->exec();
+}
+
+void ConfigWidget::editMPClicked(bool checked) {
+// QMessageBox::information(this, _windowTitle, "Not implemented yet.",
QMessageBox::Ok);
+
+ if(_mpAvailList == NULL)
+ return;
+
+ QList<QListWidgetItem*> list = _mpAvailList->selectedItems();
+ for(int i=0;i<list.size(); i++) {
+ QListWidgetItem* tmp = _mpAvailList->item(_mpAvailList->row(list.at(i)));
+ ProfileEditDialog* dlg = new ProfileEditDialog(tmp->text(), _manager);
+ QObject::connect(dlg, SIGNAL(profileNameChange(QString, QString)), this,
SLOT(profileNameChange(QString, QString)));
+ dlg->exec();
+
+ //clean up
+ tmp = NULL;
+ delete dlg;
+ dlg = NULL;
+ }
+}
+
+void ConfigWidget::deleteMPClicked(bool checked) {
+ if(_mpAvailList == NULL)
+ return;
+
+ QList<QListWidgetItem*> list = _mpAvailList->selectedItems();
+ for(int i=0;i<list.size(); i++) {
+ // get the selected master profile
+ QListWidgetItem* tmp =
_mpAvailList->takeItem(_mpAvailList->row(list.at(i)));
+ QString name = tmp->text();
+ delete tmp;
+ tmp = NULL;
+
+ //delete the background profile
+ MasterProfile tempMp = _manager->getProfile(name);
+ _manager->removeBackgroundProfile(tempMp.getBackgroundProfileName());
+
+ //delete the master profile
+ _manager->removeProfile(name);
+
+ //now remove the master profile from selected list, if it is in there.
+ int j=0;
+ bool bDone = false;
+ while(!bDone && j<_mpSelList->count()) {
+ tmp = _mpSelList->item(j);
+ if(tmp->text() == name) {
+ bDone = true;
+ _mpSelList->takeItem(j);
+ delete tmp;
+ tmp = NULL;
+ }
+
+ j++;
+ }
+ }
+}
+
+void ConfigWidget::advancedChecked(bool checked) {
+// nada
+}
+
+//clears and then populates both MasterProfile lists.
+void ConfigWidget::populateMPLists() {
+ if(_mpAvailList == NULL || _mpSelList == NULL)
+ return;
+
+ //available list
+ _mpAvailList->clear();
+ _mpAvailList->addItems(_manager->getAvailableProfiles());
+
+ //selected list
+ _mpSelList->clear();
+ _mpSelList->addItems(_manager->getSelectedProfiles());
+}
+
+//generates a widget that contains the available and selected
+//master profile lists as well as the requisite buttons.
+QWidget* ConfigWidget::genMPWidget() {
+ QWidget* tempWidget = NULL;
+ QPushButton* tempButton = NULL;
+
+ QVBoxLayout* mpLayout = new QVBoxLayout();
+
+ QHBoxLayout* listsLayout = new QHBoxLayout();
+
+ _mpAvailList = new QListWidget();
+ _mpAvailList->setSelectionMode(QAbstractItemView::ExtendedSelection);
+ _mpAvailList->setToolTip(tr("This is the list of available configuration
profiles."));
+
+ listsLayout->addWidget(_mpAvailList);
+
+ QVBoxLayout* listButtonLayout = new QVBoxLayout();
+
+ tempButton = new QPushButton(">>");
+ tempButton->setToolTip(tr("Click to add the items selected in the list of
available configuration profiles")+"\n"
+ +tr("to the list of selected configuration profiles."));
+ QObject::connect(tempButton, SIGNAL(clicked(bool)), this,
SLOT(addListClicked(bool)));
+ listButtonLayout->addWidget(tempButton);
+ tempButton = NULL;
+
+ tempButton = new QPushButton("<<");
+ tempButton->setToolTip(tr("Click to remove the selected items in the list
of selected configuration profiles."));
+ QObject::connect(tempButton, SIGNAL(clicked(bool)), this,
SLOT(removeListClicked(bool)));
+ listButtonLayout->addWidget(tempButton);
+ tempButton = NULL;
+
+ tempButton = new QPushButton(tr("Up"));
+ tempButton->setToolTip(tr("Click to move the selected item in the list of
selected configuration profiles up in")+"\n"
+ +tr("the order."));
+ QObject::connect(tempButton, SIGNAL(clicked(bool)), this,
SLOT(upListClicked(bool)));
+ listButtonLayout->addWidget(tempButton);
+ tempButton = NULL;
+
+ tempButton = new QPushButton(tr("Down"));
+ tempButton->setToolTip(tr("Click to move the selected item in the list of
selected configuration profiles")+"\n"
+ +tr("down in the order."));
+ QObject::connect(tempButton, SIGNAL(clicked(bool)), this,
SLOT(downListClicked(bool)));
+ listButtonLayout->addWidget(tempButton);
+ tempButton = NULL;
+
+ tempWidget = new QWidget();
+ tempWidget->setLayout(listButtonLayout);
+ listsLayout->addWidget(tempWidget);
+ tempWidget = NULL;
+
+ _mpSelList = new QListWidget();
+ _mpSelList->setSelectionMode(QAbstractItemView::ExtendedSelection);
+ _mpSelList->setToolTip(tr("This is the list of currently selected
configuration profiles."));
+ listsLayout->addWidget(_mpSelList);
+
+ tempWidget = new QWidget();
+ tempWidget->setLayout(listsLayout);
+ mpLayout->addWidget(tempWidget);
+ tempWidget = NULL;
+
+ //add/edit/delete buttons, stretch, history box
+ QHBoxLayout* bottomButtonLayout = new QHBoxLayout();
+
+ tempButton = new QPushButton(tr("New"));
+ tempButton->setToolTip(tr("Click to add a new configuration profile."));
+ QObject::connect(tempButton, SIGNAL(clicked(bool)), this,
SLOT(addMPClicked(bool)));
+ bottomButtonLayout->addWidget(tempButton);
+ tempButton = NULL;
+
+ tempButton = new QPushButton(tr("Edit"));
+ tempButton->setToolTip(tr("Click to edit the currently selected
configuration profile."));
+ QObject::connect(tempButton, SIGNAL(clicked(bool)), this,
SLOT(editMPClicked(bool)));
+ bottomButtonLayout->addWidget(tempButton);
+ tempButton = NULL;
+
+ tempButton = new QPushButton(tr("Delete"));
+ tempButton->setToolTip(tr("Click to permanently remove the currently
selected configuration profile."));
+ QObject::connect(tempButton, SIGNAL(clicked(bool)), this,
SLOT(deleteMPClicked(bool)));
+ bottomButtonLayout->addWidget(tempButton);
+ tempButton = NULL;
+
+ bottomButtonLayout->addStretch(0);
+
+ //history box
+ QGroupBox* randomBox = new QGroupBox(tr("Choose &Randomly"));
+ randomBox->setCheckable(true);
+ randomBox->setChecked(_manager->isRandomProfile());
+ randomBox->setToolTip(tr("Enabling this will randomize the order in which
the configuration profiles will run."));
+ QObject::connect(randomBox, SIGNAL(clicked(bool)), this,
SLOT(randomClicked(bool)));
+
+ QHBoxLayout* historyLayout = new QHBoxLayout();
+ QLabel* historyLabel = new QLabel(tr("Size of History"));
+ historyLabel->setToolTip(tr("The number of times before a configuration
profile can run again."));
+ historyLayout->addWidget(historyLabel);
+
+ _historyBox = new QSpinBox();
+ _historyBox->setRange(0,10);
+ _historyBox->setSingleStep(1);
+ _historyBox->setValue(_manager->getProfileHistorySize());
+ _historyBox->setToolTip(tr("The number of times before a configuration
profile can run again."));
+ historyLayout->addWidget(_historyBox);
+
+ randomBox->setLayout(historyLayout);
+ bottomButtonLayout->addWidget(randomBox);
+
+ tempWidget = new QWidget();
+ tempWidget->setLayout(bottomButtonLayout);
+ mpLayout->addWidget(tempWidget);
+ tempWidget = NULL;
+
+ tempWidget = new QWidget();
+ tempWidget->setLayout(mpLayout);
+ return tempWidget;
+}
+
+//saves all data back to the configuration manager
+void ConfigWidget::saveData() {
+ //update list of selected profiles
+ if(_mpSelList != NULL) {
+ QStringList retVal;
+ for(int i=0;i<_mpSelList->count();i++) {
+ QListWidgetItem* tmp = _mpSelList->item(i);
+ if(tmp != NULL) {
+ retVal.append(tmp->text());
+ }
+ }
+ _manager->setSelectedProfiles(retVal);
+ }
+
+ //update history size
+ _manager->setProfileHistorySize(_historyBox->value());
+
+ _manager->save();
+}
+void ConfigWidget::profileNameChange(QString oldName, QString newName) {
+ if(_mpAvailList == NULL)
+ return;
+
+ if(oldName != newName) {
+ //it is an addition. Append to the available list.
+ if(oldName == "") {
+ _mpAvailList->addItem(newName);
+ } else {
+ //otherwise, we're replacing.
+
+ //search the list for the old name, remove it and
+ //insert the new one in the same position.
+ int j=0;
+ bool bDone = false;
+ while(!bDone && j < _mpAvailList->count()) {
+ QListWidgetItem* tmp = _mpAvailList->item(j);
+ if(tmp->text() == oldName) {
+ bDone = true;
+ //remove
+ _mpAvailList->takeItem(j);
+ delete tmp;
+ tmp = NULL;
+
+ //insert
+ _mpAvailList->insertItem(j, newName);
+ }
+
+ j++;
+ }
+ // repeat on the list of selected items
+ j=0;
+ bDone = false;
+ while(!bDone &&j<_mpSelList->count()) {
+ QListWidgetItem* tmp = _mpSelList->item(j);
+ if(tmp->text() == oldName) {
+ bDone = true;
+ //remove
+ _mpSelList->takeItem(j);
+ delete tmp;
+ tmp = NULL;
+
+ //insert
+ _mpSelList->insertItem(j, newName);
+ }
+ j++;
+ }
+ }
+ }
+}
+
+void ConfigWidget::importClicked(bool checked) {
+// QMessageBox::information(this, _windowTitle, "Not implemented yet.",
QMessageBox::Ok);
+ ImportExportDialog dlg(true);
+
+ // get file name to import from
+ QString filename = QFileDialog::getOpenFileName(this, tr("Import Settings
From File"), QDir::homePath(),
+ tr("Settings Files (*.xml)"));
+
+ if(filename.isEmpty())
+ return;
+
+ // create a temporary config manager and load
+ // it with data from the import file.
+ ConfigManager* tmpMgr = new ConfigManager();
+ if(tmpMgr == NULL)
+ return;
+ tmpMgr->importFromFile(filename, false);
+
+ // populate dialog box
+ QStringList bkgnds = tmpMgr->getAvailableProfiles();
+ dlg.addSubItems("Configuration Profiles", bkgnds, true);
+
+ QStringList palettes = tmpMgr->getPaletteNames();
+ dlg.addSubItems("Palettes", palettes, true);
+
+ // show dialog and get lists of checked items
+ if(dlg.exec() == QDialog::Rejected) {
+ delete tmpMgr;
+ tmpMgr = NULL;
+ return;
+ }
+ bkgnds = dlg.getSubItems("Configuration Profiles", true);
+ palettes = dlg.getSubItems("Palettes", true);
+
+ // first, add in the palettes, since they don't
+ // have any dependencies
+ for(int i = 0; i<palettes.size(); i++) {
+ IndexedPaletteProfile tmpPal = tmpMgr->getPaletteProfile(palettes.at(i));
+ _manager->addPalette(tmpPal);
+ }
+
+ // now go through the MasterProfiles, adding sub profiles
+ // it requires (including IndexedPaletteProfiles).
+ for(int i = 0; i<bkgnds.size(); i++) {
+ MasterProfile tmpMp = tmpMgr->getProfile(bkgnds.at(i));
+ // make sure the master profile doesn't exist, so that we don't
+ // unnecessarily the other things. No need to check everything else
+ // since the respective add routines will check before appending
+ // to the lists.
+ if(!_manager->doesProfileExist(tmpMp.getName())) {
+ LensProfile* tmpLens =
tmpMgr->getLensProfile(tmpMp.getLensProfileName());
+ _manager->addLensProfile(tmpLens);
+ //debug?
+ tmpLens = NULL;
+ //end debug
+ PlasmaFractalBackgroundProfile* tmpBkgnd =
(PlasmaFractalBackgroundProfile*)tmpMgr->getBackgroundProfile(tmpMp.getBackgroundProfileName());
+ IndexedPaletteProfile tmpPal =
tmpMgr->getPaletteProfile(tmpBkgnd->getPaletteName());
+ _manager->addPalette(tmpPal);
+ _manager->addBackgroundProfile(*tmpBkgnd);
+ _manager->addProfile(tmpMp);
+ _mpAvailList->addItem(tmpMp.getName());
+ }
+ }
+}
+
+void ConfigWidget::exportClicked(bool checked) {
+ ImportExportDialog dlg(false);
+
+ // populate dialog box
+ QStringList bkgnds = _manager->getAvailableProfiles();
+ dlg.addSubItems("Configuration Profiles", bkgnds, true);
+
+ QStringList palettes = _manager->getPaletteNames();
+ dlg.addSubItems("Palettes", palettes, true);
+
+ // show dialog and get lists of checked items
+ if(dlg.exec() == 0)
+ return;
+ bkgnds = dlg.getSubItems("Configuration Profiles", true);
+ palettes = dlg.getSubItems("Palettes", true);
+
+ // get file name to export to
+ QString filename = QFileDialog::getSaveFileName(this, tr("Export Settings
to File"), QDir::homePath(),
+ tr("Settings Files (*.xml)"));
+
+ if(filename.isEmpty())
+ return;
+
+ // now create a temporary config manager that
+ // contains only the profiles that we want. Be sure to grab
+ // all miscellaneous profiles that the MasterProfile
+ // (including the IndexedPaletteProfiles).
+ ConfigManager* tmpMgr = new ConfigManager();
+ if(tmpMgr == NULL)
+ return;
+
+ // first, add in the palettes, since they don't
+ // have any dependencies
+ for(int i = 0; i<palettes.size(); i++) {
+ IndexedPaletteProfile tmpPal =
_manager->getPaletteProfile(palettes.at(i));
+ tmpMgr->addPalette(tmpPal);
+ }
+
+ // now go through the MasterProfiles, adding sub profiles
+ // it requires (including IndexedPaletteProfiles).
+ for(int i = 0; i<bkgnds.size(); i++) {
+ MasterProfile tmpMp = _manager->getProfile(bkgnds.at(i));
+ LensProfile* tmpLens =
_manager->getLensProfile(tmpMp.getLensProfileName());
+ tmpMgr->addLensProfile(tmpLens);
+ //debug?
+ tmpLens = NULL;
+ //debug?
+ PlasmaFractalBackgroundProfile* tmpBkgnd =
(PlasmaFractalBackgroundProfile*)_manager->getBackgroundProfile(tmpMp.getBackgroundProfileName());
+ IndexedPaletteProfile tmpPal =
_manager->getPaletteProfile(tmpBkgnd->getPaletteName());
+ tmpMgr->addPalette(tmpPal);
+ tmpMgr->addBackgroundProfile(*tmpBkgnd);
+ tmpMgr->addProfile(tmpMp);
+ }
+
+ // save!
+ tmpMgr->exportToFile(filename, false);
+ delete tmpMgr;
+ tmpMgr = NULL;
+}
+
+void ConfigWidget::paletteEditorClicked(bool checked) {
+ PaletteEditor* dlg = new PaletteEditor(_manager, this);
+ dlg->exec();
+
+ //clean up
+ delete dlg;
+ dlg = NULL;
+}
+void ConfigWidget::helpClicked(bool checked) {
+ HelpDialog* dlg = new HelpDialog("qrc:/help/index.html");
+ if(dlg != NULL) {
+ dlg->exec();
+ delete dlg;
+ dlg = NULL;
+ }
+}
Added: branches/backus_dev/src/SpiralLenz/src/ProfileEditDialog.cpp
==============================================================================
--- (empty file)
+++ branches/backus_dev/src/SpiralLenz/src/ProfileEditDialog.cpp Mon Mar 16
14:29:13 2009
@@ -0,0 +1,823 @@
+/**
+ * Copyright (c) 2008 Jeff Backus.
+ *
+ * Licensed under the GNU General Public License, Version 2.0
(the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Additionally, this code makes heavy use of the Qt libraries from
+ * Trolltech. These libraries are released under the GNU
+ * General Public License, Version 2.0, as well. Please contact
+ * Trolltech for more information.
+ *
+ * http://trolltech.com/
+ *
+ */
+
+#include <QVBoxLayout>
+#include <QHBoxLayout>
+#include <QPushButton>
+#include <QGroupBox>
+#include <QLabel>
+
+#include <QMessageBox>
+
+#include "ProfileEditDialog.h"
+#include "2d_bgnd_w_lens/lens_engine/SphericalLensProfile.h"
+#include "utility/misc_funcs.h"
+#include "utility/HelpDialog.h"
+
+ProfileEditDialog::ProfileEditDialog(QString targetName, ConfigManager*
confMgr, QWidget* parent, Qt::WindowFlags f) {
+ QDialog(parent, f);
+
+ _coarsenessAdjust = 100.0;
+ _nameBox = NULL;
+ _timerBox = NULL;
+ _screenXBox = NULL;
+ _screenYBox = NULL;
+ _coarsenessBox = NULL;
+ _paletteBox = NULL;
+ _paletteXSpeedBox = NULL;
+ _paletteYSpeedBox = NULL;
+ _clampColorBox = NULL;
+ _palDlg = NULL;
+ _lensSizeSlider = NULL;
+ _lensVarSlider = NULL;
+ _numLenses = NULL;
+
+ _confMgr = confMgr;
+
+ if(confMgr == NULL)
+ return;
+
+ _windowTitle = tr("Profile Editor");
+
+ setWindowTitle(_windowTitle);
+ setWindowModality(Qt::WindowModal);
+ QIcon icon(":/app_icon.png");
+ setWindowIcon(icon);
+
+ _oldName = targetName;
+ if(targetName != "") {
+ _mp = _confMgr->getProfile(targetName);
+ }
+
+ //set up dialog box
+ QWidget* tempWidget = NULL;
+ QPushButton* tempButton = NULL;
+ QVBoxLayout* mainLayout = new QVBoxLayout();
+ QString tempToolTip;
+
+ // Begin MasterProfile related.
+ // Note: MasterProfiles & BackgroundProfiles are
+ // collectively called "Configuration Profiles"
+ // throughout the program (i.e. that's what the
+ // user sees.)
+
+ //name field
+ QHBoxLayout* nameLayout = new QHBoxLayout();
+
+ tempToolTip = tr("The name of this configuration profile.");
+
+ tempWidget = new QLabel(tr("Name:"));
+ tempWidget->setToolTip(tempToolTip);
+ nameLayout->addWidget(tempWidget);
+ tempWidget = NULL;
+
+ _nameBox = new QLineEdit(_mp.getName());
+ _nameBox->setToolTip(tempToolTip);
+ nameLayout->addWidget(_nameBox);
+
+ tempWidget = new QWidget();
+ tempWidget->setLayout(nameLayout);
+ mainLayout->addWidget(tempWidget);
+ tempWidget = NULL;
+
+ //timer and dimensions
+ QHBoxLayout* dimAndTimeLayout = new QHBoxLayout();
+
+ //dimensions group box
+ QGroupBox* dimBox = new QGroupBox(tr("Plasma Dimensions"));
+ QHBoxLayout* dimBoxLayout = new QHBoxLayout();
+
+ _screenXBox = new QComboBox();
+ _screenYBox = new QComboBox();
+
+ _screenXBox->setEditable(false);
+ _screenXBox->setEditable(false);
+
+ //populate the combo box with powers of 2
+ int val = 64; //2^6
+ int xCurVal = 0;
+ int yCurVal = 0;
+ for(int i=0;i<13-6;i++) {
+ _screenXBox->addItem(QString::number(val));
+ _screenYBox->addItem(QString::number(val));
+ if(val <= _mp.getScreenHeight()) {
+ yCurVal=i;
+ }
+ if(val <= _mp.getScreenWidth()) {
+ xCurVal=i;
+ }
+ val*=2;
+ }
+
+ _screenXBox->setCurrentIndex(xCurVal);
+ _screenYBox->setCurrentIndex(yCurVal);
+
+ tempToolTip = tr("The resolution width of the plasma in pixels. Does not
need to match actual")+"\n"
+ +tr("screen resolution.");
+ tempWidget = new QLabel(tr("Width:"));
+ tempWidget->setToolTip(tempToolTip);
+ dimBoxLayout->addWidget(tempWidget);
+ tempWidget = NULL;
+ _screenXBox->setToolTip(tempToolTip);
+ dimBoxLayout->addWidget(_screenXBox);
+
+ dimBoxLayout->addStretch(0);
+
+ tempToolTip = tr("The resolution height of the plasma in pixels. Does
not need to match actual")+"\n"
+ +tr("screen resolution.");
+ tempWidget = new QLabel(tr("Height:"));
+ tempWidget->setToolTip(tempToolTip);
+ dimBoxLayout->addWidget(tempWidget);
+ tempWidget = NULL;
+ _screenYBox->setToolTip(tempToolTip);
+ dimBoxLayout->addWidget(_screenYBox);
+
+ dimBox->setLayout(dimBoxLayout);
+ dimAndTimeLayout->addWidget(dimBox);
+ tempWidget = NULL;
+
+ dimAndTimeLayout->addStretch(0);
+
+ tempWidget = new QLabel(tr("Milliseconds Between Frames:"));
+ tempToolTip = tr("The number of milliseconds between frames. The higher
the number, the")+"\n"
+ +tr("slower the animation.");
+ tempWidget->setToolTip(tempToolTip);
+ dimAndTimeLayout->addWidget(tempWidget);
+ tempWidget = NULL;
+
+ _timerBox = new QSpinBox();
+
+ _timerBox = new QSpinBox();
+ _timerBox->setRange(10,1000);
+ _timerBox->setSingleStep(10);
+ _timerBox->setValue(_mp.getTimerMillis());
+ _timerBox->setToolTip(tempToolTip);
+ dimAndTimeLayout->addWidget(_timerBox);
+
+ tempWidget = new QWidget();
+ tempWidget->setLayout(dimAndTimeLayout);
+ mainLayout->addWidget(tempWidget);
+ tempWidget = NULL;
+
+ // Begin PlasmaFractalBackgroundProfile related
+
+ // get the backgroundprofile in order to populate the data fields.
+ PlasmaFractalBackgroundProfile* plasmaProfile = NULL;
+ QString bkgndProfileName = _mp.getBackgroundProfileName();
+ if(_confMgr->doesBackgroundProfileExist(bkgndProfileName)) {
+ plasmaProfile = new PlasmaFractalBackgroundProfile();
+ if(plasmaProfile != NULL) {
+ PlasmaFractalBackgroundProfile* tempProfile =
(PlasmaFractalBackgroundProfile*)
(_confMgr->getBackgroundProfile(bkgndProfileName));
+ *plasmaProfile = *tempProfile;
+ _bAnimatePalette = plasmaProfile->getAnimatePalette();
+ }
+ }
+
+ // palette name combo box + add & edit buttons
+ QGroupBox* palGroupBox = new QGroupBox(tr("Palette"));
+ if(palGroupBox == NULL)
+ return;
+ palGroupBox->setCheckable(false);
+ palGroupBox->setFlat(false);
+
+ QHBoxLayout* palBoxLayout = new QHBoxLayout();
+
+ _paletteBox = new QComboBox();
+ _paletteBox->setEditable(false);
+ if(plasmaProfile != NULL) {
+ populatePalList(plasmaProfile->getPaletteName());
+ } else {
+ populatePalList("");
+ }
+ tempToolTip = tr("The currently selected palette.");
+ _paletteBox->setToolTip(tempToolTip);
+ palBoxLayout->addWidget(_paletteBox);
+
+ palBoxLayout->addStretch(0);
+
+ tempButton = new QPushButton(tr("&Add"));
+ tempButton->setDefault(false);
+ tempButton->setAutoDefault(false);
+ tempToolTip = tr("Add a new palette.");
+ tempButton->setToolTip(tempToolTip);
+ QObject::connect(tempButton, SIGNAL(clicked(bool)), this,
SLOT(addPalClicked(bool)));
+ palBoxLayout->addWidget(tempButton);
+ tempButton = NULL;
+
+ tempButton = new QPushButton(tr("&Edit"));
+ tempButton->setDefault(false);
+ tempButton->setAutoDefault(false);
+ tempToolTip = tr("Edit the selected palette.");
+ tempButton->setToolTip(tempToolTip);
+ QObject::connect(tempButton, SIGNAL(clicked(bool)), this,
SLOT(editPalClicked(bool)));
+ palBoxLayout->addWidget(tempButton);
+ tempButton = NULL;
+
+ palGroupBox->setLayout(palBoxLayout);
+ mainLayout->addWidget(palGroupBox);
+ tempWidget = NULL;
+
+ // Palette Animation enable and speeds
+ QGroupBox* animPalBox = new QGroupBox(tr("Animate Palette"));
+ animPalBox->setCheckable(true);
+ animPalBox->setChecked(_bAnimatePalette);
+ animPalBox->setFlat(false);
+ animPalBox->setToolTip(tr("This will enable rotating the palette in both
the X and Y directions by the specified speed."));
+ QObject::connect(animPalBox, SIGNAL(clicked(bool)), this,
SLOT(animatePalClicked(bool)));
+
+ QHBoxLayout* animPalLayout = new QHBoxLayout();
+ tempWidget = new QLabel(tr("X Speed:"));
+ tempToolTip = tr("This is how fast the palette will change in the X
(primary) direction.");
+ tempWidget->setToolTip(tempToolTip);
+ animPalLayout->addWidget(tempWidget);
+
+ _paletteXSpeedBox = new QDoubleSpinBox();
+ _paletteXSpeedBox->setDecimals(1);
+ _paletteXSpeedBox->setMinimum(0.0);
+ _paletteXSpeedBox->setSingleStep(0.1);
+ if(plasmaProfile != NULL) {
+ _paletteXSpeedBox->setValue(plasmaProfile->getPaletteXSpeed());
+ } else {
+ _paletteXSpeedBox->setValue(1.0);
+ }
+ _paletteXSpeedBox->setToolTip(tempToolTip);
+ animPalLayout->addWidget(_paletteXSpeedBox);
+
+ animPalLayout->addStretch(0);
+
+ tempWidget = new QLabel(tr("Y Speed:"));
+ tempToolTip = tr("This is how fast the palette will change in the Y
(secondary) direction.");
+ tempWidget->setToolTip(tempToolTip);
+ animPalLayout->addWidget(tempWidget);
+
+ _paletteYSpeedBox = new QDoubleSpinBox();
+ _paletteYSpeedBox->setDecimals(1);
+ _paletteYSpeedBox->setMinimum(0.0);
+ _paletteYSpeedBox->setSingleStep(0.1);
+ if(plasmaProfile != NULL) {
+ _paletteYSpeedBox->setValue(plasmaProfile->getPaletteYSpeed());
+ } else {
+ _paletteYSpeedBox->setValue(1.0);
+ }
+ _paletteYSpeedBox->setToolTip(tempToolTip);
+ animPalLayout->addWidget(_paletteYSpeedBox);
+
+ animPalBox->setLayout(animPalLayout);
+ mainLayout->addWidget(animPalBox);
+
+ QGroupBox* fieldBox = new QGroupBox(tr("Field Generation"));
+ if(fieldBox == NULL)
+ return;
+ fieldBox->setCheckable(false);
+ fieldBox->setFlat(false);
+
+ QHBoxLayout* ccLayout = new QHBoxLayout();
+
+ tempWidget = new QLabel(tr("Less Volatile"));
+ tempToolTip = tr("This quantity determines how coarse or volatile the
fractal is. More volatile, the more variation.");
+ tempWidget->setToolTip(tempToolTip);
+ ccLayout->addWidget(tempWidget);
+
+ _coarsenessBox = new QSlider(Qt::Horizontal);
+ _coarsenessBox->setTickInterval(0.10*_coarsenessAdjust);
+ //_coarsenessBox->setTickPosition(QSlider::TicksBelow);
+ _coarsenessBox->setMinimum(0.01*_coarsenessAdjust);
+ _coarsenessBox->setMaximum(6.00*_coarsenessAdjust);
+ if(plasmaProfile != NULL) {
+
_coarsenessBox->setValue(plasmaProfile->getCoarseness()*_coarsenessAdjust);
+ } else {
+ _coarsenessBox->setValue(4.50*_coarsenessAdjust);
+ }
+ _coarsenessBox->setToolTip(tempToolTip);
+ ccLayout->addWidget(_coarsenessBox);
+
+ tempWidget = new QLabel(tr("More Volatile"));
+ tempWidget->setToolTip(tempToolTip);
+ ccLayout->addWidget(tempWidget);
+
+ ccLayout->addStretch(0);
+
+ _clampColorBox = new QCheckBox(tr("Clamp color on overflow"));
+ if(plasmaProfile != NULL) {
+ _clampColorBox->setChecked(plasmaProfile->getClampColorIndex());
+ } else {
+ _clampColorBox->setChecked(true);
+ }
+ _clampColorBox->setToolTip(tr("When the plasma algorithm generates an
invalid color index, it will clamp")+"\n"
+ +tr("to the nearest valid color if checked, or wrap around if
unchecked."));
+ ccLayout->addWidget(_clampColorBox);
+
+ fieldBox->setLayout(ccLayout);
+ mainLayout->addWidget(fieldBox);
+ tempWidget = NULL;
+
+ // Begin SphericalLensProfile related
+ _numLenses = new QSpinBox();
+ if(_numLenses == NULL)
+ return;
+ _numLenses->setMinimum(0);
+ _numLenses->setMaximum(100);
+ _lensSizeSlider = new QSlider(Qt::Horizontal);
+ if(_lensSizeSlider == NULL)
+ return;
+ _lensVarSlider = new QSlider(Qt::Horizontal);
+ if(_lensVarSlider == NULL)
+ return;
+ _lensSizeSlider->setMinimum(1);
+ _lensSizeSlider->setMaximum(50);
+ _lensVarSlider->setMinimum(0);
+ _lensVarSlider->setMaximum(100);
+ _lensSizeSlider->setTickInterval(1);
+ _lensVarSlider->setTickInterval(1);
+
+ QString lensProfileName = _mp.getLensProfileName();
+
+ if(!lensProfileName.isEmpty()) {
+ SphericalLensProfile* lp =
(SphericalLensProfile*)_confMgr->getLensProfile(lensProfileName);
+
+ _numLenses->setValue(lp->getMaxNumLenses());
+ float maxR = lp->getMaxRadius();
+ float avgR = (lp->getMinRadius()+maxR)/2.0;
+ _lensSizeSlider->setValue(avgR*100.0);
+ _lensVarSlider->setValue( (maxR-avgR)*100.0/avgR);
+ } else {
+ _numLenses->setValue(0);
+ _lensSizeSlider->setValue(1);
+ _lensVarSlider->setValue(0);
+ }
+
+ QHBoxLayout* tmpHBox = NULL;
+ QVBoxLayout* tmpVBox = NULL;
+ QGroupBox* lensBox = new QGroupBox(tr("Lenses"));
+ if(lensBox == NULL)
+ return;
+ lensBox->setFlat(false);
+ lensBox->setCheckable(false);
+ QHBoxLayout* lensLayout = new QHBoxLayout();
+ if(lensLayout == NULL)
+ return;
+
+ tempToolTip = tr("Determines the maximum number of lenses on screen at
one time.");
+ tempWidget = new QLabel(tr("Number:"));
+ tempWidget->setToolTip(tempToolTip);
+ lensLayout->addWidget(tempWidget);
+ tempWidget = NULL;
+ _numLenses->setToolTip(tempToolTip);
+ lensLayout->addWidget(_numLenses);
+
+ lensLayout->addStretch(0);
+
+ tmpVBox = new QVBoxLayout();
+ if(tmpVBox == NULL)
+ return;
+ tmpHBox = new QHBoxLayout();
+ if(tmpHBox == NULL)
+ return;
+
+ tempToolTip = tr("Determines the average size of the lenses.");
+ tempWidget = new QLabel(tr("Size"));
+ if(tempWidget == NULL)
+ return;
+ tempWidget->setToolTip(tempToolTip);
+ tmpHBox->addWidget(tempWidget);
+ tempWidget = NULL;
+
+ tmpHBox->addStretch(0);
+
+ tempWidget = new QLabel(tr("Min"));
+ if(tempWidget == NULL)
+ return;
+ tempWidget->setToolTip(tempToolTip);
+ tmpHBox->addWidget(tempWidget);
+ tempWidget = NULL;
+
+ _lensSizeSlider->setToolTip(tempToolTip);
+ tmpHBox->addWidget(_lensSizeSlider);
+
+ tempWidget = new QLabel(tr("Max"));
+ if(tempWidget == NULL)
+ return;
+ tempWidget->setToolTip(tempToolTip);
+ tmpHBox->addWidget(tempWidget);
+ tempWidget = NULL;
+
+ tempWidget = new QWidget();
+ tempWidget->setLayout(tmpHBox);
+ tmpVBox->addWidget(tempWidget);
+ tempWidget = NULL;
+ tmpHBox = NULL;
+
+ tmpHBox = new QHBoxLayout();
+ if(tmpHBox == NULL)
+ return;
+
+ tempToolTip = tr("Determines the amount of size variation.");
+ tempWidget = new QLabel(tr("Variation"));
+ if(tempWidget == NULL)
+ return;
+ tempWidget->setToolTip(tempToolTip);
+ tmpHBox->addWidget(tempWidget);
+ tempWidget = NULL;
+
+ tmpHBox->addStretch(0);
+
+ tempWidget = new QLabel(tr("Min"));
+ if(tempWidget == NULL)
+ return;
+ tempWidget->setToolTip(tempToolTip);
+ tmpHBox->addWidget(tempWidget);
+ tempWidget = NULL;
+
+ _lensVarSlider->setToolTip(tempToolTip);
+ tmpHBox->addWidget(_lensVarSlider);
+
+ tempWidget = new QLabel(tr("Max"));
+ if(tempWidget == NULL)
+ return;
+ tempWidget->setToolTip(tempToolTip);
+ tmpHBox->addWidget(tempWidget);
+ tempWidget = NULL;
+
+ tempWidget = new QWidget();
+ tempWidget->setLayout(tmpHBox);
+ tmpVBox->addWidget(tempWidget);
+ tempWidget = NULL;
+ tmpHBox = NULL;
+
+ tempWidget = new QWidget();
+ tempWidget->setLayout(tmpVBox);
+ lensLayout->addWidget(tempWidget);
+ tempWidget = NULL;
+
+ lensBox->setLayout(lensLayout);
+ mainLayout->addWidget(lensBox);
+
+ //Help, OK and Cancel buttons
+ QHBoxLayout* botButtonsLayout = new QHBoxLayout();
+
+ tempButton = new QPushButton(tr("&Help"));
+ tempButton->setDefault(false);
+ tempButton->setAutoDefault(false);
+ QObject::connect(tempButton, SIGNAL(clicked(bool)), this,
SLOT(helpClicked(bool)));
+ botButtonsLayout->addWidget(tempButton);
+ tempButton = NULL;
+
+ botButtonsLayout->addStretch(0);
+
+ tempButton = new QPushButton(tr("&OK"));
+ tempButton->setDefault(true);
+ tempButton->setAutoDefault(true);
+ QObject::connect(tempButton, SIGNAL(clicked(bool)), this,
SLOT(okClicked(bool)));
+ botButtonsLayout->addWidget(tempButton);
+ tempButton = NULL;
+
+ tempButton = new QPushButton(tr("&Cancel"));
+ QObject::connect(tempButton, SIGNAL(clicked(bool)), this,
SLOT(cancelClicked(bool)));
+ botButtonsLayout->addWidget(tempButton);
+ tempButton = NULL;
+
+ tempWidget = new QWidget();
+ tempWidget->setLayout(botButtonsLayout);
+ mainLayout->addWidget(tempWidget);
+ tempWidget = NULL;
+
+ setLayout(mainLayout);
+}
+
+ProfileEditDialog::~ProfileEditDialog() {
+ _confMgr = NULL;
+
+ if(_nameBox != NULL) {
+ delete _nameBox;
+ _nameBox = NULL;
+ }
+
+ if(_timerBox != NULL) {
+ delete _timerBox;
+ _timerBox = NULL;
+ }
+
+ if(_screenXBox != NULL) {
+ delete _screenXBox;
+ _screenXBox = NULL;
+ }
+
+ if(_screenYBox != NULL) {
+ delete _screenYBox;
+ _screenYBox = NULL;
+ }
+
+ if(_coarsenessBox != NULL) {
+ delete _coarsenessBox;
+ _coarsenessBox = NULL;
+ }
+
+ if(_paletteBox != NULL) {
+ delete _paletteBox;
+ _paletteBox = NULL;
+ }
+
+ if(_paletteXSpeedBox != NULL) {
+ delete _paletteXSpeedBox;
+ _paletteXSpeedBox = NULL;
+ }
+
+ if(_paletteYSpeedBox != NULL) {
+ delete _paletteYSpeedBox;
+ _paletteYSpeedBox = NULL;
+ }
+
+ if(_clampColorBox != NULL) {
+ delete _clampColorBox;
+ _clampColorBox = NULL;
+ }
+ if(_palDlg != NULL) {
+ delete _palDlg;
+ _palDlg = NULL;
+ }
+ if(_lensSizeSlider != NULL) {
+ delete _lensSizeSlider;
+ _lensSizeSlider = NULL;
+ }
+ if(_lensVarSlider != NULL) {
+ delete _lensVarSlider;
+ _lensVarSlider = NULL;
+ }
+ if(_numLenses != NULL) {
+ delete _numLenses;
+ _numLenses = NULL;
+ }
+}
+
+void ProfileEditDialog::okClicked(bool checked) {
+
+ /** !!!!!!!!!!!! NOTE !!!!!!!!!
+ * This code needs modified to handle the BackgroundProfile and
LensProfile
+ * modifications/additions.
+ */
+
+ if(_confMgr == NULL)
+ return;
+
+ //update data in local copy
+
+ // BackgroundProfile related
+ // populate data fields
+ if(_paletteBox->currentIndex() < 0) {
+ QMessageBox::warning(this, _windowTitle, "Please choose a palette from
the drop-down box.", QMessageBox::Ok);
+ return;
+ }
+
+ PlasmaFractalBackgroundProfile tmpProfile;
+ tmpProfile.setAnimatePalette(_bAnimatePalette);
+ tmpProfile.setClampColorIndex(_clampColorBox->isChecked());
+
tmpProfile.setCoarseness(((float)_coarsenessBox->value())/_coarsenessAdjust);
+ tmpProfile.setGenStepsPerTick(2048);
+ tmpProfile.setPaletteXSpeed(_paletteXSpeedBox->value());
+ tmpProfile.setPaletteYSpeed(_paletteYSpeedBox->value());
+ tmpProfile.setPaletteName(_paletteBox->currentText());
+
+ // check for an existing BackgroundProfile. If none
+ // create a new one, otherwise update the current one.
+ QString tempName = _mp.getBackgroundProfileName();
+ if(tempName == "" || !_confMgr->doesBackgroundProfileExist(tempName)) {
+ // generate a random BackgroundProfile name that doesn't exist.
+ while(tempName == "" || _confMgr->doesBackgroundProfileExist(tempName)) {
+ tempName = QString("BackgroundProfile_")+randStr(20);
+ }
+ tmpProfile.setName(tempName);
+ _confMgr->addBackgroundProfile(tmpProfile);
+ } else {
+ tmpProfile.setName(tempName);
+ _confMgr->replaceBackgroundProfile(tempName,tmpProfile);
+ }
+ _mp.setBackgroundProfileName(tempName);
+
+ // LensProfile related
+ SphericalLensProfile tmpSphere;
+ tmpSphere.setMaxNumLenses(_numLenses->value());
+ float avgR = _lensSizeSlider->value();
+ float rangeR = _lensVarSlider->value();
+ float minR = avgR * (1.00 - rangeR/100.0);
+ float maxR = avgR * (1.00 + rangeR/100.0);
+ tmpSphere.setRadius(minR/100.0, maxR/100.0, (rangeR > 0.00));
+ tempName = _mp.getLensProfileName();
+
+ //!!! NOTE: There is a bug that causes a core dump in this code!
+ if(tempName == "" || !_confMgr->doesLensProfileExist(tempName)) {
+ // generate a random LensProfile name that doesn't exist.
+ while(tempName == "" || _confMgr->doesLensProfileExist(tempName)) {
+ tempName = QString("LensProfile_")+randStr(20);
+ }
+ tmpSphere.setName(tempName);
+
+ LensProfile* tL = tmpSphere.clone();
+ _confMgr->addLensProfile(tL);
+ } else {
+ tmpSphere.setName(tempName);
+ LensProfile* tL = tmpSphere.clone();
+ _confMgr->replaceLensProfile(tempName,*tL);
+ }
+ _mp.setLensProfileName(tempName);
+ // !!! end note
+
+ // master profile related
+ _mp.setTimerMillis(_timerBox->value());
+ _mp.setScreenWidth(_screenXBox->currentText().toInt());
+ _mp.setScreenHeight(_screenYBox->currentText().toInt());
+
+ QString newName = _nameBox->text();
+ _mp.setName(newName);
+
+ //send local copy back to config manager.
+ //need to check to see if this was an addition,
+ //if the name has changed
+ //if the new name conflicts
+ //etc.
+ if(newName == "") {
+ QString message(tr("Please enter a valid name."));
+ QMessageBox::warning(this, _windowTitle, message, QMessageBox::Ok);
+ return;
+ }
+
+ //Check to see if the name is already in use.
+ if(_oldName != newName &&_confMgr->doesProfileExist(newName)) {
+ QString message(tr("A profile with name '"));
+ message += newName;
+ message += tr("' already exists. Please choose a new name.");
+ QMessageBox::warning(this, _windowTitle, message, QMessageBox::Ok);
+ return;
+ }
+
+ if(_oldName == "") {
+ //add it!
+ _confMgr->addProfile(_mp);
+ } else {
+ //we've editted a preexisting palette.
+ _confMgr->replaceProfile(_oldName, _mp);
+ }
+
+ if(_oldName != newName) {
+ emit profileNameChange(_oldName, newName);
+ }
+ emit accepted();
+ //emit finished(0);
+ close();
+}
+
+void ProfileEditDialog::cancelClicked(bool checked) {
+ //emit finished(1);
+ emit rejected();
+ close();
+}
+
+void ProfileEditDialog::addPalClicked(bool checked) {
+ if(_confMgr == NULL || _paletteBox == NULL)
+ return;
+
+ editPalette(QString(""), false);
+}
+
+void ProfileEditDialog::editPalClicked(bool checked) {
+ if(_confMgr == NULL || _paletteBox == NULL)
+ return;
+
+ if(_paletteBox->currentIndex() >= 0) {
+ QString selected = _paletteBox->currentText();
+
+ //check for existence and edit if so
+ if(_confMgr->doesPaletteExist(selected)) {
+ editPalette(selected, true);
+ }
+ }
+}
+
+//attempts to edit the specified palette.
+void ProfileEditDialog::editPalette(const QString& palName, bool bReplace)
{
+ if(_confMgr == NULL || _paletteBox == NULL)
+ return;
+
+ QString oldPalName = palName;
+
+ bool bDone = false;
+ bool bFirstPass = true;
+
+ IndexedPaletteDialog* palDlg = NULL;
+ IndexedPaletteProfile tmpProfile;
+ if(bReplace) {
+ tmpProfile = _confMgr->getPaletteProfile(palName);
+ }
+
+ while(!bDone) {
+ // display the palette editor dialog using either a new
+ // object or the one requested for edit.
+ if(bFirstPass && !bReplace) {
+ palDlg = new IndexedPaletteDialog(NULL,this);
+ } else {
+ palDlg = new IndexedPaletteDialog(&tmpProfile,this);
+ }
+ bFirstPass = false;
+ if(palDlg != NULL) {
+ // if the user clicked ok, then try to update the palette
+ if(palDlg->exec() == QDialog::Accepted) {
+ tmpProfile = palDlg->getPalette();
+
+ // check the name to make sure it is valid and not
+ // already in the list.
+ QString newName = tmpProfile.getName();
+ if(newName == "") {
+ //give the user a warning dialog box
+ QMessageBox::warning(this, 0, "Please enter a valid name.",
QMessageBox::Ok);
+ } else if(oldPalName != newName && _confMgr->doesPaletteExist(newName)) {
+ //give the user a warning dialog box
+ QString message(tr("A palette with name '"));
+ message += newName;
+ message += "' already exists. Please choose a new name.";
+ QMessageBox::warning(this, 0, message, QMessageBox::Ok);
+ } else {
+ // name is valid, so try to insert or replace based on bReplace
+ if(bReplace) {
+ _confMgr->replacePalette(oldPalName, tmpProfile);
+ } else {
+ _confMgr->addPalette(tmpProfile);
+ }
+
+ // if we are replacing, remove old name first, then
+ // insert the new name.
+ if(oldPalName != "" && oldPalName != newName) {
+ int i=0;
+ int count = _paletteBox->count();
+ QString tmpItem = _paletteBox->itemText(0);
+ while(tmpItem != oldPalName && i < count) {
+ i++;
+ tmpItem = _paletteBox->itemText(i);
+ }
+ if(tmpItem == oldPalName) {
+ _paletteBox->removeItem(i);
+ }
+ }
+ _paletteBox->addItem(newName);
+ _paletteBox->setCurrentIndex(_paletteBox->count()-1);
+ bDone = true;
+ }
+ } else {
+ bDone = true;
+ }
+ //clean up
+ delete _palDlg;
+ _palDlg = NULL;
+ } else {
+ bDone = true;
+ }
+ }
+}
+
+void ProfileEditDialog::animatePalClicked(bool checked) {
+ _bAnimatePalette = checked;
+}
+
+// populates the palette name selection combo box
+void ProfileEditDialog::populatePalList(QString selected) {
+ if(_paletteBox == NULL)
+ return;
+
+ // empty list and repopulate
+ _paletteBox->clear();
+ _paletteBox->addItems(_confMgr->getPaletteNames());
+
+ // select the currently selected.
+ int idx = _paletteBox->findText(selected);
+ _paletteBox->setCurrentIndex(idx);
+}
+
+void ProfileEditDialog::helpClicked(bool checked) {
+ //QMessageBox::information(this, _windowTitle, "Not implemented yet.",
QMessageBox::Ok);
+ HelpDialog* dlg = new HelpDialog("qrc:/help/ProfileEditDialog.html");
+ if(dlg != NULL) {
+ dlg->exec();
+ delete dlg;
+ dlg = NULL;
+ }
+}
+
Added: branches/backus_dev/src/SpiralLenz/src/ProfileEditDialog.h
==============================================================================
--- (empty file)
+++ branches/backus_dev/src/SpiralLenz/src/ProfileEditDialog.h Mon Mar 16
14:29:13 2009
@@ -0,0 +1,117 @@
+/**
+ * Copyright (c) 2008 Jeff Backus.
+ *
+ * Licensed under the GNU General Public License, Version 2.0
(the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Additionally, this code makes heavy use of the Qt libraries from
+ * Trolltech. These libraries are released under the GNU
+ * General Public License, Version 2.0, as well. Please contact
+ * Trolltech for more information.
+ *
+ * http://trolltech.com/
+ *
+ */
+
+/**
+ * This class represents the dialog box used to edit the screen saver
profiles.
+ * Manages both the MasterProfile and BackgroundProfile objects.
+ *
+ * Revision History:
+ * 080301 jsbackus Initial Revision.
+ */
+
+#ifndef __PROFILEEDITDIALOG_H__
+#define __PROFILEEDITDIALOG_H__
+
+#include <QDialog>
+#include <QListWidget>
+#include <QComboBox>
+#include <QCheckBox>
+#include <QLineEdit>
+#include <QSpinBox>
+#include <QDoubleSpinBox>
+#include <QSlider>
+
+//#include "../../common/2d_bgnd_w_lens/ConfigManager.h"
+//#include "../../common/2d_bgnd_w_lens/MasterProfile.h"
+//#include "../../common/2d_bgnd_w_lens/BackgroundProfile.h"
+//#include "PlasmaFractalBackgroundProfile.h"
+//#include "../../../common/IndexedPalette/IndexedPaletteDialog.h"
+
+#include "2d_bgnd_w_lens/ConfigManager.h"
+#include "2d_bgnd_w_lens/MasterProfile.h"
+#include "2d_bgnd_w_lens/BackgroundProfile.h"
+#include "PlasmaFractalBackgroundProfile.h"
+#include "IndexedPalette/IndexedPaletteDialog.h"
+
+class ProfileEditDialog : public QDialog {
+
+ Q_OBJECT
+
+public:
+ ProfileEditDialog(QString targetName = "", ConfigManager* confMgr = NULL,
QWidget* parent = 0, Qt::WindowFlags f = 0);
+ ~ProfileEditDialog();
+
+public slots:
+ //ok is responsible for updating the ConfigManager
+ void okClicked(bool checked = false);
+ void cancelClicked(bool checked = false);
+ void helpClicked(bool checked = false);
+
+ void addPalClicked(bool checked = false);
+ void editPalClicked(bool checked = false);
+ void animatePalClicked(bool checked = false);
+
+signals:
+ void profileNameChange(QString oldName, QString newName);
+
+private:
+ //attempts to edit the specified palette.
+ //void editPalette(IndexedPaletteProfile* pal, bool bWasAddRename =
false);
+ //attempts to edit the specified palette.
+ void editPalette(const QString& palName, bool bReplace = false);
+
+ // populates the palette name selection combo box
+ void populatePalList(QString selected);
+
+ //MasterProfile related
+ QLineEdit* _nameBox;
+ QSpinBox* _timerBox;
+ QComboBox* _screenXBox;
+ QComboBox* _screenYBox;
+
+ MasterProfile _mp;
+
+ //PlasmaFractalBackgroundProfile related
+ QSlider* _coarsenessBox;
+ float _coarsenessAdjust;
+ QComboBox* _paletteBox;
+ bool _bAnimatePalette;
+ QDoubleSpinBox* _paletteXSpeedBox;
+ QDoubleSpinBox* _paletteYSpeedBox;
+ QCheckBox* _clampColorBox;
+
+ IndexedPaletteDialog* _palDlg;
+ QString _palOldName;
+
+ // lens related
+ QSlider* _lensSizeSlider;
+ QSlider* _lensVarSlider;
+ QSpinBox* _numLenses;
+
+ ConfigManager* _confMgr;
+
+ QString _oldName;
+ QString _windowTitle;
+};
+#endif
Added: branches/backus_dev/src/SpiralLenz/src/SpiralBackground.cpp
==============================================================================
--- (empty file)
+++ branches/backus_dev/src/SpiralLenz/src/SpiralBackground.cpp Mon Mar 16
14:29:13 2009
@@ -0,0 +1,136 @@
+/**
+ * Copyright (c) 2009 Jeff Backus.
+ *
+ * Licensed under the GNU General Public License, Version 2.0
(the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Additionally, this code makes heavy use of the Qt libraries from
+ * Trolltech. These libraries are released under the GNU
+ * General Public License, Version 2.0, as well. Please contact
+ * Trolltech for more information.
+ *
+ * http://trolltech.com/
+ *
+ */
+
+
+#include "SpiralBackground.h"
+
+/**
+ * Constructor takes the dimensions, a pointer to the palette,
+ * whether to rotate the palette, and the palette color skip.
+ */
+SpiralBackground::SpiralBackground(int sizeX, int sizeY, IndexedPalette*
pal,
+ bool bAnimatePalette, float paletteXSpeed,
+ float paletteYSpeed) {
+
+ // base class specific
+ initIndexedPaletteBackground(sizeX,sizeY);
+ setPalette(pal);
+ _bEnableAnimation = bAnimatePalette;
+ _xSpeed = paletteXSpeed;
+ _ySpeed = paletteYSpeed;
+
+ _bSetupFinished = false;
+
+ // general defaults
+ _numGenStepsPerTick = 0;
+ _bRandomColor = false;
+ _algorithm = NULL;
+ _style = SINGLE;
+
+ // SINGLE style specific
+ _bLerpToDefault = false;
+ _singleWidth = 1;
+ // end SINGLE style
+
+
+ // initialize field to -1 (no color)
+ for(int i=0;i<_height*_width;i++)
+ {
+ _field[i] = -1;
+ }
+
+}
+
+SpiralBackground::~SpiralBackground() {
+ destroyIndexedPaletteBackground();
+}
+
+/**
+ * Initializes the generator algorithm to generate a single-color
+ * spiral of the specified width, rotating through the primary palette
+ * direction as it extends outward. If bLerpToDefaultColor is true,
+ * the palette color will be in the middle with, the default palette color
+ * on the borders. If bRandomColor is true, the first color index is
+ * randomly picked.
+ * If genStepsPerTick is 0, then it will all be done in one swoop.
+ */
+void SpiralBackground::genSingleColorSpiral(SpiralBackgroundShape shape,
+ int genStepsPerTick, int width,
+ bool bRandomColor,
+ bool bLerpToDefaultColor) {
+ _numGenStepsPerTick = genStepsPerTick;
+ _bRandomColor = bRandomColor;
+
+ _style = SINGLE;
+ _singleWidth = width;
+ _bLerpToDefaultColor = bLerpToDefaultColor;
+
+ //_algorithm =
+ //_shape = shape;
+}
+
+/**
+ * Initializes the generator algorithm to generate a multi-color spiral,
+ * that remains constant through the whole spiral. The width is the
+ * width (primary axis) of the palette. If bRandomColor is true,
+ * the initial index is randomly picked and the palette will be wrapped.
+ * If genStepsPerTick is 0, then it will all be done in one swoop.
+ */
+void SpiralBackground::genMultiColorSpiral(SpiralBackgroundShape shape,
+ int genStepsPerTick,
+ bool bRandomColor) {
+ _numGenStepsPerTick = genStepsPerTick;
+ _bRandomColor = bRandomColor;
+
+ _style = MULTIWIDTH;
+
+ //_shape = shape;
+ //_algorithm =
+}
+
+/**
+ * Finishes generating the spiral then rotates the palette when done.
+ */
+void SpiralBackground::clocktick() {
+ if(_paletteWidth > 0)
+ {
+ if(!_bSetupFinished)
+ {
+ spiralGenStep();
+ }
+ else
+ {
+ rotateColorIndex();
+ }
+ }
+}
+
+/**
+ * Performs one iteration of the fractal generation.
+ */
+void SpiralBackground::spiralGenStep() {
+ if(_algorithm.calc(_numGenStepsPerTick))
+ _bSetupFinished = true;
+}
+
Added: branches/backus_dev/src/SpiralLenz/src/SpiralBackground.h
==============================================================================
--- (empty file)
+++ branches/backus_dev/src/SpiralLenz/src/SpiralBackground.h Mon Mar 16
14:29:13 2009
@@ -0,0 +1,112 @@
+/**
+ * Copyright (c) 2009 Jeff Backus.
+ *
+ * Licensed under the GNU General Public License, Version 2.0
(the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Additionally, this code makes heavy use of the Qt libraries from
+ * Trolltech. These libraries are released under the GNU
+ * General Public License, Version 2.0, as well. Please contact
+ * Trolltech for more information.
+ *
+ * http://trolltech.com/
+ *
+ */
+
+/**
+ * This class generates a spiral background. After generation,
+ * it will rotate the palette with the specified primary and
+ * secondary speeds.
+ */
+
+//#include <stdlib.h>
+//#include <ctime>
+
+//using namespace std;
+
+#ifndef __SPIRALBACKGROUND_H__
+#define __SPIRALBACKGROUND_H__
+
+#include "2d_bgnd_w_lens/globaldefs.h"
+#include "2d_bgnd_w_lens/IndexedPaletteBackground.h"
+
+#include "SpiralBackgroundAlgorithm.h"
+#include "RectangularSpiral.h"
+
+enum SpiralBackgroundShape {
+ POLAR, RECTANGULAR, DIAMOND, TRIANGULAR
+};
+
+enum SpiralBackgroundSytle {
+ SINGLE, MULTIWIDTH
+};
+
+class SpiralBackground : public IndexedPaletteBackground {
+
+ public:
+ /**
+ * Constructor takes the dimensions, a pointer to the palette,
+ * whether to rotate the palette, and the palette color skip.
+ */
+ SpiralBackground(int sizeX, int sizeY, IndexedPalette* pal,
+ bool bAnimatePalette, float paletteXSpeed,
+ float paletteYSpeed);
+
+ ~SpiralBackground();
+
+ /**
+ * Initializes the generator algorithm to generate a single-color
+ * spiral of the specified width, rotating through the primary palette
+ * direction as it extends outward. If bLerpToDefaultColor is true,
+ * the palette color will be in the middle with, the default palette
color
+ * on the borders. If bRandomColor is true, the first color index is
+ * randomly picked.
+ * If genStepsPerTick is 0, then it will all be done in one swoop.
+ */
+ void genSingleColorSpiral(int genStepsPerTick, int width,
+ bool bRandomColor, bool bLerpToDefaultColor);
+
+ /**
+ * Initializes the generator algorithm to generate a multi-color spiral,
+ * that remains constant through the whole spiral. The width is the
+ * width (primary axis) of the palette. If bRandomColor is true,
+ * the initial index is randomly picked and the palette will be wrapped.
+ * If genStepsPerTick is 0, then it will all be done in one swoop.
+ */
+ void genMultiColorSpiral(int genStepsPerTick, bool bRandomColor);
+
+ // *** Begin Extended Methods ***
+ /**
+ * Finishes generating the spiral then rotates the palette when done.
+ */
+ virtual void clocktick();
+ // *** End Extended Methods ***
+
+ private:
+ /**
+ * Performs one iteration of the fractal generation.
+ */
+ void spiralGenStep();
+
+ int _numGenStepsPerTick;
+ bool _bRandomColor;
+
+ // specific to SINGLE style
+ bool _bLerpToDefaultColor;
+ int _singleWidth;
+ // end specific to SINGLE style
+
+ SpiralBackgroundShapeAlgorithm* _algorithm;
+ SpiralBackgroundStyle _style;
+};
+
+#endif
Added: branches/backus_dev/src/SpiralLenz/src/SpiralBackgroundProfile.cpp
==============================================================================
--- (empty file)
+++ branches/backus_dev/src/SpiralLenz/src/SpiralBackgroundProfile.cpp Mon
Mar 16 14:29:13 2009
@@ -0,0 +1,332 @@
+/**
+ * Copyright (c) 2008 Jeff Backus.
+ *
+ * Licensed under the GNU General Public License, Version 2.0
(the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Additionally, this code makes heavy use of the Qt libraries from
+ * Trolltech. These libraries are released under the GNU
+ * General Public License, Version 2.0, as well. Please contact
+ * Trolltech for more information.
+ *
+ * http://trolltech.com/
+ *
+ */
+
+#include <QtXml/QDomElement>
+#include <QtXml/QDomText>
+
+//#include "../../common/utility/misc_funcs.h"
+
+#include "utility/misc_funcs.h"
+#include "PlasmaFractalBackgroundProfile.h"
+#include "PlasmaFractal.h"
+
+PlasmaFractalBackgroundProfile::PlasmaFractalBackgroundProfile() {
+ _xmlTypeValue = "PlasmaFractalBackground";
+
+ //defaults
+ _name = "Empty";
+ _palName = "";
+ _coarseness = 1.0;
+ _genStepsPerTick = 2048;
+ _bAnimatePalette = true;
+ _paletteXSpeed = 1;
+ _paletteYSpeed = 1;
+ _bClampColorIndex = true;
+}
+
+PlasmaFractalBackgroundProfile::~PlasmaFractalBackgroundProfile() {
+}
+
+/* Attempts to load this background profile object from the
+ * specified QDomNode.
+ */
+BackgroundProfile* PlasmaFractalBackgroundProfile::load(QDomNode &node) {
+ float tmpF;
+ int tmpI;
+ QDomElement tempElem;
+
+ //sanity check on the input
+ if(node.nodeName() != getXMLTagName())
+ return NULL;
+
+ //make sure that the type value matches
+ tempElem = node.firstChildElement("type");
+ if(tempElem.isNull() || tempElem.text() != _xmlTypeValue)
+ return NULL;
+
+ PlasmaFractalBackgroundProfile* retVal = new
PlasmaFractalBackgroundProfile();
+
+ tempElem = node.firstChildElement("name");
+ if(!tempElem.isNull()) {
+ retVal->_name = tempElem.text();
+ }
+
+ tempElem = node.firstChildElement("coarseness");
+ if(!tempElem.isNull()) {
+ tmpF = tempElem.text().toFloat();
+ if(tmpF > 0.00 && tmpF < 10000.00) {
+ retVal->_coarseness = tmpF;
+ }
+ }
+
+ tempElem = node.firstChildElement("steps_per_tick");
+ if(!tempElem.isNull()) {
+ tmpI = tempElem.text().toInt();
+ if(tmpI > 0 && tmpI < 30000) {
+ retVal->_genStepsPerTick = tmpI;
+ }
+ }
+
+ tempElem = node.firstChildElement("anmiate_palette");
+ if(!tempElem.isNull()) {
+ QString param = tempElem.text();
+ retVal->_bAnimatePalette = stringToBool(param);
+ }
+
+ tempElem = node.firstChildElement("palette_x_speed");
+ if(!tempElem.isNull()) {
+ tmpI = tempElem.text().toInt();
+ if(tmpI >= 0 && tmpI < 30000) {
+ retVal->_paletteXSpeed = tmpI;
+ }
+ }
+
+ tempElem = node.firstChildElement("palette_y_speed");
+ if(!tempElem.isNull()) {
+ tmpI = tempElem.text().toInt();
+ if(tmpI >= 0 && tmpI < 30000) {
+ retVal->_paletteYSpeed = tmpI;
+ }
+ }
+
+ tempElem = node.firstChildElement("clamp_color");
+ if(!tempElem.isNull()) {
+ QString param = tempElem.text();
+ retVal->_bClampColorIndex = stringToBool(param);
+ }
+
+ tempElem = node.firstChildElement("palette");
+ if(!tempElem.isNull()) {
+ retVal->_palName = tempElem.text();
+ }
+
+ return retVal;
+}
+
+
+/*
+ * Returns a QDomNode object that represents this profile.
+ */
+QDomNode PlasmaFractalBackgroundProfile::save(QDomDocument* doc) {
+ QString tempStr;
+ QDomText tempNode;
+ QDomElement tempElem;
+ QDomElement retVal = doc->createElement(getXMLTagName());
+
+ //type
+ tempNode = doc->createTextNode(_xmlTypeValue);
+ tempElem = doc->createElement("type");
+ tempElem.appendChild(tempNode);
+ retVal.appendChild(tempElem);
+
+ //name
+ tempNode = doc->createTextNode(_name);
+ tempElem = doc->createElement("name");
+ tempElem.appendChild(tempNode);
+ retVal.appendChild(tempElem);
+
+ //coarseness
+ tempStr.setNum(_coarseness);
+ tempNode = doc->createTextNode(tempStr);
+ tempElem = doc->createElement("coarseness");
+ tempElem.appendChild(tempNode);
+ retVal.appendChild(tempElem);
+
+ //steps per tick
+ tempStr.setNum(_genStepsPerTick);
+ tempNode = doc->createTextNode(tempStr);
+ tempElem = doc->createElement("steps_per_tick");
+ tempElem.appendChild(tempNode);
+ retVal.appendChild(tempElem);
+
+ //animate palette?
+ tempNode = doc->createTextNode(boolToString(_bAnimatePalette));
+ tempElem = doc->createElement("anmiate_palette");
+ tempElem.appendChild(tempNode);
+ retVal.appendChild(tempElem);
+
+ //palette X speed
+ tempStr.setNum(_paletteXSpeed);
+ tempNode = doc->createTextNode(tempStr);
+ tempElem = doc->createElement("palette_x_speed");
+ tempElem.appendChild(tempNode);
+ retVal.appendChild(tempElem);
+
+ //palette Y speed
+ tempStr.setNum(_paletteYSpeed);
+ tempNode = doc->createTextNode(tempStr);
+ tempElem = doc->createElement("palette_y_speed");
+ tempElem.appendChild(tempNode);
+ retVal.appendChild(tempElem);
+
+ //clamp color index?
+ tempNode = doc->createTextNode(boolToString(_bClampColorIndex));
+ tempElem = doc->createElement("clamp_color");
+ tempElem.appendChild(tempNode);
+ retVal.appendChild(tempElem);
+
+ //palette name
+ tempNode = doc->createTextNode(_palName);
+ tempElem = doc->createElement("palette");
+ tempElem.appendChild(tempNode);
+ retVal.appendChild(tempElem);
+
+ return retVal;
+}
+
+/*
+ * Creates and returns a new background object.
+ */
+Background* PlasmaFractalBackgroundProfile::getNewBackgroundObj(int
height, int width, QHash<QString, IndexedPaletteProfile*>* palHash) {
+ return new PlasmaFractal(width, height,
+ palHash->value(_palName)->createPalette(), _coarseness,
_genStepsPerTick,
+ _bAnimatePalette, _paletteXSpeed, _paletteYSpeed, _bClampColorIndex);
+}
+
+/*
+ * get/set palette name.
+ */
+QString PlasmaFractalBackgroundProfile::getPaletteName() {
+ return _palName;
+}
+
+void PlasmaFractalBackgroundProfile::setPaletteName(QString paletteName) {
+ _palName = paletteName;
+}
+
+/*
+ * get/set coarseness.
+ */
+float PlasmaFractalBackgroundProfile::getCoarseness() {
+ return _coarseness;
+}
+
+void PlasmaFractalBackgroundProfile::setCoarseness(float coarseness) {
+ _coarseness = coarseness;
+}
+
+/*
+ * get/set steps per tick
+ */
+int PlasmaFractalBackgroundProfile::getGenStepsPerTick() {
+ return _genStepsPerTick;
+}
+
+void PlasmaFractalBackgroundProfile::setGenStepsPerTick(int
genStepsPerTick) {
+ _genStepsPerTick = genStepsPerTick;
+}
+
+/*
+ * Get/set animate palette.
+ */
+bool PlasmaFractalBackgroundProfile::getAnimatePalette() {
+ return _bAnimatePalette;
+}
+
+void PlasmaFractalBackgroundProfile::setAnimatePalette(bool
bAnimatePalette) {
+ _bAnimatePalette = bAnimatePalette;
+}
+
+/*
+ * get/set palette x speed.
+ */
+float PlasmaFractalBackgroundProfile::getPaletteXSpeed() {
+ return _paletteXSpeed;
+}
+
+void PlasmaFractalBackgroundProfile::setPaletteXSpeed(float speed) {
+ _paletteXSpeed = speed;
+}
+
+/*
+ * get/set palette y speed.
+ */
+float PlasmaFractalBackgroundProfile::getPaletteYSpeed() {
+ return _paletteYSpeed;
+}
+
+void PlasmaFractalBackgroundProfile::setPaletteYSpeed(float speed) {
+ _paletteYSpeed = speed;
+}
+
+/*
+ * Get/set clamp color index.
+ */
+bool PlasmaFractalBackgroundProfile::getClampColorIndex() {
+ return _bClampColorIndex;
+}
+
+void PlasmaFractalBackgroundProfile::setClampColorIndex(bool
bClampColorIndex) {
+ _bClampColorIndex = bClampColorIndex;
+}
+
+/*
+ * Overloaded assignment operator
+ */
+PlasmaFractalBackgroundProfile&
PlasmaFractalBackgroundProfile::operator=(PlasmaFractalBackgroundProfile&
other) {
+ _name = other._name;
+ _palName = other._palName;
+ _coarseness = other._coarseness;
+ _genStepsPerTick = other._genStepsPerTick;
+ _bAnimatePalette = other._bAnimatePalette;
+ _paletteXSpeed = other._paletteXSpeed;
+ _paletteYSpeed = other._paletteYSpeed;
+ _bClampColorIndex = other._bClampColorIndex;
+
+ return *this;
+}
+
+/*
+ * Creates a new object with this object's settings.
+ */
+BackgroundProfile* PlasmaFractalBackgroundProfile::clone() {
+ PlasmaFractalBackgroundProfile* retVal = new
PlasmaFractalBackgroundProfile();
+
+ *retVal = *this;
+
+ return (BackgroundProfile*)retVal;
+}
+
+/**
+ * Called whenever palette names change
+ */
+void PlasmaFractalBackgroundProfile::paletteNameChanged(QString oldName,
+ QString newName) {
+ // if the palette name matches the old name, change the name.
+ if(_palName == oldName) {
+ _palName = newName;
+ }
+}
+
+/**
+ * Called whenever a palette is removed.
+ */
+void PlasmaFractalBackgroundProfile::paletteRemoved(QString palName) {
+ // if this palette has been removed, set current palette name to ""
+ if(_palName == palName) {
+ _palName = QString("");
+ }
+}
+
+
Added: branches/backus_dev/src/SpiralLenz/src/SpiralBackgroundProfile.h
==============================================================================
--- (empty file)
+++ branches/backus_dev/src/SpiralLenz/src/SpiralBackgroundProfile.h Mon
Mar 16 14:29:13 2009
@@ -0,0 +1,134 @@
+/**
+ * Copyright (c) 2008 Jeff Backus.
+ *
+ * Licensed under the GNU General Public License, Version 2.0
(the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Additionally, this code makes heavy use of the Qt libraries from
+ * Trolltech. These libraries are released under the GNU
+ * General Public License, Version 2.0, as well. Please contact
+ * Trolltech for more information.
+ *
+ * http://trolltech.com/
+ *
+ */
+
+/**
+ * This background profile is responsible for setting up and returning a
new
+ * PlasmaFractal background object.
+ *
+ * @author jeff backus
+ * @date 09/01/2007
+ */
+
+#ifndef __PLASMAFRACTALBACKGROUNDPROFILE_H__
+#define __PLASMAFRACTALBACKGROUNDPROFILE_H__
+
+#include <QString>
+#include <QtXml/QDomNode>
+#include <QtXml/QDomDocument>
+
+#include "../../common/2d_bgnd_w_lens/BackgroundProfile.h"
+
+class PlasmaFractalBackgroundProfile : public BackgroundProfile {
+
+public:
+ PlasmaFractalBackgroundProfile();
+ ~PlasmaFractalBackgroundProfile();
+
+ /* Attempts to load this background profile object from the
+ * specified QDomNode.
+ */
+ BackgroundProfile* load(QDomNode &node);
+
+ /*
+ * Returns a QDomNode object that represents this profile.
+ */
+ QDomNode save(QDomDocument* doc);
+
+ /*
+ * Creates and returns a new background object.
+ */
+ Background* getNewBackgroundObj(int height, int width, QHash<QString,
IndexedPaletteProfile*>* palHash);
+
+ /*
+ * get/set palette name.
+ */
+ QString getPaletteName();
+ void setPaletteName(QString paletteName);
+
+ /*
+ * get/set coarseness.
+ */
+ float getCoarseness();
+ void setCoarseness(float coarseness);
+
+ /*
+ * get/set steps per tick
+ */
+ int getGenStepsPerTick();
+ void setGenStepsPerTick(int genStepsPerTick);
+
+ /*
+ * Get/set animate palette.
+ */
+ bool getAnimatePalette();
+ void setAnimatePalette(bool bAnimatePalette);
+
+ /*
+ * get/set palette x speed.
+ */
+ float getPaletteXSpeed();
+ void setPaletteXSpeed(float speed);
+
+ /*
+ * get/set palette y speed.
+ */
+ float getPaletteYSpeed();
+ void setPaletteYSpeed(float speed);
+
+ /*
+ * Get/set clamp color index.
+ */
+ bool getClampColorIndex();
+ void setClampColorIndex(bool bClampColorIndex);
+
+ /*
+ * Overloaded assignment operator.
+ */
+ PlasmaFractalBackgroundProfile& operator=(PlasmaFractalBackgroundProfile&
other);
+
+ /*
+ * Creates a new object with this object's settings.
+ */
+ BackgroundProfile* clone();
+
+ /**
+ * Called whenever palette names change
+ */
+ virtual void paletteNameChanged(QString oldName, QString newName);
+
+ /**
+ * Called whenever a palette is removed.
+ */
+ virtual void paletteRemoved(QString palName);
+
+private:
+ QString _palName;
+ float _coarseness;
+ int _genStepsPerTick;
+ bool _bAnimatePalette;
+ float _paletteXSpeed;
+ float _paletteYSpeed;
+ bool _bClampColorIndex;
+};
+#endif
Added: branches/backus_dev/src/SpiralLenz/src/project_specific_externs.cpp
==============================================================================
--- (empty file)
+++ branches/backus_dev/src/SpiralLenz/src/project_specific_externs.cpp Mon
Mar 16 14:29:13 2009
@@ -0,0 +1,114 @@
+/**
+ * Copyright (c) 2008 Jeff Backus.
+ *
+ * Licensed under the GNU General Public License, Version 2.0
(the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Additionally, this code makes heavy use of the Qt libraries from
+ * Trolltech. These libraries are released under the GNU
+ * General Public License, Version 2.0, as well. Please contact
+ * Trolltech for more information.
+ *
+ * http://trolltech.com/
+ *
+ */
+
+/**
+ * This file contains project specific definitions, including version
number.
+ */
+
+#include <QString>
+
+#include "../../common/2d_bgnd_w_lens/BackgroundProfile.h"
+#include "../../common/2d_bgnd_w_lens/lens_engine/LensProfile.h"
+#include "../../common/2d_bgnd_w_lens/lens_engine/SphericalLensProfile.h"
+#include "SpiralBackgroundProfile.h"
+
+/**
+ * This function will create an array that contains the profiles
+ * for allowable backgrounds and sets numProfiles to indicate
+ * the number of profiles in the array. If there is a problem,
+ * numProfiles will be set to 0 and NULL will be returned.
+ */
+BackgroundProfile** getBackgroundTypes(int* numProfiles) {
+ BackgroundProfile** retVal = NULL;
+
+ *numProfiles = 1;
+ retVal = new BackgroundProfile*[*numProfiles];
+
+ if(retVal == NULL) {
+ *numProfiles = 0;
+ return NULL;
+ }
+
+ retVal[0] = (BackgroundProfile*) (new SpiralBackgroundProfile());
+
+ if(retVal[0] == NULL) {
+ *numProfiles = 0;
+ return NULL;
+ }
+
+ return retVal;
+}
+
+/**
+ * This function will create an array that contains the profiles
+ * for allowable lenses and sets numProfiles to indicate
+ * the number of profiles in the array. If there is a problem,
+ * numProfiles will be set to 0 and NULL will be returned.
+ */
+LensProfile** getLensTypes(int* numProfiles) {
+ LensProfile** retVal = NULL;
+
+ *numProfiles = 1;
+ retVal = new LensProfile*[*numProfiles];
+
+ if(retVal == NULL) {
+ *numProfiles = 0;
+ return NULL;
+ }
+
+ retVal[0] = (LensProfile*) (new SphericalLensProfile());
+
+ if(retVal[0] == NULL) {
+ *numProfiles = 0;
+ return NULL;
+ }
+
+ return retVal;
+}
+
+/**
+ * This function returns the string used to create the path for
+ * the settings file. It is also used to define the XML
+ * document root.
+ */
+QString getAppConfigName(){
+ return QString("SpiralLenz");
+}
+
+/**
+ * Returns the full name of the screen saver to be used in
+ * places such as title bars of dialog boxes and the About
+ * dialog box.
+ */
+QString getAppFullName() {
+ return QString("SpiralLenz");
+}
+
+/**
+ * Returns the version string for the screen saver.
+ */
+QString getAppVersion() {
+ return QString("0.1");
+}
+
Added: branches/backus_dev/src/SpiralLenz/src/redirector_main.cpp
==============================================================================
--- (empty file)
+++ branches/backus_dev/src/SpiralLenz/src/redirector_main.cpp Mon Mar 16
14:29:13 2009
@@ -0,0 +1,40 @@
+/**
+ * Copyright (c) 2008 Jeff Backus.
+ *
+ * Licensed under the GNU General Public License, Version 2.0
(the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * This is the main entry point for the redirector exec. The majority
+ * of the code is in redirector.cpp, located in the common/utility.
+ *
+ * Revision history:
+ * 090314 jsbackus Initial version.
+ */
+#include <windows.h>
+
+#include "../resource_files/resource.h"
+
+#include "../../common/utility/redirector.h"
+
+const char KEY_NAME[] = "SpiralLenz";
+
+/**
+ * Main entry point.
+ */
+//int winmain(int argc, char** argv) {
+int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
int nCmdShow) {
+
+ return redirector(lpCmdLine, &KEY_NAME[0]);
+}
Added: branches/backus_dev/src/common/spirals/RectangularSpiralAlgorithm.cpp
==============================================================================
--- (empty file)
+++ branches/backus_dev/src/common/spirals/RectangularSpiralAlgorithm.cpp
Mon Mar 16 14:29:13 2009
@@ -0,0 +1,290 @@
+#include "RectangularSpiralAlgorithm.h"
+
+/**
+ * Constructor.
+ */
+RectangularSpiralAlgorithm::RectangularSpiralAlgorithm() {
+ _cornerSeg = NULL;
+ _straightSeg = NULL;
+}
+
+RectangularSpiralAlgorithm::~RectangularSpiralAlgorithm() {
+ if(_cornerSeg != NULL) {
+ delete [] _cornerSeg;
+ _cornerSeg = NULL;
+ }
+ if(_straightSeg != NULL) {
+ delete [] _straightSeg;
+ _straightSeg = NULL;
+ }
+}
+
+/**
+ * Initializes the algorithm. Doesn't perform any actual generation.
+ * @param field The array of integers in which to generate the spiral
field.
+ * @param screenWidth the width of the screen in pixels.
+ * @param screenHeight the height of the screen in pixels.
+ * @param numColors the number of colors in the palette primary direction.
+ * @param colorWidth the width of the strip of color.
+ * @param emptyWidth the width of the default color region.
+ * @param bConstantColor whether or not to hold the color index constant.
+ * @param bRandomColor whether or not the initial color is randomly
selected.
+ * @see calc()
+ */
+void RectangularSpiralAlgorithm::initialize(int* field, int screenWidth,
+ int screenHeight, int numColors,
+ int colorWidth, int emptyWidth,
+ bool bConstantColor,
+ bool bRandomColor) {
+ initializeBase(field, screenWidth, screenHeight, numColors, colorWidth,
+ colorHeight, bConstantColor);
+
+ if(_height <= 0)
+ return;
+ if(_width <= 0)
+ return;
+ if(_numColors <= 0)
+ return;
+
+ calcSegs();
+
+ // set initial starting position
+ _currX = screenWidth / 2;
+ _currY = screenHeight / 2;
+
+ // pick initial color
+ if(bRandomColor) {
+ _nextIdx = jrand() % numColors;
+ } else {
+ _nextIdx = 0;
+ }
+
+ // pick direction
+ _dir = jrand() % 4;
+ _bClockwise = (jrand() % 2 == 0);
+
+ // set initial distances
+ switch(_dir) {
+ case UP:
+ _bXPositive = _bClockwise;
+ _xSegs = 2;
+
+ _bYPositive = true;
+ _ySegs = 1;
+ _remainingSegs = 1;
+ break;
+ case DOWN:
+ _bXPositive = !_bClockwise;
+ _xSegs = 2;
+
+ _bYPositive = false;
+ _ySegs = 1;
+ _remainingSegs = 1;
+ break;
+ case LEFT:
+ _bXPositive = false;
+ _xSegs = 1;
+ _remainingSegs = 1;
+
+ _bYPositive = _bClockwise;
+ _ySegs = 2;
+ break;
+ case RIGHT:
+ default:
+ _bXPositive = true;
+ _xSegs = 1;
+ _remainingSegs = 1;
+
+ _bYPositive = !_bClockwise;
+ _ySegs = 2;
+ }
+
+}
+
+/**
+ * Completes one iteration of the algorithm. Returns true if the algorithm
+ * is completed.
+ */
+bool RectangularSpiralAlgorithm::calc() {
+ if(_field == NULL)
+ return;
+ if(_cornerSeg == NULL)
+ return;
+ if(_straightSeg == NULL)
+ return;
+
+ int i;
+
+ /**
+ * To Do:
+ * - Process a segment
+ * - Update _currX and/or _currY
+ * - Update color index, if necessary
+ * - Decrement _remainingSegs
+ * - if _remainingSegs == 0:
+ * - change _dir
+ * - update polarities, current/next segs, and _remainingSegs.
+ */
+
+ // update color index
+ if(!_bConstantColor) {
+ _nextIdx = (_nextIdx+_segmentSize)%_numColors;
+ }
+
+ // update the number of remaining segments. If we hit 0,
+ // time to change direction!
+ _remainingSegs--;
+ if(_remainingSegs <= 0) {
+ // establish new direction
+ switch(_dir) {
+ case UP:
+ _dir = _bClockwise ? RIGHT : LEFT;
+ break;
+ case DOWN:
+ _dir = _bClockwise ? LEFT : RIGHT;
+ break;
+ case LEFT:
+ _dir = _bClockwise ? UP : DOWN;
+ break;
+ case RIGHT:
+ default:
+ _dir = _bClockwise ? DOWN : UP;
+ }
+ }
+
+ /*
+ // old
+ // Check the remaining distance. If it is 0, then we are turning.
+ if(_remainingSegs == 0) {
+ int bevDim = _colorWidth+2*_emptyWidth;
+
+ // move through the turn
+ switch(_dir) {
+ case UP:
+ // up to right or up to left is a counter-clockwise rotation
+ _currY++;
+ int tmpX = _currX;
+ int tmpY = _currY*_width;
+
+ if(_currY >= 0 && _currY < _height) {
+ for(i=0; i<bevDim;i++) {
+ if(tmpX >= 0 && _tmpX < _width) {
+ int bevX = bevDim - _remainingTurn;
+ int bevY = (bevDim - i - 1)*bevDim;
+ if(_bevel[bevX + bevY] >= 0) {
+ _field[tmpY+(tmpX++)] = _nextIdx + _bevel[bevX + bevY];
+ } else {
+ _field[tmpY+(tmpX++)] = -1;
+ }
+ }
+ }
+ }
+ break;
+ case DOWN:
+ // down to right or down to left is a clockwise rotation
+ _currY--;
+ int tmpX = _currX;
+ int tmpY = _currY*_width;
+
+ if(_currY >= 0 && _currY < _height) {
+ for(i=0; i<bevDim;i++) {
+ if(tmpX >= 0 && _tmpX < _width) {
+ int bevX = _remainingTurn;
+ int bevY = (i)*bevDim;
+ if(_bevel[bevX + bevY] >= 0) {
+ _field[tmpY+(tmpX++)] = _nextIdx + _bevel[bevX + bevY];
+ } else {
+ _field[tmpY+(tmpX++)] = -1;
+ }
+ }
+ }
+ }
+ break;
+ case LEFT:
+ break;
+ case RIGHT:
+ default:
+ }
+*/
+}
+
+/**
+ * Calculates both the corner and "straight away" segments.
+ * These segments are _segmentSize x _segmentSize in size.
+ * They are also oriented such that (0,0) is the bottom left corner.
+ * _straightSeg is such that it flows from left to right, and
+ * _cornerSeg is such that it flows from right to up if _bClockwise
+ * is false, or right to down if _bClockwise is true. Note that in
+ * either case, the color index offset has not been properly modulo'd
+ * and should be done so after being added to the current color index,
+ * if _bConstantColor is false. In the case where _bConstantColor is
+ * true, the index offset will always be 0.
+ */
+void RectangularSpiralAlgorithm::calcSegments() {
+ if(_colorWidth <= 0)
+ return;
+ if(_emptyWidth < 0)
+ _emptyWidth = 0;
+
+ // set the segment dimension
+ _segmentSize = _colorWidth + 2*_emptyWidth;
+
+ // create space for the two segments
+ _straightSeg = new int[_segmentSize * _segmentSize];
+ if(_straightSeg == NULL)
+ return;
+ _cornerSeg = new int[_segmentSize * _segmentSize];
+ if(_cornerSeg == NULL)
+ return;
+
+ // build the straight segment. See comment in header file for more
+ // information.
+ int x, y, yCalc, yInvCalc;
+ for(y=0;y<_segmentSize; y++) {
+ yCalc = y * _segmentSize;
+ for(x=0;x<_segmentSize;x++) {
+ if(y<_emptyWidth || y >= _colorWidth + _emptyWidth) {
+ // we're in empty space, so use default color.
+ _straightSeg[yCalc+x] = -1;
+ } else {
+ // we're in the color space. If _bConstantColor, set
+ // to 0, otherwise use x.
+ if(_bConstantColor) {
+ _straightSeg[yCalc+x] = 0;
+ } else {
+ _straightSeg[yCalc+x] = x;
+ }
+ }
+ }
+ }
+
+ // now, we build the corner segment. If _bClockwise is true,
+ // then copy the top left corner as is, and rotate the bottom right
+ // corner about x=y. If _bClockwise is false, copy the bottom left
+ // corner as is, and rotate the top right about x=_segmentSize-y.
+ if(_bClockwise) {
+ for(y = 0; y<_segmentSize; y++) {
+ yCalc = y*_segmentSize;
+ yInvCalc = (_segmentSize - y)*_segmentSize;
+ for(x = 0; x<_segmentSize; x++) {
+ if(x < y) {
+ _cornerSeg[yCalc+x] = _straightSeg[yCalc+x];
+ } else {
+ _cornerSeg[yCalc+x] = _straightSeg[yInvCalc+(_segmentSize-x)];
+ }
+ }
+ }
+ } else {
+ for(y = 0; y<_segmentSize; y++) {
+ yCalc = y*_segmentSize;
+ yInvCalc = (_segmentSize - y)*_segmentSize;
+ for(x = 0; x<_segmentSize; x++) {
+ if(x < (_segmentSize-y)) {
+ _cornerSeg[yCalc+x] = _straightSeg[yCalc+x];
+ } else {
+ _cornerSeg[yCalc+x] = _straightSeg[yInvCalc+(_segmentSize-x)];
+ }
+ }
+ }
+ }
+}
Added: branches/backus_dev/src/common/spirals/RectangularSpiralAlgorithm.h
==============================================================================
--- (empty file)
+++ branches/backus_dev/src/common/spirals/RectangularSpiralAlgorithm.h Mon
Mar 16 14:29:13 2009
@@ -0,0 +1,102 @@
+/**
+ * Copyright (c) 2009 Jeff Backus.
+ *
+ * Licensed under the GNU General Public License, Version 2.0
(the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Additionally, this code makes heavy use of the Qt libraries from
+ * Trolltech. These libraries are released under the GNU
+ * General Public License, Version 2.0, as well. Please contact
+ * Trolltech for more information.
+ *
+ * http://trolltech.com/
+ *
+ */
+
+/**
+ * This algorithm will generate a rectangular spiral.
+ */
+
+#include "utility/misc_funcs.h"
+
+#ifndef __RECTANGULARSPIRALALGORITHM_H__
+#define __RECTANGULARSPIRALALGORITHM_H__
+
+enum RectangularSpiralAlgorithmDir { UP=0, DOWN=1, LEFT=2, RIGHT=3 };
+
+class RectangularSpiralAlgorithm : public SpiralAlgorithm {
+
+ public:
+
+ /**
+ * Constructor.
+ */
+ RectangularSpiralAlgorithm();
+
+ ~RectangularSpiralAlgorithm();
+
+ /**
+ * Initializes the algorithm. Doesn't perform any actual generation.
+ * @param field The array of integers in which to generate the spiral
field.
+ * @param screenWidth the width of the screen in pixels.
+ * @param screenHeight the height of the screen in pixels.
+ * @param numColors the number of colors in the palette primary
direction.
+ * @param colorWidth the width of the strip of color.
+ * @param emptyWidth the width of the default color region.
+ * @param bConstantColor whether or not to hold the color index constant.
+ * @param bRandomColor whether or not the initial color is randomly
selected.
+ * @see calc()
+ */
+ void initialize(int* field, int screenWidth, int screenHeight,
+ int numColors, int colorWidth, int emptyWidth,
+ bool bConstantColor, bool bRandomColor);
+
+ /**
+ * Completes one iteration of the algorithm. Returns true if the
algorithm
+ * is completed.
+ */
+ bool calc();
+
+ private:
+ /**
+ * Calculates both the corner and "straight away" segments.
+ * These segments are _segmentSize x _segmentSize in size.
+ * They are also oriented such that (0,0) is the bottom left corner.
+ * _straightSeg is such that it flows from left to right, and
+ * _cornerSeg is such that it flows from right to up if _bClockwise
+ * is false, or right to down if _bClockwise is true. Note that in
+ * either case, the color index offset has not been properly modulo'd
+ * and should be done so after being added to the current color index,
+ * if _bConstantColor is false. In the case where _bConstantColor is
+ * true, the index offset will always be 0.
+ */
+ void calcSegments();
+
+ int _segmentSize;
+ int* _cornerSeg;
+ int* _straightSeg;
+
+ RectangularSpiralAlgorithmDir _dir;
+ bool _bClockwise;
+ int _currX;
+ int _currY;
+ int _nextIdx;
+
+ bool _bXPositive; //> either current or next polarity
+ bool _bYPositive; //> either current or next polarity
+ int _xSegs; //> either current or next number of segments
+ int _ySegs; //> either current or next number of segments
+ int _remainingSegs;
+
+};
+
+#endif
Added: branches/backus_dev/src/common/spirals/SpiralAlgorithm.cpp
==============================================================================
--- (empty file)
+++ branches/backus_dev/src/common/spirals/SpiralAlgorithm.cpp Mon Mar 16
14:29:13 2009
@@ -0,0 +1,97 @@
+#include "SpiralAlgorithm.h"
+
+/**
+ * Constructor.
+ */
+SpiralAlgorithm::SpiralAlgorithm() {
+ _field = NULL;
+ _width = 0;
+ _height = 0;
+ _numColors = 0;
+ _colorWidth = 1;
+ _emptyWidth = 0;
+ _bConstantColor = false;
+}
+
+SpiralAlgorithm::~SpiralAlgorithm() {
+ // someone else is responsible for destroying _field
+ _field = NULL;
+}
+
+ /**
+ * Initializes the algorithm. Doesn't perform any actual generation.
+ * @param field The array of integers in which to generate the spiral
field.
+ * @param screenWidth the width of the screen in pixels.
+ * @param screenHeight the height of the screen in pixels.
+ * @param numColors the number of colors in the palette primary
direction.
+ * @param colorWidth the width of the strip of color.
+ * @param emptyWidth the width of the default color region.
+ * @param bConstantColor whether or not to hold the color index constant.
+ * @param bRandomColor whether or not the initial color is randomly
selected.
+ * @see calc()
+ */
+void SpiralAlgorithm::initialize(int* field, int screenWidth, int
screenHeight,
+ int numColors, int colorWidth, int emptyWidth,
+ bool bConstantColor, bool bRandomColor) {
+
+ initializeBase(field, screenWidth, screenHeight, numColors, colorWidth,
+ colorHeight, bConstantColor);
+}
+
+/**
+ * Completes one iteration of the algorithm. Returns true if the algorithm
+ * is completed.
+ */
+bool SpiralAlgorithm::calc() {
+ // base does nada.
+ return true;
+}
+
+/**
+ * Completes up to numIterations iterations of the algorithm. If N <= 0,
+ * the algorithm will continue until finished.
+ */
+bool SpiralAlgorithm::calc(int numIterations) {
+ for(int i=0; i<numIterations; i++) {
+ if(calc())
+ return true;
+ }
+ return false;
+}
+
+/**
+ * This is a convenience function that is the same as calling calc(-1).
+ */
+bool SpiralAlgorithm::calcAll() {
+ return calc(-1);
+}
+
+ /**
+ * Initializes the base algorithm. Doesn't perform any actual
generation.
+ * @param field The array of integers in which to generate the spiral
field.
+ * @param screenWidth the width of the screen in pixels.
+ * @param screenHeight the height of the screen in pixels.
+ * @param numColors the number of colors in the palette primary
direction.
+ * @param colorWidth the width of the strip of color.
+ * @param emptyWidth the width of the default color region.
+ * @param bConstantColor whether or not to hold the color index constant.
+ * @see initialize()
+ */
+void SpiralAlgorithm::initializeBase(int* field, int screenWidth,
+ int screenHeight, int numColors,
+ int colorWidth, int emptyWidth,
+ bool bConstantColor) {
+ _field = field;
+ _width = screenWidth;
+ _height = screenHeight;
+ _numColors = numColors;
+ _colorWidth = colorWidth;
+ _emptyWidth = emptyWidth;
+ _bConstantColor = bConstantColor;
+
+ if(_colorWidth < 0)
+ _colorWidth = 0;
+ if(_emptyWidth < 0)
+ _emptyWidth = 0;
+}
+
Added: branches/backus_dev/src/common/spirals/SpiralAlgorithm.h
==============================================================================
--- (empty file)
+++ branches/backus_dev/src/common/spirals/SpiralAlgorithm.h Mon Mar 16
14:29:13 2009
@@ -0,0 +1,110 @@
+/**
+ * Copyright (c) 2009 Jeff Backus.
+ *
+ * Licensed under the GNU General Public License, Version 2.0
(the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Additionally, this code makes heavy use of the Qt libraries from
+ * Trolltech. These libraries are released under the GNU
+ * General Public License, Version 2.0, as well. Please contact
+ * Trolltech for more information.
+ *
+ * http://trolltech.com/
+ *
+ */
+
+/**
+ * This is the base class for the spiral algorithms.
+ */
+
+/*
+#include <stdlib.h>
+#include <ctime>
+using namespace std;
+*/
+
+#ifndef __SPIRALALGORITHM_H__
+#define __SPIRALALGORITHM_H__
+
+class SpiralAlgorithm {
+
+ public:
+
+ /**
+ * Constructor.
+ */
+ SpiralAlgorithm();
+
+ virtual ~SpiralAlgorithm();
+
+ /**
+ * Initializes the algorithm. Doesn't perform any actual generation.
+ * @param field The array of integers in which to generate the spiral
field.
+ * @param screenWidth the width of the screen in pixels.
+ * @param screenHeight the height of the screen in pixels.
+ * @param numColors the number of colors in the palette primary
direction.
+ * @param colorWidth the width of the strip of color.
+ * @param emptyWidth the width of the default color region.
+ * @param bConstantColor whether or not to hold the color index constant.
+ * @param bRandomColor whether or not the initial color is randomly
selected.
+ * @see calc()
+ */
+ virtual void initialize(int* field, int screenWidth, int screenHeight,
+ int numColors, int colorWidth, int emptyWidth,
+ bool bConstantColor, bool bRandomColor);
+
+ /**
+ * Completes one iteration of the algorithm. Returns true if the
algorithm
+ * is completed.
+ */
+ virtual bool calc();
+
+ /**
+ * Completes up to numIterations iterations of the algorithm. If N <= 0,
+ * the algorithm will continue until finished.
+ * @param numIterations the number of iterations to perform.
+ * @return true if the spiral generation is complete.
+ * @see calc();
+ */
+ bool calc(int numIterations);
+
+ /**
+ * This is a convenience function that is the same as calling calc(-1).
+ * @see calc();
+ */
+ bool calcAll();
+
+ protected:
+ /**
+ * Initializes the base algorithm. Doesn't perform any actual
generation.
+ * @param field The array of integers in which to generate the spiral
field.
+ * @param screenWidth the width of the screen in pixels.
+ * @param screenHeight the height of the screen in pixels.
+ * @param numColors the number of colors in the palette primary
direction.
+ * @param colorWidth the width of the strip of color.
+ * @param emptyWidth the width of the default color region.
+ * @param bConstantColor whether or not to hold the color index constant.
+ * @see initialize()
+ */
+ void initialize(int* field, int screenWidth, int screenHeight,
+ int numColors, int colorWidth, int emptyWidth,
+ bool bConstantColor);
+
+ int _width;
+ int _height;
+ int _numColors;
+ int _colorWidth;
+ int _emptyWidth;
+ bool _bConstantColor;
+};
+
+#endif