Added:
branches/backus_dev/src/SpiralLenz/src/RectangularSpiralBackgroundProfile.cpp
branches/backus_dev/src/SpiralLenz/src/RectangularSpiralBackgroundProfile.h
branches/backus_dev/src/common/spirals/NgonSpiralAlgorithm.cpp
branches/backus_dev/src/common/spirals/NgonSpiralAlgorithm.h
Modified:
branches/backus_dev/Makefile.in
branches/backus_dev/configure.ac
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/defaults.xml
branches/backus_dev/src/SpiralLenz/src/ConfigWidget.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/2d_bgnd_w_lens/Background.h
branches/backus_dev/src/common/2d_bgnd_w_lens/BackgroundProfile.cpp
branches/backus_dev/src/common/2d_bgnd_w_lens/BackgroundProfile.h
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
branches/backus_dev/src/common/utility/misc_funcs.cpp
branches/backus_dev/src/common/utility/misc_funcs.h
Log:
Made a number of changes, but currently working on redoing the spiral
algorithm to use
a generic N-gon+polar spiral algorithm.
Modified: branches/backus_dev/Makefile.in
==============================================================================
--- branches/backus_dev/Makefile.in (original)
+++ branches/backus_dev/Makefile.in Sun Apr 26 17:56:58 2009
@@ -89,6 +89,16 @@
-o Makefile.PlasmaGenerator && \
$(MAKE) -f Makefile.PlasmaGenerator
+bin/SpiralLenz : src/SpiralLenz/project_files/SpiralLenz_scr.pro
+ cd $(srcdir)/src/SpiralLenz/project_files/ && $(QMAKE) SpiralLenz_scr.pro
\
+ -o Makefile.SpiralLenz_scr && \
+ $(MAKE) -f Makefile.SpiralLenz_scr
+
+bin/SpiralLenz_glut : src/SpiralLenz/project_files/SpiralLenz_glut.pro
+ cd $(srcdir)/src/SpiralLenz/project_files/ && $(QMAKE)
SpiralLenz_glut.pro \
+ -o Makefile.SpiralLenz_glut && \
+ $(MAKE) -f Makefile.SpiralLenz_glut
+
doc :
cd doc; $(MAKE)
@@ -97,6 +107,7 @@
-rm bin/PlasmaLenz bin/PlasmaLenz_glut
-rm bin/Crawlies bin/Crawlies_glut
-rm bin/AcidRain bin/AcidRain_glut
+ -rm bin/SpiralLenz bin/SpiralLenz_glut
-rm bin/PlasmaGenerator
-cd $(srcdir)/src/PlasmaLenz/project_files/ && $(MAKE) -f
Makefile.PlasmaLenz_scr clean
-cd $(srcdir)/src/PlasmaLenz/project_files/ && $(MAKE) -f
Makefile.PlasmaLenz_glut clean
@@ -104,6 +115,8 @@
-cd $(srcdir)/src/Crawlies/project_files/ && $(MAKE) -f
Makefile.Crawlies_glut clean
-cd $(srcdir)/src/AcidRain/project_files/ && $(MAKE) -f
Makefile.AcidRain_scr clean
-cd $(srcdir)/src/AcidRain/project_files/ && $(MAKE) -f
Makefile.AcidRain_glut clean
+ -cd $(srcdir)/src/SpiralLenz/project_files/ && $(MAKE) -f
Makefile.SpiralLenz_scr clean
+ -cd $(srcdir)/src/SpiralLenz/project_files/ && $(MAKE) -f
Makefile.SpiralLenz_glut clean
-cd $(srcdir)/src/PlasmaGenerator/project_files/ && $(MAKE) -f
Makefile.PlasmaGenerator clean
-cd doc; $(MAKE) -f Makefile clean
@@ -112,12 +125,15 @@
-rm bin/PlasmaLenz bin/PlasmaLenz_glut
-rm bin/Crawlies bin/Crawlies_glut
-rm bin/AcidRain bin/AcidRain_glut
+ -rm bin/SpiralLenz bin/SpiralLenz_glut
-cd $(srcdir)/src/PlasmaLenz/project_files/ && $(MAKE) -f
Makefile.PlasmaLenz_scr distclean
-cd $(srcdir)/src/PlasmaLenz/project_files/ && $(MAKE) -f
Makefile.PlasmaLenz_glut distclean
-cd $(srcdir)/src/Crawlies/project_files/ && $(MAKE) -f
Makefile.Crawlies_scr distclean
-cd $(srcdir)/src/Crawlies/project_files/ && $(MAKE) -f
Makefile.Crawlies_glut distclean
-cd $(srcdir)/src/AcidRain/project_files/ && $(MAKE) -f
Makefile.AcidRain_scr distclean
-cd $(srcdir)/src/AcidRain/project_files/ && $(MAKE) -f
Makefile.AcidRain_glut distclean
+ -cd $(srcdir)/src/SpiralLenz/project_files/ && $(MAKE) -f
Makefile.SpiralLenz_scr distclean
+ -cd $(srcdir)/src/SpiralLenz/project_files/ && $(MAKE) -f
Makefile.SpiralLenz_glut distclean
-cd $(srcdir)/src/PlasmaGenerator/project_files/ && $(MAKE) -f
Makefile.PlasmaGenerator distclean
-cd doc; $(MAKE) -f Makefile distclean
-rm -rf autom4te.cache
Modified: branches/backus_dev/configure.ac
==============================================================================
--- branches/backus_dev/configure.ac (original)
+++ branches/backus_dev/configure.ac Sun Apr 26 17:56:58 2009
@@ -127,6 +127,33 @@
[man_targets="$man_targets PlasmaGenerator/man_page/PlasmaGenerator.1"]
fi
+AC_ARG_ENABLE([spirallenz], [AC_HELP_STRING([--enable-spirallenz],
+ [build SpiralLenz screen saver default=yes])],
+ [enable_spirallenz=$enableval],
+ [enable_spirallenz=yes])
+
+if test "$enable_spirallenz" == "yes";
+ then
+ [qt_targets="$qt_targets SpiralLenz"]
+ [data_targets="$data_targets SpiralLenz.xml"]
+ [man_targets="$man_targets SpiralLenz/man_page/SpiralLenz.1"]
+fi
+
+AC_ARG_ENABLE([spirallenz-glut],
[AC_HELP_STRING([--enable-spirallenz-glut],
+ [build SpiralLenz GLUT demo default=no])],
+ [enable_spirallenz_glut=$enableval],
+ [enable_spirallenz_glut=no])
+
+if test "$enable_spirallenz_glut" == "yes";
+ then
+ [qt_targets="$qt_targets SpiralLenz_glut"]
+ [enable_glut="yes"]
+ [data_targets="$data_targets SpiralLenz.xml"]
+ [man_targets="$man_targets SpiralLenz/man_page/SpiralLenz.1"]
+fi
+
+
+# substitute in targets
AC_SUBST(bintrg, $qt_targets)
AC_SUBST(datatrg, $data_targets)
AC_SUBST(mantrg, $man_targets)
Modified:
branches/backus_dev/src/SpiralLenz/project_files/SpiralLenz_glut.pro
==============================================================================
--- branches/backus_dev/src/SpiralLenz/project_files/SpiralLenz_glut.pro
(original)
+++ branches/backus_dev/src/SpiralLenz/project_files/SpiralLenz_glut.pro
Sun Apr 26 17:56:58 2009
@@ -14,7 +14,12 @@
INCLUDEPATH = $$COMMON_PATH $$SOURCE_PATH $$RESOURCE_PATH
-SOURCES = $$COMMON_PATH/core/glut_demo.cpp
$$COMMON_PATH/core/win_misc_funcs.cpp
+SOURCES = $$COMMON_PATH/core/glut_demo.cpp
+SOURCES += $$COMMON_PATH/core/win_misc_funcs.cpp
+
+SOURCES += $$COMMON_PATH/spirals/SpiralAlgorithm.cpp
+SOURCES += $$COMMON_PATH/spirals/RectangularSpiralAlgorithm.cpp
+SOURCES += $$COMMON_PATH/spirals/NgonSpiralAlgorithm.cpp
SOURCES += $$COMMON_PATH/IndexedPalette/IndexedPalette.cpp
SOURCES += $$COMMON_PATH/IndexedPalette/IndexedPaletteDialog.cpp
@@ -28,11 +33,12 @@
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/Background.cpp
+SOURCES += $$COMMON_PATH/2d_bgnd_w_lens/BackgroundProfile.cpp
+SOURCES += $$COMMON_PATH/2d_bgnd_w_lens/configdlg_main.cpp
+SOURCES += $$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
@@ -44,13 +50,20 @@
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 += $$SOURCE_PATH/ConfigWidget.cpp
+SOURCES += $$SOURCE_PATH/project_specific_externs.cpp
SOURCES += $$COMMON_PATH/utility/AboutDialog.cpp
-SOURCES += $$SOURCE_PATH/ProfileEditDialog.cpp
+//SOURCES += $$SOURCE_PATH/ProfileEditDialog.cpp
+SOURCES += $$SOURCE_PATH/SpiralBackground.cpp
+SOURCES += $$SOURCE_PATH/SpiralBackgroundProfile.cpp
+SOURCES += $$SOURCE_PATH/RectangularSpiralBackgroundProfile.cpp
HEADERS = $$COMMON_PATH/core/win_misc_funcs.h
+HEADERS += $$COMMON_PATH/spirals/SpiralAlgorithm.h
+HEADERS += $$COMMON_PATH/spirals/RectangularSpiralAlgorithm.h
+HEADERS += $$COMMON_PATH/spirals/NgonSpiralAlgorithm.h
+
HEADERS += $$COMMON_PATH/IndexedPalette/IndexedPalette.h
HEADERS += $$COMMON_PATH/IndexedPalette/IndexedPaletteDialog.h
HEADERS += $$COMMON_PATH/IndexedPalette/IndexedPaletteDialogEntryButton.h
@@ -63,10 +76,10 @@
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/Background.h
+HEADERS += $$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
@@ -82,10 +95,12 @@
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
+//HEADERS += $$SOURCE_PATH/ProfileEditDialog.h
+HEADERS += $$SOURCE_PATH/SpiralBackground.h
+HEADERS += $$SOURCE_PATH/SpiralBackgroundProfile.h
+HEADERS += $$SOURCE_PATH/RectangularSpiralBackgroundProfile.h
TARGET = SpiralLenz_glut
RESOURCES = $$RESOURCE_PATH/qt_resource.qrc
Modified:
branches/backus_dev/src/SpiralLenz/project_files/SpiralLenz_scr.pro
==============================================================================
--- branches/backus_dev/src/SpiralLenz/project_files/SpiralLenz_scr.pro
(original)
+++ branches/backus_dev/src/SpiralLenz/project_files/SpiralLenz_scr.pro Sun
Apr 26 17:56:58 2009
@@ -18,6 +18,9 @@
unix:SOURCES = $$COMMON_PATH/core/unix_main.cpp
SOURCES += $$COMMON_PATH/core/win_misc_funcs.cpp
+SOURCES += $$COMMON_PATH/spirals/SpiralAlgorithm.cpp
+SOURCES += $$COMMON_PATH/spirals/RectangularSpiralAlgorithm.cpp
+
SOURCES += $$COMMON_PATH/IndexedPalette/IndexedPalette.cpp
SOURCES += $$COMMON_PATH/IndexedPalette/IndexedPaletteDialog.cpp
SOURCES +=
$$COMMON_PATH/IndexedPalette/IndexedPaletteDialogEntryButton.cpp
@@ -30,7 +33,6 @@
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
@@ -53,6 +55,9 @@
HEADERS = $$COMMON_PATH/core/win_misc_funcs.h
+HEADERS += $$COMMON_PATH/spirals/SpiralAlgorithm.h
+HEADERS += $$COMMON_PATH/spirals/RectangularSpiralAlgorithm.h
+
HEADERS += $$COMMON_PATH/IndexedPalette/IndexedPalette.h
HEADERS += $$COMMON_PATH/IndexedPalette/IndexedPaletteDialog.h
HEADERS += $$COMMON_PATH/IndexedPalette/IndexedPaletteDialogEntryButton.h
@@ -65,7 +70,6 @@
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
Modified: branches/backus_dev/src/SpiralLenz/resource_files/defaults.xml
==============================================================================
--- branches/backus_dev/src/SpiralLenz/resource_files/defaults.xml
(original)
+++ branches/backus_dev/src/SpiralLenz/resource_files/defaults.xml Sun Apr
26 17:56:58 2009
@@ -1,14 +1,12 @@
-<!DOCTYPE PlasmaLenz_Configuration>
-<PlasmaLenz_Configuration>
+<!DOCTYPE SpiralLenz_Configuration>
+<SpiralLenz_Configuration>
<BackgroundProfile>
- <type>PlasmaFractalBackground</type>
+ <type>RectangularSpiralBackground</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>
@@ -107,5 +105,5 @@
<location>0</location>
</selected_entry>
</selected_master_profile_list>
-</PlasmaLenz_Configuration>
+</SpiralLenz_Configuration>
Modified: branches/backus_dev/src/SpiralLenz/src/ConfigWidget.cpp
==============================================================================
--- branches/backus_dev/src/SpiralLenz/src/ConfigWidget.cpp (original)
+++ branches/backus_dev/src/SpiralLenz/src/ConfigWidget.cpp Sun Apr 26
17:56:58 2009
@@ -25,7 +25,7 @@
//begin debug
//#include <iostream>
//using namespace std;
-#include "2d_bgnd_w_lens/lens_engine/SphericalLensProfile.h"
+//#include "2d_bgnd_w_lens/lens_engine/SphericalLensProfile.h"
//end debug
#include <QVBoxLayout>
@@ -40,650 +40,659 @@
#include <QDir>
//temp
-//#include <QMessageBox>
+#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"
+#include "2d_bgnd_w_lens/ConfigWidget.h"
+#include "2d_bgnd_w_lens/PaletteEditor.h"
+#include "utility/ImportExportDialog.h"
+#include "utility/misc_funcs.h"
+#include "utility/AboutDialog.h"
+#include "utility/HelpDialog.h"
+#include "2d_bgnd_w_lens/project_specific_extern_defs.h"
+//#include "ProfileEditDialog.h"
//constructor & destructor
ConfigWidget::ConfigWidget(QWidget* parent, Qt::WindowFlags f) {
- QDialog(parent, f);
+ QDialog(parent, f);
- _manager = NULL;
- _gplDialog = NULL;
- _stackedLayout = NULL;
- _mpAvailList = NULL;
- _mpSelList = NULL;
+ _manager = NULL;
+ _gplDialog = NULL;
+ _stackedLayout = NULL;
+ _mpAvailList = NULL;
+ _mpSelList = NULL;
- _windowTitle = tr("PlasmaLenz Configuration");
+ _windowTitle = tr("SpiralLenz Configuration");
- setWindowTitle(_windowTitle);
+ setWindowTitle(_windowTitle);
- QIcon icon(":/app_icon.png");
- setWindowIcon(icon);
+ QIcon icon(":/app_icon.png");
+ setWindowIcon(icon);
}
ConfigWidget::~ConfigWidget() {
- _manager = NULL;
+ _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;
- }
+ 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;
- //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();
+ //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;
+ 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);
+ setLayout(mainLayout);
- populateMPLists();
+ populateMPLists();
+ */
}
void ConfigWidget::setManager(ConfigManager* manager) {
- _manager = manager;
+ _manager = manager;
}
void ConfigWidget::addListClicked(bool checked) {
- if(_mpAvailList == NULL || _mpSelList == NULL)
- return;
+ 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());
- }
- }
+ 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;
+ 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;
- }
+ 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;
+ if(_mpSelList == NULL)
+ return;
- int row = _mpSelList->currentRow();
- if(row > 0) {
- _mpSelList->insertItem(row-1,_mpSelList->takeItem(row));
- _mpSelList->setCurrentRow(row-1);
- }
+ 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;
+ 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);
- }
- }
+ 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();
+ saveData();
- emit dialogFinished();
+ emit dialogFinished();
}
void ConfigWidget::applyClicked(bool checked) {
- saveData();
+ saveData();
}
void ConfigWidget::cancelClicked(bool checked) {
- emit dialogFinished();
+ emit dialogFinished();
}
void ConfigWidget::randomClicked(bool checked) {
- _manager->setRandomProfile(checked);
+ _manager->setRandomProfile(checked);
}
void ConfigWidget::aboutClicked(bool checked) {
- AboutDialog* dlg = new AboutDialog(getAppFullName(), getAppVersion());
- if(dlg != NULL) {
- dlg->exec();
- delete dlg;
- dlg = NULL;
- }
+ 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();
- }
+ _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();
+ QMessageBox::information(this, _windowTitle, "Not implemented yet.",
QMessageBox::Ok);
+ /*
+ 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;
- }
+ 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;
+ 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;
- }
+ 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++;
- }
- }
+ j++;
+ }
+ }
}
void ConfigWidget::advancedChecked(bool checked) {
-// nada
+ // nada
}
//clears and then populates both MasterProfile lists.
void ConfigWidget::populateMPLists() {
- if(_mpAvailList == NULL || _mpSelList == NULL)
- return;
+ if(_mpAvailList == NULL || _mpSelList == NULL)
+ return;
- //available list
- _mpAvailList->clear();
- _mpAvailList->addItems(_manager->getAvailableProfiles());
-
- //selected list
- _mpSelList->clear();
- _mpSelList->addItems(_manager->getSelectedProfiles());
+ //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;
+ QWidget* tempWidget = NULL;
+ QPushButton* tempButton = NULL;
- QVBoxLayout* mpLayout = new QVBoxLayout();
+ QVBoxLayout* mpLayout = new QVBoxLayout();
- QHBoxLayout* listsLayout = new QHBoxLayout();
+ QHBoxLayout* listsLayout = new QHBoxLayout();
- _mpAvailList = new QListWidget();
- _mpAvailList->setSelectionMode(QAbstractItemView::ExtendedSelection);
- _mpAvailList->setToolTip(tr("This is the list of available configuration
profiles."));
+ _mpAvailList = new QListWidget();
+ _mpAvailList->setSelectionMode(QAbstractItemView::ExtendedSelection);
+ _mpAvailList->setToolTip(tr("This is the list of available configuration
profiles."));
- listsLayout->addWidget(_mpAvailList);
+ listsLayout->addWidget(_mpAvailList);
- QVBoxLayout* listButtonLayout = new QVBoxLayout();
+ 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 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("<<");
+ 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;
+ 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 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());
+ //update history size
+ _manager->setProfileHistorySize(_historyBox->value());
- _manager->save();
+ _manager->save();
}
void ConfigWidget::profileNameChange(QString oldName, QString newName) {
- if(_mpAvailList == NULL)
- return;
+ 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++;
- }
- }
+ 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);
+ 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)"));
- // 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;
+ 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());
- }
- }
+ // 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)"));
+ QMessageBox::information(this, _windowTitle, "Not implemented yet.",
QMessageBox::Ok);
+ /*
+ 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;
+ 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;
+ // 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();
+ PaletteEditor* dlg = new PaletteEditor(_manager, this);
+ dlg->exec();
- //clean up
- delete dlg;
- dlg = NULL;
+ //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;
- }
+ HelpDialog* dlg = new HelpDialog("qrc:/help/index.html");
+ if(dlg != NULL) {
+ dlg->exec();
+ delete dlg;
+ dlg = NULL;
+ }
}
Modified: branches/backus_dev/src/SpiralLenz/src/ProfileEditDialog.h
==============================================================================
--- branches/backus_dev/src/SpiralLenz/src/ProfileEditDialog.h (original)
+++ branches/backus_dev/src/SpiralLenz/src/ProfileEditDialog.h Sun Apr 26
17:56:58 2009
@@ -1,117 +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
+/**
+ * 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/RectangularSpiralBackgroundProfile.cpp
==============================================================================
--- (empty file)
+++
branches/backus_dev/src/SpiralLenz/src/RectangularSpiralBackgroundProfile.cpp
Sun Apr 26 17:56:58 2009
@@ -0,0 +1,304 @@
+/**
+ * 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;
+// end debug
+
+#include <QtXml/QDomElement>
+#include <QtXml/QDomText>
+
+#include "utility/misc_funcs.h"
+#include "spirals/RectangularSpiralAlgorithm.h"
+#include "RectangularSpiralBackgroundProfile.h"
+#include "SpiralBackground.h"
+
+// begin tmp
+#include "spirals/NgonSpiralAlgorithm.h"
+// end tmp
+
+RectangularSpiralBackgroundProfile::RectangularSpiralBackgroundProfile() {
+ _xmlTypeValue = "RectangularSpiralBackground";
+
+ //defaults
+ _colorWidth = 2;
+ _emptyWidth = 1;
+ _bConstantColor = false;
+ _bRandomColor = false;
+ _bIncrementColor = false;
+}
+
+RectangularSpiralBackgroundProfile::~RectangularSpiralBackgroundProfile() {
+ // no es nada
+}
+
+/**
+ * Attempts to load this background profile object from the
+ * specified QDomNode.
+ */
+BackgroundProfile* RectangularSpiralBackgroundProfile::load(QDomNode
&node) {
+ 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;
+
+ RectangularSpiralBackgroundProfile* retVal = new
RectangularSpiralBackgroundProfile();
+ if(retVal == NULL)
+ return NULL;
+
+ // load base
+ retVal->loadBase(node);
+
+ // load extended data
+ tempElem = node.firstChildElement("color_width");
+ if(!tempElem.isNull()) {
+ tmpI = tempElem.text().toInt();
+ retVal->setColorWidth(tmpI);
+ }
+
+ tempElem = node.firstChildElement("empty_width");
+ if(!tempElem.isNull()) {
+ tmpI = tempElem.text().toInt();
+ retVal->setEmptyWidth(tmpI);
+ }
+
+ tempElem = node.firstChildElement("constant_color");
+ if(!tempElem.isNull()) {
+ QString param = tempElem.text();
+ retVal->setConstantColor(stringToBool(param));
+ }
+
+ tempElem = node.firstChildElement("random_color");
+ if(!tempElem.isNull()) {
+ QString param = tempElem.text();
+ retVal->setRandomColor(stringToBool(param));
+ }
+
+ tempElem = node.firstChildElement("increment_color");
+ if(!tempElem.isNull()) {
+ QString param = tempElem.text();
+ retVal->setColorIncrement(stringToBool(param));
+ }
+
+ // return new profile
+ return retVal;
+}
+
+/**
+ * Returns a QDomNode object that represents this profile.
+ */
+QDomNode RectangularSpiralBackgroundProfile::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);
+
+ // save base class values
+ saveBase(&retVal, doc);
+
+ // save extended data
+ //color width
+ tempStr.setNum(_colorWidth);
+ tempNode = doc->createTextNode(tempStr);
+ tempElem = doc->createElement("color_width");
+ tempElem.appendChild(tempNode);
+ retVal.appendChild(tempElem);
+
+ //empty width
+ tempStr.setNum(_emptyWidth);
+ tempNode = doc->createTextNode(tempStr);
+ tempElem = doc->createElement("empty_width");
+ tempElem.appendChild(tempNode);
+ retVal.appendChild(tempElem);
+
+ //constant color?
+ tempNode = doc->createTextNode(boolToString(_bConstantColor));
+ tempElem = doc->createElement("constant_color");
+ tempElem.appendChild(tempNode);
+ retVal.appendChild(tempElem);
+
+ //random color?
+ tempNode = doc->createTextNode(boolToString(_bRandomColor));
+ tempElem = doc->createElement("random_color");
+ tempElem.appendChild(tempNode);
+ retVal.appendChild(tempElem);
+
+ //increment color?
+ tempNode = doc->createTextNode(boolToString(_bIncrementColor));
+ tempElem = doc->createElement("increment_color");
+ tempElem.appendChild(tempNode);
+ retVal.appendChild(tempElem);
+
+ // return node.
+ return retVal;
+}
+
+ /**
+ * Gets the width of the line to be filled with color
+ */
+int RectangularSpiralBackgroundProfile::getColorWidth() {
+ return _colorWidth;
+}
+
+ /**
+ * Sets the width of the line to be filled with color.
+ */
+void RectangularSpiralBackgroundProfile::setColorWidth(int colorWidth) {
+ cout<<"Attempting to set color width to "<<colorWidth<<"...";
+ if(0 < colorWidth && colorWidth < 30000) {
+ _colorWidth = colorWidth;
+ cout<<"Successful.";
+ }
+ cout<<endl;
+}
+
+ /**
+ * Gets the width of the line to be filled with "empty space" (palette's
+ * default color).
+ */
+int RectangularSpiralBackgroundProfile::getEmptyWidth() {
+ return _emptyWidth;
+}
+
+ /**
+ * Gets the width of the line to be filled with "empty space" (palette's
+ * default color).
+ */
+void RectangularSpiralBackgroundProfile::setEmptyWidth(int emptyWidth) {
+ if(0 <= emptyWidth && emptyWidth < 30000) {
+ _emptyWidth = emptyWidth;
+ }
+}
+
+ /**
+ * Gets whether or not the color should remain constant.
+ */
+bool RectangularSpiralBackgroundProfile::isConstantColor() {
+ return _bConstantColor;
+}
+
+ /**
+ * Sets whether or not the color should remain constant.
+ */
+void RectangularSpiralBackgroundProfile::setConstantColor(bool
bConstantColor) {
+ _bConstantColor = bConstantColor;
+}
+
+ /**
+ * Gets whether or not the initial color is random or index 0.
+ */
+bool RectangularSpiralBackgroundProfile::isRandomColor() {
+ return _bRandomColor;
+}
+
+ /**
+ * Sets whether or not the initial color is random or index 0.
+ */
+void RectangularSpiralBackgroundProfile::setRandomColor(bool bRandomColor)
{
+ _bRandomColor = bRandomColor;
+}
+
+/**
+ * Gets whether or not the color index increases as it spirals out.
+ */
+bool RectangularSpiralBackgroundProfile::doesColorIncrement() {
+ return _bIncrementColor;
+}
+
+ /**
+ * Sets whether or not the color index increases as it spirals out.
+ */
+void RectangularSpiralBackgroundProfile::setColorIncrement(bool
bIncrementColor) {
+ _bIncrementColor = bIncrementColor;
+}
+
+/**
+ * Creates and returns a new background object.
+ */
+Background* RectangularSpiralBackgroundProfile::getNewBackgroundObj(int
height,
+ int width,
+ QHash<QString, IndexedPaletteProfile*>* palHash) {
+
+
+ NgonSpiralAlgorithm* alg =
+ new NgonSpiralAlgorithm(0,_colorWidth,_emptyWidth,_bConstantColor,
+ _bRandomColor, _bIncrementColor);
+ /*
+ RectangularSpiralAlgorithm* alg =
+ new RectangularSpiralAlgorithm(_colorWidth,_emptyWidth,_bConstantColor,
+ _bRandomColor, _bIncrementColor);
+ */
+ if(alg == NULL)
+ return NULL;
+
+ return new SpiralBackground(width, height, alg,
+ palHash->value(_palName)->createPalette(),
+ _bAnimatePalette, _paletteXSpeed, _paletteYSpeed,
+ _genStepsPerTick);
+}
+
+/**
+ * Overloaded assignment operator
+ */
+RectangularSpiralBackgroundProfile&
RectangularSpiralBackgroundProfile::operator=(RectangularSpiralBackgroundProfile&
other) {
+
+ baseCopy(other);
+
+ _colorWidth = other._colorWidth;
+ _emptyWidth = other._emptyWidth;
+ _bConstantColor = other._bConstantColor;
+ _bRandomColor = other._bRandomColor;
+ _bIncrementColor = other._bIncrementColor;
+
+ return *this;
+}
+
+/**
+ * Creates a new object with this object's settings.
+ */
+BackgroundProfile* RectangularSpiralBackgroundProfile::clone() {
+ RectangularSpiralBackgroundProfile* retVal =
+ new RectangularSpiralBackgroundProfile();
+
+ *retVal = *this;
+
+ return (BackgroundProfile*)retVal;
+}
+
+
+
Added:
branches/backus_dev/src/SpiralLenz/src/RectangularSpiralBackgroundProfile.h
==============================================================================
--- (empty file)
+++
branches/backus_dev/src/SpiralLenz/src/RectangularSpiralBackgroundProfile.h
Sun Apr 26 17:56:58 2009
@@ -0,0 +1,135 @@
+/**
+ * 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 all spiral background profiles.
+ *
+ * @author jeff backus
+ * @date 03/23/2009
+ */
+
+#ifndef __RECTANGULARSPIRALBACKGROUNDPROFILE_H__
+#define __RECTANGULARSPIRALBACKGROUNDPROFILE_H__
+
+#include <QString>
+#include <QtXml/QDomNode>
+#include <QtXml/QDomDocument>
+
+#include "SpiralBackgroundProfile.h"
+
+class RectangularSpiralBackgroundProfile : public SpiralBackgroundProfile {
+
+ public:
+ RectangularSpiralBackgroundProfile();
+ ~RectangularSpiralBackgroundProfile();
+
+ /**
+ * 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
+ );
+
+ /**
+ * Gets the width of the line to be filled with color
+ */
+ int getColorWidth();
+
+ /**
+ * Sets the width of the line to be filled with color.
+ */
+ void setColorWidth(int colorWidth);
+
+ /**
+ * Gets the width of the line to be filled with "empty space" (palette's
+ * default color).
+ */
+ int getEmptyWidth();
+
+ /**
+ * Gets the width of the line to be filled with "empty space" (palette's
+ * default color).
+ */
+ void setEmptyWidth(int emptyWidth);
+
+ /**
+ * Gets whether or not the color should remain constant.
+ */
+ bool isConstantColor();
+
+ /**
+ * Sets whether or not the color should remain constant.
+ */
+ void setConstantColor(bool bConstantColor);
+
+ /**
+ * Gets whether or not the initial color is random or index 0.
+ */
+ bool isRandomColor();
+
+ /**
+ * Sets whether or not the initial color is random or index 0.
+ */
+ void setRandomColor(bool bRandomColor);
+
+ /**
+ * Gets whether or not the color index increases as it spirals out.
+ */
+ bool doesColorIncrement();
+
+ /**
+ * Sets whether or not the color index increases as it spirals out.
+ */
+ void setColorIncrement(bool bIncrementColor);
+
+ /**
+ * Overloaded assignment operator.
+ */
+ RectangularSpiralBackgroundProfile&
operator=(RectangularSpiralBackgroundProfile& other);
+
+ /**
+ * Creates a new object with this object's settings.
+ */
+ BackgroundProfile* clone();
+
+ private:
+
+ int _colorWidth;
+ int _emptyWidth;
+ bool _bConstantColor;
+ bool _bRandomColor;
+ bool _bIncrementColor;
+};
+#endif
Modified: branches/backus_dev/src/SpiralLenz/src/SpiralBackground.cpp
==============================================================================
--- branches/backus_dev/src/SpiralLenz/src/SpiralBackground.cpp (original)
+++ branches/backus_dev/src/SpiralLenz/src/SpiralBackground.cpp Sun Apr 26
17:56:58 2009
@@ -1,136 +1,92 @@
-/**
- * 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;
-}
-
+/**
+ * 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 algorithm,
+ * a pointer to the palette, whether to rotate the palette,
+ * and the palette color skip. This class takes responsibility for
+ * destroying both the algorithm and the palette.
+ * @param sizeX The width of the background.
+ * @param sizeY The height of the background.
+ * @param algorithm A pointer to the spiral algorithm.
+ * @param pal A pointer to the palette.
+ * @param bAnimatePalette Whether or not to animate the palette.
+ * @param paletteXSpeed The palette rotational speed in the primary
direction.
+ * @param paletteYSpeed The palette rotational speed in the secondary dir.
+ * @param genStepsPerTick The number of generation steps per tick.
+ */
+SpiralBackground::SpiralBackground(int sizeX, int sizeY,
+ SpiralAlgorithm* algorithm,
+ IndexedPalette* pal, bool bAnimatePalette,
+ float paletteXSpeed, float paletteYSpeed,
+ int genStepsPerTick) {
+
+ // general defaults
+ _algorithm = NULL;
+
+ // base class specific
+ initIndexedPaletteBackground(sizeX,sizeY);
+ setPalette(pal);
+ _bEnableAnimation = bAnimatePalette;
+ _xSpeed = paletteXSpeed;
+ _ySpeed = paletteYSpeed;
+ _algorithm = algorithm;
+ _numGenStepsPerTick = genStepsPerTick;
+
+ _bSetupFinished = false;
+
+ // initialize field to -1 (no color)
+ if(_field != NULL) {
+ for(int i=0;i<_sizeX*_sizeY;i++) {
+ _field[i] = -1;
+ }
+ }
+
+ // initialize the algorithm
+ if(_algorithm != NULL) {
+ _algorithm->initialize(_field, sizeX, sizeY, _paletteWidth);
+ }
+}
+
+SpiralBackground::~SpiralBackground() {
+ destroyIndexedPaletteBackground();
+}
+
+/**
+ * Finishes generating the spiral then rotates the palette when done.
+ */
+void SpiralBackground::clocktick() {
+ if(_paletteWidth > 0) {
+ if(!_bSetupFinished && _algorithm != NULL) {
+ if(_algorithm->calc(_numGenStepsPerTick))
+ _bSetupFinished = true;
+ } else {
+ rotateColorIndex();
+ }
+ }
+}
+
Modified: branches/backus_dev/src/SpiralLenz/src/SpiralBackground.h
==============================================================================
--- branches/backus_dev/src/SpiralLenz/src/SpiralBackground.h (original)
+++ branches/backus_dev/src/SpiralLenz/src/SpiralBackground.h Sun Apr 26
17:56:58 2009
@@ -1,112 +1,81 @@
-/**
- * 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
+/**
+ * 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 "spirals/SpiralAlgorithm.h"
+
+class SpiralBackground : public IndexedPaletteBackground {
+
+ public:
+ /**
+ * Constructor takes the dimensions, a pointer to the algorithm,
+ * a pointer to the palette, whether to rotate the palette,
+ * and the palette color skip. This class takes responsibility for
+ * destroying both the algorithm and the palette.
+ * @param sizeX The width of the background.
+ * @param sizeY The height of the background.
+ * @param algorithm A pointer to the spiral algorithm.
+ * @param pal A pointer to the palette.
+ * @param bAnimatePalette Whether or not to animate the palette.
+ * @param paletteXSpeed The palette rotational speed in the primary
direction.
+ * @param paletteYSpeed The palette rotational speed in the secondary
dir.
+ * @param genStepsPerTick The number of generation steps per tick.
+ */
+ SpiralBackground(int sizeX, int sizeY, SpiralAlgorithm* algorithm,
+ IndexedPalette* pal, bool bAnimatePalette,
+ float paletteXSpeed, float paletteYSpeed,
+ int genStepsPerTick);
+
+ ~SpiralBackground();
+
+ // *** Begin Extended Methods ***
+ /**
+ * Finishes generating the spiral then rotates the palette when done.
+ */
+ void clocktick();
+ // *** End Extended Methods ***
+
+ private:
+ int _numGenStepsPerTick;
+
+ SpiralAlgorithm* _algorithm;
+};
+
+#endif
Modified: branches/backus_dev/src/SpiralLenz/src/SpiralBackgroundProfile.cpp
==============================================================================
--- branches/backus_dev/src/SpiralLenz/src/SpiralBackgroundProfile.cpp
(original)
+++ branches/backus_dev/src/SpiralLenz/src/SpiralBackgroundProfile.cpp Sun
Apr 26 17:56:58 2009
@@ -1,332 +1,326 @@
-/**
- * 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("");
- }
-}
-
-
+/**
+ * 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 "utility/misc_funcs.h"
+#include "SpiralBackgroundProfile.h"
+#include "SpiralBackground.h"
+#include "spirals/SpiralAlgorithm.h"
+
+SpiralBackgroundProfile::SpiralBackgroundProfile() {
+ _xmlTypeValue = "SpiralBackground";
+
+ //defaults
+ _name = "Empty";
+ _palName = "";
+ _genStepsPerTick = 100;
+ _bAnimatePalette = true;
+ _paletteXSpeed = 1;
+ _paletteYSpeed = 1;
+}
+
+SpiralBackgroundProfile::~SpiralBackgroundProfile() {
+ // no es nada
+}
+
+/**
+ * Attempts to load this background profile object from the
+ * specified QDomNode.
+ */
+BackgroundProfile* SpiralBackgroundProfile::load(QDomNode &node) {
+ 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;
+
+ SpiralBackgroundProfile* retVal = new SpiralBackgroundProfile();
+ if(retVal == NULL)
+ return NULL;
+
+ // load base
+ retVal->loadBase(node);
+
+ // derivative classes would load data here...
+
+ // return new profile
+ return retVal;
+}
+
+
+/**
+ * Attempts to load the base profile object from the
+ * specified QDomNode.
+ */
+void SpiralBackgroundProfile::loadBase(QDomNode &node) {
+ int tmpI;
+ QDomElement tempElem;
+
+ tempElem = node.firstChildElement("name");
+ if(!tempElem.isNull()) {
+ QString str = tempElem.text();
+ setName(str);
+ }
+
+ tempElem = node.firstChildElement("steps_per_tick");
+ if(!tempElem.isNull()) {
+ tmpI = tempElem.text().toInt();
+ setGenStepsPerTick(tmpI);
+ }
+
+ tempElem = node.firstChildElement("anmiate_palette");
+ if(!tempElem.isNull()) {
+ QString param = tempElem.text();
+ setAnimatePalette(stringToBool(param));
+ }
+
+ tempElem = node.firstChildElement("palette_x_speed");
+ if(!tempElem.isNull()) {
+ tmpI = tempElem.text().toInt();
+ setPaletteXSpeed(tmpI);
+ }
+
+ tempElem = node.firstChildElement("palette_y_speed");
+ if(!tempElem.isNull()) {
+ tmpI = tempElem.text().toInt();
+ setPaletteYSpeed(tmpI);
+ }
+
+ tempElem = node.firstChildElement("palette");
+ if(!tempElem.isNull()) {
+ setPaletteName(tempElem.text());
+ }
+}
+
+/**
+ * Returns a QDomNode object that represents this profile.
+ */
+QDomNode SpiralBackgroundProfile::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);
+
+ // save base class values
+ saveBase(&retVal, doc);
+
+ // derivative clases would save data here
+
+ // return node.
+ return retVal;
+}
+
+
+/**
+ * Returns a QDomNode object that represents the base profile.
+ */
+void SpiralBackgroundProfile::saveBase(QDomElement* node, QDomDocument*
doc) {
+
+ QString tempStr;
+ QDomText tempNode;
+ QDomElement tempElem;
+
+ //name
+ tempNode = doc->createTextNode(_name);
+ tempElem = doc->createElement("name");
+ tempElem.appendChild(tempNode);
+ node->appendChild(tempElem);
+
+ //steps per tick
+ tempStr.setNum(_genStepsPerTick);
+ tempNode = doc->createTextNode(tempStr);
+ tempElem = doc->createElement("steps_per_tick");
+ tempElem.appendChild(tempNode);
+ node->appendChild(tempElem);
+
+ //animate palette?
+ tempNode = doc->createTextNode(boolToString(_bAnimatePalette));
+ tempElem = doc->createElement("anmiate_palette");
+ tempElem.appendChild(tempNode);
+ node->appendChild(tempElem);
+
+ //palette X speed
+ tempStr.setNum(_paletteXSpeed);
+ tempNode = doc->createTextNode(tempStr);
+ tempElem = doc->createElement("palette_x_speed");
+ tempElem.appendChild(tempNode);
+ node->appendChild(tempElem);
+
+ //palette Y speed
+ tempStr.setNum(_paletteYSpeed);
+ tempNode = doc->createTextNode(tempStr);
+ tempElem = doc->createElement("palette_y_speed");
+ tempElem.appendChild(tempNode);
+ node->appendChild(tempElem);
+
+ //palette name
+ tempNode = doc->createTextNode(_palName);
+ tempElem = doc->createElement("palette");
+ tempElem.appendChild(tempNode);
+ node->appendChild(tempElem);
+}
+
+/**
+ * Creates and returns a new background object.
+ */
+Background* SpiralBackgroundProfile::getNewBackgroundObj(int height, int
width,
+ QHash<QString, IndexedPaletteProfile*>* palHash) {
+
+ SpiralAlgorithm* alg = new SpiralAlgorithm();
+ if(alg == NULL)
+ return NULL;
+
+ return new SpiralBackground(width, height, alg,
+ palHash->value(_palName)->createPalette(),
+ _bAnimatePalette, _paletteXSpeed, _paletteYSpeed,
+ _genStepsPerTick);
+}
+
+/**
+ * get/set palette name.
+ */
+QString SpiralBackgroundProfile::getPaletteName() {
+ return _palName;
+}
+
+void SpiralBackgroundProfile::setPaletteName(QString paletteName) {
+ _palName = paletteName;
+}
+
+/**
+ * get/set steps per tick
+ */
+int SpiralBackgroundProfile::getGenStepsPerTick() {
+ return _genStepsPerTick;
+}
+
+void SpiralBackgroundProfile::setGenStepsPerTick(int genStepsPerTick) {
+ _genStepsPerTick = genStepsPerTick;
+}
+
+/**
+ * Get/set animate palette.
+ */
+bool SpiralBackgroundProfile::getAnimatePalette() {
+ return _bAnimatePalette;
+}
+
+void SpiralBackgroundProfile::setAnimatePalette(bool bAnimatePalette) {
+ _bAnimatePalette = bAnimatePalette;
+}
+
+/**
+ * get/set palette x speed.
+ */
+float SpiralBackgroundProfile::getPaletteXSpeed() {
+ return _paletteXSpeed;
+}
+
+void SpiralBackgroundProfile::setPaletteXSpeed(float speed) {
+ if(0.0 <= speed && speed <= 30000.0)
+ _paletteXSpeed = speed;
+}
+
+/**
+ * get/set palette y speed.
+ */
+float SpiralBackgroundProfile::getPaletteYSpeed() {
+ return _paletteYSpeed;
+}
+
+void SpiralBackgroundProfile::setPaletteYSpeed(float speed) {
+ if(0.0 <= speed && speed <= 30000.0)
+ _paletteYSpeed = speed;
+}
+
+/**
+ * Called whenever palette names change
+ */
+void SpiralBackgroundProfile::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 SpiralBackgroundProfile::paletteRemoved(QString palName) {
+ // if this palette has been removed, set current palette name to ""
+ if(_palName == palName) {
+ _palName = QString("");
+ }
+}
+
+/**
+ * Copies the base values of the specified profile to this profile.
+ */
+void SpiralBackgroundProfile::baseCopy(SpiralBackgroundProfile& other) {
+ _name = other._name;
+ _palName = other._palName;
+ _genStepsPerTick = other._genStepsPerTick;
+ _bAnimatePalette = other._bAnimatePalette;
+ _paletteXSpeed = other._paletteXSpeed;
+ _paletteYSpeed = other._paletteYSpeed;
+
+}
+
+/**
+ * Overloaded assignment operator
+ */
+SpiralBackgroundProfile&
SpiralBackgroundProfile::operator=(SpiralBackgroundProfile& other) {
+
+ baseCopy(other);
+
+ return *this;
+}
+
+/**
+ * Creates a new object with this object's settings.
+ */
+BackgroundProfile* SpiralBackgroundProfile::clone() {
+ SpiralBackgroundProfile* retVal = new SpiralBackgroundProfile();
+
+ *retVal = *this;
+
+ return (BackgroundProfile*)retVal;
+}
+
+
+
Modified: branches/backus_dev/src/SpiralLenz/src/SpiralBackgroundProfile.h
==============================================================================
--- branches/backus_dev/src/SpiralLenz/src/SpiralBackgroundProfile.h
(original)
+++ branches/backus_dev/src/SpiralLenz/src/SpiralBackgroundProfile.h Sun
Apr 26 17:56:58 2009
@@ -1,134 +1,162 @@
-/**
- * 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
+/**
+ * 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 is the base class for all spiral background profiles.
+ *
+ * @author jeff backus
+ * @date 03/23/2009
+ */
+
+#ifndef __SPIRALBACKGROUNDPROFILE_H__
+#define __SPIRALBACKGROUNDPROFILE_H__
+
+#include <QString>
+#include <QtXml/QDomNode>
+#include <QtXml/QDomDocument>
+#include <QLayout>
+
+#include "2d_bgnd_w_lens/BackgroundProfile.h"
+
+class SpiralBackgroundProfile : public BackgroundProfile {
+
+ public:
+ SpiralBackgroundProfile();
+ virtual ~SpiralBackgroundProfile();
+
+ /**
+ * Attempts to load this background profile object from the
+ * specified QDomNode.
+ */
+ virtual BackgroundProfile* load(QDomNode &node);
+
+ /**
+ * Returns a QDomNode object that represents this profile.
+ */
+ virtual QDomNode save(QDomDocument* doc);
+
+ /**
+ * Creates and returns a new background object.
+ */
+ virtual Background* getNewBackgroundObj(int height, int width,
+ QHash<QString, IndexedPaletteProfile*>* palHash
+ );
+
+ /**
+ * get/set palette name.
+ */
+ QString getPaletteName();
+ void setPaletteName(QString paletteName);
+
+ /**
+ * 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);
+
+ /**
+ * Overloaded assignment operator.
+ */
+ virtual SpiralBackgroundProfile& operator=(SpiralBackgroundProfile&
other);
+
+ /**
+ * Creates a new object with this object's settings.
+ */
+ virtual 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);
+
+ /**
+ * Retrieves the configuration QLayout. The receiver is
+ * responsible for deleting the QLayout, which in turn will delete
+ * all of the components it contains. Does not contain the base
+ * class information!
+ *
+ * @see SpiralBackgroundProfileWidget
+ *
+ * @param bCreateNewWidget If false, the last widget created will be
returned.
+ * If true or the first time this function is called, it will create a
new
+ * layout.
+ */
+ //virtual QLayout* getConfigPanel(bool bCreateNewPanel);
+
+ /**
+ * Transfers all of the data in the panel to the internal data
structures.
+ */
+ //virtual void saveGUIData();
+
+ protected:
+ /**
+ * Attempts to load the base profile object from the
+ * specified QDomNode.
+ */
+ void loadBase(QDomNode &node);
+
+ /**
+ * Returns a QDomNode object that represents the base profile.
+ */
+ void saveBase(QDomElement* node, QDomDocument* doc);
+
+ /**
+ * Copies the base values of the specified profile to this profile.
+ */
+ void baseCopy(SpiralBackgroundProfile& other);
+
+ QString _palName;
+ int _genStepsPerTick;
+ bool _bAnimatePalette;
+ float _paletteXSpeed;
+ float _paletteYSpeed;
+
+ // begin GUI related
+ QLayout* _configLayout;
+
+};
+#endif
Modified:
branches/backus_dev/src/SpiralLenz/src/project_specific_externs.cpp
==============================================================================
--- branches/backus_dev/src/SpiralLenz/src/project_specific_externs.cpp
(original)
+++ branches/backus_dev/src/SpiralLenz/src/project_specific_externs.cpp Sun
Apr 26 17:56:58 2009
@@ -1,114 +1,123 @@
-/**
- * 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");
-}
-
+/**
+ * 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 "2d_bgnd_w_lens/BackgroundProfile.h"
+#include "2d_bgnd_w_lens/lens_engine/LensProfile.h"
+#include "2d_bgnd_w_lens/lens_engine/SphericalLensProfile.h"
+#include "SpiralBackgroundProfile.h"
+#include "RectangularSpiralBackgroundProfile.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 = 2;
+ retVal = new BackgroundProfile*[*numProfiles];
+
+ if(retVal == NULL) {
+ *numProfiles = 0;
+ return NULL;
+ }
+
+ retVal[0] = (BackgroundProfile*) (new SpiralBackgroundProfile());
+
+ if(retVal[0] == NULL) {
+ *numProfiles = 0;
+ return NULL;
+ }
+
+ retVal[1] = (BackgroundProfile*)
+ (new RectangularSpiralBackgroundProfile());
+
+ if(retVal[1] == 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");
+}
+
Modified: branches/backus_dev/src/SpiralLenz/src/redirector_main.cpp
==============================================================================
--- branches/backus_dev/src/SpiralLenz/src/redirector_main.cpp (original)
+++ branches/backus_dev/src/SpiralLenz/src/redirector_main.cpp Sun Apr 26
17:56:58 2009
@@ -1,40 +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]);
-}
+/**
+ * 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]);
+}
Modified: branches/backus_dev/src/common/2d_bgnd_w_lens/Background.h
==============================================================================
--- branches/backus_dev/src/common/2d_bgnd_w_lens/Background.h (original)
+++ branches/backus_dev/src/common/2d_bgnd_w_lens/Background.h Sun Apr 26
17:56:58 2009
@@ -34,72 +34,72 @@
class Background {
-public:
- /**
- * Draws the whole Background.
- */
- virtual void drawBackground(screen_struct* screenObj);
-
- /**
- * Whether or not the background should animate
- * itself (if it supports it)
- */
- void enableAnimation(bool bEnableAnimation);
-
- /**
- * Call this every tick to animate.
- * Must be overloaded by derived class.
- */
- virtual void clocktick();
-
- /**
- * Used to set whether to show the fractal generation or not.
- * If so, the number of steps are shown per render pass.
- */
- //void setShowGeneration(bool bShowGen, int numPasses);
-
- /**
- * Returns true if the background has finished whatever
- * setup it needs to do, animated or otherwise.
- */
- bool isSetupFinished();
-
- /**
- * Constructor takes the background dimensions as
- * arguments.
- */
- Background(int sizeX, int sizeY);
-
- ~Background(void);
-
- //*** Begin Screen Related ***
- int getScreenWidth();
- int getScreenHeight();
- int getTextureWidth();
- int getTextureHeight();
- //*** End Screen Related
-
-protected:
- /**
- * Default constructor...
- */
- Background();
-
- /**
- * Called from the constructor and does all of the work,
- * so that derived classes can call from their constructors.
- * sizeX and sizeY are the dimensions of the background, not
- * necessarily the size of the screen object, which has to
- * be a power of 2.
- */
- void initBackground(int sizeX, int sizeY);
+ public:
+ /**
+ * Draws the whole Background.
+ */
+ virtual void drawBackground(screen_struct* screenObj);
+
+ /**
+ * Whether or not the background should animate
+ * itself (if it supports it)
+ */
+ void enableAnimation(bool bEnableAnimation);
+
+ /**
+ * Call this every tick to animate.
+ * Must be overloaded by derived class.
+ */
+ virtual void clocktick();
+
+ /**
+ * Used to set whether to show the fractal generation or not.
+ * If so, the number of steps are shown per render pass.
+ */
+ //void setShowGeneration(bool bShowGen, int numPasses);
+
+ /**
+ * Returns true if the background has finished whatever
+ * setup it needs to do, animated or otherwise.
+ */
+ bool isSetupFinished();
+
+ /**
+ * Constructor takes the background dimensions as
+ * arguments.
+ */
+ Background(int sizeX, int sizeY);
+
+ ~Background(void);
+
+ //*** Begin Screen Related ***
+ int getScreenWidth();
+ int getScreenHeight();
+ int getTextureWidth();
+ int getTextureHeight();
+ //*** End Screen Related
+
+ protected:
+ /**
+ * Default constructor...
+ */
+ Background();
+
+ /**
+ * Called from the constructor and does all of the work,
+ * so that derived classes can call from their constructors.
+ * sizeX and sizeY are the dimensions of the background, not
+ * necessarily the size of the screen object, which has to
+ * be a power of 2.
+ */
+ void initBackground(int sizeX, int sizeY);
- int _sizeX;
- int _sizeY;
+ int _sizeX;
+ int _sizeY;
- bool _bEnableAnimation;
+ bool _bEnableAnimation;
- bool _bSetupFinished;
+ bool _bSetupFinished;
};
-#endif
\ No newline at end of file
+#endif
Modified:
branches/backus_dev/src/common/2d_bgnd_w_lens/BackgroundProfile.cpp
==============================================================================
--- branches/backus_dev/src/common/2d_bgnd_w_lens/BackgroundProfile.cpp
(original)
+++ branches/backus_dev/src/common/2d_bgnd_w_lens/BackgroundProfile.cpp Sun
Apr 26 17:56:58 2009
@@ -24,6 +24,17 @@
#include "BackgroundProfile.h"
+ /**
+ * Default constructor/destructor
+ */
+BackgroundProfile::BackgroundProfile() {
+ _name = "Uninitialized Base Backround Profile";
+ _xmlTypeValue = "Base Background Profile";
+}
+BackgroundProfile::~BackgroundProfile() {
+ // no es nada
+}
+
/* Attempts to load this background profile object from the
* specified QDomNode.
*/
Modified: branches/backus_dev/src/common/2d_bgnd_w_lens/BackgroundProfile.h
==============================================================================
--- branches/backus_dev/src/common/2d_bgnd_w_lens/BackgroundProfile.h
(original)
+++ branches/backus_dev/src/common/2d_bgnd_w_lens/BackgroundProfile.h Sun
Apr 26 17:56:58 2009
@@ -44,58 +44,64 @@
class BackgroundProfile {
-public:
- /* Attempts to load this background profile object from the
- * specified QDomNode.
- */
- virtual BackgroundProfile* load(QDomNode &node);
-
- /*
- * Returns a QDomNode object that represents this profile.
- */
- virtual QDomNode save(QDomDocument* doc);
-
- /*
- * Creates and returns a new background object.
- */
- virtual Background* getNewBackgroundObj(int height, int width,
QHash<QString, IndexedPaletteProfile*>* palHash);
-
- /**
- * Called whenever palette names change
- */
- virtual void paletteNameChanged(QString oldName, QString newName);
+ public:
+ /**
+ * Default constructor/destructor
+ */
+ BackgroundProfile();
+ virtual ~BackgroundProfile();
+
+ /* Attempts to load this background profile object from the
+ * specified QDomNode.
+ */
+ virtual BackgroundProfile* load(QDomNode &node);
+
+ /*
+ * Returns a QDomNode object that represents this profile.
+ */
+ virtual QDomNode save(QDomDocument* doc);
+
+ /*
+ * Creates and returns a new background object.
+ */
+ virtual Background* getNewBackgroundObj(int height, int width,
QHash<QString, IndexedPaletteProfile*>* palHash);
+
+ /**
+ * Called whenever palette names change
+ */
+ virtual void paletteNameChanged(QString oldName, QString newName);
- /**
- * Called whenever a palette is removed.
- */
- virtual void paletteRemoved(QString palName);
-
- /*
- * Get/set the name of this profile.
- */
- void setName(QString &name);
- QString getName();
-
- /*
- * Returns the tag name used by Dom elements for all
- * subclasses of BackgroundProfile.
- */
- static QString getXMLTagName();
-
- /*
- * Returns the type of BackgroundProfile.
- */
- QString getBackgroundType();
-
- /*
- * Creates a new object with this object's settings.
- */
- virtual BackgroundProfile* clone();
+ /**
+ * Called whenever a palette is removed.
+ */
+ virtual void paletteRemoved(QString palName);
+
+ /*
+ * Get/set the name of this profile.
+ */
+ void setName(QString &name);
+ QString getName();
+
+ /*
+ * Returns the tag name used by Dom elements for all
+ * subclasses of BackgroundProfile.
+ */
+ static QString getXMLTagName();
+
+ /*
+ * Returns the type of BackgroundProfile.
+ */
+ QString getBackgroundType();
+
+ /*
+ * Creates a new object with this object's settings.
+ */
+ virtual BackgroundProfile* clone();
-protected:
+ protected:
- QString _name;
- QString _xmlTypeValue; /* Needs set by subclasses!*/
+ QString _name;
+ QString _xmlTypeValue; /* Needs set by subclasses!*/
};
#endif
Added: branches/backus_dev/src/common/spirals/NgonSpiralAlgorithm.cpp
==============================================================================
--- (empty file)
+++ branches/backus_dev/src/common/spirals/NgonSpiralAlgorithm.cpp Sun Apr
26 17:56:58 2009
@@ -0,0 +1,258 @@
+
+// debug
+#include <iostream>
+// end debug
+#include <math.h>
+using namespace std;
+
+#include "NgonSpiralAlgorithm.h"
+
+/**
+ * Constructor.
+ */
+NgonSpiralAlgorithm::NgonSpiralAlgorithm() {
+
+ // parameters
+ _n = 0;
+ _colorWidth = 1;
+ _emptyWidth = 0;
+ _bConstantColor = true;
+ _bRandomColor = false;
+ _bIncrementColor = true;
+
+ // internals
+ _nextIdx = 0;
+ _currX = 0.0;
+ _currY = 0.0;
+ _rCoeff = 0.0;
+ _currR = 0.0;
+ _currTheta = 0.0;
+ _maxR = 0.0;
+
+ // misc constants
+ _maxFieldIdx = 0;
+ _screenXOffset = 0;
+ _screenYOffset = 0;
+}
+
+ /**
+ * Constructor takes initialization parameters.
+ * @param N the number of sides the Ngon has. N=0 for a polar spiral.
+ * @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.
+ * @param bIncrementColor whether to increment the color as it spirals
out.
+ * @see calc()
+ */
+NgonSpiralAlgorithm::NgonSpiralAlgorithm(const int N, const int colorWidth,
+ const int emptyWidth,
+ const bool bConstantColor,
+ const bool bRandomColor,
+ const bool bIncrementColor) {
+
+ // empty constants until initialize(...) is called
+ _maxFieldIdx = 0;
+ _screenXOffset = 0;
+ _screenYOffset = 0;
+ _maxR = 0.0;
+
+ // initial values for internals
+ _nextIdx = 0;
+ _currX = 0.0;
+ _currY = 0.0;
+
+ // set parameters
+ _n = N;
+ _colorWidth = colorWidth;
+ _emptyWidth = emptyWidth;
+ _bConstantColor = bConstantColor;
+ _bRandomColor = bRandomColor;
+ _bIncrementColor = bIncrementColor;
+
+ if(_colorWidth < 0)
+ _colorWidth = 0;
+ if(_emptyWidth < 0)
+ _emptyWidth = 0;
+
+ // calculate misc constants
+ _segmentWidth = _colorWidth + (_emptyWidth<<1);
+
+ // calculate spiral constants and initial values
+ _rCoeff = double(_segmentWidth)/(2.0*NGONSPIRAL_PI);
+ _rCoeff *= (jrand() % 2 == 0) ? 1.0 : -1.0; // whether clockwise or not.
+ _currR = 0.0;
+
+ // for now, just start at 0.
+ _currTheta = 0.0;
+ _lastThetaStep = NGONSPIRAL_PI/16.0;
+
+}
+
+
+NgonSpiralAlgorithm::~NgonSpiralAlgorithm() {
+}
+
+/**
+ * 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.
+ */
+void NgonSpiralAlgorithm::initialize(int* field, const int screenWidth,
+ const int screenHeight,
+ const int numColors) {
+ initializeBase(field, screenWidth, screenHeight, numColors);
+
+ if(_height <= 0)
+ return;
+ if(_width <= 0)
+ return;
+ if(_numColors <= 0)
+ return;
+
+ // calculate remaining internal constants
+ _maxFieldIdx = screenWidth * screenHeight - 1;
+ _screenXOffset = screenWidth>>1;
+ _screenYOffset = screenHeight>>1;
+
+ // calculate polar stopping condition.
+ _maxR = sqrt( _screenXOffset*_screenXOffset +
+ _screenYOffset*_screenYOffset);
+
+ // pick initial color
+ if(_bRandomColor) {
+ _nextIdx = jrand() % numColors;
+ } else {
+ _nextIdx = 0;
+ }
+
+ // begin debug
+ _stepCount = 128; //16;
+ // end debug
+
+}
+
+/**
+ * Completes one iteration of the algorithm. Returns true if the algorithm
+ * is completed.
+ */
+bool NgonSpiralAlgorithm::calc() {
+ if(_field == NULL)
+ return true;
+
+ if(_stepCount < 0)
+ return true;
+ //_stepCount--;
+ // if N is valid, use the N-gon spiral calculations.
+ // Otherwise, use the polar spiral calculations
+ bool retVal;
+ if(2 < _n && _n <= NGONSPIRAL_MAX_N) {
+ retVal = true; // < Temporary!
+ } else {
+ retVal = calcSpiral(&_currX, &_currY, &_currR, &_currTheta,
+ &_lastThetaStep);
+ //retVal = (_currR >= _maxR);
+ }
+
+ // set pixel to next color, if it is within the boundaries.
+ int px = roundDtoI(_currX)+_screenXOffset;
+ int py = roundDtoI(_currY)+_screenYOffset;
+ int fieldIdx = px+py*_width;
+ if(0 <= px && px < _width && 0 <= py && py < _height &&
+ fieldIdx < _maxFieldIdx) {
+ _field[fieldIdx] = _nextIdx;
+ }
+
+ // update color
+ if(!_bConstantColor) {
+ if(_bIncrementColor) {
+ _nextIdx = (_nextIdx+1)%_numColors;
+ } else {
+ _nextIdx = _nextIdx - 1;
+ if(_nextIdx < 0) {
+ _nextIdx = _numColors - _nextIdx;
+ }
+ }
+ }
+
+ return retVal;
+}
+
+/**
+ * Calculates a new X,Y using a polar spiral. Utilizes an adaptive
+ * algorithm to adjust thetaStep such that the new (x,y) value will
+ * be adjacent but not on the previous (x,y) value.
+ *
+ * @param x the previous X value. On return, it is the new X value.
+ * @param y the previous Y value. On return, it is the new Y value.
+ * @param r the previous R value. On return, it is the new R value.
+ * @param theta the previous Theta value. It is updated on return.
+ * @param thetaStep the previous Theta step value. Updated on return.
+ * @return True if the calculation is complete.
+ */
+bool NgonSpiralAlgorithm::calcSpiral(double* x, double* y, double* r,
+ double* theta, double* thetaStep) {
+ //cout<<"Entering calcSpiral"<<endl;
+ double newX;
+ double newY;
+ double newR;
+ double newTheta;
+ double newThetaStep = *thetaStep;
+
+ int iOldX = roundDtoI(*x);
+ int iOldY = roundDtoI(*y);
+ int iNewX;
+ int iNewY;
+
+ int escape_count = 0;
+ bool bDone = false;
+ while(!bDone) {
+ // update Theta
+ newTheta = *theta + newThetaStep;
+
+ // calculate the new R, X and Y
+ newR = _rCoeff * newTheta;
+ newX = newR * cos(newTheta);
+ newY = newR * sin(newTheta);
+
+ // check to see if we've calculated for an adjacent pixel
+ iNewX = roundDtoI(newX);
+ iNewY = roundDtoI(newY);
+ /*
+ cout<<"newX: "<<newX<<","<<iNewX<<endl;
+ cout<<"newY: "<<newY<<","<<iNewY<<endl;
+ cout<<"oldX: "<<*x<<","<<iOldX<<endl;
+ cout<<"oldY: "<<*y<<","<<iOldY<<endl;
+ */
+
+ bDone = true;
+ if(iNewX == iOldX && iNewY == iOldY) {
+ // theta too small
+ newThetaStep*=2.0;
+ bDone = false;
+ } else if(iNewX <= iOldX-2 || iOldX+2 <= iNewX ||
+ iNewY <= iOldY-2 || iOldY+2 <= iNewY) {
+ // theta too large
+ newThetaStep*=0.5;
+ bDone = false;
+ }
+
+ if(++escape_count >= 100) {
+ cout<<"NgonSpiralAlgorithm::calcSpiral() Escape count
reached!"<<endl;
+ cout<<"maxR: "<<_maxR<<endl;
+ //exit(1);
+ //*r = _maxR+1.0;
+ _maxR = -1;
+ bDone = true;
+ }
+ }
+ *x = newX;
+ *y = newY;
+ *r = newR;
+ *theta = newTheta;
+ *thetaStep = newThetaStep;
+
+ return (newR >= _maxR);
+}
Added: branches/backus_dev/src/common/spirals/NgonSpiralAlgorithm.h
==============================================================================
--- (empty file)
+++ branches/backus_dev/src/common/spirals/NgonSpiralAlgorithm.h Sun Apr 26
17:56:58 2009
@@ -0,0 +1,167 @@
+/**
+ * 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 a generic N-gon spiral algorithm. If N is invalid, a polar
+ * spiral algorithm is used.
+ */
+
+#include "utility/misc_funcs.h"
+#include "SpiralAlgorithm.h"
+
+#ifndef __NGONSPIRALALGORITHM_H__
+#define __NGONSPIRALALGORITHM_H__
+
+//enum NgonSpiralAlgorithmDir { UP=0, DOWN=1, LEFT=2, RIGHT=3 };
+
+#define NGONSPIRAL_PI 3.14159265f
+#define NGONSPIRAL_MAX_N 20
+
+class NgonSpiralAlgorithm : public SpiralAlgorithm {
+
+ public:
+
+ /**
+ * Default constructor.
+ */
+ NgonSpiralAlgorithm();
+
+ /**
+ * Constructor takes initialization parameters.
+ * @param N the number of sides the Ngon has. N=0 for a polar spiral.
+ * @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.
+ * @param bIncrementColor whether to increment the color as it spirals
out.
+ * @see calc()
+ */
+ NgonSpiralAlgorithm(const int N, const int colorWidth, const int
emptyWidth,
+ const bool bConstantColor, const bool bRandomColor,
+ const bool bIncrementColor);
+
+ ~NgonSpiralAlgorithm();
+
+ /**
+ * 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.
+ */
+ void initialize(int* field, const int screenWidth,
+ const int screenHeight, const int numColors);
+
+ /**
+ * Completes one iteration of the algorithm. Returns true if the
algorithm
+ * is completed.
+ */
+ bool calc();
+
+ private:
+ /**
+ * Calculates a new X,Y using a polar spiral. Utilizes an adaptive
+ * algorithm to adjust thetaStep such that the new (x,y) value will
+ * be adjacent but not on the previous (x,y) value.
+ * @param x the previous X value. On return, it is the new X value.
+ * @param y the previous Y value. On return, it is the new Y value.
+ * @param r the previous R value. On return, it is the new R value.
+ * @param theta the previous Theta value. It is updated on return.
+ * @param thetaStep the previous Theta step value. Updated on return.
+ * @return True if the calculation is complete.
+ */
+ bool calcSpiral(double* x, double* y, double* r, double* theta,
+ double* thetaStep);
+
+ /**
+ * 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();
+
+ /**
+ * Rotates and draws the specified segment at (_currX,_currY) based
+ * on _dir.
+ * @param seg Must be either _cornerSeg or _straightSeg.
+ */
+ //void drawSegment(int* seg);
+
+ // begin parameters
+ int _n;
+ int _colorWidth;
+ int _emptyWidth;
+ bool _bConstantColor;
+ bool _bRandomColor;
+ bool _bIncrementColor;
+ // end parameters
+
+ // begin spiral specific
+ double _rCoeff; // accounts for clockwise/counterclockwise!
+ double _currR;
+ double _currTheta;
+ double _lastThetaStep;
+ double _maxR; //!< polar stopping condition
+ // end spiral specific
+
+ double _currX;
+ double _currY;
+ int _nextIdx;
+
+ // begin constants to speed up calculations
+ int _screenXOffset;
+ int _screenYOffset;
+ int _segmentWidth;
+ int _maxFieldIdx; //> _sizeX * _sizeY - 1;
+ // end constants
+
+ // begin debug
+ int _stepCount;
+
+ /*
+ int* _cornerSeg;
+ int* _straightSeg;
+
+ NgonSpiralAlgorithmDir _dir;
+ bool _bClockwise;
+
+ int _xSegs; //> either current or next number of segments
+ int _ySegs; //> either current or next number of segments
+ int _remainingSegs; //> Segments remaining to draw.
+ int _xMaxSegs; //> Maximum number of segments in the x direction.
+ int _yMaxSegs; //> Maximum number of segments in the y direction.
+
+ // These are to speed up some calculations, since they only need done
once.
+ float _halfSegSize; //> _segmentSize / 2.0
+ */
+};
+
+#endif
Modified:
branches/backus_dev/src/common/spirals/RectangularSpiralAlgorithm.cpp
==============================================================================
--- branches/backus_dev/src/common/spirals/RectangularSpiralAlgorithm.cpp
(original)
+++ branches/backus_dev/src/common/spirals/RectangularSpiralAlgorithm.cpp
Sun Apr 26 17:56:58 2009
@@ -1,3 +1,9 @@
+
+// debug
+//#include <iostream>
+//using namespace std;
+// end debug
+
#include "RectangularSpiralAlgorithm.h"
/**
@@ -6,8 +12,67 @@
RectangularSpiralAlgorithm::RectangularSpiralAlgorithm() {
_cornerSeg = NULL;
_straightSeg = NULL;
+
+ _colorWidth = 1;
+ _emptyWidth = 0;
+ _bConstantColor = true;
+ _bRandomColor = false;
+ _bClockwise = false;
+ _bIncrementColor = true;
+ _currX = 0;
+ _currY = 0;
+ _nextIdx = 0;
+ _xSegs = 0;
+ _ySegs = 0;
+ _remainingSegs = 0;
+ _xMaxSegs = 0;
+ _yMaxSegs = 0;
+ _maxFieldIdx = 0;
+ _halfSegSize = 0;
+}
+
+/**
+ * Constructor takes initialization parameters.
+ * @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.
+ * @param bIncrementColor whether to increment the color as it spirals out.
+ * @see calc()
+ */
+RectangularSpiralAlgorithm::RectangularSpiralAlgorithm(const int
colorWidth,
+ const int emptyWidth,
+ const bool bConstantColor,
+ const bool bRandomColor,
+ const bool bIncrementColor) {
+ _cornerSeg = NULL;
+ _straightSeg = NULL;
+
+ _currX = 0;
+ _currY = 0;
+ _nextIdx = 0;
+ _xSegs = 0;
+ _ySegs = 0;
+ _remainingSegs = 0;
+ _xMaxSegs = 0;
+ _yMaxSegs = 0;
+ _maxFieldIdx = 0;
+ _halfSegSize = 0;
+ _bClockwise = false;
+
+ _colorWidth = colorWidth;
+ _emptyWidth = emptyWidth;
+ _bConstantColor = bConstantColor;
+ _bRandomColor = bRandomColor;
+ _bIncrementColor = bIncrementColor;
+
+ if(_colorWidth < 0)
+ _colorWidth = 0;
+ if(_emptyWidth < 0)
+ _emptyWidth = 0;
}
+
RectangularSpiralAlgorithm::~RectangularSpiralAlgorithm() {
if(_cornerSeg != NULL) {
delete [] _cornerSeg;
@@ -25,19 +90,12 @@
* @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);
+void RectangularSpiralAlgorithm::initialize(int* field, const int
screenWidth,
+ const int screenHeight,
+ const int numColors) {
+ initializeBase(field, screenWidth, screenHeight, numColors);
if(_height <= 0)
return;
@@ -46,59 +104,63 @@
if(_numColors <= 0)
return;
- calcSegs();
-
// set initial starting position
_currX = screenWidth / 2;
_currY = screenHeight / 2;
+ _maxFieldIdx = screenWidth * screenHeight - 1;
// pick initial color
- if(bRandomColor) {
+ if(_bRandomColor) {
_nextIdx = jrand() % numColors;
} else {
_nextIdx = 0;
}
// pick direction
- _dir = jrand() % 4;
+ _dir = (RectangularSpiralAlgorithmDir) (jrand() % 4);
_bClockwise = (jrand() % 2 == 0);
+ // begin debug
+ //cout<<"Forcing dir!"<<endl;
+ //_dir = RIGHT;
+ //_bClockwise = true;
+ // end debug
+
// set initial distances
switch(_dir) {
case UP:
- _bXPositive = _bClockwise;
- _xSegs = 2;
+ _xSegs = 1;
- _bYPositive = true;
- _ySegs = 1;
+ _ySegs = 0;
_remainingSegs = 1;
break;
case DOWN:
- _bXPositive = !_bClockwise;
- _xSegs = 2;
+ _xSegs = 1;
- _bYPositive = false;
- _ySegs = 1;
+ _ySegs = 0;
_remainingSegs = 1;
break;
case LEFT:
- _bXPositive = false;
- _xSegs = 1;
+ _xSegs = 0;
_remainingSegs = 1;
- _bYPositive = _bClockwise;
- _ySegs = 2;
+ _ySegs = 1;
break;
case RIGHT:
default:
- _bXPositive = true;
- _xSegs = 1;
+ _xSegs = 0;
_remainingSegs = 1;
- _bYPositive = !_bClockwise;
- _ySegs = 2;
+ _ySegs = 1;
}
+ // calculate segments
+ calcSegments();
+
+ // calculate stopping condition.
+ _xMaxSegs = _width / _segmentSize;
+ _yMaxSegs = _height / _segmentSize;
+
}
/**
@@ -107,105 +169,120 @@
*/
bool RectangularSpiralAlgorithm::calc() {
if(_field == NULL)
- return;
+ return true;
if(_cornerSeg == NULL)
- return;
+ return true;
if(_straightSeg == NULL)
- return;
-
- int i;
+ return true;
/**
- * To Do:
+ * Algorithm:
* - Process a segment
* - Update _currX and/or _currY
* - Update color index, if necessary
* - Decrement _remainingSegs
- * - if _remainingSegs == 0:
+ * - if _remainingSegs == 1:
* - change _dir
- * - update polarities, current/next segs, and _remainingSegs.
+ * - update 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
+ // draw a segment
+ if(_remainingSegs <= 1) {
+ // draw a corner segment
+ drawSegment(_cornerSeg);
+
+ //float halfSegSize = float(_segmentSize)/2;
+
+ // update position and reset _remainingSegs
switch(_dir) {
case UP:
- _dir = _bClockwise ? RIGHT : LEFT;
+ _currY += _halfSegSize;
+ if(_bClockwise) {
+ _currX += _halfSegSize;
+ _dir = RIGHT;
+ } else {
+ _currX -= _halfSegSize;
+ _dir = LEFT;
+ }
+ _ySegs++;
+ _remainingSegs = _xSegs;
break;
case DOWN:
- _dir = _bClockwise ? LEFT : RIGHT;
+ _currY -= _halfSegSize;
+ if(_bClockwise) {
+ _currX -= _halfSegSize;
+ _dir = LEFT;
+ } else {
+ _currX += _halfSegSize;
+ _dir = RIGHT;
+ }
+ _ySegs++;
+ _remainingSegs = _xSegs;
break;
case LEFT:
- _dir = _bClockwise ? UP : DOWN;
+ _currX -= _halfSegSize;
+ if(_bClockwise) {
+ _currY += _halfSegSize;
+ _dir = UP;
+ } else {
+ _currY -= _halfSegSize;
+ _dir = DOWN;
+ }
+ _xSegs++;
+ _remainingSegs = _ySegs;
break;
case RIGHT:
default:
- _dir = _bClockwise ? DOWN : UP;
+ _currX += _halfSegSize;
+ if(_bClockwise) {
+ _currY -= _halfSegSize;
+ _dir = DOWN;
+ } else {
+ _currY += _halfSegSize;
+ _dir = UP;
+ }
+ _xSegs++;
+ _remainingSegs = _ySegs;
}
- }
-
- /*
- // 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
+ // debug
+ //return true;
+ // end debug
+ } else {
+ // draw a straight segment
+ drawSegment(_straightSeg);
+
+ // update position
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;
- }
- }
- }
- }
+ _currY += _segmentSize;
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;
- }
- }
- }
- }
+ _currY -= _segmentSize;
break;
case LEFT:
+ _currX -= _segmentSize;
break;
case RIGHT:
default:
+ _currX += _segmentSize;
+ }
+ _remainingSegs--;
+ }
+
+ // update color index
+ if(!_bConstantColor) {
+ if(_bIncrementColor) {
+ _nextIdx = (_nextIdx+_segmentSize)%_numColors;
+ } else {
+ _nextIdx = _nextIdx - _segmentSize;
+ if(_nextIdx < 0) {
+ _nextIdx = _numColors - _nextIdx;
+ }
}
-*/
+ }
+
+ //return true;
+ return (_xSegs > _xMaxSegs) && (_ySegs > _yMaxSegs);
}
/**
@@ -228,6 +305,7 @@
// set the segment dimension
_segmentSize = _colorWidth + 2*_emptyWidth;
+ _halfSegSize = float(_segmentSize)/2.0;
// create space for the two segments
_straightSeg = new int[_segmentSize * _segmentSize];
@@ -237,9 +315,19 @@
if(_cornerSeg == NULL)
return;
+ int x, y, yCalc;
+
+ // init segment space
+ for(y=0;y<_segmentSize;y++) {
+ yCalc = y*_segmentSize;
+ for(x=0;x<_segmentSize;x++) {
+ _straightSeg[yCalc+x] = -1;
+ _cornerSeg[yCalc+x] = -1;
+ }
+ }
+
// 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++) {
@@ -252,7 +340,11 @@
if(_bConstantColor) {
_straightSeg[yCalc+x] = 0;
} else {
- _straightSeg[yCalc+x] = x;
+ if(_bIncrementColor) {
+ _straightSeg[yCalc+x] = x;
+ } else {
+ _straightSeg[yCalc+x] = _segmentSize - x - 1;
+ }
}
}
}
@@ -265,26 +357,119 @@
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)];
+ _cornerSeg[yCalc+x] = _straightSeg[(_segmentSize -x -1)*_segmentSize
+ + (_segmentSize -y -1)];
}
}
}
} else {
for(y = 0; y<_segmentSize; y++) {
yCalc = y*_segmentSize;
- yInvCalc = (_segmentSize - y)*_segmentSize;
for(x = 0; x<_segmentSize; x++) {
- if(x < (_segmentSize-y)) {
+ if(x < _segmentSize-y-1) {
_cornerSeg[yCalc+x] = _straightSeg[yCalc+x];
} else {
- _cornerSeg[yCalc+x] = _straightSeg[yInvCalc+(_segmentSize-x)];
+ _cornerSeg[yCalc+x] = _straightSeg[x*_segmentSize + y];
}
}
}
+ }
+}
+
+/**
+ * Rotates and draws the specified segment at (_currX,_currY) based
+ * on _dir.
+ */
+void RectangularSpiralAlgorithm::drawSegment(int* seg) {
+ if(seg == NULL)
+ return;
+
+ // first, we need to translate the _currX and _currY positions to
+ // the lower left-hand corner. Remember: (_currX,_currY) is the
+ // midpoint of the side opposite the direction we're going. i.e.
+ // (_currX,_currY) is the midpoint of the left side when going right.
+ float xCornerFloat, yCornerFloat;
+
+ switch(_dir) {
+ case UP:
+ xCornerFloat = _currX - _halfSegSize;
+ yCornerFloat = _currY;
+ break;
+ case DOWN:
+ xCornerFloat = _currX - _halfSegSize;
+ yCornerFloat = _currY - float(_segmentSize);
+ break;
+ case LEFT:
+ xCornerFloat = _currX - float(_segmentSize);
+ yCornerFloat = _currY - _halfSegSize;
+ break;
+ case RIGHT:
+ default:
+ xCornerFloat = _currX;
+ yCornerFloat = _currY - _halfSegSize;
+ }
+
+ // there seems to be a rounding error
+ if(xCornerFloat < 0.0) {
+ xCornerFloat -= 0.5;
+ }
+ if(yCornerFloat < 0.0) {
+ yCornerFloat -= 0.5;
+ }
+ int xCorner = xCornerFloat;
+ int yCorner = yCornerFloat;
+
+ // adjust yCorner to be ready for copying
+ int yCornerAdjusted = yCorner * _width;
+
+ // now copy from seg to _field. Modifying (x,y) in order
+ // to rotate:
+ // Rt: field(x,y) = seg( x, y)
+ // Up: field(x,y) = seg(-y, x)
+ // Lf: field(x,y) = seg(-x,-y)
+ // Dn: field(x,y) = seg( y,-x)
+
+ for(int i=0; i<_segmentSize; i++) {
+ int fieldY = i*_width;
+ for(int j=0; j<_segmentSize; j++) {
+ // set (x,y) = rot(j,i)
+ int x;
+ int y;
+ switch(_dir) {
+ case UP:
+ x = i;
+ y = _segmentSize-j-1;
+ break;
+ case DOWN:
+ x = _segmentSize-i-1;
+ y = j;
+ break;
+ case LEFT:
+ x = _segmentSize-j-1;
+ y = _segmentSize-i-1;
+ break;
+ case RIGHT:
+ default:
+ x = j;
+ y = i;
+ }
+
+ // copy
+ int ySeg = y*_segmentSize;
+ int fieldIdx = yCornerAdjusted+fieldY+xCorner+j;
+ if(0 <= xCorner+j && xCorner+j < _width &&
+ 0 <= yCorner+i && yCorner+i < _height &&
+ 0 <= ySeg+x && ySeg+x < _segmentSize*_segmentSize-1) {
+ if(seg[ySeg + x] < 0) {
+ _field[fieldIdx] = -1;
+ } else {
+ _field[fieldIdx] = (_nextIdx + seg[ySeg + x]) % _numColors;
+ }
+ }
+ }
}
}
Modified:
branches/backus_dev/src/common/spirals/RectangularSpiralAlgorithm.h
==============================================================================
--- branches/backus_dev/src/common/spirals/RectangularSpiralAlgorithm.h
(original)
+++ branches/backus_dev/src/common/spirals/RectangularSpiralAlgorithm.h Sun
Apr 26 17:56:58 2009
@@ -27,6 +27,7 @@
*/
#include "utility/misc_funcs.h"
+#include "SpiralAlgorithm.h"
#ifndef __RECTANGULARSPIRALALGORITHM_H__
#define __RECTANGULARSPIRALALGORITHM_H__
@@ -38,10 +39,23 @@
public:
/**
- * Constructor.
+ * Default constructor.
*/
RectangularSpiralAlgorithm();
+ /**
+ * Constructor takes initialization parameters.
+ * @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.
+ * @param bIncrementColor whether to increment the color as it spirals
out.
+ * @see calc()
+ */
+ RectangularSpiralAlgorithm(const int colorWidth, const int emptyWidth,
+ const bool bConstantColor, const bool bRandomColor,
+ const bool bIncrementColor);
+
~RectangularSpiralAlgorithm();
/**
@@ -50,15 +64,9 @@
* @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);
+ void initialize(int* field, const int screenWidth, const int
screenHeight,
+ const int numColors);
/**
* Completes one iteration of the algorithm. Returns true if the
algorithm
@@ -81,21 +89,38 @@
*/
void calcSegments();
+ /**
+ * Rotates and draws the specified segment at (_currX,_currY) based
+ * on _dir.
+ * @param seg Must be either _cornerSeg or _straightSeg.
+ */
+ void drawSegment(int* seg);
+
+ int _colorWidth;
+ int _emptyWidth;
+ bool _bConstantColor;
+ bool _bRandomColor;
+ bool _bIncrementColor;
+
int _segmentSize;
int* _cornerSeg;
int* _straightSeg;
RectangularSpiralAlgorithmDir _dir;
bool _bClockwise;
- int _currX;
- int _currY;
+ float _currX;
+ float _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;
+ int _remainingSegs; //> Segments remaining to draw.
+ int _xMaxSegs; //> Maximum number of segments in the x direction.
+ int _yMaxSegs; //> Maximum number of segments in the y direction.
+
+ // These are to speed up some calculations, since they only need done
once.
+ int _maxFieldIdx; //> _sizeX * _sizeY - 1;
+ float _halfSegSize; //> _segmentSize / 2.0
};
Modified: branches/backus_dev/src/common/spirals/SpiralAlgorithm.cpp
==============================================================================
--- branches/backus_dev/src/common/spirals/SpiralAlgorithm.cpp (original)
+++ branches/backus_dev/src/common/spirals/SpiralAlgorithm.cpp Sun Apr 26
17:56:58 2009
@@ -8,9 +8,6 @@
_width = 0;
_height = 0;
_numColors = 0;
- _colorWidth = 1;
- _emptyWidth = 0;
- _bConstantColor = false;
}
SpiralAlgorithm::~SpiralAlgorithm() {
@@ -24,18 +21,13 @@
* @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) {
+void SpiralAlgorithm::initialize(int* field, const int screenWidth,
+ const int screenHeight,
+ const int numColors) {
- initializeBase(field, screenWidth, screenHeight, numColors, colorWidth,
- colorHeight, bConstantColor);
+ initializeBase(field, screenWidth, screenHeight, numColors);
}
/**
@@ -51,7 +43,7 @@
* Completes up to numIterations iterations of the algorithm. If N <= 0,
* the algorithm will continue until finished.
*/
-bool SpiralAlgorithm::calc(int numIterations) {
+bool SpiralAlgorithm::calc(const int numIterations) {
for(int i=0; i<numIterations; i++) {
if(calc())
return true;
@@ -72,26 +64,14 @@
* @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) {
+void SpiralAlgorithm::initializeBase(int* field, const int screenWidth,
+ const int screenHeight,
+ const int numColors) {
_field = field;
_width = screenWidth;
_height = screenHeight;
_numColors = numColors;
- _colorWidth = colorWidth;
- _emptyWidth = emptyWidth;
- _bConstantColor = bConstantColor;
-
- if(_colorWidth < 0)
- _colorWidth = 0;
- if(_emptyWidth < 0)
- _emptyWidth = 0;
}
Modified: branches/backus_dev/src/common/spirals/SpiralAlgorithm.h
==============================================================================
--- branches/backus_dev/src/common/spirals/SpiralAlgorithm.h (original)
+++ branches/backus_dev/src/common/spirals/SpiralAlgorithm.h Sun Apr 26
17:56:58 2009
@@ -26,15 +26,16 @@
* This is the base class for the spiral algorithms.
*/
-/*
-#include <stdlib.h>
-#include <ctime>
-using namespace std;
-*/
-
#ifndef __SPIRALALGORITHM_H__
#define __SPIRALALGORITHM_H__
+#ifdef _M_IX86
+#include <windows.h>
+#else
+//#include <stream.h>
+#include <stdlib.h>
+#endif
+
class SpiralAlgorithm {
public:
@@ -52,15 +53,10 @@
* @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);
+ virtual void initialize(int* field, const int screenWidth,
+ const int screenHeight, const int numColors);
/**
* Completes one iteration of the algorithm. Returns true if the
algorithm
@@ -75,7 +71,7 @@
* @return true if the spiral generation is complete.
* @see calc();
*/
- bool calc(int numIterations);
+ bool calc(const int numIterations);
/**
* This is a convenience function that is the same as calling calc(-1).
@@ -90,21 +86,16 @@
* @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 bIncrementColor whether the colors increment as they spiral
out.
* @see initialize()
*/
- void initialize(int* field, int screenWidth, int screenHeight,
- int numColors, int colorWidth, int emptyWidth,
- bool bConstantColor);
+ void initializeBase(int* field, const int screenWidth, const int
screenHeight,
+ const int numColors);
int _width;
int _height;
int _numColors;
- int _colorWidth;
- int _emptyWidth;
- bool _bConstantColor;
+ int* _field;
};
#endif
Modified: branches/backus_dev/src/common/utility/misc_funcs.cpp
==============================================================================
--- branches/backus_dev/src/common/utility/misc_funcs.cpp (original)
+++ branches/backus_dev/src/common/utility/misc_funcs.cpp Sun Apr 26
17:56:58 2009
@@ -103,3 +103,16 @@
return Qt::Unchecked;
}
+/**
+ * Rounds a float to the nearest whole number and casts to integer.
+ */
+int roundFtoI(const float& val) {
+ return (val < 0.0) ? int(val-0.5) : int(val+0.5);
+}
+
+/**
+ * Rounds a double to the nearest whole number and casts to integer.
+ */
+int roundDtoI(const double& val) {
+ return (val < 0.0) ? int(val-0.5) : int(val+0.5);
+}
Modified: branches/backus_dev/src/common/utility/misc_funcs.h
==============================================================================
--- branches/backus_dev/src/common/utility/misc_funcs.h (original)
+++ branches/backus_dev/src/common/utility/misc_funcs.h Sun Apr 26 17:56:58
2009
@@ -24,6 +24,8 @@
#include <QString>
+//#ifndef __MISC_FUNCS_H__
+//#define __MISC_FUNCS_H__
/**
* Returns a random integer just like rand() does, however it will
* periodically reseed the generator using the current time.
@@ -55,3 +57,19 @@
* Converts the specified bool to Qt::CheckState.
*/
extern Qt::CheckState boolToCheckState(bool bVal);
+
+/**
+ * Rounds a float to the nearest whole number and casts to integer.
+ */
+extern int roundFtoI(const float& val);/* {
+ return (val < 0.0) ? int(val-0.5) : int(val+0.5);
+ }*/
+
+/**
+ * Rounds a double to the nearest whole number and casts to integer.
+ */
+extern int roundDtoI(const double& val);/* {
+ return (val < 0.0) ? int(val-0.5) : int(val+0.5);
+ }*/
+
+//#endif