]> git.xonotic.org Git - xonotic/netradiant.git/commitdiff
* added MeshTex plugin src to project (can't compile)
authorGarux <garux@mail.ru>
Tue, 1 Aug 2017 11:09:50 +0000 (14:09 +0300)
committerGarux <garux@mail.ru>
Tue, 1 Aug 2017 11:09:50 +0000 (14:09 +0300)
48 files changed:
Makefile
contrib/meshtex/.gitattributes [new file with mode: 0644]
contrib/meshtex/.gitignore [new file with mode: 0644]
contrib/meshtex/AllocatedMatrix.h [new file with mode: 0644]
contrib/meshtex/COMPILING [new file with mode: 0644]
contrib/meshtex/Doxyfile [new file with mode: 0644]
contrib/meshtex/GeneralFunctionDialog.cpp [new file with mode: 0644]
contrib/meshtex/GeneralFunctionDialog.h [new file with mode: 0644]
contrib/meshtex/GenericDialog.cpp [new file with mode: 0644]
contrib/meshtex/GenericDialog.h [new file with mode: 0644]
contrib/meshtex/GenericMainMenu.cpp [new file with mode: 0644]
contrib/meshtex/GenericMainMenu.h [new file with mode: 0644]
contrib/meshtex/GenericPluginUI.cpp [new file with mode: 0644]
contrib/meshtex/GenericPluginUI.h [new file with mode: 0644]
contrib/meshtex/GenericPluginUIMessages.h [new file with mode: 0644]
contrib/meshtex/GetInfoDialog.cpp [new file with mode: 0644]
contrib/meshtex/GetInfoDialog.h [new file with mode: 0644]
contrib/meshtex/HISTORY [new file with mode: 0644]
contrib/meshtex/LICENSE [new file with mode: 0644]
contrib/meshtex/MainMenu.cpp [new file with mode: 0644]
contrib/meshtex/MainMenu.h [new file with mode: 0644]
contrib/meshtex/MeshEntity.cpp [new file with mode: 0644]
contrib/meshtex/MeshEntity.h [new file with mode: 0644]
contrib/meshtex/MeshEntityMessages.h [new file with mode: 0644]
contrib/meshtex/MeshVisitor.cpp [new file with mode: 0644]
contrib/meshtex/MeshVisitor.h [new file with mode: 0644]
contrib/meshtex/PluginModule.cpp [new file with mode: 0644]
contrib/meshtex/PluginModule.h [new file with mode: 0644]
contrib/meshtex/PluginProperties.h [new file with mode: 0644]
contrib/meshtex/PluginRegistration.cpp [new file with mode: 0644]
contrib/meshtex/PluginUI.cpp [new file with mode: 0644]
contrib/meshtex/PluginUI.h [new file with mode: 0644]
contrib/meshtex/PluginUIMessages.h [new file with mode: 0644]
contrib/meshtex/README.md [new file with mode: 0644]
contrib/meshtex/RefCounted.cpp [new file with mode: 0644]
contrib/meshtex/RefCounted.h [new file with mode: 0644]
contrib/meshtex/SetScaleDialog.cpp [new file with mode: 0644]
contrib/meshtex/SetScaleDialog.h [new file with mode: 0644]
contrib/meshtex/UtilityMacros.h [new file with mode: 0644]
contrib/meshtex/docs/docs.7z [new file with mode: 0644]
contrib/meshtex/localdirs.vsprops [new file with mode: 0644]
contrib/meshtex/mainpage.dox [new file with mode: 0644]
contrib/meshtex/meshtex.def [new file with mode: 0644]
contrib/meshtex/meshtex.rc [new file with mode: 0644]
contrib/meshtex/meshtex.sln [new file with mode: 0644]
contrib/meshtex/meshtex.vcproj [new file with mode: 0644]
contrib/meshtex/modules.dox [new file with mode: 0644]
contrib/meshtex/resource.h [new file with mode: 0644]

index 457f459af41166fc89d9ec437264fdfc9227aa61..661aec24bfb1f98197235eb718a49dd54bc9b1bd 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -397,6 +397,7 @@ binaries-radiant-plugins: \
        $(INSTALLDIR)/plugins/shaderplug.$(DLL) \
        $(INSTALLDIR)/plugins/sunplug.$(DLL) \
        $(INSTALLDIR)/plugins/ufoaiplug.$(DLL) \
+       $(INSTALLDIR)/plugins/meshtex.$(DLL) \
 
 .PHONY: binaries-radiant
 binaries-radiant-core: \
@@ -1002,6 +1003,23 @@ $(INSTALLDIR)/plugins/ufoaiplug.$(DLL): \
        contrib/ufoaiplug/ufoai_level.o \
        contrib/ufoaiplug/ufoai.o \
 
+$(INSTALLDIR)/plugins/meshtex.$(DLL): LIBS_EXTRA := $(LIBS_GLIB) $(LIBS_GTK)
+$(INSTALLDIR)/plugins/meshtex.$(DLL): CPPFLAGS_EXTRA := $(CPPFLAGS_GLIB) $(CPPFLAGS_GTK) -Ilibs -Iinclude
+$(INSTALLDIR)/plugins/meshtex.$(DLL): \
+       contrib/meshtex/GeneralFunctionDialog.o \
+       contrib/meshtex/GenericDialog.o \
+       contrib/meshtex/GenericMainMenu.o \
+       contrib/meshtex/GenericPluginUI.o \
+       contrib/meshtex/GetInfoDialog.o \
+       contrib/meshtex/MainMenu.o \
+       contrib/meshtex/MeshEntity.o \
+       contrib/meshtex/MeshVisitor.o \
+       contrib/meshtex/PluginModule.o \
+       contrib/meshtex/PluginRegistration.o \
+       contrib/meshtex/PluginUI.o \
+       contrib/meshtex/RefCounted.o \
+       contrib/meshtex/SetScaleDialog.o \
+
 $(INSTALLDIR)/plugins/bkgrnd2d.$(DLL): LIBS_EXTRA := $(LIBS_GLIB) $(LIBS_GTK)
 $(INSTALLDIR)/plugins/bkgrnd2d.$(DLL): CPPFLAGS_EXTRA := $(CPPFLAGS_GLIB) $(CPPFLAGS_GTK) -Ilibs -Iinclude
 $(INSTALLDIR)/plugins/bkgrnd2d.$(DLL): \
diff --git a/contrib/meshtex/.gitattributes b/contrib/meshtex/.gitattributes
new file mode 100644 (file)
index 0000000..dfe0770
--- /dev/null
@@ -0,0 +1,2 @@
+# Auto detect text files and perform LF normalization
+* text=auto
diff --git a/contrib/meshtex/.gitignore b/contrib/meshtex/.gitignore
new file mode 100644 (file)
index 0000000..db8ef93
--- /dev/null
@@ -0,0 +1,10 @@
+# Visual Studio generated files
+*.aps
+*.ncb
+*.suo
+*.user
+CodeVersion.h
+
+# build results
+Debug/
+Release/
diff --git a/contrib/meshtex/AllocatedMatrix.h b/contrib/meshtex/AllocatedMatrix.h
new file mode 100644 (file)
index 0000000..db3850f
--- /dev/null
@@ -0,0 +1,67 @@
+/**
+ * @file AllocatedMatrix.h
+ * Declares and implements the AllocatedMatrix template class.
+ * @ingroup meshtex-util
+ */
+
+/*
+ * Copyright 2012 Joel Baxter
+ *
+ * This file is part of MeshTex.
+ *
+ * MeshTex is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MeshTex is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MeshTex.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#if !defined(INCLUDED_ALLOCATEDMATRIX_H)
+#define INCLUDED_ALLOCATEDMATRIX_H
+
+#include "debugging/debugging.h"
+#include "ipatch.h"
+
+/**
+ * Matrix subclass that allocates its data array on construction and
+ * deallocates it on destruction.
+ *
+ * @ingroup meshtex-util
+ */
+template<typename Element>
+class AllocatedMatrix : public Matrix<Element>
+{
+       std::size_t m_x, m_y;
+       Element* m_data; 
+public: // public methods
+
+   /**
+    * Constructor. Allocates a data array of the appropriate size.
+    *
+    * @param x Matrix x dimension.
+    * @param y Matrix y dimension.
+    */
+   AllocatedMatrix(std::size_t x, std::size_t y) : m_x(x), m_y(y), m_data(_allocated = new Element[x*y]){}
+//      Matrix(x, y, (_allocated = new Element[x*y])) {}
+
+   /**
+    * Destructor. Deallocates the data array.
+    */
+   ~AllocatedMatrix() { delete [] _allocated; }
+
+private: // private member vars
+
+   /**
+    * Pointer to the data array so that the destructor can find it for deletion.
+    */
+   Element *_allocated;
+};
+
+#endif // #if !defined(INCLUDED_ALLOCATEDMATRIX_H)
\ No newline at end of file
diff --git a/contrib/meshtex/COMPILING b/contrib/meshtex/COMPILING
new file mode 100644 (file)
index 0000000..56ce951
--- /dev/null
@@ -0,0 +1,65 @@
+*** Downloading the latest source:
+
+https://github.com/neogeographica/MeshTex
+
+
+*** Downloading dependences:
+
+This project depends on sources/SDKs for GtkRadiant 1.5, GTK+ 2, and STLport 5.  It was most recently compiled against minor versions GtkRadiant 1.5.0, GTK+ 2.24.10 (32-bit), and STLport 5.2.1.  At the time of writing this file, those were available at:
+
+  - GtkRadiant 1.5: https://github.com/TTimo/GtkRadiant/tree/1.5-release
+  - GTK+ 2 stack: http://www.gtk.org/download/index.php
+  - STLport 5: http://sourceforge.net/projects/stlport/files/STLport/
+
+Note that you should get the entire GTK+ stack (linked as an "all-in-one bundle" on the GTK+ download page), not just the gtk library.
+
+Unzip the resources that you download and place them in a handy location that can be accessed by the computer you will be using to build the plugin.  You do not need to build any libraries for these dependences:
+
+  - For GtkRadiant, only the header files are important.
+  - The GTK+ download includes prebuilt libraries.
+  - STLport does not need a library built, as long as you are not using STL iostreams.  In the folder where you placed the STLport distribution, navigate into stlport\stl\config and open user_config.h in a text editor.  Uncomment the line that defines _STLP_NO_IOSTREAMS to a value of 1.
+
+You also need an installation of the GtkRadiant 1.5 application in order to actually use the plugin.  Rather than building it from source, you will probably just want to download and execute the usual GtkRadiant installer: http://icculus.org/gtkradiant/downloads.html#gtkr15
+
+It can also be helpful to have git installed... which you probably do, if you got this from GitHub.  Nevertheless it's not actually necessary to have git available during the compile process; it's just used to gather some information if it is available, as described below.
+
+
+*** Building:
+
+There's no platform-specific code in the MeshTex plugin, but currently I'm only building it on Windows.  Adventurous Mac/Linux porters are welcome to have a go.
+
+meshtex.sln is a Visual Studio 2008 solution.  (It may very well also import correctly into later versions of Visual Studio.)
+
+Open meshtex.sln using Visual Studio.  Before building the project you must configure a few directories, as follows:
+
+- In the left pane, choose the Property Manager tab.
+- Under either the "Debug | Win32" or "Release | Win32" folder (it doesn't matter which), double-click on "localdirs".  This opens a custom properties dialog.
+- On the left side of the custom properties dialog, select "User Macros".  This will display definitions for some necessary directories on the right side of the dialog.
+- On the right side, double-click on "RadiantSrcDir".  This will open a dialog to edit its value.
+- Replace the Value entry here with the correct path to the root of your GtkRadiant source.  The directory referenced here should be the one that CONTAINS the "include" and "libs" directories.
+- Click OK to set that value for "RadiantSrcDir".
+- Similarly you should edit the value for "StlportDir".  The directory referenced here is the one that CONTAINS the "stlport" directory for your downloaded STLport source.
+- Similarly you should edit the value for "GtkDir".  The directory referenced here is the one that CONTAINS the "include" and "lib" directories for your downloaded GTK+ SDK.
+- Similarly you should edit the value for "GitDir".  The directory referenced here is the one that contains the "git.exe" program on your system.  If you don't have git installed, this can be any bogus path.  It is used in a pre-build step as described below.
+- Finally, edit the value for "RadiantExeDir".  The directory referenced here is the one that contains "GtkRadiant.exe" for your working installation of the GtkRadiant 1.5 application.  It is used in a post-build step as described below.
+- Click the OK button to accept and close the dialog.
+
+Once you have configured the directories, it seems to be helpful to quit out of Visual Studio (save your changes when prompted) and restart before attempting to build.
+
+The build process has a pre-build step that uses <GitDir>/git to find the current git commit hash for the codebase that you are building.  This commit hash is placed in a generated header file, CodeVersion.h.  If the git executable cannot be located then the string "n/a" will be used for the commit hash.  During the build process the commit hash will be used as part of the product version string that will be visible in the DLL properties.  This information is just FYI; you don't need to do anything about this other than set the value of GitDir as per above if you do have git installed.
+
+The build process also has a post-build step that will copy meshtex.dll to <RadiantExeDir>/plugins after each build.  If RadiantExeDir points to a protected directory that requires elevated user permissions (such as "Program Files (x86)") then you will need to be running Visual Studio as administrator in order for this copy to succeed.
+
+If you do NOT want the build process to perform the post-build copy of meshtex.dll, then follow these steps:
+
+- Right click on the "meshtex" project in the Solution Explorer or Property Manager, and choose "properties".  This opens its properties dialog.
+- In the "Configuration" dropdown, choose "All Configurations".
+- On the left side of the dialog, find "Post-Build Event" under "Build Events", which is under "Configuration Properties".  Select "Post-Build Event".
+- The right-hand side should now show the command line and description for the copy process.
+- The right-hand side also has a property called "Excluded From Build".  Change that from "No" to "Yes".
+- Click the OK button to accept and close the dialog.
+
+
+You should be ready to build!  Press F7, or select "Build Solution" from the "Build" menu on the top bar.
+
+After building, you can run GtkRadiant by pressing F5, or selecting "Start Debugging" from the "Debug" menu on the top bar.  If you have not removed the post-build copy step -- and that step has succeeded -- then GtkRadiant will have the most recently built version of the plugin installed.
diff --git a/contrib/meshtex/Doxyfile b/contrib/meshtex/Doxyfile
new file mode 100644 (file)
index 0000000..2ca3c81
--- /dev/null
@@ -0,0 +1,1795 @@
+# Doxyfile 1.8.1.1
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project
+#
+# All text after a hash (#) is considered a comment and will be ignored
+# The format is:
+#       TAG = value [value, ...]
+# For lists items can also be appended using:
+#       TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (" ")
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+# This tag specifies the encoding used for all characters in the config file 
+# that follow. The default is UTF-8 which is also the encoding used for all 
+# text before the first occurrence of this tag. Doxygen uses libiconv (or the 
+# iconv built into libc) for the transcoding. See 
+# http://www.gnu.org/software/libiconv for the list of possible encodings.
+
+DOXYFILE_ENCODING      = UTF-8
+
+# The PROJECT_NAME tag is a single word (or sequence of words) that should 
+# identify the project. Note that if you do not use Doxywizard you need 
+# to put quotes around the project name if it contains spaces.
+
+PROJECT_NAME           = MeshTex
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number. 
+# This could be handy for archiving the generated documentation or 
+# if some version control system is used.
+
+PROJECT_NUMBER         = 3.0
+
+# Using the PROJECT_BRIEF tag one can provide an optional one line description 
+# for a project that appears at the top of each page and should give viewer 
+# a quick idea about the purpose of the project. Keep the description short.
+
+PROJECT_BRIEF          = 
+
+# With the PROJECT_LOGO tag one can specify an logo or icon that is 
+# included in the documentation. The maximum height of the logo should not 
+# exceed 55 pixels and the maximum width should not exceed 200 pixels. 
+# Doxygen will copy the logo to the output directory.
+
+PROJECT_LOGO           = 
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) 
+# base path where the generated documentation will be put. 
+# If a relative path is entered, it will be relative to the location 
+# where doxygen was started. If left blank the current directory will be used.
+
+OUTPUT_DIRECTORY       = docs
+
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 
+# 4096 sub-directories (in 2 levels) under the output directory of each output 
+# format and will distribute the generated files over these directories. 
+# Enabling this option can be useful when feeding doxygen a huge amount of 
+# source files, where putting all generated files in the same directory would 
+# otherwise cause performance problems for the file system.
+
+CREATE_SUBDIRS         = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all 
+# documentation generated by doxygen is written. Doxygen will use this 
+# information to generate all constant output in the proper language. 
+# The default language is English, other supported languages are: 
+# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, 
+# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, 
+# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English 
+# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, 
+# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, 
+# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.
+
+OUTPUT_LANGUAGE        = English
+
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will 
+# include brief member descriptions after the members that are listed in 
+# the file and class documentation (similar to JavaDoc). 
+# Set to NO to disable this.
+
+BRIEF_MEMBER_DESC      = YES
+
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend 
+# the brief description of a member or function before the detailed description. 
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the 
+# brief descriptions will be completely suppressed.
+
+REPEAT_BRIEF           = YES
+
+# This tag implements a quasi-intelligent brief description abbreviator 
+# that is used to form the text in various listings. Each string 
+# in this list, if found as the leading text of the brief description, will be 
+# stripped from the text and the result after processing the whole list, is 
+# used as the annotated text. Otherwise, the brief description is used as-is. 
+# If left blank, the following values are used ("$name" is automatically 
+# replaced with the name of the entity): "The $name class" "The $name widget" 
+# "The $name file" "is" "provides" "specifies" "contains" 
+# "represents" "a" "an" "the"
+
+ABBREVIATE_BRIEF       = "The $name class" \
+                         "The $name widget" \
+                         "The $name file" \
+                         is \
+                         provides \
+                         specifies \
+                         contains \
+                         represents \
+                         a \
+                         an \
+                         the
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then 
+# Doxygen will generate a detailed section even if there is only a brief 
+# description.
+
+ALWAYS_DETAILED_SEC    = NO
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all 
+# inherited members of a class in the documentation of that class as if those 
+# members were ordinary class members. Constructors, destructors and assignment 
+# operators of the base classes will not be shown.
+
+INLINE_INHERITED_MEMB  = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full 
+# path before files name in the file list and in the header files. If set 
+# to NO the shortest path that makes the file name unique will be used.
+
+FULL_PATH_NAMES        = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag 
+# can be used to strip a user-defined part of the path. Stripping is 
+# only done if one of the specified strings matches the left-hand part of 
+# the path. The tag can be used to show relative paths in the file list. 
+# If left blank the directory from which doxygen is run is used as the 
+# path to strip.
+
+STRIP_FROM_PATH        = 
+
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of 
+# the path mentioned in the documentation of a class, which tells 
+# the reader which header file to include in order to use a class. 
+# If left blank only the name of the header file containing the class 
+# definition is used. Otherwise one should specify the include paths that 
+# are normally passed to the compiler using the -I flag.
+
+STRIP_FROM_INC_PATH    = 
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter 
+# (but less readable) file names. This can be useful if your file system 
+# doesn't support long names like on DOS, Mac, or CD-ROM.
+
+SHORT_NAMES            = NO
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen 
+# will interpret the first line (until the first dot) of a JavaDoc-style 
+# comment as the brief description. If set to NO, the JavaDoc 
+# comments will behave just like regular Qt-style comments 
+# (thus requiring an explicit @brief command for a brief description.)
+
+JAVADOC_AUTOBRIEF      = YES
+
+# If the QT_AUTOBRIEF tag is set to YES then Doxygen will 
+# interpret the first line (until the first dot) of a Qt-style 
+# comment as the brief description. If set to NO, the comments 
+# will behave just like regular Qt-style comments (thus requiring 
+# an explicit \brief command for a brief description.)
+
+QT_AUTOBRIEF           = NO
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen 
+# treat a multi-line C++ special comment block (i.e. a block of //! or /// 
+# comments) as a brief description. This used to be the default behaviour. 
+# The new default is to treat a multi-line C++ comment block as a detailed 
+# description. Set this tag to YES if you prefer the old behaviour instead.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented 
+# member inherits the documentation from any documented member that it 
+# re-implements.
+
+INHERIT_DOCS           = YES
+
+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce 
+# a new page for each member. If set to NO, the documentation of a member will 
+# be part of the file/class/namespace that contains it.
+
+SEPARATE_MEMBER_PAGES  = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab. 
+# Doxygen uses this value to replace tabs by spaces in code fragments.
+
+TAB_SIZE               = 8
+
+# This tag can be used to specify a number of aliases that acts 
+# as commands in the documentation. An alias has the form "name=value". 
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to 
+# put the command \sideeffect (or @sideeffect) in the documentation, which 
+# will result in a user-defined paragraph with heading "Side Effects:". 
+# You can put \n's in the value part of an alias to insert newlines.
+
+ALIASES                = 
+
+# This tag can be used to specify a number of word-keyword mappings (TCL only). 
+# A mapping has the form "name=value". For example adding 
+# "class=itcl::class" will allow you to use the command class in the 
+# itcl::class meaning.
+
+TCL_SUBST              = 
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C 
+# sources only. Doxygen will then generate output that is more tailored for C. 
+# For instance, some of the names that are used will be different. The list 
+# of all members will be omitted, etc.
+
+OPTIMIZE_OUTPUT_FOR_C  = NO
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java 
+# sources only. Doxygen will then generate output that is more tailored for 
+# Java. For instance, namespaces will be presented as packages, qualified 
+# scopes will look different, etc.
+
+OPTIMIZE_OUTPUT_JAVA   = NO
+
+# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran 
+# sources only. Doxygen will then generate output that is more tailored for 
+# Fortran.
+
+OPTIMIZE_FOR_FORTRAN   = NO
+
+# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL 
+# sources. Doxygen will then generate output that is tailored for 
+# VHDL.
+
+OPTIMIZE_OUTPUT_VHDL   = NO
+
+# Doxygen selects the parser to use depending on the extension of the files it 
+# parses. With this tag you can assign which parser to use for a given extension. 
+# Doxygen has a built-in mapping, but you can override or extend it using this 
+# tag. The format is ext=language, where ext is a file extension, and language 
+# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, 
+# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make 
+# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C 
+# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions 
+# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen.
+
+EXTENSION_MAPPING      = 
+
+# If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all 
+# comments according to the Markdown format, which allows for more readable 
+# documentation. See http://daringfireball.net/projects/markdown/ for details. 
+# The output of markdown processing is further processed by doxygen, so you 
+# can mix doxygen, HTML, and XML commands with Markdown formatting. 
+# Disable only in case of backward compatibilities issues.
+
+MARKDOWN_SUPPORT       = NO
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want 
+# to include (a tag file for) the STL sources as input, then you should 
+# set this tag to YES in order to let doxygen match functions declarations and 
+# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. 
+# func(std::string) {}). This also makes the inheritance and collaboration 
+# diagrams that involve STL classes more complete and accurate.
+
+BUILTIN_STL_SUPPORT    = YES
+
+# If you use Microsoft's C++/CLI language, you should set this option to YES to 
+# enable parsing support.
+
+CPP_CLI_SUPPORT        = NO
+
+# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. 
+# Doxygen will parse them like normal C++ but will assume all classes use public 
+# instead of private inheritance when no explicit protection keyword is present.
+
+SIP_SUPPORT            = NO
+
+# For Microsoft's IDL there are propget and propput attributes to indicate getter 
+# and setter methods for a property. Setting this option to YES (the default) 
+# will make doxygen replace the get and set methods by a property in the 
+# documentation. This will only work if the methods are indeed getting or 
+# setting a simple type. If this is not the case, or you want to show the 
+# methods anyway, you should set this option to NO.
+
+IDL_PROPERTY_SUPPORT   = NO
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC 
+# tag is set to YES, then doxygen will reuse the documentation of the first 
+# member in the group (if any) for the other members of the group. By default 
+# all members of a group must be documented explicitly.
+
+DISTRIBUTE_GROUP_DOC   = NO
+
+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of 
+# the same type (for instance a group of public functions) to be put as a 
+# subgroup of that type (e.g. under the Public Functions section). Set it to 
+# NO to prevent subgrouping. Alternatively, this can be done per class using 
+# the \nosubgrouping command.
+
+SUBGROUPING            = YES
+
+# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and 
+# unions are shown inside the group in which they are included (e.g. using 
+# @ingroup) instead of on a separate page (for HTML and Man pages) or 
+# section (for LaTeX and RTF).
+
+INLINE_GROUPED_CLASSES = NO
+
+# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and 
+# unions with only public data fields will be shown inline in the documentation 
+# of the scope in which they are defined (i.e. file, namespace, or group 
+# documentation), provided this scope is documented. If set to NO (the default), 
+# structs, classes, and unions are shown on a separate page (for HTML and Man 
+# pages) or section (for LaTeX and RTF).
+
+INLINE_SIMPLE_STRUCTS  = NO
+
+# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum 
+# is documented as struct, union, or enum with the name of the typedef. So 
+# typedef struct TypeS {} TypeT, will appear in the documentation as a struct 
+# with name TypeT. When disabled the typedef will appear as a member of a file, 
+# namespace, or class. And the struct will be named TypeS. This can typically 
+# be useful for C code in case the coding convention dictates that all compound 
+# types are typedef'ed and only the typedef is referenced, never the tag name.
+
+TYPEDEF_HIDES_STRUCT   = YES
+
+# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to 
+# determine which symbols to keep in memory and which to flush to disk. 
+# When the cache is full, less often used symbols will be written to disk. 
+# For small to medium size projects (<1000 input files) the default value is 
+# probably good enough. For larger projects a too small cache size can cause 
+# doxygen to be busy swapping symbols to and from disk most of the time 
+# causing a significant performance penalty. 
+# If the system has enough physical memory increasing the cache will improve the 
+# performance by keeping more symbols in memory. Note that the value works on 
+# a logarithmic scale so increasing the size by one will roughly double the 
+# memory usage. The cache size is given by this formula: 
+# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, 
+# corresponding to a cache size of 2^16 = 65536 symbols.
+
+SYMBOL_CACHE_SIZE      = 0
+
+# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be 
+# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given 
+# their name and scope. Since this can be an expensive process and often the 
+# same symbol appear multiple times in the code, doxygen keeps a cache of 
+# pre-resolved symbols. If the cache is too small doxygen will become slower. 
+# If the cache is too large, memory is wasted. The cache size is given by this 
+# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, 
+# corresponding to a cache size of 2^16 = 65536 symbols.
+
+LOOKUP_CACHE_SIZE      = 0
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in 
+# documentation are documented, even if no documentation was available. 
+# Private class members and static file members will be hidden unless 
+# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
+
+EXTRACT_ALL            = NO
+
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class 
+# will be included in the documentation.
+
+EXTRACT_PRIVATE        = YES
+
+# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal
+# scope will be included in the documentation.
+
+EXTRACT_PACKAGE        = YES
+
+# If the EXTRACT_STATIC tag is set to YES all static members of a file 
+# will be included in the documentation.
+
+EXTRACT_STATIC         = YES
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) 
+# defined locally in source files will be included in the documentation. 
+# If set to NO only classes defined in header files are included.
+
+EXTRACT_LOCAL_CLASSES  = YES
+
+# This flag is only useful for Objective-C code. When set to YES local 
+# methods, which are defined in the implementation section but not in 
+# the interface are included in the documentation. 
+# If set to NO (the default) only methods in the interface are included.
+
+EXTRACT_LOCAL_METHODS  = YES
+
+# If this flag is set to YES, the members of anonymous namespaces will be 
+# extracted and appear in the documentation as a namespace called 
+# 'anonymous_namespace{file}', where file will be replaced with the base 
+# name of the file that contains the anonymous namespace. By default 
+# anonymous namespaces are hidden.
+
+EXTRACT_ANON_NSPACES   = NO
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all 
+# undocumented members of documented classes, files or namespaces. 
+# If set to NO (the default) these members will be included in the 
+# various overviews, but no documentation section is generated. 
+# This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_MEMBERS     = NO
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all 
+# undocumented classes that are normally visible in the class hierarchy. 
+# If set to NO (the default) these classes will be included in the various 
+# overviews. This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_CLASSES     = YES
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all 
+# friend (class|struct|union) declarations. 
+# If set to NO (the default) these declarations will be included in the 
+# documentation.
+
+HIDE_FRIEND_COMPOUNDS  = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any 
+# documentation blocks found inside the body of a function. 
+# If set to NO (the default) these blocks will be appended to the 
+# function's detailed documentation block.
+
+HIDE_IN_BODY_DOCS      = NO
+
+# The INTERNAL_DOCS tag determines if documentation 
+# that is typed after a \internal command is included. If the tag is set 
+# to NO (the default) then the documentation will be excluded. 
+# Set it to YES to include the internal documentation.
+
+INTERNAL_DOCS          = NO
+
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate 
+# file names in lower-case letters. If set to YES upper-case letters are also 
+# allowed. This is useful if you have classes or files whose names only differ 
+# in case and if your file system supports case sensitive file names. Windows 
+# and Mac users are advised to set this option to NO.
+
+CASE_SENSE_NAMES       = NO
+
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen 
+# will show members with their full class and namespace scopes in the 
+# documentation. If set to YES the scope will be hidden.
+
+HIDE_SCOPE_NAMES       = NO
+
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen 
+# will put a list of the files that are included by a file in the documentation 
+# of that file.
+
+SHOW_INCLUDE_FILES     = YES
+
+# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen 
+# will list include files with double quotes in the documentation 
+# rather than with sharp brackets.
+
+FORCE_LOCAL_INCLUDES   = NO
+
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] 
+# is inserted in the documentation for inline members.
+
+INLINE_INFO            = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen 
+# will sort the (detailed) documentation of file and class members 
+# alphabetically by member name. If set to NO the members will appear in 
+# declaration order.
+
+SORT_MEMBER_DOCS       = YES
+
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the 
+# brief documentation of file, namespace and class members alphabetically 
+# by member name. If set to NO (the default) the members will appear in 
+# declaration order.
+
+SORT_BRIEF_DOCS        = NO
+
+# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen 
+# will sort the (brief and detailed) documentation of class members so that 
+# constructors and destructors are listed first. If set to NO (the default) 
+# the constructors will appear in the respective orders defined by 
+# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. 
+# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO 
+# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO.
+
+SORT_MEMBERS_CTORS_1ST = NO
+
+# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the 
+# hierarchy of group names into alphabetical order. If set to NO (the default) 
+# the group names will appear in their defined order.
+
+SORT_GROUP_NAMES       = NO
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be 
+# sorted by fully-qualified names, including namespaces. If set to 
+# NO (the default), the class list will be sorted only by class name, 
+# not including the namespace part. 
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. 
+# Note: This option applies only to the class list, not to the 
+# alphabetical list.
+
+SORT_BY_SCOPE_NAME     = NO
+
+# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to 
+# do proper type resolution of all parameters of a function it will reject a 
+# match between the prototype and the implementation of a member function even 
+# if there is only one candidate or it is obvious which candidate to choose 
+# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen 
+# will still accept a match between prototype and implementation in such cases.
+
+STRICT_PROTO_MATCHING  = NO
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or 
+# disable (NO) the todo list. This list is created by putting \todo 
+# commands in the documentation.
+
+GENERATE_TODOLIST      = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or 
+# disable (NO) the test list. This list is created by putting \test 
+# commands in the documentation.
+
+GENERATE_TESTLIST      = YES
+
+# The GENERATE_BUGLIST tag can be used to enable (YES) or 
+# disable (NO) the bug list. This list is created by putting \bug 
+# commands in the documentation.
+
+GENERATE_BUGLIST       = YES
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or 
+# disable (NO) the deprecated list. This list is created by putting 
+# \deprecated commands in the documentation.
+
+GENERATE_DEPRECATEDLIST= YES
+
+# The ENABLED_SECTIONS tag can be used to enable conditional 
+# documentation sections, marked by \if sectionname ... \endif.
+
+ENABLED_SECTIONS       = 
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines 
+# the initial value of a variable or macro consists of for it to appear in 
+# the documentation. If the initializer consists of more lines than specified 
+# here it will be hidden. Use a value of 0 to hide initializers completely. 
+# The appearance of the initializer of individual variables and macros in the 
+# documentation can be controlled using \showinitializer or \hideinitializer 
+# command in the documentation regardless of this setting.
+
+MAX_INITIALIZER_LINES  = 30
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated 
+# at the bottom of the documentation of classes and structs. If set to YES the 
+# list will mention the files that were used to generate the documentation.
+
+SHOW_USED_FILES        = YES
+
+# Set the SHOW_FILES tag to NO to disable the generation of the Files page. 
+# This will remove the Files entry from the Quick Index and from the 
+# Folder Tree View (if specified). The default is YES.
+
+SHOW_FILES             = YES
+
+# Set the SHOW_NAMESPACES tag to NO to disable the generation of the 
+# Namespaces page.  This will remove the Namespaces entry from the Quick Index 
+# and from the Folder Tree View (if specified). The default is YES.
+
+SHOW_NAMESPACES        = NO
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that 
+# doxygen should invoke to get the current version for each file (typically from 
+# the version control system). Doxygen will invoke the program by executing (via 
+# popen()) the command <command> <input-file>, where <command> is the value of 
+# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file 
+# provided by doxygen. Whatever the program writes to standard output 
+# is used as the file version. See the manual for examples.
+
+FILE_VERSION_FILTER    = 
+
+# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed 
+# by doxygen. The layout file controls the global structure of the generated 
+# output files in an output format independent way. To create the layout file 
+# that represents doxygen's defaults, run doxygen with the -l option. 
+# You can optionally specify a file name after the option, if omitted 
+# DoxygenLayout.xml will be used as the name of the layout file.
+
+LAYOUT_FILE            = 
+
+# The CITE_BIB_FILES tag can be used to specify one or more bib files 
+# containing the references data. This must be a list of .bib files. The 
+# .bib extension is automatically appended if omitted. Using this command 
+# requires the bibtex tool to be installed. See also 
+# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style 
+# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this 
+# feature you need bibtex and perl available in the search path.
+
+CITE_BIB_FILES         = 
+
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated 
+# by doxygen. Possible values are YES and NO. If left blank NO is used.
+
+QUIET                  = NO
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are 
+# generated by doxygen. Possible values are YES and NO. If left blank 
+# NO is used.
+
+WARNINGS               = YES
+
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings 
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will 
+# automatically be disabled.
+
+WARN_IF_UNDOCUMENTED   = YES
+
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for 
+# potential errors in the documentation, such as not documenting some 
+# parameters in a documented function, or documenting parameters that 
+# don't exist or using markup commands wrongly.
+
+WARN_IF_DOC_ERROR      = YES
+
+# The WARN_NO_PARAMDOC option can be enabled to get warnings for 
+# functions that are documented, but have no documentation for their parameters 
+# or return value. If set to NO (the default) doxygen will only warn about 
+# wrong or incomplete parameter documentation, but not about the absence of 
+# documentation.
+
+WARN_NO_PARAMDOC       = NO
+
+# The WARN_FORMAT tag determines the format of the warning messages that 
+# doxygen can produce. The string should contain the $file, $line, and $text 
+# tags, which will be replaced by the file and line number from which the 
+# warning originated and the warning text. Optionally the format may contain 
+# $version, which will be replaced by the version of the file (if it could 
+# be obtained via FILE_VERSION_FILTER)
+
+WARN_FORMAT            = "$file:$line: $text"
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning 
+# and error messages should be written. If left blank the output is written 
+# to stderr.
+
+WARN_LOGFILE           = 
+
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag can be used to specify the files and/or directories that contain 
+# documented source files. You may enter file names like "myfile.cpp" or 
+# directories like "/usr/src/myproject". Separate the files or directories 
+# with spaces.
+
+INPUT                  = 
+
+# This tag can be used to specify the character encoding of the source files 
+# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is 
+# also the default input encoding. Doxygen uses libiconv (or the iconv built 
+# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for 
+# the list of possible encodings.
+
+INPUT_ENCODING         = UTF-8
+
+# If the value of the INPUT tag contains directories, you can use the 
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
+# and *.h) to filter out the source-files in the directories. If left 
+# blank the following patterns are tested: 
+# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh 
+# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py 
+# *.f90 *.f *.for *.vhd *.vhdl
+
+FILE_PATTERNS          = *.cpp \
+                         *.h \
+                         *.dox
+
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories 
+# should be searched for input files as well. Possible values are YES and NO. 
+# If left blank NO is used.
+
+RECURSIVE              = NO
+
+# The EXCLUDE tag can be used to specify files and/or directories that should be 
+# excluded from the INPUT source files. This way you can easily exclude a 
+# subdirectory from a directory tree whose root is specified with the INPUT tag. 
+# Note that relative paths are relative to the directory from which doxygen is 
+# run.
+
+EXCLUDE                = resource.h
+
+# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or 
+# directories that are symbolic links (a Unix file system feature) are excluded 
+# from the input.
+
+EXCLUDE_SYMLINKS       = NO
+
+# If the value of the INPUT tag contains directories, you can use the 
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude 
+# certain files from those directories. Note that the wildcards are matched 
+# against the file with absolute path, so to exclude all test directories 
+# for example use the pattern */test/*
+
+EXCLUDE_PATTERNS       = 
+
+# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names 
+# (namespaces, classes, functions, etc.) that should be excluded from the 
+# output. The symbol name can be a fully qualified name, a word, or if the 
+# wildcard * is used, a substring. Examples: ANamespace, AClass, 
+# AClass::ANamespace, ANamespace::*Test
+
+EXCLUDE_SYMBOLS        = 
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or 
+# directories that contain example code fragments that are included (see 
+# the \include command).
+
+EXAMPLE_PATH           = 
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the 
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
+# and *.h) to filter out the source-files in the directories. If left 
+# blank all files are included.
+
+EXAMPLE_PATTERNS       = *
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be 
+# searched for input files to be used with the \include or \dontinclude 
+# commands irrespective of the value of the RECURSIVE tag. 
+# Possible values are YES and NO. If left blank NO is used.
+
+EXAMPLE_RECURSIVE      = NO
+
+# The IMAGE_PATH tag can be used to specify one or more files or 
+# directories that contain image that are included in the documentation (see 
+# the \image command).
+
+IMAGE_PATH             = docs/images
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should 
+# invoke to filter for each input file. Doxygen will invoke the filter program 
+# by executing (via popen()) the command <filter> <input-file>, where <filter> 
+# is the value of the INPUT_FILTER tag, and <input-file> is the name of an 
+# input file. Doxygen will then use the output that the filter program writes 
+# to standard output.  If FILTER_PATTERNS is specified, this tag will be 
+# ignored.
+
+INPUT_FILTER           = 
+
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern 
+# basis.  Doxygen will compare the file name with each pattern and apply the 
+# filter if there is a match.  The filters are a list of the form: 
+# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further 
+# info on how filters are used. If FILTER_PATTERNS is empty or if 
+# non of the patterns match the file name, INPUT_FILTER is applied.
+
+FILTER_PATTERNS        = 
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using 
+# INPUT_FILTER) will be used to filter the input files when producing source 
+# files to browse (i.e. when SOURCE_BROWSER is set to YES).
+
+FILTER_SOURCE_FILES    = NO
+
+# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file 
+# pattern. A pattern will override the setting for FILTER_PATTERN (if any) 
+# and it is also possible to disable source filtering for a specific pattern 
+# using *.ext= (so without naming a filter). This option only has effect when 
+# FILTER_SOURCE_FILES is enabled.
+
+FILTER_SOURCE_PATTERNS = 
+
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will 
+# be generated. Documented entities will be cross-referenced with these sources. 
+# Note: To get rid of all source code in the generated output, make sure also 
+# VERBATIM_HEADERS is set to NO.
+
+SOURCE_BROWSER         = NO
+
+# Setting the INLINE_SOURCES tag to YES will include the body 
+# of functions and classes directly in the documentation.
+
+INLINE_SOURCES         = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct 
+# doxygen to hide any special comment blocks from generated source code 
+# fragments. Normal C, C++ and Fortran comments will always remain visible.
+
+STRIP_CODE_COMMENTS    = YES
+
+# If the REFERENCED_BY_RELATION tag is set to YES 
+# then for each documented function all documented 
+# functions referencing it will be listed.
+
+REFERENCED_BY_RELATION = NO
+
+# If the REFERENCES_RELATION tag is set to YES 
+# then for each documented function all documented entities 
+# called/used by that function will be listed.
+
+REFERENCES_RELATION    = NO
+
+# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) 
+# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from 
+# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will 
+# link to the source code.  Otherwise they will link to the documentation.
+
+REFERENCES_LINK_SOURCE = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code 
+# will point to the HTML generated by the htags(1) tool instead of doxygen 
+# built-in source browser. The htags tool is part of GNU's global source 
+# tagging system (see http://www.gnu.org/software/global/global.html). You 
+# will need version 4.8.6 or higher.
+
+USE_HTAGS              = NO
+
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen 
+# will generate a verbatim copy of the header file for each class for 
+# which an include is specified. Set to NO to disable this.
+
+VERBATIM_HEADERS       = YES
+
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index 
+# of all compounds will be generated. Enable this if the project 
+# contains a lot of classes, structs, unions or interfaces.
+
+ALPHABETICAL_INDEX     = YES
+
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then 
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns 
+# in which this list will be split (can be a number in the range [1..20])
+
+COLS_IN_ALPHA_INDEX    = 2
+
+# In case all classes in a project start with a common prefix, all 
+# classes will be put under the same header in the alphabetical index. 
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that 
+# should be ignored while generating the index headers.
+
+IGNORE_PREFIX          = 
+
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will 
+# generate HTML output.
+
+GENERATE_HTML          = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `html' will be used as the default path.
+
+HTML_OUTPUT            = html
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for 
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank 
+# doxygen will generate files with .html extension.
+
+HTML_FILE_EXTENSION    = .html
+
+# The HTML_HEADER tag can be used to specify a personal HTML header for 
+# each generated HTML page. If it is left blank doxygen will generate a 
+# standard header. Note that when using a custom header you are responsible  
+# for the proper inclusion of any scripts and style sheets that doxygen 
+# needs, which is dependent on the configuration options used. 
+# It is advised to generate a default header using "doxygen -w html 
+# header.html footer.html stylesheet.css YourConfigFile" and then modify 
+# that header. Note that the header is subject to change so you typically 
+# have to redo this when upgrading to a newer version of doxygen or when 
+# changing the value of configuration settings such as GENERATE_TREEVIEW!
+
+HTML_HEADER            = 
+
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for 
+# each generated HTML page. If it is left blank doxygen will generate a 
+# standard footer.
+
+HTML_FOOTER            = 
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading 
+# style sheet that is used by each HTML page. It can be used to 
+# fine-tune the look of the HTML output. If the tag is left blank doxygen 
+# will generate a default style sheet. Note that doxygen will try to copy 
+# the style sheet file to the HTML output directory, so don't put your own 
+# style sheet in the HTML output directory as well, or it will be erased!
+
+HTML_STYLESHEET        = 
+
+# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or 
+# other source files which should be copied to the HTML output directory. Note 
+# that these files will be copied to the base HTML output directory. Use the 
+# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these 
+# files. In the HTML_STYLESHEET file, use the file name only. Also note that 
+# the files will be copied as-is; there are no commands or markers available.
+
+HTML_EXTRA_FILES       = 
+
+# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. 
+# Doxygen will adjust the colors in the style sheet and background images 
+# according to this color. Hue is specified as an angle on a colorwheel, 
+# see http://en.wikipedia.org/wiki/Hue for more information. 
+# For instance the value 0 represents red, 60 is yellow, 120 is green, 
+# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. 
+# The allowed range is 0 to 359.
+
+HTML_COLORSTYLE_HUE    = 220
+
+# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of 
+# the colors in the HTML output. For a value of 0 the output will use 
+# grayscales only. A value of 255 will produce the most vivid colors.
+
+HTML_COLORSTYLE_SAT    = 100
+
+# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to 
+# the luminance component of the colors in the HTML output. Values below 
+# 100 gradually make the output lighter, whereas values above 100 make 
+# the output darker. The value divided by 100 is the actual gamma applied, 
+# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, 
+# and 100 does not change the gamma.
+
+HTML_COLORSTYLE_GAMMA  = 80
+
+# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML 
+# page will contain the date and time when the page was generated. Setting 
+# this to NO can help when comparing the output of multiple runs.
+
+HTML_TIMESTAMP         = YES
+
+# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML 
+# documentation will contain sections that can be hidden and shown after the 
+# page has loaded.
+
+HTML_DYNAMIC_SECTIONS  = NO
+
+# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of 
+# entries shown in the various tree structured indices initially; the user 
+# can expand and collapse entries dynamically later on. Doxygen will expand 
+# the tree to such a level that at most the specified number of entries are 
+# visible (unless a fully collapsed tree already exceeds this amount). 
+# So setting the number of entries 1 will produce a full collapsed tree by 
+# default. 0 is a special value representing an infinite number of entries 
+# and will result in a full expanded tree by default.
+
+HTML_INDEX_NUM_ENTRIES = 100
+
+# If the GENERATE_DOCSET tag is set to YES, additional index files 
+# will be generated that can be used as input for Apple's Xcode 3 
+# integrated development environment, introduced with OSX 10.5 (Leopard). 
+# To create a documentation set, doxygen will generate a Makefile in the 
+# HTML output directory. Running make will produce the docset in that 
+# directory and running "make install" will install the docset in 
+# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find 
+# it at startup. 
+# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html 
+# for more information.
+
+GENERATE_DOCSET        = NO
+
+# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the 
+# feed. A documentation feed provides an umbrella under which multiple 
+# documentation sets from a single provider (such as a company or product suite) 
+# can be grouped.
+
+DOCSET_FEEDNAME        = "Doxygen generated docs"
+
+# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that 
+# should uniquely identify the documentation set bundle. This should be a 
+# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen 
+# will append .docset to the name.
+
+DOCSET_BUNDLE_ID       = org.doxygen.Project
+
+# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify 
+# the documentation publisher. This should be a reverse domain-name style 
+# string, e.g. com.mycompany.MyDocSet.documentation.
+
+DOCSET_PUBLISHER_ID    = org.doxygen.Publisher
+
+# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher.
+
+DOCSET_PUBLISHER_NAME  = Publisher
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files 
+# will be generated that can be used as input for tools like the 
+# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) 
+# of the generated HTML documentation.
+
+GENERATE_HTMLHELP      = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can 
+# be used to specify the file name of the resulting .chm file. You 
+# can add a path in front of the file if the result should not be 
+# written to the html output directory.
+
+CHM_FILE               = 
+
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can 
+# be used to specify the location (absolute path including file name) of 
+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run 
+# the HTML help compiler on the generated index.hhp.
+
+HHC_LOCATION           = 
+
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag 
+# controls if a separate .chi index file is generated (YES) or that 
+# it should be included in the master .chm file (NO).
+
+GENERATE_CHI           = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING 
+# is used to encode HtmlHelp index (hhk), content (hhc) and project file 
+# content.
+
+CHM_INDEX_ENCODING     = 
+
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag 
+# controls whether a binary table of contents is generated (YES) or a 
+# normal table of contents (NO) in the .chm file.
+
+BINARY_TOC             = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members 
+# to the contents of the HTML help documentation and to the tree view.
+
+TOC_EXPAND             = NO
+
+# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and 
+# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated 
+# that can be used as input for Qt's qhelpgenerator to generate a 
+# Qt Compressed Help (.qch) of the generated HTML documentation.
+
+GENERATE_QHP           = NO
+
+# If the QHG_LOCATION tag is specified, the QCH_FILE tag can 
+# be used to specify the file name of the resulting .qch file. 
+# The path specified is relative to the HTML output folder.
+
+QCH_FILE               = 
+
+# The QHP_NAMESPACE tag specifies the namespace to use when generating 
+# Qt Help Project output. For more information please see 
+# http://doc.trolltech.com/qthelpproject.html#namespace
+
+QHP_NAMESPACE          = org.doxygen.Project
+
+# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating 
+# Qt Help Project output. For more information please see 
+# http://doc.trolltech.com/qthelpproject.html#virtual-folders
+
+QHP_VIRTUAL_FOLDER     = doc
+
+# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to 
+# add. For more information please see 
+# http://doc.trolltech.com/qthelpproject.html#custom-filters
+
+QHP_CUST_FILTER_NAME   = 
+
+# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the 
+# custom filter to add. For more information please see 
+# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters"> 
+# Qt Help Project / Custom Filters</a>.
+
+QHP_CUST_FILTER_ATTRS  = 
+
+# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this 
+# project's 
+# filter section matches. 
+# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes"> 
+# Qt Help Project / Filter Attributes</a>.
+
+QHP_SECT_FILTER_ATTRS  = 
+
+# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can 
+# be used to specify the location of Qt's qhelpgenerator. 
+# If non-empty doxygen will try to run qhelpgenerator on the generated 
+# .qhp file.
+
+QHG_LOCATION           = 
+
+# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files  
+# will be generated, which together with the HTML files, form an Eclipse help 
+# plugin. To install this plugin and make it available under the help contents 
+# menu in Eclipse, the contents of the directory containing the HTML and XML 
+# files needs to be copied into the plugins directory of eclipse. The name of 
+# the directory within the plugins directory should be the same as 
+# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before 
+# the help appears.
+
+GENERATE_ECLIPSEHELP   = NO
+
+# A unique identifier for the eclipse help plugin. When installing the plugin 
+# the directory name containing the HTML and XML files should also have 
+# this name.
+
+ECLIPSE_DOC_ID         = org.doxygen.Project
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) 
+# at top of each HTML page. The value NO (the default) enables the index and 
+# the value YES disables it. Since the tabs have the same information as the 
+# navigation tree you can set this option to NO if you already set 
+# GENERATE_TREEVIEW to YES.
+
+DISABLE_INDEX          = YES
+
+# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index 
+# structure should be generated to display hierarchical information. 
+# If the tag value is set to YES, a side panel will be generated 
+# containing a tree-like index structure (just like the one that 
+# is generated for HTML Help). For this to work a browser that supports 
+# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). 
+# Windows users are probably better off using the HTML help feature. 
+# Since the tree basically has the same information as the tab index you 
+# could consider to set DISABLE_INDEX to NO when enabling this option.
+
+GENERATE_TREEVIEW      = YES
+
+# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values 
+# (range [0,1..20]) that doxygen will group on one line in the generated HTML 
+# documentation. Note that a value of 0 will completely suppress the enum 
+# values from appearing in the overview section.
+
+ENUM_VALUES_PER_LINE   = 4
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be 
+# used to set the initial width (in pixels) of the frame in which the tree 
+# is shown.
+
+TREEVIEW_WIDTH         = 250
+
+# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open 
+# links to external symbols imported via tag files in a separate window.
+
+EXT_LINKS_IN_WINDOW    = NO
+
+# Use this tag to change the font size of Latex formulas included 
+# as images in the HTML documentation. The default is 10. Note that 
+# when you change the font size after a successful doxygen run you need 
+# to manually remove any form_*.png images from the HTML output directory 
+# to force them to be regenerated.
+
+FORMULA_FONTSIZE       = 10
+
+# Use the FORMULA_TRANPARENT tag to determine whether or not the images 
+# generated for formulas are transparent PNGs. Transparent PNGs are 
+# not supported properly for IE 6.0, but are supported on all modern browsers. 
+# Note that when changing this option you need to delete any form_*.png files 
+# in the HTML output before the changes have effect.
+
+FORMULA_TRANSPARENT    = YES
+
+# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax 
+# (see http://www.mathjax.org) which uses client side Javascript for the 
+# rendering instead of using prerendered bitmaps. Use this if you do not 
+# have LaTeX installed or if you want to formulas look prettier in the HTML 
+# output. When enabled you may also need to install MathJax separately and 
+# configure the path to it using the MATHJAX_RELPATH option.
+
+USE_MATHJAX            = NO
+
+# When MathJax is enabled you need to specify the location relative to the 
+# HTML output directory using the MATHJAX_RELPATH option. The destination 
+# directory should contain the MathJax.js script. For instance, if the mathjax 
+# directory is located at the same level as the HTML output directory, then 
+# MATHJAX_RELPATH should be ../mathjax. The default value points to 
+# the MathJax Content Delivery Network so you can quickly see the result without 
+# installing MathJax.  However, it is strongly recommended to install a local 
+# copy of MathJax from http://www.mathjax.org before deployment.
+
+MATHJAX_RELPATH        = http://cdn.mathjax.org/mathjax/latest
+
+# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension 
+# names that should be enabled during MathJax rendering.
+
+MATHJAX_EXTENSIONS     = 
+
+# When the SEARCHENGINE tag is enabled doxygen will generate a search box 
+# for the HTML output. The underlying search engine uses javascript 
+# and DHTML and should work on any modern browser. Note that when using 
+# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets 
+# (GENERATE_DOCSET) there is already a search function so this one should 
+# typically be disabled. For large projects the javascript based search engine 
+# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution.
+
+SEARCHENGINE           = YES
+
+# When the SERVER_BASED_SEARCH tag is enabled the search engine will be 
+# implemented using a PHP enabled web server instead of at the web client 
+# using Javascript. Doxygen will generate the search PHP script and index 
+# file to put on the web server. The advantage of the server 
+# based approach is that it scales better to large projects and allows 
+# full text search. The disadvantages are that it is more difficult to setup 
+# and does not have live searching capabilities.
+
+SERVER_BASED_SEARCH    = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will 
+# generate Latex output.
+
+GENERATE_LATEX         = NO
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `latex' will be used as the default path.
+
+LATEX_OUTPUT           = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be 
+# invoked. If left blank `latex' will be used as the default command name. 
+# Note that when enabling USE_PDFLATEX this option is only used for 
+# generating bitmaps for formulas in the HTML output, but not in the 
+# Makefile that is written to the output directory.
+
+LATEX_CMD_NAME         = latex
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to 
+# generate index for LaTeX. If left blank `makeindex' will be used as the 
+# default command name.
+
+MAKEINDEX_CMD_NAME     = makeindex
+
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact 
+# LaTeX documents. This may be useful for small projects and may help to 
+# save some trees in general.
+
+COMPACT_LATEX          = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used 
+# by the printer. Possible values are: a4, letter, legal and 
+# executive. If left blank a4wide will be used.
+
+PAPER_TYPE             = a4
+
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX 
+# packages that should be included in the LaTeX output.
+
+EXTRA_PACKAGES         = 
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for 
+# the generated latex document. The header should contain everything until 
+# the first chapter. If it is left blank doxygen will generate a 
+# standard header. Notice: only use this tag if you know what you are doing!
+
+LATEX_HEADER           = 
+
+# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for 
+# the generated latex document. The footer should contain everything after 
+# the last chapter. If it is left blank doxygen will generate a 
+# standard footer. Notice: only use this tag if you know what you are doing!
+
+LATEX_FOOTER           = 
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated 
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will 
+# contain links (just like the HTML output) instead of page references 
+# This makes the output suitable for online browsing using a pdf viewer.
+
+PDF_HYPERLINKS         = YES
+
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of 
+# plain latex in the generated Makefile. Set this option to YES to get a 
+# higher quality PDF documentation.
+
+USE_PDFLATEX           = YES
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. 
+# command to the generated LaTeX files. This will instruct LaTeX to keep 
+# running if errors occur, instead of asking the user for help. 
+# This option is also used when generating formulas in HTML.
+
+LATEX_BATCHMODE        = NO
+
+# If LATEX_HIDE_INDICES is set to YES then doxygen will not 
+# include the index chapters (such as File Index, Compound Index, etc.) 
+# in the output.
+
+LATEX_HIDE_INDICES     = NO
+
+# If LATEX_SOURCE_CODE is set to YES then doxygen will include 
+# source code with syntax highlighting in the LaTeX output. 
+# Note that which sources are shown also depends on other settings 
+# such as SOURCE_BROWSER.
+
+LATEX_SOURCE_CODE      = NO
+
+# The LATEX_BIB_STYLE tag can be used to specify the style to use for the 
+# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See 
+# http://en.wikipedia.org/wiki/BibTeX for more info.
+
+LATEX_BIB_STYLE        = plain
+
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output 
+# The RTF output is optimized for Word 97 and may not look very pretty with 
+# other RTF readers or editors.
+
+GENERATE_RTF           = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `rtf' will be used as the default path.
+
+RTF_OUTPUT             = rtf
+
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact 
+# RTF documents. This may be useful for small projects and may help to 
+# save some trees in general.
+
+COMPACT_RTF            = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated 
+# will contain hyperlink fields. The RTF file will 
+# contain links (just like the HTML output) instead of page references. 
+# This makes the output suitable for online browsing using WORD or other 
+# programs which support those fields. 
+# Note: wordpad (write) and others do not support links.
+
+RTF_HYPERLINKS         = NO
+
+# Load style sheet definitions from file. Syntax is similar to doxygen's 
+# config file, i.e. a series of assignments. You only have to provide 
+# replacements, missing definitions are set to their default value.
+
+RTF_STYLESHEET_FILE    = 
+
+# Set optional variables used in the generation of an rtf document. 
+# Syntax is similar to doxygen's config file.
+
+RTF_EXTENSIONS_FILE    = 
+
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will 
+# generate man pages
+
+GENERATE_MAN           = NO
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `man' will be used as the default path.
+
+MAN_OUTPUT             = man
+
+# The MAN_EXTENSION tag determines the extension that is added to 
+# the generated man pages (default is the subroutine's section .3)
+
+MAN_EXTENSION          = .3
+
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output, 
+# then it will generate one additional man file for each entity 
+# documented in the real man page(s). These additional files 
+# only source the real man page, but without them the man command 
+# would be unable to find the correct page. The default is NO.
+
+MAN_LINKS              = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES Doxygen will 
+# generate an XML file that captures the structure of 
+# the code including all documentation.
+
+GENERATE_XML           = NO
+
+# The XML_OUTPUT tag is used to specify where the XML pages will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `xml' will be used as the default path.
+
+XML_OUTPUT             = xml
+
+# The XML_SCHEMA tag can be used to specify an XML schema, 
+# which can be used by a validating XML parser to check the 
+# syntax of the XML files.
+
+XML_SCHEMA             = 
+
+# The XML_DTD tag can be used to specify an XML DTD, 
+# which can be used by a validating XML parser to check the 
+# syntax of the XML files.
+
+XML_DTD                = 
+
+# If the XML_PROGRAMLISTING tag is set to YES Doxygen will 
+# dump the program listings (including syntax highlighting 
+# and cross-referencing information) to the XML output. Note that 
+# enabling this will significantly increase the size of the XML output.
+
+XML_PROGRAMLISTING     = YES
+
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will 
+# generate an AutoGen Definitions (see autogen.sf.net) file 
+# that captures the structure of the code including all 
+# documentation. Note that this feature is still experimental 
+# and incomplete at the moment.
+
+GENERATE_AUTOGEN_DEF   = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will 
+# generate a Perl module file that captures the structure of 
+# the code including all documentation. Note that this 
+# feature is still experimental and incomplete at the 
+# moment.
+
+GENERATE_PERLMOD       = NO
+
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate 
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able 
+# to generate PDF and DVI output from the Perl module output.
+
+PERLMOD_LATEX          = NO
+
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be 
+# nicely formatted so it can be parsed by a human reader.  This is useful 
+# if you want to understand what is going on.  On the other hand, if this 
+# tag is set to NO the size of the Perl module output will be much smaller 
+# and Perl will parse it just the same.
+
+PERLMOD_PRETTY         = YES
+
+# The names of the make variables in the generated doxyrules.make file 
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. 
+# This is useful so different doxyrules.make files included by the same 
+# Makefile don't overwrite each other's variables.
+
+PERLMOD_MAKEVAR_PREFIX = 
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will 
+# evaluate all C-preprocessor directives found in the sources and include 
+# files.
+
+ENABLE_PREPROCESSING   = YES
+
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro 
+# names in the source code. If set to NO (the default) only conditional 
+# compilation will be performed. Macro expansion can be done in a controlled 
+# way by setting EXPAND_ONLY_PREDEF to YES.
+
+MACRO_EXPANSION        = NO
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES 
+# then the macro expansion is limited to the macros specified with the 
+# PREDEFINED and EXPAND_AS_DEFINED tags.
+
+EXPAND_ONLY_PREDEF     = NO
+
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files 
+# pointed to by INCLUDE_PATH will be searched when a #include is found.
+
+SEARCH_INCLUDES        = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that 
+# contain include files that are not input files but should be processed by 
+# the preprocessor.
+
+INCLUDE_PATH           = 
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard 
+# patterns (like *.h and *.hpp) to filter out the header-files in the 
+# directories. If left blank, the patterns specified with FILE_PATTERNS will 
+# be used.
+
+INCLUDE_FILE_PATTERNS  = 
+
+# The PREDEFINED tag can be used to specify one or more macro names that 
+# are defined before the preprocessor is started (similar to the -D option of 
+# gcc). The argument of the tag is a list of macros of the form: name 
+# or name=definition (no spaces). If the definition and the = are 
+# omitted =1 is assumed. To prevent a macro definition from being 
+# undefined via #undef or recursively expanded use the := operator 
+# instead of the = operator.
+
+PREDEFINED             = 
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then 
+# this tag can be used to specify a list of macro names that should be expanded. 
+# The macro definition that is found in the sources will be used. 
+# Use the PREDEFINED tag if you want to use a different macro definition that 
+# overrules the definition found in the source code.
+
+EXPAND_AS_DEFINED      = 
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then 
+# doxygen's preprocessor will remove all references to function-like macros 
+# that are alone on a line, have an all uppercase name, and do not end with a 
+# semicolon, because these will confuse the parser if not removed.
+
+SKIP_FUNCTION_MACROS   = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references
+#---------------------------------------------------------------------------
+
+# The TAGFILES option can be used to specify one or more tagfiles. For each 
+# tag file the location of the external documentation should be added. The 
+# format of a tag file without this location is as follows: 
+#   TAGFILES = file1 file2 ... 
+# Adding location for the tag files is done as follows: 
+#   TAGFILES = file1=loc1 "file2 = loc2" ... 
+# where "loc1" and "loc2" can be relative or absolute paths 
+# or URLs. Note that each tag file must have a unique name (where the name does 
+# NOT include the path). If a tag file is not located in the directory in which 
+# doxygen is run, you must also specify the path to the tagfile here.
+
+TAGFILES               = 
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create 
+# a tag file that is based on the input files it reads.
+
+GENERATE_TAGFILE       = 
+
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed 
+# in the class index. If set to NO only the inherited external classes 
+# will be listed.
+
+ALLEXTERNALS           = NO
+
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed 
+# in the modules index. If set to NO, only the current project's groups will 
+# be listed.
+
+EXTERNAL_GROUPS        = YES
+
+# The PERL_PATH should be the absolute path and name of the perl script 
+# interpreter (i.e. the result of `which perl').
+
+PERL_PATH              = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will 
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base 
+# or super classes. Setting the tag to NO turns the diagrams off. Note that 
+# this option also works with HAVE_DOT disabled, but it is recommended to 
+# install and use dot, since it yields more powerful graphs.
+
+CLASS_DIAGRAMS         = YES
+
+# You can define message sequence charts within doxygen comments using the \msc 
+# command. Doxygen will then run the mscgen tool (see 
+# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the 
+# documentation. The MSCGEN_PATH tag allows you to specify the directory where 
+# the mscgen tool resides. If left empty the tool is assumed to be found in the 
+# default search path.
+
+MSCGEN_PATH            = 
+
+# If set to YES, the inheritance and collaboration graphs will hide 
+# inheritance and usage relations if the target is undocumented 
+# or is not a class.
+
+HIDE_UNDOC_RELATIONS   = YES
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is 
+# available from the path. This tool is part of Graphviz, a graph visualization 
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section 
+# have no effect if this option is set to NO (the default)
+
+HAVE_DOT               = NO
+
+# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is 
+# allowed to run in parallel. When set to 0 (the default) doxygen will 
+# base this on the number of processors available in the system. You can set it 
+# explicitly to a value larger than 0 to get control over the balance 
+# between CPU load and processing speed.
+
+DOT_NUM_THREADS        = 0
+
+# By default doxygen will use the Helvetica font for all dot files that 
+# doxygen generates. When you want a differently looking font you can specify 
+# the font name using DOT_FONTNAME. You need to make sure dot is able to find 
+# the font, which can be done by putting it in a standard location or by setting 
+# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the 
+# directory containing the font.
+
+DOT_FONTNAME           = Helvetica
+
+# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. 
+# The default size is 10pt.
+
+DOT_FONTSIZE           = 10
+
+# By default doxygen will tell dot to use the Helvetica font. 
+# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to 
+# set the path where dot can find it.
+
+DOT_FONTPATH           = 
+
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graph for each documented class showing the direct and 
+# indirect inheritance relations. Setting this tag to YES will force the 
+# CLASS_DIAGRAMS tag to NO.
+
+CLASS_GRAPH            = YES
+
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graph for each documented class showing the direct and 
+# indirect implementation dependencies (inheritance, containment, and 
+# class references variables) of the class with other documented classes.
+
+COLLABORATION_GRAPH    = YES
+
+# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graph for groups, showing the direct groups dependencies
+
+GROUP_GRAPHS           = YES
+
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and 
+# collaboration diagrams in a style similar to the OMG's Unified Modeling 
+# Language.
+
+UML_LOOK               = NO
+
+# If the UML_LOOK tag is enabled, the fields and methods are shown inside 
+# the class node. If there are many fields or methods and many nodes the 
+# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS 
+# threshold limits the number of items for each type to make the size more 
+# managable. Set this to 0 for no limit. Note that the threshold may be 
+# exceeded by 50% before the limit is enforced.
+
+UML_LIMIT_NUM_FIELDS   = 10
+
+# If set to YES, the inheritance and collaboration graphs will show the 
+# relations between templates and their instances.
+
+TEMPLATE_RELATIONS     = NO
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT 
+# tags are set to YES then doxygen will generate a graph for each documented 
+# file showing the direct and indirect include dependencies of the file with 
+# other documented files.
+
+INCLUDE_GRAPH          = YES
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and 
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each 
+# documented header file showing the documented files that directly or 
+# indirectly include this file.
+
+INCLUDED_BY_GRAPH      = YES
+
+# If the CALL_GRAPH and HAVE_DOT options are set to YES then 
+# doxygen will generate a call dependency graph for every global function 
+# or class method. Note that enabling this option will significantly increase 
+# the time of a run. So in most cases it will be better to enable call graphs 
+# for selected functions only using the \callgraph command.
+
+CALL_GRAPH             = NO
+
+# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then 
+# doxygen will generate a caller dependency graph for every global function 
+# or class method. Note that enabling this option will significantly increase 
+# the time of a run. So in most cases it will be better to enable caller 
+# graphs for selected functions only using the \callergraph command.
+
+CALLER_GRAPH           = NO
+
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graphical hierarchy of all classes instead of a textual one.
+
+GRAPHICAL_HIERARCHY    = YES
+
+# If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES 
+# then doxygen will show the dependencies a directory has on other directories 
+# in a graphical way. The dependency relations are determined by the #include 
+# relations between the files in the directories.
+
+DIRECTORY_GRAPH        = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images 
+# generated by dot. Possible values are svg, png, jpg, or gif. 
+# If left blank png will be used. If you choose svg you need to set 
+# HTML_FILE_EXTENSION to xhtml in order to make the SVG files 
+# visible in IE 9+ (other browsers do not have this requirement).
+
+DOT_IMAGE_FORMAT       = png
+
+# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to 
+# enable generation of interactive SVG images that allow zooming and panning. 
+# Note that this requires a modern browser other than Internet Explorer. 
+# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you 
+# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files 
+# visible. Older versions of IE do not have SVG support.
+
+INTERACTIVE_SVG        = NO
+
+# The tag DOT_PATH can be used to specify the path where the dot tool can be 
+# found. If left blank, it is assumed the dot tool can be found in the path.
+
+DOT_PATH               = 
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that 
+# contain dot files that are included in the documentation (see the 
+# \dotfile command).
+
+DOTFILE_DIRS           = 
+
+# The MSCFILE_DIRS tag can be used to specify one or more directories that 
+# contain msc files that are included in the documentation (see the 
+# \mscfile command).
+
+MSCFILE_DIRS           = 
+
+# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of 
+# nodes that will be shown in the graph. If the number of nodes in a graph 
+# becomes larger than this value, doxygen will truncate the graph, which is 
+# visualized by representing a node as a red box. Note that doxygen if the 
+# number of direct children of the root node in a graph is already larger than 
+# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note 
+# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
+
+DOT_GRAPH_MAX_NODES    = 50
+
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the 
+# graphs generated by dot. A depth value of 3 means that only nodes reachable 
+# from the root by following a path via at most 3 edges will be shown. Nodes 
+# that lay further from the root node will be omitted. Note that setting this 
+# option to 1 or 2 may greatly reduce the computation time needed for large 
+# code bases. Also note that the size of a graph can be further restricted by 
+# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
+
+MAX_DOT_GRAPH_DEPTH    = 0
+
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent 
+# background. This is disabled by default, because dot on Windows does not 
+# seem to support this out of the box. Warning: Depending on the platform used, 
+# enabling this option may lead to badly anti-aliased labels on the edges of 
+# a graph (i.e. they become hard to read).
+
+DOT_TRANSPARENT        = NO
+
+# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output 
+# files in one run (i.e. multiple -o and -T options on the command line). This 
+# makes dot run faster, but since only newer versions of dot (>1.8.10) 
+# support this, this feature is disabled by default.
+
+DOT_MULTI_TARGETS      = NO
+
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will 
+# generate a legend page explaining the meaning of the various boxes and 
+# arrows in the dot generated graphs.
+
+GENERATE_LEGEND        = YES
+
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will 
+# remove the intermediate dot files that are used to generate 
+# the various graphs.
+
+DOT_CLEANUP            = YES
diff --git a/contrib/meshtex/GeneralFunctionDialog.cpp b/contrib/meshtex/GeneralFunctionDialog.cpp
new file mode 100644 (file)
index 0000000..f6daebc
--- /dev/null
@@ -0,0 +1,703 @@
+/**
+ * @file GeneralFunctionDialog.cpp
+ * Implements the GeneralFunctionDialog class.
+ * @ingroup meshtex-ui
+ */
+
+/*
+ * Copyright 2012 Joel Baxter
+ *
+ * This file is part of MeshTex.
+ *
+ * MeshTex is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MeshTex is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MeshTex.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <gtk/gtk.h>
+
+#include "GenericPluginUI.h"
+#include "GeneralFunctionDialog.h"
+#include "PluginUIMessages.h"
+
+#include "iundo.h"
+
+
+/**
+ * Constructor. See MeshEntity::GeneralFunction for details of how these
+ * arguments are interpreted.
+ *
+ * @param sFactors      Factors to determine the S texture coords; NULL if S
+ *                      axis unaffected.
+ * @param tFactors      Factors to determine the T texture coords; NULL if T
+ *                      axis unaffected.
+ * @param alignRow      Pointer to zero-point row; if NULL, row 0 is assumed.
+ * @param alignCol      Pointer to zero-point column; if NULL, column 0 is
+ *                      assumed.
+ * @param refRow        Pointer to reference row description, including how
+ *                      to use the reference; NULL if no reference.
+ * @param refCol        Pointer to reference column description, including
+ *                      how to use the reference; NULL if no reference.
+ * @param surfaceValues true if calculations are for S/T values on the mesh
+ *                      surface; false if calculations are for S/T values at
+ *                      the control points.
+ */
+GeneralFunctionDialog::GeneralFunctionVisitor::GeneralFunctionVisitor(
+   const MeshEntity::GeneralFunctionFactors *sFactors,
+   const MeshEntity::GeneralFunctionFactors *tFactors,
+   const MeshEntity::SliceDesignation *alignRow,
+   const MeshEntity::SliceDesignation *alignCol,
+   const MeshEntity::RefSliceDescriptor *refRow,
+   const MeshEntity::RefSliceDescriptor *refCol,
+   bool surfaceValues) :
+   _sFactors(sFactors),
+   _tFactors(tFactors),
+   _alignRow(alignRow),
+   _alignCol(alignCol),
+   _refRow(refRow),
+   _refCol(refCol),
+   _surfaceValues(surfaceValues)
+{
+}
+
+/**
+ * Visitor action; invoke MeshEntity::GeneralFunction on a mesh.
+ *
+ * @param [in,out] meshEntity The mesh.
+ *
+ * @return true.
+ */
+bool
+GeneralFunctionDialog::GeneralFunctionVisitor::Execute(MeshEntity& meshEntity) const
+{
+   meshEntity.GeneralFunction(_sFactors, _tFactors,
+                              _alignRow, _alignCol, _refRow, _refCol,
+                              _surfaceValues);
+   return true;
+}
+
+/**
+ * Constructor. Configure the dialog window and create all the contained
+ * widgets. Connect widgets to callbacks as necessary.
+ *
+ * @param key The unique key identifying this dialog.
+ */
+GeneralFunctionDialog::GeneralFunctionDialog(const std::string& key) :
+   GenericDialog(key),
+   _nullVisitor(new MeshVisitor())
+{
+   // Enable the usual handling of the close event.
+   CreateWindowCloseCallback();
+
+   // Configure the dialog window.
+   gtk_window_set_resizable(GTK_WINDOW(_dialog), FALSE);
+   gtk_window_set_title(GTK_WINDOW(_dialog), DIALOG_GEN_FUNC_TITLE);
+   gtk_container_set_border_width(GTK_CONTAINER(_dialog), 10);
+
+   // Create the contained widgets.
+
+   GtkWidget *table;
+   GtkWidget *entry;
+   GtkWidget *applybutton, *refbutton, *button;
+   GtkWidget *separator;
+   GtkWidget *label;
+   GtkWidget *mainvbox, *vbox, *hbox, *mainhbox;
+   GtkWidget *frame;
+
+   table = gtk_table_new(6, 13, FALSE);
+   gtk_table_set_row_spacing(GTK_TABLE(table), 0, 5);
+   gtk_table_set_row_spacing(GTK_TABLE(table), 1, 10);
+   gtk_table_set_row_spacing(GTK_TABLE(table), 3, 15);
+   gtk_table_set_row_spacing(GTK_TABLE(table), 4, 15);
+   gtk_container_add(GTK_CONTAINER(_dialog), table);
+   gtk_widget_show(table);
+
+   hbox = gtk_hbox_new(TRUE, 10);
+   gtk_table_attach(GTK_TABLE(table), hbox, 0, 13, 0, 1, GTK_SHRINK, GTK_EXPAND, 0, 0);
+   gtk_widget_show(hbox);
+
+   // Mutually exclusive "Surface values" and "Control values" radio buttons.
+
+   button = gtk_radio_button_new_with_label(NULL,
+                                            DIALOG_GEN_FUNC_SURFACE_VALUES);
+   gtk_object_set_data(GTK_OBJECT(_dialog), "surface", button);
+   gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
+   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
+   gtk_widget_show(button);
+
+   button = gtk_radio_button_new_with_label(
+      gtk_radio_button_group(GTK_RADIO_BUTTON(button)),
+                             DIALOG_GEN_FUNC_CONTROL_VALUES);
+   gtk_object_set_data(GTK_OBJECT(_dialog), "control", button);
+   gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
+   gtk_widget_show(button);
+
+   separator = gtk_hseparator_new();
+   gtk_table_attach_defaults(GTK_TABLE(table), separator, 0, 13, 1, 2);
+   gtk_widget_show(separator);
+
+   // Checkbox for the "S" row of factors. All the other widgets on this row
+   // will have a dependence registered on this checkbox; i.e. they will only
+   // be active when it is checked.
+
+   applybutton = gtk_check_button_new();
+   gtk_object_set_data(GTK_OBJECT(_dialog), "s_apply", applybutton);
+   gtk_table_attach_defaults(GTK_TABLE(table), applybutton, 0, 1, 2, 3);
+   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(applybutton), TRUE);
+   gtk_widget_show(applybutton);
+
+   label = gtk_label_new(DIALOG_GEN_FUNC_S_FUNC_LABEL);
+   gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 2, 3);
+   gtk_widget_show(label);
+
+   UIInstance().RegisterWidgetDependence(applybutton, label);
+
+   entry = gtk_entry_new();
+   gtk_object_set_data(GTK_OBJECT(_dialog), "s_oldval", entry);
+   gtk_entry_set_text(GTK_ENTRY(entry), "1.0");
+   gtk_table_attach_defaults(GTK_TABLE(table), entry, 2, 3, 2, 3);
+   gtk_widget_set_usize(entry, 50, -2);
+   gtk_widget_show(entry);
+
+   UIInstance().RegisterWidgetDependence(applybutton, entry);
+
+   label = gtk_label_new(DIALOG_GEN_FUNC_OLD_S_LABEL);
+   gtk_table_attach_defaults(GTK_TABLE(table), label, 3, 4, 2, 3);
+   gtk_widget_show(label);
+
+   UIInstance().RegisterWidgetDependence(applybutton, label);
+
+   entry = gtk_entry_new();
+   gtk_object_set_data(GTK_OBJECT(_dialog), "s_rowdist", entry);
+   gtk_entry_set_text(GTK_ENTRY(entry), "0.0");
+   gtk_table_attach_defaults(GTK_TABLE(table), entry, 4, 5, 2, 3);
+   gtk_widget_set_usize(entry, 50, -2);
+   gtk_widget_show(entry);
+
+   UIInstance().RegisterWidgetDependence(applybutton, entry);
+
+   label = gtk_label_new(DIALOG_GEN_FUNC_ROW_DIST_LABEL);
+   gtk_table_attach_defaults(GTK_TABLE(table), label, 5, 6, 2, 3);
+   gtk_widget_show(label);
+
+   UIInstance().RegisterWidgetDependence(applybutton, label);
+
+   entry = gtk_entry_new();
+   gtk_object_set_data(GTK_OBJECT(_dialog), "s_coldist", entry);
+   gtk_entry_set_text(GTK_ENTRY(entry), "0.0");
+   gtk_table_attach_defaults(GTK_TABLE(table), entry, 6, 7, 2, 3);
+   gtk_widget_set_usize(entry, 50, -2);
+   gtk_widget_show(entry);
+
+   UIInstance().RegisterWidgetDependence(applybutton, entry);
+
+   label = gtk_label_new(DIALOG_GEN_FUNC_COL_DIST_LABEL);
+   gtk_table_attach_defaults(GTK_TABLE(table), label, 7, 8, 2, 3);
+   gtk_widget_show(label);
+
+   UIInstance().RegisterWidgetDependence(applybutton, label);
+
+   entry = gtk_entry_new();
+   gtk_object_set_data(GTK_OBJECT(_dialog), "s_rownum", entry);
+   gtk_entry_set_text(GTK_ENTRY(entry), "0.0");
+   gtk_table_attach_defaults(GTK_TABLE(table), entry, 8, 9, 2, 3);
+   gtk_widget_set_usize(entry, 50, -2);
+   gtk_widget_show(entry);
+
+   UIInstance().RegisterWidgetDependence(applybutton, entry);
+
+   label = gtk_label_new(DIALOG_GEN_FUNC_ROW_NUM_LABEL);
+   gtk_table_attach_defaults(GTK_TABLE(table), label, 9, 10, 2, 3);
+   gtk_widget_show(label);
+
+   UIInstance().RegisterWidgetDependence(applybutton, label);
+
+   entry = gtk_entry_new();
+   gtk_object_set_data(GTK_OBJECT(_dialog), "s_colnum", entry);
+   gtk_entry_set_text(GTK_ENTRY(entry), "0.0");
+   gtk_table_attach_defaults(GTK_TABLE(table), entry, 10, 11, 2, 3);
+   gtk_widget_set_usize(entry, 50, -2);
+   gtk_widget_show(entry);
+
+   UIInstance().RegisterWidgetDependence(applybutton, entry);
+
+   label = gtk_label_new(DIALOG_GEN_FUNC_COL_NUM_LABEL);
+   gtk_table_attach_defaults(GTK_TABLE(table), label, 11, 12, 2, 3);
+   gtk_widget_show(label);
+
+   UIInstance().RegisterWidgetDependence(applybutton, label);
+
+   entry = gtk_entry_new();
+   gtk_object_set_data(GTK_OBJECT(_dialog), "s_constant", entry);
+   gtk_entry_set_text(GTK_ENTRY(entry), "0.0");
+   gtk_table_attach_defaults(GTK_TABLE(table), entry, 12, 13, 2, 3);
+   gtk_widget_set_usize(entry, 50, -2);
+   gtk_widget_show(entry);
+
+   UIInstance().RegisterWidgetDependence(applybutton, entry);
+
+   // Checkbox for the "T" row of factors. All the other widgets on this row
+   // will have a dependence registered on this checkbox; i.e. they will only
+   // be active when it is checked.
+
+   applybutton = gtk_check_button_new();
+   gtk_object_set_data(GTK_OBJECT(_dialog), "t_apply", applybutton);
+   gtk_table_attach_defaults(GTK_TABLE(table), applybutton, 0, 1, 3, 4);
+   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(applybutton), TRUE);
+   gtk_widget_show(applybutton);
+
+   label = gtk_label_new(DIALOG_GEN_FUNC_T_FUNC_LABEL);
+   gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 3, 4);
+   gtk_widget_show(label);
+
+   UIInstance().RegisterWidgetDependence(applybutton, label);
+
+   entry = gtk_entry_new();
+   gtk_object_set_data(GTK_OBJECT(_dialog), "t_oldval", entry);
+   gtk_entry_set_text(GTK_ENTRY(entry), "1.0");
+   gtk_table_attach_defaults(GTK_TABLE(table), entry, 2, 3, 3, 4);
+   gtk_widget_set_usize(entry, 50, -2);
+   gtk_widget_show(entry);
+
+   UIInstance().RegisterWidgetDependence(applybutton, entry);
+
+   label = gtk_label_new(DIALOG_GEN_FUNC_OLD_T_LABEL);
+   gtk_table_attach_defaults(GTK_TABLE(table), label, 3, 4, 3, 4);
+   gtk_widget_show(label);
+
+   UIInstance().RegisterWidgetDependence(applybutton, label);
+
+   entry = gtk_entry_new();
+   gtk_object_set_data(GTK_OBJECT(_dialog), "t_rowdist", entry);
+   gtk_entry_set_text(GTK_ENTRY(entry), "0.0");
+   gtk_table_attach_defaults(GTK_TABLE(table), entry, 4, 5, 3, 4);
+   gtk_widget_set_usize(entry, 50, -2);
+   gtk_widget_show(entry);
+
+   UIInstance().RegisterWidgetDependence(applybutton, entry);
+
+   label = gtk_label_new(DIALOG_GEN_FUNC_ROW_DIST_LABEL);
+   gtk_table_attach_defaults(GTK_TABLE(table), label, 5, 6, 3, 4);
+   gtk_widget_show(label);
+
+   UIInstance().RegisterWidgetDependence(applybutton, label);
+
+   entry = gtk_entry_new();
+   gtk_object_set_data(GTK_OBJECT(_dialog), "t_coldist", entry);
+   gtk_entry_set_text(GTK_ENTRY(entry), "0.0");
+   gtk_table_attach_defaults(GTK_TABLE(table), entry, 6, 7, 3, 4);
+   gtk_widget_set_usize(entry, 50, -2);
+   gtk_widget_show(entry);
+
+   UIInstance().RegisterWidgetDependence(applybutton, entry);
+
+   label = gtk_label_new(DIALOG_GEN_FUNC_COL_DIST_LABEL);
+   gtk_table_attach_defaults(GTK_TABLE(table), label, 7, 8, 3, 4);
+   gtk_widget_show(label);
+
+   UIInstance().RegisterWidgetDependence(applybutton, label);
+
+   entry = gtk_entry_new();
+   gtk_object_set_data(GTK_OBJECT(_dialog), "t_rownum", entry);
+   gtk_entry_set_text(GTK_ENTRY(entry), "0.0");
+   gtk_table_attach_defaults(GTK_TABLE(table), entry, 8, 9, 3, 4);
+   gtk_widget_set_usize(entry, 50, -2);
+   gtk_widget_show(entry);
+
+   UIInstance().RegisterWidgetDependence(applybutton, entry);
+
+   label = gtk_label_new(DIALOG_GEN_FUNC_ROW_NUM_LABEL);
+   gtk_table_attach_defaults(GTK_TABLE(table), label, 9, 10, 3, 4);
+   gtk_widget_show(label);
+
+   UIInstance().RegisterWidgetDependence(applybutton, label);
+
+   entry = gtk_entry_new();
+   gtk_object_set_data(GTK_OBJECT(_dialog), "t_colnum", entry);
+   gtk_entry_set_text(GTK_ENTRY(entry), "0.0");
+   gtk_table_attach_defaults(GTK_TABLE(table), entry, 10, 11, 3, 4);
+   gtk_widget_set_usize(entry, 50, -2);
+   gtk_widget_show(entry);
+
+   UIInstance().RegisterWidgetDependence(applybutton, entry);
+
+   label = gtk_label_new(DIALOG_GEN_FUNC_COL_NUM_LABEL);
+   gtk_table_attach_defaults(GTK_TABLE(table), label, 11, 12, 3, 4);
+   gtk_widget_show(label);
+
+   UIInstance().RegisterWidgetDependence(applybutton, label);
+
+   entry = gtk_entry_new();
+   gtk_object_set_data(GTK_OBJECT(_dialog), "t_constant", entry);
+   gtk_entry_set_text(GTK_ENTRY(entry), "0.0");
+   gtk_table_attach_defaults(GTK_TABLE(table), entry, 12, 13, 3, 4);
+   gtk_widget_set_usize(entry, 50, -2);
+   gtk_widget_show(entry);
+
+   UIInstance().RegisterWidgetDependence(applybutton, entry);
+
+   mainhbox = gtk_hbox_new(TRUE, 0);
+   gtk_table_attach(GTK_TABLE(table), mainhbox, 0, 13, 4, 5, GTK_SHRINK, GTK_EXPAND, 0, 0);
+   gtk_widget_show(mainhbox);
+
+   mainvbox = gtk_vbox_new(FALSE, 0);
+   gtk_box_pack_start(GTK_BOX(mainhbox), mainvbox, FALSE, FALSE, 0);
+   gtk_widget_show(mainvbox);
+
+   hbox = gtk_hbox_new(FALSE, 0);
+   gtk_box_pack_start(GTK_BOX(mainvbox), hbox, TRUE, TRUE, 5);
+   gtk_widget_show(hbox);
+
+   frame = gtk_frame_new(DIALOG_GEN_FUNC_COL_ALIGN_FRAME_LABEL);
+   gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, 5);
+   gtk_widget_show(frame);
+
+   vbox = gtk_vbox_new(FALSE, 0);
+   gtk_container_add(GTK_CONTAINER(frame), vbox);
+   gtk_widget_show(vbox);
+
+   hbox = gtk_hbox_new(FALSE, 0);
+   gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 5);
+   gtk_widget_show(hbox);
+
+   // Widgets for specifying the alignment column.
+
+   button = gtk_radio_button_new(NULL);
+   gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 5);
+   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
+   gtk_widget_show(button);
+
+   entry = gtk_entry_new();
+   gtk_object_set_data(GTK_OBJECT(_dialog), "col_num_align", entry);
+   gtk_entry_set_text(GTK_ENTRY(entry), "0");
+   gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 5);
+   gtk_widget_set_usize(entry, 25, -2);
+   gtk_widget_show(entry);
+
+   UIInstance().RegisterWidgetDependence(button, entry);
+
+   button = gtk_radio_button_new_with_label(
+      gtk_radio_button_group(GTK_RADIO_BUTTON(button)),
+                             DIALOG_GEN_FUNC_MAX_OPT_LABEL);
+   gtk_object_set_data(GTK_OBJECT(_dialog), "col_max_align", button);
+   gtk_box_pack_end(GTK_BOX(hbox), button, TRUE, FALSE, 5);
+   gtk_widget_show(button);
+
+   hbox = gtk_hbox_new(FALSE, 0);
+   gtk_box_pack_start(GTK_BOX(mainvbox), hbox, TRUE, TRUE, 5);
+   gtk_widget_show(hbox);
+
+   // Widgets for specifying the reference row & usage.
+
+   refbutton = gtk_check_button_new_with_label(DIALOG_GEN_FUNC_REF_ROW_FRAME_LABEL);
+   gtk_object_set_data(GTK_OBJECT(_dialog), "row_ref", refbutton);
+   gtk_widget_show(refbutton);
+
+   frame = gtk_frame_new(NULL);
+   gtk_frame_set_label_widget(GTK_FRAME(frame), refbutton);
+   gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, 5);
+   gtk_widget_show(frame);
+
+   vbox = gtk_vbox_new(FALSE, 0);
+   gtk_container_add(GTK_CONTAINER(frame), vbox);
+   gtk_widget_show(vbox);
+
+   hbox = gtk_hbox_new(FALSE, 0);
+   gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 5);
+   gtk_widget_show(hbox);
+
+   button = gtk_radio_button_new(NULL);
+   gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 5);
+   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
+   gtk_widget_set_sensitive(button, FALSE);
+   gtk_widget_show(button);
+
+   UIInstance().RegisterWidgetDependence(refbutton, button);
+
+   entry = gtk_entry_new();
+   gtk_object_set_data(GTK_OBJECT(_dialog), "row_num_ref", entry);
+   gtk_entry_set_text(GTK_ENTRY(entry), "0");
+   gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 5);
+   gtk_widget_set_usize(entry, 25, -2);
+   gtk_widget_set_sensitive(entry, FALSE);
+   gtk_widget_show(entry);
+
+   UIInstance().RegisterWidgetDependence(refbutton, entry);
+   UIInstance().RegisterWidgetDependence(button, entry);
+
+   button = gtk_radio_button_new_with_label(
+      gtk_radio_button_group(GTK_RADIO_BUTTON(button)),
+                             DIALOG_GEN_FUNC_MAX_OPT_LABEL);
+   gtk_object_set_data(GTK_OBJECT(_dialog), "row_max_ref", button);
+   gtk_box_pack_end(GTK_BOX(hbox), button, TRUE, FALSE, 5);
+   gtk_widget_set_sensitive(button, FALSE);
+   gtk_widget_show(button);
+
+   UIInstance().RegisterWidgetDependence(refbutton, button);
+
+   hbox = gtk_hbox_new(FALSE, 0);
+   gtk_box_pack_end(GTK_BOX(vbox), hbox, TRUE, TRUE, 5);
+   gtk_widget_show(hbox);
+
+   button = gtk_check_button_new_with_label(DIALOG_GEN_FUNC_REF_TOTAL_OPT_LABEL);
+   gtk_object_set_data(GTK_OBJECT(_dialog), "row_ref_total", button);
+   gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 5);
+   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
+   gtk_widget_set_sensitive(button, FALSE);
+   gtk_widget_show(button);
+
+   UIInstance().RegisterWidgetDependence(refbutton, button);
+
+   mainvbox = gtk_vbox_new(FALSE, 0);
+   gtk_box_pack_end(GTK_BOX(mainhbox), mainvbox, FALSE, FALSE, 0);
+   gtk_widget_show(mainvbox);
+
+   hbox = gtk_hbox_new(FALSE, 0);
+   gtk_box_pack_start(GTK_BOX(mainvbox), hbox, TRUE, TRUE, 5);
+   gtk_widget_show(hbox);
+
+   frame = gtk_frame_new(DIALOG_GEN_FUNC_ROW_ALIGN_FRAME_LABEL);
+   gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, 5);
+   gtk_widget_show(frame);
+
+   vbox = gtk_vbox_new(FALSE, 0);
+   gtk_container_add(GTK_CONTAINER(frame), vbox);
+   gtk_widget_show(vbox);
+
+   hbox = gtk_hbox_new(FALSE, 0);
+   gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 5);
+   gtk_widget_show(hbox);
+
+   // Widgets for specifying the alignment row.
+
+   button = gtk_radio_button_new(NULL);
+   gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 5);
+   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
+   gtk_widget_show(button);
+
+   entry = gtk_entry_new();
+   gtk_object_set_data(GTK_OBJECT(_dialog), "row_num_align", entry);
+   gtk_entry_set_text(GTK_ENTRY(entry), "0");
+   gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 5);
+   gtk_widget_set_usize(entry, 25, -2);
+   gtk_widget_show(entry);
+
+   UIInstance().RegisterWidgetDependence(button, entry);
+
+   button = gtk_radio_button_new_with_label(
+      gtk_radio_button_group(GTK_RADIO_BUTTON(button)),
+                             DIALOG_GEN_FUNC_MAX_OPT_LABEL);
+   gtk_object_set_data(GTK_OBJECT(_dialog), "row_max_align", button);
+   gtk_box_pack_end(GTK_BOX(hbox), button, TRUE, FALSE, 5);
+   gtk_widget_show(button);
+
+   hbox = gtk_hbox_new(FALSE, 0);
+   gtk_box_pack_start(GTK_BOX(mainvbox), hbox, TRUE, TRUE, 5);
+   gtk_widget_show(hbox);
+
+   // Widgets for specifying the reference column & usage.
+
+   refbutton = gtk_check_button_new_with_label(DIALOG_GEN_FUNC_REF_COL_FRAME_LABEL);
+   gtk_object_set_data(GTK_OBJECT(_dialog), "col_ref", refbutton);
+   gtk_widget_show(refbutton);
+
+   frame = gtk_frame_new(NULL);
+   gtk_frame_set_label_widget(GTK_FRAME(frame), refbutton);
+   gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, 5);
+   gtk_widget_show(frame);
+
+   vbox = gtk_vbox_new(FALSE, 0);
+   gtk_container_add(GTK_CONTAINER(frame), vbox);
+   gtk_widget_show(vbox);
+
+   hbox = gtk_hbox_new(FALSE, 0);
+   gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 5);
+   gtk_widget_show(hbox);
+
+   button = gtk_radio_button_new(NULL);
+   gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 5);
+   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
+   gtk_widget_set_sensitive(button, FALSE);
+   gtk_widget_show(button);
+
+   UIInstance().RegisterWidgetDependence(refbutton, button);
+
+   entry = gtk_entry_new();
+   gtk_object_set_data(GTK_OBJECT(_dialog), "col_num_ref", entry);
+   gtk_entry_set_text(GTK_ENTRY(entry), "0");
+   gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 5);
+   gtk_widget_set_usize(entry, 25, -2);
+   gtk_widget_set_sensitive(entry, FALSE);
+   gtk_widget_show(entry);
+
+   UIInstance().RegisterWidgetDependence(refbutton, entry);
+   UIInstance().RegisterWidgetDependence(button, entry);
+
+   button = gtk_radio_button_new_with_label(
+      gtk_radio_button_group(GTK_RADIO_BUTTON(button)),
+                             DIALOG_GEN_FUNC_MAX_OPT_LABEL);
+   gtk_object_set_data(GTK_OBJECT(_dialog), "col_max_ref", button);
+   gtk_box_pack_end(GTK_BOX(hbox), button, TRUE, FALSE, 5);
+   gtk_widget_set_sensitive(button, FALSE);
+   gtk_widget_show(button);
+
+   UIInstance().RegisterWidgetDependence(refbutton, button);
+
+   hbox = gtk_hbox_new(FALSE, 0);
+   gtk_box_pack_end(GTK_BOX(vbox), hbox, TRUE, TRUE, 5);
+   gtk_widget_show(hbox);
+
+   button = gtk_check_button_new_with_label(DIALOG_GEN_FUNC_REF_TOTAL_OPT_LABEL);
+   gtk_object_set_data(GTK_OBJECT(_dialog), "col_ref_total", button);
+   gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 5);
+   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
+   gtk_widget_set_sensitive(button, FALSE);
+   gtk_widget_show(button);
+
+   UIInstance().RegisterWidgetDependence(refbutton, button);
+
+   hbox = gtk_hbox_new(FALSE, 0);
+   gtk_table_attach_defaults(GTK_TABLE(table), hbox, 0, 13, 5, 6);
+   gtk_widget_show(hbox);
+
+   // Create Cancel button and hook it to callback.
+
+   button = gtk_button_new_with_label(DIALOG_CANCEL_BUTTON);
+   gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
+   gtk_widget_set_usize(button, 60, -2);
+   gtk_widget_show(button);
+
+   CreateCancelButtonCallback(button);
+
+   // Create Apply button and hook it to callback.
+
+   button = gtk_button_new_with_label(DIALOG_APPLY_BUTTON);
+   gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 10);
+   gtk_widget_set_usize (button, 60, -2);
+   gtk_widget_show(button);
+
+   CreateApplyButtonCallback(button);
+
+   // Create OK button and hook it to callback.
+
+   button = gtk_button_new_with_label(DIALOG_OK_BUTTON);
+   gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
+   gtk_widget_set_usize (button, 60, -2);
+   gtk_widget_show(button);
+
+   CreateOkButtonCallback(button);
+}
+
+/**
+ * Destructor.
+ */
+GeneralFunctionDialog::~GeneralFunctionDialog()
+{
+}
+
+/**
+ * Handler for the Apply logic for this dialog. Apply the specified equations
+ * to the selected mesh entities.
+ *
+ * @return true if any meshes are selected, false otherwise.
+ */
+bool
+GeneralFunctionDialog::Apply()
+{
+   // Before doing anything, check to see if there are some meshes selected.
+   _nullVisitor->ResetVisitedCount();
+   GlobalSelectionSystem().foreachSelected(*_nullVisitor);
+   if (_nullVisitor->GetVisitedCount() == 0)
+   {
+      // Nope. Warn and bail out.
+      GenericPluginUI::WarningReportDialog(DIALOG_WARNING_TITLE,
+                                           DIALOG_NOMESHES_MSG);
+      return false;
+   }
+
+   // See if we're going to be affecting the S and/or T texture axis.
+   bool sApply = NamedToggleWidgetActive("s_apply");
+   bool tApply = NamedToggleWidgetActive("t_apply");
+
+   if (!sApply && !tApply)
+   {
+      // Not affecting either, so bail out.
+      return true;
+   }
+
+   // OK read the remaining info from the widgets.
+
+   MeshEntity::GeneralFunctionFactors s, t;
+   MeshEntity::GeneralFunctionFactors *sFactors = NULL;
+   MeshEntity::GeneralFunctionFactors *tFactors = NULL;
+   if (sApply)
+   {
+      // S axis is affected, so read the S factors.
+      s.oldValue = (float)atof(NamedEntryWidgetText("s_oldval"));
+      s.rowDistance = (float)atof(NamedEntryWidgetText("s_rowdist"));
+      s.colDistance = (float)atof(NamedEntryWidgetText("s_coldist"));
+      s.rowNumber = (float)atof(NamedEntryWidgetText("s_rownum"));
+      s.colNumber = (float)atof(NamedEntryWidgetText("s_colnum"));
+      s.constant = (float)atof(NamedEntryWidgetText("s_constant"));
+      sFactors = &s;
+   }
+   if (tApply)
+   {
+      // T axis is affected, so read the T factors.
+      t.oldValue = (float)atof(NamedEntryWidgetText("t_oldval"));
+      t.rowDistance = (float)atof(NamedEntryWidgetText("t_rowdist"));
+      t.colDistance = (float)atof(NamedEntryWidgetText("t_coldist"));
+      t.rowNumber = (float)atof(NamedEntryWidgetText("t_rownum"));
+      t.colNumber = (float)atof(NamedEntryWidgetText("t_colnum"));
+      t.constant = (float)atof(NamedEntryWidgetText("t_constant"));
+      tFactors = &t;
+   }
+   MeshEntity::SliceDesignation alignRow, alignCol;
+   alignRow.maxSlice = NamedToggleWidgetActive("row_max_align");
+   alignRow.index = atoi(NamedEntryWidgetText("row_num_align"));
+   alignCol.maxSlice = NamedToggleWidgetActive("col_max_align");
+   alignCol.index = atoi(NamedEntryWidgetText("col_num_align"));
+   MeshEntity::RefSliceDescriptor row, col;
+   MeshEntity::RefSliceDescriptor *refRow = NULL;
+   MeshEntity::RefSliceDescriptor *refCol = NULL;
+   if (NamedToggleWidgetActive("row_ref"))
+   {
+      // Reference row is specified, so get that info.
+      row.designation.maxSlice = NamedToggleWidgetActive("row_max_ref");
+      row.designation.index = atoi(NamedEntryWidgetText("row_num_ref"));
+      row.totalLengthOnly = NamedToggleWidgetActive("row_ref_total");
+      refRow = &row;
+   }
+   if (NamedToggleWidgetActive("col_ref"))
+   {
+      // Reference column is specified, so get that info.
+      col.designation.maxSlice = NamedToggleWidgetActive("col_max_ref");
+      col.designation.index = atoi(NamedEntryWidgetText("col_num_ref"));
+      col.totalLengthOnly = NamedToggleWidgetActive("col_ref_total");
+      refCol = &col;
+   }
+   bool surfaceValues = NamedToggleWidgetActive("surface");
+
+   // Let Radiant know the name of the operation responsible for the changes
+   // that are about to happen.
+   UndoableCommand undo(_triggerCommand.c_str());
+
+   // Apply the specified equation to every selected mesh.
+   SmartPointer<GeneralFunctionVisitor> funcVisitor(
+      new GeneralFunctionVisitor(sFactors, tFactors,
+                                 &alignRow, &alignCol, refRow, refCol,
+                                 surfaceValues));
+   GlobalSelectionSystem().foreachSelected(*funcVisitor);
+
+   // Done!
+   return true;
+}
diff --git a/contrib/meshtex/GeneralFunctionDialog.h b/contrib/meshtex/GeneralFunctionDialog.h
new file mode 100644 (file)
index 0000000..2ef2357
--- /dev/null
@@ -0,0 +1,85 @@
+/**
+ * @file GeneralFunctionDialog.h
+ * Declares the GeneralFunctionDialog class.
+ * @ingroup meshtex-ui
+ */
+
+/*
+ * Copyright 2012 Joel Baxter
+ *
+ * This file is part of MeshTex.
+ *
+ * MeshTex is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MeshTex is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MeshTex.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#if !defined(INCLUDED_GENERALFUNCTIONDIALOG_H)
+#define INCLUDED_GENERALFUNCTIONDIALOG_H
+
+#include "GenericDialog.h"
+#include "MeshVisitor.h"
+
+/**
+ * Subclass of GenericDialog that implements the window summoned by selecting
+ * the General Function menu entry. This window is used to specify equations
+ * for setting S and T values as a linear combination of various factors.
+ *
+ * @image html genfunc.png
+ * 
+ * @ingroup meshtex-ui
+ */
+class GeneralFunctionDialog : public GenericDialog
+{
+private: // private types
+
+   /**
+    * Visitor for applying the chosen equation to a mesh.
+    */
+   class GeneralFunctionVisitor : public MeshVisitor
+   {
+   public:
+      GeneralFunctionVisitor(const MeshEntity::GeneralFunctionFactors *sFactors,
+                             const MeshEntity::GeneralFunctionFactors *tFactors,
+                             const MeshEntity::SliceDesignation *alignRow,
+                             const MeshEntity::SliceDesignation *alignCol,
+                             const MeshEntity::RefSliceDescriptor *refRow,
+                             const MeshEntity::RefSliceDescriptor *refCol,
+                             bool surfaceValues);
+   private:
+      bool Execute(MeshEntity& meshEntity) const;
+   private:
+      const MeshEntity::GeneralFunctionFactors *_sFactors;
+      const MeshEntity::GeneralFunctionFactors *_tFactors;
+      const MeshEntity::SliceDesignation *_alignRow;
+      const MeshEntity::SliceDesignation *_alignCol;
+      const MeshEntity::RefSliceDescriptor *_refRow;
+      const MeshEntity::RefSliceDescriptor *_refCol;
+      bool _surfaceValues;
+   };
+
+public: // public methods
+
+   GeneralFunctionDialog(const std::string& key);
+   ~GeneralFunctionDialog();
+   bool Apply();
+
+private: // private member vars
+
+   /**
+    * Action-less mesh visitor used purely to count the number of selected mesh
+    * entities.
+    */
+   SmartPointer<MeshVisitor> _nullVisitor;
+};
+
+#endif // #if !defined(INCLUDED_GENERALFUNCTIONDIALOG_H)
\ No newline at end of file
diff --git a/contrib/meshtex/GenericDialog.cpp b/contrib/meshtex/GenericDialog.cpp
new file mode 100644 (file)
index 0000000..d007828
--- /dev/null
@@ -0,0 +1,268 @@
+/**
+ * @file GenericDialog.cpp
+ * Implements the GenericDialog class.
+ * @ingroup generic-ui
+ */
+
+/*
+ * Copyright 2012 Joel Baxter
+ *
+ * This file is part of MeshTex.
+ *
+ * MeshTex is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MeshTex is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MeshTex.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <gtk/gtk.h>
+
+#include "GenericDialog.h"
+#include "GenericPluginUI.h"
+
+
+/**
+ * Constructor. Create the GTK+ widget for the dialog window (not visible
+ * yet). Initialize callback IDs to zero (invalid). Note that as this is a
+ * protected method, GenericDialog objects cannot be created directly; only
+ * subclasses of GenericDialog can be created.
+ *
+ * @param key Unique key to identify this dialog widget.
+ */
+GenericDialog::GenericDialog(const std::string& key) :
+   _dialog(gtk_window_new(GTK_WINDOW_TOPLEVEL)),
+   _window(NULL),
+   _key(key),
+   _okCallbackID(0),
+   _applyCallbackID(0),
+   _cancelCallbackID(0)
+{
+   // XXX Should we go ahead invoke CreateWindowCloseCallback here (and make it
+   // private) rather than leaving that to the subclass constructors? Depends on
+   // whether it's plausible that a dialog would ever NOT want the usual
+   // handling for the close event.
+}
+
+/**
+ * Virtual destructor. Destroy the GTK+ dialog widget (and therefore its
+ * contained widgets) if necessary.
+ */
+GenericDialog::~GenericDialog()
+{
+   if (_dialog != NULL)
+   {
+      gtk_widget_destroy(_dialog);
+   }
+}
+
+/**
+ * Get the unique key that identifies this dialog widget.
+ *
+ * @return The key.
+ */
+const std::string&
+GenericDialog::GetKey() const
+{
+   return _key;
+}
+
+/**
+ * Mark this window widget as a modal dialog for a parent window.
+ *
+ * @param window The parent window.
+ */
+void
+GenericDialog::SetWindow(GtkWidget *window)
+{
+   // Remember the parent window.
+   _window = window;
+   // Mark this widget as a modal dialog for it.
+   if (_dialog != NULL)
+   {
+      gtk_window_set_transient_for(GTK_WINDOW(_dialog), GTK_WINDOW(_window));
+   }
+}
+
+/**
+ * Raise this dialog window to the top of the window stack.
+ */
+void
+GenericDialog::Raise()
+{
+   // Don't bother if not visible.
+   if (GTK_WIDGET_VISIBLE(_dialog))
+   {
+      gdk_window_raise(_dialog->window);
+   }
+}
+
+/**
+ * Make this dialog window visible and foreground.
+ *
+ * @param triggerCommand The command token that summoned the dialog.
+ */
+void
+GenericDialog::Show(const std::string& triggerCommand)
+{
+   // Remember the command token that summoned the dialog; subclasses can make
+   // use of this information.
+   _triggerCommand = triggerCommand;
+   // Show the window if it is currently hidden.
+   if (!GTK_WIDGET_VISIBLE(_dialog))
+   {
+      gtk_widget_show(_dialog);
+   }
+   // Raise the window to the top of the stack.
+   Raise();
+}
+
+/**
+ * Hide this dialog window.
+ */
+void
+GenericDialog::Hide()
+{
+   // Bail out if the window is already invisible.
+   if (!GTK_WIDGET_VISIBLE(_dialog))
+   {
+      return;
+   }
+   // Hide the window.
+   gtk_widget_hide(_dialog);
+   // If there's a parent window, raise it to the top of the stack.
+   if (_window == NULL)
+   {
+      return;
+   }
+   gdk_window_raise(_window->window);
+}
+
+/**
+ * Default handler for Apply logic. This method should be overriden by
+ * subclass implementations that need to execute some logic when OK or Apply
+ * is clicked. The return value should be the success of that logic. A
+ * successful OK will cause the window to be hidden.
+ *
+ * @return true if the apply logic executed; always the case in this skeleton
+ *         implementation.
+ */
+bool
+GenericDialog::Apply()
+{
+   // Default logic does nothing.
+   return true;
+}
+
+/**
+ * Callback for window-close event.
+ *
+ * @param widget     This dialog window widget.
+ * @param event      The event that instigated the callback.
+ * @param callbackID Unique numerical ID for the callback.
+ *
+ * @return TRUE as defined by glib.
+ */
+gint
+GenericDialog::CloseEventCallback(GtkWidget *widget,
+                                  GdkEvent* event,
+                                  gpointer callbackID)
+{
+   // All we need to do is hide the window.
+   Hide();
+   return TRUE;
+}
+
+/**
+ * Callback for clicking on OK/Apply/Cancel button.
+ *
+ * @param widget     This dialog window widget.
+ * @param callbackID Unique numerical ID for the callback.
+ */
+void
+GenericDialog::FinalizeCallback(GtkWidget *widget,
+                                gpointer callbackID)
+{
+   // Assume success until we have to do something.
+   bool success = true;
+   // If this is not a Cancel callback, run the Apply logic.
+   if (callbackID != _cancelCallbackID)
+   {
+      success = Apply();
+   }
+   // Hide the window if this is a cancel or a successful OK callback.
+   if (success && callbackID != _applyCallbackID)
+   {
+      Hide();
+   }
+}
+
+/**
+ * Register the callback for the close-window event.
+ */
+void
+GenericDialog::CreateWindowCloseCallback()
+{
+   // The close-window event will trigger the CloseEventCallback method.
+   const GenericPluginUI::DialogEventCallbackMethod
+      <GenericDialog, &GenericDialog::CloseEventCallback> closeCallback(*this);
+   UIInstance().RegisterDialogEventCallback(_dialog, "delete_event", closeCallback);
+}
+
+/**
+ * Register the callback for the OK button.
+ *
+ * @param button The OK button widget.
+ */
+void
+GenericDialog::CreateOkButtonCallback(GtkWidget *button)
+{
+   // Clicking the OK button will trigger the FinalizeCallback method. Since
+   // FinalizeCallback can be used for multiple buttons, we'll save the specific
+   // callback ID associated with the OK button.
+   const GenericPluginUI::DialogSignalCallbackMethod
+      <GenericDialog, &GenericDialog::FinalizeCallback> finalizeCallback(*this);
+   _okCallbackID =
+      UIInstance().RegisterDialogSignalCallback(button, "clicked", finalizeCallback);
+}
+
+/**
+ * Register the callback for the Apply button.
+ *
+ * @param button The Apply button widget.
+ */
+void
+GenericDialog::CreateApplyButtonCallback(GtkWidget *button)
+{
+   // Clicking the Apply button will trigger the FinalizeCallback method. Since
+   // FinalizeCallback can be used for multiple buttons, we'll save the specific
+   // callback ID associated with the Apply button.
+   const GenericPluginUI::DialogSignalCallbackMethod
+      <GenericDialog, &GenericDialog::FinalizeCallback> finalizeCallback(*this);
+   _applyCallbackID =
+      UIInstance().RegisterDialogSignalCallback(button, "clicked", finalizeCallback);
+}
+
+/**
+ * Register the callback for the Cancel button.
+ *
+ * @param button The Cancel button widget.
+ */
+void
+GenericDialog::CreateCancelButtonCallback(GtkWidget *button)
+{
+   // Clicking the Cancel button will trigger the FinalizeCallback method. Since
+   // FinalizeCallback can be used for multiple buttons, we'll save the specific
+   // callback ID associated with the Cancel button.
+   const GenericPluginUI::DialogSignalCallbackMethod
+      <GenericDialog, &GenericDialog::FinalizeCallback> finalizeCallback(*this);
+   _cancelCallbackID =
+      UIInstance().RegisterDialogSignalCallback(button, "clicked", finalizeCallback);
+}
diff --git a/contrib/meshtex/GenericDialog.h b/contrib/meshtex/GenericDialog.h
new file mode 100644 (file)
index 0000000..705a2fc
--- /dev/null
@@ -0,0 +1,156 @@
+/**
+ * @file GenericDialog.h
+ * Declares the GenericDialog class.
+ * @ingroup generic-ui
+ */
+
+/*
+ * Copyright 2012 Joel Baxter
+ *
+ * This file is part of MeshTex.
+ *
+ * MeshTex is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MeshTex is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MeshTex.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#if !defined(INCLUDED_GENERICDIALOG_H)
+#define INCLUDED_GENERICDIALOG_H
+
+#include <string>
+#include <gdk/gdk.h>
+#include <glib.h>
+
+#include "RefCounted.h"
+
+#include "qerplugin.h"
+
+/**
+ * Macro to get a handle on a widget inside the dialog by name.
+ *
+ * @param widgetName Name of the contained widget to find.
+ */
+#define NamedWidget(widgetName) \
+   (gtk_object_get_data(GTK_OBJECT(_dialog), widgetName))
+
+/**
+ * Macro to enable/disable a widget inside the dialog, selected by name.
+ *
+ * @param widgetName Name of the contained widget to enable/disable.
+ */
+#define NamedToggleWidgetActive(widgetName) \
+   (GTK_TOGGLE_BUTTON(NamedWidget(widgetName))->active)
+
+/**
+ * Macro to read text from a widget inside the dialog, selected by name.
+ *
+ * @param widgetName Name of the contained widget to read from.
+ */
+#define NamedEntryWidgetText(widgetName) \
+   (gtk_entry_get_text(GTK_ENTRY(NamedWidget(widgetName))))
+
+/**
+ * Framework for a basic dialog window with OK/Apply/Cancel actions.
+ *
+ * A subclass should handle decorating/customizing the window, populating it
+ * with contained widgets, customizing the Apply logic, and registering the
+ * appropriate OK/Apply/Cancel buttons.
+ *
+ * @ingroup generic-ui
+ */
+class GenericDialog : public RefCounted
+{
+protected: // protected methods
+
+   /// @name Lifecycle
+   //@{
+   GenericDialog(const std::string& key);
+   virtual ~GenericDialog();
+   //@}
+
+private: // private methods
+
+   /// @name Unimplemented to prevent copy/assignment
+   //@{
+   GenericDialog(const GenericDialog&);
+   const GenericDialog& operator=(const GenericDialog&);
+   //@}
+
+public: // public methods
+
+   /// @name Interrogation
+   //@{
+   const std::string& GetKey() const;
+   //@}
+   /// @name Window management
+   //@{
+   virtual void SetWindow(GtkWidget *window);
+   virtual void Raise();
+   virtual void Show(const std::string& triggerCommand);
+   virtual void Hide();
+   //@}
+   /// @name Callback implementation
+   //@{
+   virtual bool Apply();
+   virtual gint CloseEventCallback(GtkWidget *widget,
+                                   GdkEvent* event,
+                                   gpointer callbackID);
+   virtual void FinalizeCallback(GtkWidget *widget,
+                                 gpointer callbackID);
+   //@}
+   /// @name Callback creation
+   //@{
+   void CreateWindowCloseCallback();
+   void CreateOkButtonCallback(GtkWidget *button);
+   void CreateApplyButtonCallback(GtkWidget *button);
+   void CreateCancelButtonCallback(GtkWidget *button);
+   //@}
+
+protected: // protected member vars
+
+   /**
+    * This dialog widget.
+    */
+   GtkWidget *_dialog;
+
+   /**
+    * Parent window.
+    */
+   GtkWidget *_window;
+
+   /**
+    * Unique key for this dialog.
+    */
+   const std::string _key;
+
+   /**
+    * Command token that most recently summoned this dialog.
+    */
+   std::string _triggerCommand;
+
+   /**
+    * Callback ID associated with an OK button; 0 if none.
+    */
+   gpointer _okCallbackID;
+
+   /**
+    * Callback ID associated with an Apply button; 0 if none.
+    */
+   gpointer _applyCallbackID;
+
+   /**
+    * Callback ID associated with a Cancel button; 0 if none.
+    */
+   gpointer _cancelCallbackID;
+};
+
+#endif // #if !defined(INCLUDED_GENERICDIALOG_H)
diff --git a/contrib/meshtex/GenericMainMenu.cpp b/contrib/meshtex/GenericMainMenu.cpp
new file mode 100644 (file)
index 0000000..0cf4236
--- /dev/null
@@ -0,0 +1,218 @@
+/**
+ * @file GenericMainMenu.cpp
+ * Implements the GenericMainMenu class.
+ * @ingroup generic-ui
+ */
+
+/*
+ * Copyright 2012 Joel Baxter
+ *
+ * This file is part of MeshTex.
+ *
+ * MeshTex is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MeshTex is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MeshTex.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "GenericMainMenu.h"
+#include "GenericPluginUI.h"
+#include "GenericPluginUIMessages.h"
+#include "PluginProperties.h"
+
+
+/**
+ * Default constructor. Note that as this is a protected method,
+ * GenericMainMenu objects cannot be created directly; only subclasses of
+ * GenericMainMenu can be created.
+ */
+GenericMainMenu::GenericMainMenu()
+{
+}
+
+/**
+ * Virtual destructor.
+ */
+GenericMainMenu::~GenericMainMenu()
+{
+}
+
+/**
+ * Invoke the handler for the given command token.
+ *
+ * @param command The command token.
+ */
+void
+GenericMainMenu::Dispatch(const char *command)
+{
+   // Convert token to string.
+   std::string commandString(command);
+   // Invoke the function from the dispatch map that corresponds to the command.
+   // The command key should always be in the map, since the set of commands
+   // advertised to Radiant is the same as the set used to make the map.
+#if defined(_DEBUG)
+   ASSERT_MESSAGE(_dispatchMap.find(commandString) != _dispatchMap.end(),
+                  "dispatched plugin command unknown");
+#endif
+   _dispatchMap[commandString](commandString);
+}
+
+/**
+ * Handle a command that summons a dialog window.
+ *
+ * @param commandString The command token.
+ */
+void
+GenericMainMenu::CommandDialogShow(const std::string& commandString)
+{
+   // Look up the dialog window for this command.
+   DialogMap::const_iterator dialogMapIter = _dialogMap.find(commandString);
+   // Seems somewhat more plausible that we could hit an error condition here
+   // where there is no associated dialog, so handle that more gracefully
+   // than an assert.
+   GenericDialog *dialog;
+   if (dialogMapIter == _dialogMap.end() ||
+       (dialog = dialogMapIter->second) == NULL)
+   {
+      std::string message(commandString + ": " + DIALOG_INTERNAL_ERROR);
+      GenericPluginUI::ErrorReportDialog(DIALOG_ERROR_TITLE, message.c_str());
+      return;
+   }
+   // If we have the dialog though, let's summon it.
+   dialog->Show(commandString);
+}
+
+/**
+ * Get the command list for the plugin menu, as a semicolon-separated string
+ * of tokens representing each command.
+ *
+ * @return The command list string.
+ */
+const std::string&
+GenericMainMenu::GetCommandList() const
+{
+   return _menuCommands;
+}
+
+/**
+ * Get the command label list for the plugin menu, as a semicolon-separated
+ * string of labels to appear in the menu.
+ *
+ * @return The command label list string.
+ */
+const std::string&
+GenericMainMenu::GetCommandLabelList() const
+{
+   return _menuCommandLabels;
+}
+
+/**
+ * Invoked before beginning construction of the command list (by subsequent
+ * Add* invocations). In this base class, BeginEntries does nothing.
+ */
+void
+GenericMainMenu::BeginEntries()
+{
+}
+
+/**
+ * Append a command-group separator to the command list. This should be done
+ * between an invocation of BeginEntries and EndEntries. (And presumably in
+ * the neighborhood of invocations of AddEntry and/or AddDialogShowEntry.)
+ */
+void
+GenericMainMenu::AddSeparator()
+{
+   // Our internal command and command-label strings actually grow backwards,
+   // so prepend the separator to them.
+   static std::string separatorString(MENU_SEPARATOR);
+   _menuCommandLabels = separatorString + ";" + _menuCommandLabels;
+   _menuCommands = separatorString + ";" + _menuCommands;
+}
+
+/**
+ * Append a command to the command list that will trigger a callback function
+ * when the menu entry is selected. Invoking AddEntry should be done between
+ * an invocation of BeginEntries and EndEntries.
+ *
+ * @param commandLabel    The command label.
+ * @param command         The command token, unique for this plugin.
+ *                        Emptystring is interpreted as: re-use the label
+ *                        for the token.
+ * @param commandCallback The command callback function.
+ *
+ * @return The globally-unique command token: plugin name + "." + command.
+ */
+std::string
+GenericMainMenu::AddEntry(const char *commandLabel,
+                          const char *command,
+                          const CommandCallback& commandCallback)
+{
+   // Our internal command-label string actually grows backwards, so prepend the
+   // command label to it.
+   std::string commandLabelString(commandLabel);
+   _menuCommandLabels = commandLabelString + ";" + _menuCommandLabels;
+   // Use the label for the token if no token specified.
+   std::string commandString(command);
+   if (commandString.empty())
+   {
+      commandString = commandLabelString;
+   }
+   // Add the plugin name in front of the command token to globally uniquify it.
+   commandString = std::string(PLUGIN_NAME) + "." + commandString;
+   // Our internal command string actually grows backwards, so prepend the
+   // command token to it.
+   _menuCommands = commandString + ";" + _menuCommands;
+   // Save the association between the globally-unique token and callback.
+   _dispatchMap[commandString] = commandCallback;
+   // Return the globally-unique command token.
+   return commandString;
+}
+
+/**
+ * Append a command to the command list that will summon a dialog when the
+ * menu entry is selected. Invoking AddDialogShowEntry should be done between
+ * an invocation of BeginEntries and EndEntries.
+ *
+ * @param commandLabel The command label.
+ * @param command      The command token, unique for this plugin. Emptystring
+ *                     is interpreted as: re-use the label for the token.
+ * @param dialog       The dialog this command should summon.
+ */
+void
+GenericMainMenu::AddDialogShowEntry(const char *commandLabel,
+                                    const char *command,
+                                    const SmartPointer<GenericDialog>& dialog)
+{
+   // Create a new command callback specifically for summoning that dialog.
+   const CommandCallbackMethod
+      <GenericMainMenu, &GenericMainMenu::CommandDialogShow> commandDialogShow(*this);
+   // Register the command and its callback via AddEntry, and save the
+   // association between the globally-unique token and dialog.
+   _dialogMap.insert(
+      std::make_pair(AddEntry(commandLabel, command, commandDialogShow),
+                     dialog));
+}
+
+/**
+ * Invoked after ending construction of the command list. In this base class,
+ * EndEntries only removes spurious semicolons left behind by the way we
+ * constructed the lists.
+ */
+void
+GenericMainMenu::EndEntries()
+{
+   if (_menuCommandLabels.length() > 0)
+   {
+      _menuCommandLabels.resize(_menuCommandLabels.length() - 1);
+      _menuCommands.resize(_menuCommands.length() - 1);
+   }
+}
diff --git a/contrib/meshtex/GenericMainMenu.h b/contrib/meshtex/GenericMainMenu.h
new file mode 100644 (file)
index 0000000..af97226
--- /dev/null
@@ -0,0 +1,156 @@
+/**
+ * @file GenericMainMenu.h
+ * Declares the GenericMainMenu class.
+ * @ingroup generic-ui
+ */
+
+/*
+ * Copyright 2012 Joel Baxter
+ *
+ * This file is part of MeshTex.
+ *
+ * MeshTex is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MeshTex is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MeshTex.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#if !defined(INCLUDED_GENERICMAINMENU_H)
+#define INCLUDED_GENERICMAINMENU_H
+
+#include <string>
+#include <map>
+
+#include "RefCounted.h"
+#include "GenericDialog.h"
+
+#include "generic/callback.h"
+#include "generic/referencecounted.h"
+
+/**
+ * String used in lists of command tokens or command labels to separate groups
+ * of commands.
+ */
+#define MENU_SEPARATOR "-"
+
+/**
+ * Framework for a Radiant plugin's main menu. This object handles the menu
+ * logic: what commands exist and how to execute them. The actual menu
+ * display is handled by Radiant.
+ * 
+ * A subclass should handle creating the command list.
+ *
+ * @ingroup generic-ui
+ */
+class GenericMainMenu : public RefCounted
+{
+protected: // protected methods
+
+   /// @name Lifecycle
+   //@{
+   GenericMainMenu();
+   virtual ~GenericMainMenu();
+   //@}
+
+private: // private methods
+
+   /// @name Unimplemented to prevent copy/assignment
+   //@{
+   GenericMainMenu(const GenericMainMenu&);
+   const GenericMainMenu& operator=(const GenericMainMenu&);
+   //@}
+
+public: // public methods
+
+   /// @name Service the plugin interface
+   //@{
+   virtual void Dispatch(const char *command);
+   virtual void CommandDialogShow(const std::string& commandString);
+   const std::string& GetCommandList() const;
+   const std::string& GetCommandLabelList() const;
+   //@}
+
+protected: // protected types
+   /**
+    * Function signature for a menu command callback. The callback takes a
+    * string argument (the command token); it has no return value.
+    */
+   typedef Callback1<const std::string&, void> CommandCallback;
+
+   /**
+    * An instance of this class can be used as a
+    * GenericMainMenu::CommandCallback, in situations where the callback is a
+    * method to be invoked on a target object. When invoking this constructor,
+    * the target object is the constructor argument, and the target object class
+    * and method are template parameters. The target object's method must have
+    * an appropriate signature for CommandCallback: one string argument, void
+    * return.
+    */
+   template<typename ObjectClass, void (ObjectClass::*member)(const std::string&)>
+   class CommandCallbackMethod :
+      public MemberCaller1<ObjectClass, const std::string&, member>
+   {
+   public:
+      /**
+       * Constructor.
+       *
+       * @param object The object on which to invoke the callback method.
+       */
+      CommandCallbackMethod(ObjectClass& object) :
+         MemberCaller1<ObjectClass, const std::string&, member>(object) {}
+   };
+
+protected: // protected methods
+
+   /// @name Command list construction
+   //@{
+   virtual void BeginEntries();
+   virtual void AddSeparator();
+   virtual std::string AddEntry(const char *commandLabel,
+                                const char *command,
+                                const CommandCallback& commandCallback);
+   virtual void AddDialogShowEntry(const char *commandLabel,
+                                   const char *command,
+                                   const SmartPointer<GenericDialog>& dialog);
+   virtual void EndEntries();
+   //@}
+
+private: // private types
+
+   /**
+    * Type for a map between string and reference-counted dialog window.
+    */
+   typedef std::map<std::string, SmartPointer<GenericDialog> > DialogMap;
+
+private: // private member vars
+
+   /**
+    * Semicolon-separated string of command tokens.
+    */
+   std::string _menuCommands;
+
+   /**
+    * Semicolon-separated string of command labels.
+    */
+   std::string _menuCommandLabels;
+
+   /**
+    * Associations between command tokens and callbacks.
+    */
+   std::map<std::string, CommandCallback> _dispatchMap;
+
+   /**
+    * Associations between command tokens and dialog windows.
+    */
+   DialogMap _dialogMap;
+};
+
+#endif // #if !defined(INCLUDED_GENERICMAINMENU_H)
\ No newline at end of file
diff --git a/contrib/meshtex/GenericPluginUI.cpp b/contrib/meshtex/GenericPluginUI.cpp
new file mode 100644 (file)
index 0000000..2da58c8
--- /dev/null
@@ -0,0 +1,374 @@
+/**
+ * @file GenericPluginUI.cpp
+ * Implements the GenericPluginUI class.
+ * @ingroup generic-ui
+ */
+
+/*
+ * Copyright 2012 Joel Baxter
+ *
+ * This file is part of MeshTex.
+ *
+ * MeshTex is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MeshTex is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MeshTex.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <gtk/gtk.h>
+
+#include "GenericPluginUI.h"
+
+
+/**
+ * Default constructor. Initialize object state; the initial callback ID to
+ * use is 1 because 0 is reserved for "invalid". Note that as this is a
+ * protected method, GenericPluginUI objects cannot be created directly; only
+ * subclasses of GenericPluginUI can be created.
+ */
+GenericPluginUI::GenericPluginUI() :
+   _window(NULL),
+   _mainMenu(NULL),
+   _callbackID(1),
+   _widgetControlCallback(*this)
+{
+}
+
+/**
+ * Virtual destructor. Remove references to UI elements (which should
+ * trigger garbage collection).
+ */
+GenericPluginUI::~GenericPluginUI()
+{
+   // Remove any reference to the menu object.
+   if (_mainMenu != NULL)
+   {
+      delete _mainMenu;
+   }
+   // The _dialogMap will also be deleted by the normal destructor operation,
+   // which will clear any references we hold on dialog windows.
+}
+
+/**
+ * Register the command menu.
+ *
+ * @param mainMenu The command menu.
+ */
+void
+GenericPluginUI::RegisterMainMenu(SmartPointer<GenericMainMenu>& mainMenu)
+{
+   // Remember the menu object, and hold a reference on it so it won't be
+   // garbage-collected while this object exists.
+   _mainMenu = new SmartPointer<GenericMainMenu>(mainMenu);
+}
+
+/**
+ * Register a dialog window.
+ *
+ * @param dialog The dialog.
+ */
+void
+GenericPluginUI::RegisterDialog(SmartPointer<GenericDialog>& dialog)
+{
+   // Remember the association between key and dialog, and hold a reference
+   // on it so it won't be garbage-collected while this object exists.
+   _dialogMap.insert(std::make_pair(dialog->GetKey(), dialog));
+}
+
+/**
+ * Specify the main application window.
+ *
+ * @param window The main window.
+ */
+void
+GenericPluginUI::SetWindow(GtkWidget *window)
+{
+   // Remember it.
+   _window = window;
+   // Set it as the parent for every dialog window.
+   DialogMap::const_iterator dialogMapIter = _dialogMap.begin();
+   for (; dialogMapIter != _dialogMap.end(); ++dialogMapIter)
+   {
+      if (dialogMapIter->second.get() != NULL)
+      {
+         dialogMapIter->second->SetWindow(window);
+      }
+   }
+}
+
+/**
+ * Get the command menu.
+ *
+ * @return The command menu, or NULL if none has been registered.
+ */
+GenericMainMenu *
+GenericPluginUI::MainMenu()
+{
+   if (_mainMenu == NULL)
+   {
+      return NULL;
+   }
+   return _mainMenu->get();
+}
+
+/**
+ * Get the dialog identified by the specified key.
+ *
+ * @param key The key.
+ *
+ * @return The dialog, or NULL if none found for that key.
+ */
+GenericDialog *
+GenericPluginUI::Dialog(const std::string& key)
+{
+   DialogMap::const_iterator dialogMapIter = _dialogMap.find(key);
+   if (dialogMapIter == _dialogMap.end())
+   {
+      return NULL;
+   }
+   return dialogMapIter->second;
+}
+
+/**
+ * Generic event callback used to invoke the specific callback functions
+ * registered with this manager. Those specific callbacks are not themselves
+ * registered directly with GTK+ because they may be methods that must be
+ * invoked on objects. (Unlike this function, which is a static method.)
+ *
+ * @param widget The widget generating the event.
+ * @param event  The event.
+ * @param data   ID of the specific callback registered with this manager.
+ *
+ * @return The return value from the specific callback.
+ */
+gint
+GenericPluginUI::DialogEventCallbackDispatch(GtkWidget *widget,
+                                             GdkEvent* event,
+                                             gpointer data)
+{
+   // Look up the callback ID in our registration map.
+   DialogEventCallbackMap::iterator dialogEventCallbackMapIter =
+      UIInstance()._dialogEventCallbackMap.find(data);
+   if (dialogEventCallbackMapIter == UIInstance()._dialogEventCallbackMap.end())
+   {
+      // If we didn't find it, nothing to do.
+      return TRUE;
+   }
+   // Otherwise invoke that callback.
+   return dialogEventCallbackMapIter->second(widget, event, data);
+}
+
+/**
+ * Generic signal callback used to invoke the specific callback functions
+ * registered with this manager. Those specific callbacks are not themselves
+ * registered directly with GTK+ because they may be methods that must be
+ * invoked on objects. (Unlike this function, which is a static method.)
+ *
+ * @param widget The widget generating the signal.
+ * @param data   ID of the specific callback registered with this manager.
+ */
+void
+GenericPluginUI::DialogSignalCallbackDispatch(GtkWidget *widget,
+                                              gpointer data)
+{
+   // Look up the callback ID in our registration map.
+   DialogSignalCallbackMap::iterator dialogSignalCallbackMapIter =
+      UIInstance()._dialogSignalCallbackMap.find(data);
+   if (dialogSignalCallbackMapIter == UIInstance()._dialogSignalCallbackMap.end())
+   {
+      // If we didn't find it, nothing to do.
+      return;
+   }
+   // Otherwise invoke that callback.
+   dialogSignalCallbackMapIter->second(widget, data);
+}
+
+/**
+ * Register a function to be invoked when a widget generates an event.
+ *
+ * @param widget   The widget generating the event.
+ * @param name     The name of the event.
+ * @param callback The callback function.
+ *
+ * @return The unique ID for the registered callback function.
+ */
+gpointer
+GenericPluginUI::RegisterDialogEventCallback(GtkWidget *widget,
+                                             const gchar *name,
+                                             const DialogEventCallback& callback)
+{
+   // Get the next callback ID to use.
+   gpointer callbackID = GUINT_TO_POINTER(_callbackID++);
+   // Make that event on that dialog widget trigger our event dispatch.
+   g_signal_connect(G_OBJECT(widget), name,
+                    G_CALLBACK(DialogEventCallbackDispatch), callbackID);
+   // Save the association between callback ID and function.
+   _dialogEventCallbackMap.insert(std::make_pair(callbackID, callback));
+   // Return the generated unique callback ID.
+   return callbackID;
+}
+
+/**
+ * Register a function to be invoked when a widget generates a signal.
+ *
+ * @param widget   The widget generating the signal.
+ * @param name     The name of the signal.
+ * @param callback The callback function.
+ *
+ * @return The unique ID for the registered callback function.
+ */
+gpointer
+GenericPluginUI::RegisterDialogSignalCallback(GtkWidget *widget,
+                                              const gchar *name,
+                                              const DialogSignalCallback& callback)
+{
+   // Get the next callback ID to use.
+   gpointer callbackID = GUINT_TO_POINTER(_callbackID++);
+   // Make that signal on that dialog widget trigger our signal dispatch.
+   g_signal_connect(G_OBJECT(widget), name,
+                    G_CALLBACK(DialogSignalCallbackDispatch), callbackID);
+   // Save the association between callback ID and function.
+   _dialogSignalCallbackMap.insert(std::make_pair(callbackID, callback));
+   // Return the generated unique callback ID.
+   return callbackID;
+}
+
+/**
+ * Declare that the controllee widget should be inactive when the
+ * controller widget is inactive. The controllee will be active only
+ * when all of its controllers allow it to be so.
+ *
+ * @param controller The controller widget.
+ * @param controllee The controllee widget.
+ */
+void
+GenericPluginUI::RegisterWidgetDependence(GtkWidget *controller,
+                                          GtkWidget *controllee)
+{
+   // Make sure we get a callback when the controller is toggled.
+   if (_widgetControlMap.find(controller) == _widgetControlMap.end())
+   {
+      RegisterDialogSignalCallback(controller, "clicked", _widgetControlCallback);
+   }
+   // Save the association.
+   _widgetControlMap[controller].push_back(controllee);
+   _widgetControlledByMap[controllee].push_back(controller);
+}
+
+/**
+ * Declare that the controllee widget should be inactive when the
+ * controller widget is active. The controllee will be active only
+ * when all of its controllers allow it to be so.
+ *
+ * @param controller The controller widget.
+ * @param controllee The controllee widget.
+ */
+void
+GenericPluginUI::RegisterWidgetAntiDependence(GtkWidget *controller,
+                                              GtkWidget *controllee)
+{
+   // Make sure we get a callback when the controller is toggled.
+   if (_widgetControlMap.find(controller) == _widgetControlMap.end())
+   {
+      RegisterDialogSignalCallback(controller, "clicked", _widgetControlCallback);
+   }
+   // Save the association.
+   _widgetControlMap[controller].push_back(controllee);
+   _widgetAntiControlledByMap[controllee].push_back(controller);
+}
+
+/**
+ * Manage the state of controllee widgets when a controller widget is clicked.
+ *
+ * @param widget     The controller widget.
+ * @param callbackID Unique numerical ID for the callback.
+ */
+void
+GenericPluginUI::WidgetControlCallback(GtkWidget *widget,
+                                       gpointer callbackID)
+{
+   // Iterate over all controllees registered for this widget.
+   std::vector<GtkWidget *>::iterator controlleeIter =
+      _widgetControlMap[widget].begin();
+   for (; controlleeIter != _widgetControlMap[widget].end(); ++controlleeIter)
+   {
+      GtkWidget *controllee = *controlleeIter;
+      std::vector<GtkWidget *>::iterator controllerIter;
+      // Start with an assumption that the controllee widget will be active.
+      bool sensitive = true;
+      // Look for a dependence on any widget.
+      controllerIter = _widgetControlledByMap[controllee].begin();
+      for (; controllerIter != _widgetControlledByMap[controllee].end(); ++controllerIter)
+      {
+         // Dependence found; honor it.
+         if (!(GTK_TOGGLE_BUTTON(*controllerIter)->active))
+         {
+            sensitive = false;
+            break;
+         }
+      }
+      // Look for an anti-dependence on any widget.
+      controllerIter = _widgetAntiControlledByMap[controllee].begin();
+      for (; controllerIter != _widgetAntiControlledByMap[controllee].end(); ++controllerIter)
+      {
+         // Anti-dependence found; honor it.
+         if (GTK_TOGGLE_BUTTON(*controllerIter)->active)
+         {
+            sensitive = false;
+            break;
+         }
+      }
+      // Set the active state of the controllee appropriately.
+      gtk_widget_set_sensitive(controllee, sensitive);
+   }
+}
+
+/**
+ * Generate an error dialog.
+ *
+ * @param title   The dialog title.
+ * @param message The error message.
+ */
+void
+GenericPluginUI::ErrorReportDialog(const char *title,
+                                   const char *message)
+{
+   // Pass this operation to Radiant.
+   GlobalRadiant().m_pfnMessageBox(UIInstance()._window, message, title, eMB_OK, eMB_ICONERROR);
+}
+
+/**
+ * Generate a warning dialog.
+ *
+ * @param title   The dialog title.
+ * @param message The warning message.
+ */
+void
+GenericPluginUI::WarningReportDialog(const char *title,
+                                     const char *message)
+{
+   // Pass this operation to Radiant.
+   GlobalRadiant().m_pfnMessageBox(UIInstance()._window, message, title, eMB_OK, eMB_ICONWARNING);
+}
+
+/**
+ * Generate an info dialog.
+ *
+ * @param title   The dialog title.
+ * @param message The info message.
+ */
+void
+GenericPluginUI::InfoReportDialog(const char *title,
+                                  const char *message)
+{
+   // Pass this operation to Radiant.
+   GlobalRadiant().m_pfnMessageBox(UIInstance()._window, message, title, eMB_OK, eMB_ICONDEFAULT);
+}
\ No newline at end of file
diff --git a/contrib/meshtex/GenericPluginUI.h b/contrib/meshtex/GenericPluginUI.h
new file mode 100644 (file)
index 0000000..8b6c241
--- /dev/null
@@ -0,0 +1,276 @@
+/**
+ * @file GenericPluginUI.h
+ * Declares the GenericPluginUI class.
+ * @ingroup generic-ui
+ */
+
+/*
+ * Copyright 2012 Joel Baxter
+ *
+ * This file is part of MeshTex.
+ *
+ * MeshTex is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MeshTex is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MeshTex.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#if !defined(INCLUDED_GENERICPLUGINUI_H)
+#define INCLUDED_GENERICPLUGINUI_H
+
+#include <vector>
+#include <gdk/gdk.h>
+#include <glib.h>
+
+#include "GenericMainMenu.h"
+#include "GenericDialog.h"
+
+#include "qerplugin.h"
+#include "generic/referencecounted.h"
+
+/**
+ * Framework for a manager of a command menu and dialog windows. It is
+ * responsible for:
+ * - holding a reference on those objects for lifecycle management
+ * - providing lookup facilities for those objects
+ * - mapping GTK+ event/signal callbacks into method invocations on
+ * the dialog objects
+ * - providing automatic handling of widgets that should be active or
+ * inactive based on the active state of other widgets
+ * - providing utility functions for generating message popups
+ *
+ * A subclass should handle the creation and registration of the UI objects.
+ *
+ * @ingroup generic-ui
+ */
+class GenericPluginUI
+{
+protected: // protected methods
+
+   /// @name Lifecycle
+   //@{
+   GenericPluginUI();
+   virtual ~GenericPluginUI();
+   //@}
+
+private: // private methods
+
+   /// @name Unimplemented to prevent copy/assignment
+   //@{
+   GenericPluginUI(const GenericPluginUI&);
+   const GenericPluginUI& operator=(const GenericPluginUI&);
+   //@}
+
+public: // public types
+
+   /**
+    * Type for GTK+ event callbacks. The callback takes a GtkWidget* argument
+    * (widget generating the event), a GdkEvent* argument (the event), and a
+    * gpointer argument (the callback ID); it returns gint (success as TRUE or
+    * FALSE).
+    */
+   typedef Callback3<GtkWidget *, GdkEvent *, gpointer, gint> DialogEventCallback;
+
+   /**
+    * Type for GTK+ signal callbacks. The callback takes a GtkWidget* argument
+    * (widget generating the signal) and a gpointer argument (the callback data);
+    * it has no return value.
+    */
+   typedef Callback2<GtkWidget *, gpointer, void> DialogSignalCallback;
+
+   /**
+    * An instance of this class can be used as a
+    * GenericPluginUI::DialogEventCallback, in situations where the callback is
+    * a method to be invoked on a target object. When invoking this constructor,
+    * the target object is the constructor argument, and the target object class
+    * and method are template parameters. The target object's method must have
+    * an appropriate signature for DialogEventCallback: one GtkWidget* argument,
+    * one GdkEvent* argument, one gpointer argument, gint return.
+    */
+   template<typename ObjectClass, gint (ObjectClass::*member)(GtkWidget *, GdkEvent*, gpointer)>
+   class DialogEventCallbackMethod : public BindFirstOpaque3<Member3<ObjectClass, GtkWidget *, GdkEvent*, gpointer, gint, member> >
+   {
+   public:
+      /**
+       * Constructor.
+       *
+       * @param object The object on which to invoke the callback method.
+       */
+      DialogEventCallbackMethod(ObjectClass& object) :
+         BindFirstOpaque3<Member3<ObjectClass, GtkWidget *, GdkEvent *, gpointer, gint, member> >(object) {}
+   };
+
+   /**
+    * An instance of this class can be used as a
+    * GenericPluginUI::DialogSignalCallback, in situations where the callback is
+    * a method to be invoked on a target object. When invoking this constructor,
+    * the target object is the constructor argument, and the target object class
+    * and method are template parameters. The target object's method must have
+    * an appropriate signature for DialogSignalCallback: one GtkWidget* argument,
+    * one gpointer argument, void return.
+    */
+   template<typename ObjectClass, void (ObjectClass::*member)(GtkWidget *, gpointer)>
+   class DialogSignalCallbackMethod : public BindFirstOpaque2<Member2<ObjectClass, GtkWidget *, gpointer, void, member> >
+   {
+   public:
+      /**
+       * Constructor.
+       *
+       * @param object The object on which to invoke the callback method.
+       */
+      DialogSignalCallbackMethod(ObjectClass& object) :
+         BindFirstOpaque2<Member2<ObjectClass, GtkWidget *, gpointer, void, member> >(object) {}
+   };
+
+public: // public methods
+
+   /// @name Setup
+   //@{
+   void RegisterMainMenu(SmartPointer<GenericMainMenu>& mainMenu);
+   void RegisterDialog(SmartPointer<GenericDialog>& dialog);
+   void SetWindow(GtkWidget *window);
+   //@}
+   /// @name Lookup
+   //@{
+   GenericMainMenu *MainMenu();
+   GenericDialog *Dialog(const std::string& key);
+   //@}
+   /// @name Event/signal dispatch
+   //@{
+   static gint DialogEventCallbackDispatch(GtkWidget *widget,
+                                           GdkEvent* event,
+                                           gpointer data);
+   static void DialogSignalCallbackDispatch(GtkWidget *widget,
+                                            gpointer data);
+   gpointer RegisterDialogEventCallback(GtkWidget *widget,
+                                        const gchar *name,
+                                        const DialogEventCallback& callback);
+   gpointer RegisterDialogSignalCallback(GtkWidget *widget,
+                                         const gchar *name,
+                                         const DialogSignalCallback& callback);
+   //@}
+   /// @name Widget dependence
+   //@{
+   void RegisterWidgetDependence(GtkWidget *controller,
+                                 GtkWidget *controllee);
+   void RegisterWidgetAntiDependence(GtkWidget *controller,
+                                     GtkWidget *controllee);
+   void WidgetControlCallback(GtkWidget *widget,
+                              gpointer callbackID);
+   //@}
+   /// @name Message popups
+   //@{
+   static void ErrorReportDialog(const char *title,
+                                 const char *message);
+   static void WarningReportDialog(const char *title,
+                                   const char *message);
+   static void InfoReportDialog(const char *title,
+                                const char *message);
+   //@}
+
+private: // private types
+
+   /**
+    * Type for a map between string and reference-counted dialog window.
+    */
+   typedef std::map<std::string, SmartPointer<GenericDialog> > DialogMap;
+
+   /**
+    * Type for a map between gpointer (for callback ID) and event callback.
+    */
+   typedef std::map<gpointer, DialogEventCallback> DialogEventCallbackMap;
+
+   /**
+    * Type for a map between gpointer (for callback ID) and signal callback.
+    */
+   typedef std::map<gpointer, DialogSignalCallback> DialogSignalCallbackMap;
+
+   /**
+    * Type for a map between a widget and a vector of widgets.
+    */
+   typedef std::map<GtkWidget *, std::vector<GtkWidget *> > WidgetDependenceMap;
+
+private: // private member vars
+
+   /**
+    * The parent window.
+    */
+   GtkWidget *_window;
+
+   /**
+    * Pointer to a reference-counted handle on the main menu object.
+    */
+   SmartPointer<GenericMainMenu> *_mainMenu;
+
+   /**
+    * Next ID to use when registering an event or signal callback. Starts at 1;
+    * 0 is reserved to mean invalid.
+    */
+   unsigned _callbackID;
+
+   /**
+    * Callback to implement widget-active dependences.
+    */
+   const DialogSignalCallbackMethod<GenericPluginUI, &GenericPluginUI::WidgetControlCallback>
+      _widgetControlCallback;
+
+   /**
+    * Associations between keys and dialog windows.
+    */
+   DialogMap _dialogMap;
+
+   /**
+    * Associations between callback IDs and event callbacks.
+    */
+   DialogEventCallbackMap _dialogEventCallbackMap;
+
+   /**
+    * Associations between callback IDs and signal callbacks.
+    */
+   DialogSignalCallbackMap _dialogSignalCallbackMap;
+
+   /**
+    * Associations between controller and controllee widgets for all dependences
+    * and anti-dependences.
+    */
+   WidgetDependenceMap _widgetControlMap;
+
+   /**
+    * Associations between controller and controllee widgets for dependences
+    * only.
+    */
+   WidgetDependenceMap _widgetControlledByMap;
+
+   /**
+    * Associations between controller and controllee widgets for anti-
+    * dependences only.
+    */
+   WidgetDependenceMap _widgetAntiControlledByMap;
+};
+
+
+/**
+ * Get the singleton instance of the UI manager.
+ *
+ * @internal
+ * This function is not implemented in the GenericPluginUI.cpp file. It must
+ * be implemented somewhere, because it is invoked from various places even
+ * within the generic UI code. The implementation of this function should
+ * return a reference to the singleton instance of a GenericPluginUI subclass.
+ * @endinternal
+ *
+ * @return Reference to a singleton that implements GenericPluginUI.
+ *
+ * @relates GenericPluginUI
+ */
+GenericPluginUI& UIInstance();
+
+#endif // #if !defined(INCLUDED_GENERICPLUGINUI_H)
diff --git a/contrib/meshtex/GenericPluginUIMessages.h b/contrib/meshtex/GenericPluginUIMessages.h
new file mode 100644 (file)
index 0000000..0e0d0cc
--- /dev/null
@@ -0,0 +1,47 @@
+/**
+ * @file GenericPluginUIMessages.h
+ * String constants for messages shown in dialogs.
+ * @ingroup generic-ui
+ */
+
+/*
+ * Copyright 2012 Joel Baxter
+ *
+ * This file is part of MeshTex.
+ *
+ * MeshTex is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MeshTex is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MeshTex.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#if !defined(INCLUDED_GENERICPLUGINUIMESSAGES_H)
+#define INCLUDED_GENERICPLUGINUIMESSAGES_H
+
+/// @name Window titles
+//@{
+#define DIALOG_ERROR_TITLE "Error"
+#define DIALOG_WARNING_TITLE "Warning"
+//@}
+
+/// @name Window content
+//@{
+#define DIALOG_INTERNAL_ERROR "Internal error in plugin code."
+//@}
+
+/// @name Button labels
+//@{
+#define DIALOG_CANCEL_BUTTON "Cancel"
+#define DIALOG_APPLY_BUTTON "Apply"
+#define DIALOG_OK_BUTTON "OK"
+//@}
+
+#endif // #if !defined(INCLUDED_GENERICPLUGINUIMESSAGES_H)
diff --git a/contrib/meshtex/GetInfoDialog.cpp b/contrib/meshtex/GetInfoDialog.cpp
new file mode 100644 (file)
index 0000000..9c9fd29
--- /dev/null
@@ -0,0 +1,287 @@
+/**
+ * @file GetInfoDialog.cpp
+ * Implements the GetInfoDialog class.
+ * @ingroup meshtex-ui
+ */
+
+/*
+ * Copyright 2012 Joel Baxter
+ *
+ * This file is part of MeshTex.
+ *
+ * MeshTex is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MeshTex is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MeshTex.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <gtk/gtk.h>
+
+#include "GenericPluginUI.h"
+#include "GetInfoDialog.h"
+#include "PluginUIMessages.h"
+
+
+/**
+ * Constructor. See MeshEntity::GetInfo for details of how these arguments
+ * are interpreted.
+ *
+ * @param refRow             Pointer to reference row number; NULL if none.
+ * @param refCol             Pointer to reference column number; NULL if none.
+ * @param rowTexInfoCallback Pointer to callback for reference row info; NULL
+ *                           if none.
+ * @param colTexInfoCallback Pointer to callback for reference column info;
+ *                           NULL if none.
+ */
+GetInfoDialog::GetInfoVisitor::GetInfoVisitor(
+   const int *refRow,
+   const int *refCol,
+   const MeshEntity::TexInfoCallback *rowTexInfoCallback,
+   const MeshEntity::TexInfoCallback *colTexInfoCallback) :
+   _refRow(refRow),
+   _refCol(refCol),
+   _rowTexInfoCallback(rowTexInfoCallback),
+   _colTexInfoCallback(colTexInfoCallback)
+{
+}
+
+/**
+ * Visitor action; invoke MeshEntity::GetInfo on a mesh.
+ *
+ * @param [in,out] meshEntity The mesh.
+ *
+ * @return true.
+ */
+bool
+GetInfoDialog::GetInfoVisitor::Execute(MeshEntity& meshEntity) const
+{
+   meshEntity.GetInfo(_refRow, _refCol, _rowTexInfoCallback, _colTexInfoCallback);
+   return true;
+}
+
+/**
+ * Constructor. Connect the row and column texture info callbacks to the
+ * appropriate methods on the Set S/T Scale dialog object. Configure the
+ * dialog window and create all the contained widgets. Connect widgets to
+ * callbacks as necessary.
+ *
+ * @param key            The unique key identifying this dialog.
+ * @param setScaleDialog Reference-counted handle on the Set S/T Scale dialog.
+ */
+GetInfoDialog::GetInfoDialog(const std::string& key,
+                             SmartPointer<SetScaleDialog>& setScaleDialog) :
+   GenericDialog(key),
+   _setScaleDialog(setScaleDialog),
+   _rowTexInfoCallback(
+      MeshEntity::TexInfoCallbackMethod<SetScaleDialog,
+                                        &SetScaleDialog::PopulateSWidgets>(*setScaleDialog)),
+   _colTexInfoCallback(
+      MeshEntity::TexInfoCallbackMethod<SetScaleDialog,
+                                        &SetScaleDialog::PopulateTWidgets>(*setScaleDialog)),
+   _nullVisitor(new MeshVisitor())
+{
+   // Enable the usual handling of the close event.
+   CreateWindowCloseCallback();
+
+   // Configure the dialog window.
+   gtk_window_set_resizable(GTK_WINDOW(_dialog), FALSE);
+   gtk_window_set_title(GTK_WINDOW(_dialog), DIALOG_GET_INFO_TITLE);
+   gtk_container_set_border_width(GTK_CONTAINER(_dialog), 10);
+
+   // Create the contained widgets.
+
+   GtkWidget *table;
+   GtkWidget *entry;
+   GtkWidget *button;
+   GtkWidget *label;
+   GtkWidget *hbox;
+
+   table = gtk_table_new(4, 3, FALSE);
+   gtk_table_set_row_spacing(GTK_TABLE(table), 1, 10);
+   gtk_table_set_row_spacing(GTK_TABLE(table), 2, 15);
+   gtk_container_add(GTK_CONTAINER(_dialog), table);
+   gtk_widget_show(table);
+
+   // Widgets for specifying the reference row if any.
+
+   button = gtk_check_button_new();
+   gtk_object_set_data(GTK_OBJECT(_dialog), "s_apply", button);
+   gtk_table_attach_defaults(GTK_TABLE(table), button, 0, 1, 0, 1);
+   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
+   gtk_widget_show(button);
+
+   label = gtk_label_new(DIALOG_GET_INFO_S_ROW_HEADER);
+   gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_RIGHT);
+   gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 0, 1);
+   gtk_widget_show(label);
+
+   entry = gtk_entry_new();
+   gtk_object_set_data(GTK_OBJECT(_dialog), "s_ref_row", entry);
+   gtk_entry_set_text(GTK_ENTRY(entry), "0");
+   gtk_table_attach_defaults(GTK_TABLE(table), entry, 2, 3, 0, 1);
+   gtk_widget_set_usize(entry, 50, -2);
+   gtk_widget_show(entry);
+
+   UIInstance().RegisterWidgetDependence(button, label);
+   UIInstance().RegisterWidgetDependence(button, entry);
+
+   // Widgets for specifying the reference column if any.
+
+   button = gtk_check_button_new();
+   gtk_object_set_data(GTK_OBJECT(_dialog), "t_apply", button);
+   gtk_table_attach_defaults(GTK_TABLE(table), button, 0, 1, 1, 2);
+   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
+   gtk_widget_show(button);
+
+   label = gtk_label_new(DIALOG_GET_INFO_T_COL_HEADER);
+   gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_RIGHT);
+   gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 1, 2);
+   gtk_widget_show(label);
+
+   entry = gtk_entry_new();
+   gtk_object_set_data(GTK_OBJECT(_dialog), "t_ref_col", entry);
+   gtk_entry_set_text(GTK_ENTRY(entry), "0");
+   gtk_table_attach_defaults(GTK_TABLE(table), entry, 2, 3, 1, 2);
+   gtk_widget_set_usize(entry, 50, -2);
+   gtk_widget_show(entry);
+
+   UIInstance().RegisterWidgetDependence(button, label);
+   UIInstance().RegisterWidgetDependence(button, entry);
+
+   // Checkbox to enable the callbacks to Set S/T Scale.
+
+   button = gtk_check_button_new_with_label(DIALOG_GET_INFO_XFER_OPT_LABEL);
+   gtk_object_set_data(GTK_OBJECT(_dialog), "transfer", button);
+   gtk_table_attach(GTK_TABLE(table), button, 0, 3, 2, 3, GTK_EXPAND, GTK_EXPAND, 0, 0);
+   gtk_widget_show(button);
+
+   hbox = gtk_hbox_new(FALSE, 0);
+   gtk_table_attach_defaults(GTK_TABLE(table), hbox, 0, 3, 3, 4);
+   gtk_widget_show(hbox);
+
+   // Create Cancel button and hook it to callback.
+
+   button = gtk_button_new_with_label(DIALOG_CANCEL_BUTTON);
+   gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
+   gtk_widget_set_usize(button, 60, -2);
+   gtk_widget_show(button);
+
+   CreateCancelButtonCallback(button);
+
+   // Create Apply button and hook it to callback.
+
+   button = gtk_button_new_with_label(DIALOG_APPLY_BUTTON);
+   gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 10);
+   gtk_widget_set_usize (button, 60, -2);
+   gtk_widget_show(button);
+
+   CreateApplyButtonCallback(button);
+
+   // Create OK button and hook it to callback.
+
+   button = gtk_button_new_with_label(DIALOG_OK_BUTTON);
+   gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
+   gtk_widget_set_usize (button, 60, -2);
+   gtk_widget_show(button);
+
+   CreateOkButtonCallback(button);
+}
+
+/**
+ * Destructor.
+ */
+GetInfoDialog::~GetInfoDialog()
+{
+}
+
+/**
+ * Handler for the Apply logic for this dialog. Interrogate the selected mesh
+ * entities.
+ *
+ * @return false if no meshes are selected, false if multiple meshes are
+ *         selected along with the transfer option, true otherwise.
+ */
+bool
+GetInfoDialog::Apply()
+{
+   // Before doing anything, check to see if there are some meshes selected.
+   _nullVisitor->ResetVisitedCount();
+   GlobalSelectionSystem().foreachSelected(*_nullVisitor);
+   if (_nullVisitor->GetVisitedCount() == 0)
+   {
+      // Nope. Warn and bail out.
+      GenericPluginUI::WarningReportDialog(DIALOG_WARNING_TITLE,
+                                           DIALOG_NOMESHES_MSG);
+      return false;
+   }
+
+   // If the option to transfer info to Set S/T Scale is active, then only one
+   // mesh may be selected.
+   bool transfer = NamedToggleWidgetActive("transfer");
+   if (transfer && _nullVisitor->GetVisitedCount() != 1)
+   {
+      // Multiple selected. Warn and bail out.
+      GenericPluginUI::ErrorReportDialog(DIALOG_ERROR_TITLE,
+                                         DIALOG_MULTIMESHES_ERROR);
+      return false;
+   }
+
+   // OK read the remaining info from the widgets.
+
+   bool sApply = NamedToggleWidgetActive("s_apply");
+   bool tApply = NamedToggleWidgetActive("t_apply");
+
+   int row, col;
+   int *refRow = NULL;
+   int *refCol = NULL;
+   MeshEntity::TexInfoCallback *rowTexInfoCallback = NULL;
+   MeshEntity::TexInfoCallback *colTexInfoCallback = NULL;
+   if (sApply)
+   {
+      // Reference row is specified, so get that info.
+      row = atoi(NamedEntryWidgetText("s_ref_row"));
+      refRow = &row;
+      if (transfer)
+      {
+         // If transferring to Set S/T Scale, get that callback.
+         rowTexInfoCallback = &_rowTexInfoCallback;
+      }
+   }
+   if (tApply)
+   {
+      // Reference column is specified, so get that info.
+      col = atoi(NamedEntryWidgetText("t_ref_col"));
+      refCol = &col;
+      if (transfer)
+      {
+         // If transferring to Set S/T Scale, get that callback.
+         colTexInfoCallback = &_colTexInfoCallback;
+      }
+   }
+
+   // We don't need to instantiate an UndoableCommand since we won't be making
+   // any changes.
+
+   // Interrogate every selected mesh.
+   SmartPointer<GetInfoVisitor> infoVisitor(
+      new GetInfoVisitor(refRow, refCol, rowTexInfoCallback, colTexInfoCallback));
+   GlobalSelectionSystem().foreachSelected(*infoVisitor);
+
+   // If we populated something in the Set S/T Scale dialog, give that dialog a
+   // courtesy raise.
+   if (transfer)
+   {
+      _setScaleDialog->Raise();
+   }
+
+   // Done!
+   return true;
+}
diff --git a/contrib/meshtex/GetInfoDialog.h b/contrib/meshtex/GetInfoDialog.h
new file mode 100644 (file)
index 0000000..ef266d5
--- /dev/null
@@ -0,0 +1,99 @@
+/**
+ * @file GetInfoDialog.h
+ * Declares the GetInfoDialog class.
+ * @ingroup meshtex-ui
+ */
+
+/*
+ * Copyright 2012 Joel Baxter
+ *
+ * This file is part of MeshTex.
+ *
+ * MeshTex is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MeshTex is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MeshTex.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#if !defined(INCLUDED_GETINFODIALOG_H)
+#define INCLUDED_GETINFODIALOG_H
+
+#include "GenericDialog.h"
+#include "SetScaleDialog.h"
+#include "MeshVisitor.h"
+
+#include "generic/referencecounted.h"
+
+/**
+ * Subclass of GenericDialog that implements the window summoned by selecting
+ * the Get Info menu entry. This window allows the user to query information
+ * about selected meshes and optionally transfer some of that information to
+ * the Set S/T Scale dialog.
+ * 
+ * @image html getinfo.png
+ *
+ * @ingroup meshtex-ui
+ */
+class GetInfoDialog : public GenericDialog
+{
+private: // private types
+
+   /**
+    * Visitor for interrogating a mesh.
+    */
+   class GetInfoVisitor : public MeshVisitor
+   {
+   public:
+      GetInfoVisitor(const int *refRow,
+                     const int *refCol,
+                     const MeshEntity::TexInfoCallback *rowTexInfoCallback,
+                     const MeshEntity::TexInfoCallback *colTexInfoCallback);
+   private:
+      bool Execute(MeshEntity& meshEntity) const;
+   private:
+      const int *_refRow;
+      const int *_refCol;
+      const MeshEntity::TexInfoCallback *_rowTexInfoCallback;
+      const MeshEntity::TexInfoCallback *_colTexInfoCallback;
+   };
+
+public: // public methods
+
+   GetInfoDialog(const std::string& key,
+                 SmartPointer<SetScaleDialog>& setScaleDialog);
+   ~GetInfoDialog();
+   bool Apply();
+
+private: // private member vars
+
+   /**
+    * Handle on the Set S/T Scale dialog.
+    */
+   SmartPointer<SetScaleDialog> _setScaleDialog;
+
+   /**
+    * Callback to process row texture scale information from a query.
+    */
+   MeshEntity::TexInfoCallback _rowTexInfoCallback;
+
+   /**
+    * Callback to process column texture scale information from a query.
+    */
+   MeshEntity::TexInfoCallback _colTexInfoCallback;
+
+   /**
+    * Action-less mesh visitor used purely to count the number of selected mesh
+    * entities.
+    */
+   SmartPointer<MeshVisitor> _nullVisitor;
+};
+
+#endif // #if !defined(INCLUDED_GETINFODIALOG_H)
\ No newline at end of file
diff --git a/contrib/meshtex/HISTORY b/contrib/meshtex/HISTORY
new file mode 100644 (file)
index 0000000..5cef999
--- /dev/null
@@ -0,0 +1,41 @@
+Version history
+
+3.0 in progress:
+- Rewrite.  Bugfixes along the way.  Bugs undoubtedly introduced.
+- Moved to GtkRadiant 1.5 compatibility.
+- A few new features, TBD (to be documented).
+- Dropped Linux build for now.
+
+...time passes, things happen, continents drift...
+
+2.4 May 17, 2001:
+- Flipped the T scaling, to be consistent with the way Natural scaling works
+  in the new GtkRadiant.
+- Linux version still untested, but it's been updated too.
+
+2.3 May 13, 2001:
+- Added a Version resource.
+- Added a TEST compile of the plugin for Linux... no idea if it works.
+
+2.2 May 8, 2001:
+- Flipped sense of min/max align if scale/reps is negative.
+- Disallowed scale/reps of zero.
+
+2.1 May 5, 2001:
+- Fixed max align for natural scale without reference row.
+
+2.0 May 5, 2001:
+- Added the Set S/T Scale dialog and the General Function dialog.
+- Reworked Get Info, added capability to transfer scale info to the
+  Set S/T Scale dialog.
+- General noodlings to make negative scales work, other fixes.
+- Updated the texture mapping explanation and moved it into its own file.
+
+1.1 April 28, 2001:
+- Fixed the Min/Max Align functions, they weren't getting dispatched.
+- Fixed the Stretch/Shrink functions to work if the min S/T is nonzero.
+- Added Both Align, S Align, and T Align.
+- Added the +/- indicator in the info dialog.
+
+1.0 April 27, 2001:
+- Hey, it works and stuff.
diff --git a/contrib/meshtex/LICENSE b/contrib/meshtex/LICENSE
new file mode 100644 (file)
index 0000000..ca3a430
--- /dev/null
@@ -0,0 +1,339 @@
+                    GNU GENERAL PUBLIC LICENSE
+                       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+                            NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    &lt;one line to give the program's name and a brief idea of what it does.&gt;
+    Copyright (C) &lt;year&gt;  &lt;name of author&gt;
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License along
+    with this program; if not, write to the Free Software Foundation, Inc.,
+    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  &lt;signature of Ty Coon&gt;, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
diff --git a/contrib/meshtex/MainMenu.cpp b/contrib/meshtex/MainMenu.cpp
new file mode 100644 (file)
index 0000000..08b708c
--- /dev/null
@@ -0,0 +1,236 @@
+/**
+ * @file MainMenu.cpp
+ * Implements the MainMenu class.
+ * @ingroup meshtex-ui
+ */
+
+/*
+ * Copyright 2012 Joel Baxter
+ *
+ * This file is part of MeshTex.
+ *
+ * MeshTex is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MeshTex is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MeshTex.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "MainMenu.h"
+#include "PluginUI.h"
+#include "PluginUIMessages.h"
+
+#include "scenelib.h"
+#include "iundo.h"
+
+
+/**
+ * Constructor.
+ *
+ * @param visitorFunctor The functor for the mesh preset function.
+ * @param axes           The texture axes to affect.
+ */
+MainMenu::PresetFuncVisitor::PresetFuncVisitor(
+   const VisitorFunctor& visitorFunctor,
+   MeshEntity::TextureAxisSelection axes) :
+   _visitorFunctor(visitorFunctor),
+   _axes(axes)
+{
+}
+
+/**
+ * Visitor action; invoke a preset function on a mesh.
+ *
+ * @param [in,out] meshEntity The mesh entity.
+ *
+ * @return true.
+ */
+bool
+MainMenu::PresetFuncVisitor::Execute(MeshEntity& meshEntity) const
+{
+   (meshEntity.*_visitorFunctor)(_axes);
+   return true;
+}
+
+/**
+ * Constructor. Instantiate the command callbacks and construct the command
+ * list.
+ *
+ * @param setScaleDialog Reference-counted handle on the Set S/T Scale dialog.
+ * @param getInfoDialog  Reference-counted handle on the Get Info dialog.
+ * @param genFuncDialog  Reference-counted handle on the General Function
+ *                       dialog.
+ */
+MainMenu::MainMenu(SmartPointer<GenericDialog>& setScaleDialog,
+                   SmartPointer<GenericDialog>& getInfoDialog,
+                   SmartPointer<GenericDialog>& genFuncDialog) :
+   _commandMeshVisitor(*this)
+{
+   // Like _commandMeshVisitor, the callbacks for the Help and About commands
+   // also specify functions on this object. 
+   const CommandCallbackMethod
+      <MainMenu, &MainMenu::CommandHelp> commandHelp(*this);
+   const CommandCallbackMethod
+      <MainMenu, &MainMenu::CommandAbout> commandAbout(*this);
+
+   // Start constructing the command list.
+   BeginEntries();
+   // First two commands summon dialogs.
+   AddDialogShowEntry("Set S/T Scale...", "SetScale", setScaleDialog);
+   AddDialogShowEntry("Get Info...", "GetInfo", getInfoDialog);
+   AddSeparator();
+   // Next command summons a dialog.
+   AddDialogShowEntry("General Function...", "GeneralFunction", genFuncDialog);
+   AddSeparator();
+   // The next few groups of commands are all similar "preset function"
+   // commands. They will each trigger the CommandMeshVisitor callback when
+   // selected in the menu. CommandMeshVisitor needs a visitor object to apply
+   // to the selected meshes, which we are specifying here. 
+   AddMeshVisitorEntry("S&T Align Auto", "STMinMaxAlignAuto",
+                       SmartPointer<MeshVisitor>(
+                          new PresetFuncVisitor(&MeshEntity::MinMaxAlignAutoScale,
+                                                MeshEntity::ALL_TEX_AXES)));
+   AddMeshVisitorEntry("S Align Auto", "SMinMaxAlignAuto",
+                       SmartPointer<MeshVisitor>(
+                          new PresetFuncVisitor(&MeshEntity::MinMaxAlignAutoScale,
+                                                MeshEntity::S_TEX_AXIS_ONLY)));
+   AddMeshVisitorEntry("T Align Auto", "TMinMaxAlignAuto",
+                       SmartPointer<MeshVisitor>(
+                          new PresetFuncVisitor(&MeshEntity::MinMaxAlignAutoScale,
+                                                MeshEntity::T_TEX_AXIS_ONLY)));
+   AddSeparator();
+   AddMeshVisitorEntry("S Align Stretch", "SMinMaxAlignStretch",
+                       SmartPointer<MeshVisitor>(
+                          new PresetFuncVisitor(&MeshEntity::MinMaxAlignStretch,
+                                                MeshEntity::S_TEX_AXIS_ONLY)));
+   AddMeshVisitorEntry("S Align Shrink", "SMinMaxAlignShrink",
+                       SmartPointer<MeshVisitor>(
+                          new PresetFuncVisitor(&MeshEntity::MinMaxAlignShrink,
+                                                MeshEntity::S_TEX_AXIS_ONLY)));
+   AddMeshVisitorEntry("T Align Stretch", "TMinMaxAlignStretch",
+                       SmartPointer<MeshVisitor>(
+                          new PresetFuncVisitor(&MeshEntity::MinMaxAlignStretch,
+                                                MeshEntity::T_TEX_AXIS_ONLY)));
+   AddMeshVisitorEntry("T Align Shrink", "TMinMaxAlignShrink",
+                   SmartPointer<MeshVisitor>(
+                      new PresetFuncVisitor(&MeshEntity::MinMaxAlignShrink,
+                                            MeshEntity::T_TEX_AXIS_ONLY)));
+   AddSeparator();
+   AddMeshVisitorEntry("S Min Align", "SMinAlign",
+                       SmartPointer<MeshVisitor>(
+                          new PresetFuncVisitor(&MeshEntity::MinAlign,
+                                                MeshEntity::S_TEX_AXIS_ONLY)));
+   AddMeshVisitorEntry("S Max Align", "SMaxAlign",
+                       SmartPointer<MeshVisitor>(
+                          new PresetFuncVisitor(&MeshEntity::MaxAlign,
+                                                MeshEntity::S_TEX_AXIS_ONLY)));
+   AddMeshVisitorEntry("T Min Align", "TMinAlign",
+                       SmartPointer<MeshVisitor>(
+                          new PresetFuncVisitor(&MeshEntity::MinAlign,
+                                                MeshEntity::T_TEX_AXIS_ONLY)));
+   AddMeshVisitorEntry("T Max Align", "TMaxAlign",
+                       SmartPointer<MeshVisitor>(
+                          new PresetFuncVisitor(&MeshEntity::MaxAlign,
+                                                MeshEntity::T_TEX_AXIS_ONLY)));
+   AddSeparator();
+   // These commands each invoke a unique callback when selected.
+   AddEntry("Help...", "Help", commandHelp);
+   AddEntry("About...", "About", commandAbout);
+   // Done!
+   EndEntries();
+}
+
+/**
+ * Destructor.
+ */
+MainMenu::~MainMenu()
+{
+}
+
+/**
+ * Callback common to all of the commands that trigger a processing by mesh
+ * visitor when selected. This callback does its own internal dispatch to
+ * distinctly handle the various commands.
+ *
+ * @param commandString The command token.
+ */
+void
+MainMenu::CommandMeshVisitor(const std::string& commandString)
+{
+   // Look up the registered mesh visitor for this command.
+   VisitorMap::const_iterator visitorMapIter = _visitorMap.find(commandString);
+   MeshVisitor *meshVisitor;
+   if (visitorMapIter == _visitorMap.end() ||
+       (meshVisitor = visitorMapIter->second) == NULL)
+   {
+      // That's odd, there isn't one. Bail out.
+      std::string message(commandString + ": " + DIALOG_INTERNAL_ERROR);
+      GenericPluginUI::ErrorReportDialog(DIALOG_ERROR_TITLE, message.c_str());
+      return;
+   }
+   // Let Radiant know the name of the operation responsible for the changes
+   // that are about to happen.
+   UndoableCommand undo(commandString.c_str());
+   // Apply the visitor to every selected mesh.
+   meshVisitor->ResetVisitedCount();
+   GlobalSelectionSystem().foreachSelected(*meshVisitor);
+   if (meshVisitor->GetVisitedCount() == 0)
+   {
+      // Warn if there weren't any meshes selected (so nothing happened). 
+      GenericPluginUI::WarningReportDialog(DIALOG_WARNING_TITLE,
+                                           DIALOG_NOMESHES_MSG);
+   }
+}
+
+/**
+ * Callback triggered when the Help menu entry is selected.
+ *
+ * @param commandString The command token.
+ */
+void
+MainMenu::CommandHelp(const std::string& commandString)
+{
+   // Pop up a hopefully somewhat helpful message dialog.
+   GenericPluginUI::InfoReportDialog(DIALOG_HELP_TITLE,
+                                     DIALOG_HELP_MSG);
+}
+
+/**
+ * Callback triggered when the About menu entry is selected.
+ *
+ * @param commandString The command token.
+ */
+void
+MainMenu::CommandAbout(const std::string& commandString)
+{
+   // Pop up a message dialog that describes the plugin.
+   GenericPluginUI::InfoReportDialog(DIALOG_ABOUT_TITLE,
+                                     DIALOG_ABOUT_MSG);
+}
+
+/**
+ * Register a mesh visitor to be used to implement a specified command.
+ *
+ * @param commandLabel The command label.
+ * @param command      The command token.
+ * @param visitor      The mesh visitor.
+ */
+void
+MainMenu::AddMeshVisitorEntry(const char *commandLabel,
+                              const char *command,
+                              const SmartPointer<MeshVisitor>& visitor)
+{
+   // Add to the command list, and indicate that CommandMeshVisitor is the
+   // callback for this command. Then save the association between command and
+   // visitor, for CommandMeshVisitor to reference.
+   _visitorMap.insert(
+      std::make_pair(AddEntry(commandLabel, command, _commandMeshVisitor),
+                     visitor));
+}
\ No newline at end of file
diff --git a/contrib/meshtex/MainMenu.h b/contrib/meshtex/MainMenu.h
new file mode 100644 (file)
index 0000000..d6e3296
--- /dev/null
@@ -0,0 +1,105 @@
+/**
+ * @file MainMenu.h
+ * Declares the MainMenu class.
+ * @ingroup meshtex-ui
+ */
+
+/*
+ * Copyright 2012 Joel Baxter
+ *
+ * This file is part of MeshTex.
+ *
+ * MeshTex is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MeshTex is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MeshTex.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#if !defined(INCLUDED_MAINMENU_H)
+#define INCLUDED_MAINMENU_H
+
+#include "GenericMainMenu.h"
+#include "MeshVisitor.h"
+
+/**
+ * Subclass of GenericMainMenu that constructs the commands for this plugin.
+ *
+ * @ingroup meshtex-ui
+ */
+class MainMenu : public GenericMainMenu
+{
+private: // private types
+
+   /**
+    * Visitor for invoking a function on a MeshEntity when that function does
+    * not require any arguments other than the texture axes. These operations
+    * are triggered immediately on selecting a menu entry, rather than being
+    * triggered by applying some other dialog.
+    */
+   class PresetFuncVisitor : public MeshVisitor
+   {
+   public:
+      /**
+       * Function signature for a preset function.
+       */
+      typedef void(MeshEntity::*VisitorFunctor)(MeshEntity::TextureAxisSelection axes);
+   public:
+      PresetFuncVisitor(const VisitorFunctor& visitorFunctor,
+                        MeshEntity::TextureAxisSelection axes);
+   private:
+      bool Execute(MeshEntity& meshEntity) const;
+
+   private:
+      const VisitorFunctor _visitorFunctor;
+      const MeshEntity::TextureAxisSelection _axes;
+   };
+
+public: // public methods
+
+   MainMenu(SmartPointer<GenericDialog>& setScaleDialog,
+            SmartPointer<GenericDialog>& getInfoDialog,
+            SmartPointer<GenericDialog>& genFuncDialog);
+   ~MainMenu();
+   void CommandMeshVisitor(const std::string& commandString);
+   void CommandHelp(const std::string& commandString);
+   void CommandAbout(const std::string& commandString);
+
+private: // private methods
+
+   void AddMeshVisitorEntry(const char *commandLabel,
+                            const char *command,
+                            const SmartPointer<MeshVisitor>& visitor);
+
+private: // private types
+
+   /**
+    * Type for a map between a string and a reference-counted visitor.
+    */
+   typedef std::map<std::string, SmartPointer<MeshVisitor> > VisitorMap;
+
+private:
+
+   /**
+    * Associations between commands and visitors that implement them.
+    */
+   VisitorMap _visitorMap;
+
+   /**
+    * Callback for all of the commands that trigger CommandMeshVisitor. This is
+    * stored in a member var rather than a local var just because otherwise it
+    * would need to be passed around and clutter up an already ugly set of
+    * invocations.
+    */
+   const CommandCallbackMethod
+      <MainMenu, &MainMenu::CommandMeshVisitor> _commandMeshVisitor;
+};
+
+#endif // #if !defined(INCLUDED_MAINMENU_H)
\ No newline at end of file
diff --git a/contrib/meshtex/MeshEntity.cpp b/contrib/meshtex/MeshEntity.cpp
new file mode 100644 (file)
index 0000000..faac7ee
--- /dev/null
@@ -0,0 +1,1821 @@
+/**
+ * @file MeshEntity.cpp
+ * Implements the MeshEntity class.
+ * @ingroup meshtex-core
+ */
+
+/*
+ * Copyright 2012 Joel Baxter
+ *
+ * This file is part of MeshTex.
+ *
+ * MeshTex is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MeshTex is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MeshTex.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <cmath>
+
+#include "MeshEntity.h"
+#include "MeshEntityMessages.h"
+
+#include "ishaders.h"
+#include "texturelib.h"
+
+
+/**
+ * Size of buffer for composing messages to send to the info callback.
+ */
+#define INFO_BUFFER_SIZE 1024
+
+/**
+ * Stop successive refinement of path length estimates when the change in values
+ * is equal to or less than this tolerance.
+ */
+#define UNITS_ERROR_BOUND 0.5
+
+/**
+ * Macro to get ROW_SLICE_TYPE from COL_SLICE_TYPE and vice versa, used in
+ * code that can operate on either kind of slice. This does mean that the
+ * numerical values assigned to ROW_SLICE_TYPE and COL_SLICE_TYPE are
+ * meaningful.
+ *
+ * @param sliceType Kind of slice to find the other of, so to speak.
+ */
+#define OtherSliceType(sliceType) (1 - (sliceType))
+
+/**
+ * Macro to find the number of control points in a slice, which is equal to
+ * the number of slices of the other kind.
+ *
+ * @param sliceType Kind of slice to measure.
+ */
+#define SliceSize(sliceType) (_numSlices[OtherSliceType(sliceType)])
+
+/**
+ * Macro to get rid of negative-zero values.
+ *
+ * @param floatnum Number to be sanitized.
+ */
+#define SanitizeFloat(floatnum) ((floatnum) == -0.0f ? 0.0f : (floatnum))
+
+
+/**
+ * For a given slice kind, which texture axis (S or T) normally changes
+ * along it.
+ */
+MeshEntity::TextureAxis MeshEntity::_naturalAxis[NUM_SLICE_TYPES] =
+   { S_TEX_AXIS, T_TEX_AXIS };
+
+/**
+ * For a given slice kind, whether Radiant's "natural" scale along a texture
+ * axis is backwards compared to the progression of the indices of the
+ * orthogonal slices.
+ */
+bool MeshEntity::_radiantScaleInverted[NUM_SLICE_TYPES] = { false, true };
+
+/**
+ * For a given slice kind, whether Radiant's interpretation of tiling along a
+ * texture axis is backwards compared to the progression of the indices of
+ * the orthogonal slices.
+ */
+bool MeshEntity::_radiantTilesInverted[NUM_SLICE_TYPES] = { false, false };
+
+/**
+  * Message format strings for describing texture mapping on a slice.
+  */
+const char *MeshEntity::_infoSliceFormatString[NUM_SLICE_TYPES] =
+   { INFO_ROW_FORMAT, INFO_COL_FORMAT };
+
+/**
+ * Message format strings for describing texture mapping on a slice in the
+ * unusual case where the scale value is infinite.
+ */
+const char *MeshEntity::_infoSliceInfscaleFormatString[NUM_SLICE_TYPES] =
+   { INFO_ROW_INFSCALE_FORMAT, INFO_COL_INFSCALE_FORMAT };
+
+/**
+ * Message format strings for warning that a scale value is infinite and
+ * cannot be transferred to the Set S/T Scale dialog.
+ */
+const char *MeshEntity::_warningSliceInfscaleFormatString[NUM_SLICE_TYPES] =
+   { WARNING_ROW_INFSCALE, WARNING_COL_INFSCALE };
+
+/**
+ * Message format strings for an illegal slice number error.
+ */
+const char *MeshEntity::_errorBadSliceString[NUM_SLICE_TYPES] =
+   { ERROR_BAD_ROW, ERROR_BAD_COL };
+
+/**
+ * Message format strings for a scale = 0 error.
+ */
+const char *MeshEntity::_errorSliceZeroscaleString[NUM_SLICE_TYPES] =
+   { ERROR_ROW_ZEROSCALE, ERROR_COL_ZEROSCALE };
+
+/**
+ * Message format strings for a tiles = 0 error.
+ */
+const char *MeshEntity::_errorSliceZerotilesString[NUM_SLICE_TYPES] =
+   { ERROR_ROW_ZEROTILES, ERROR_COL_ZEROTILES };
+
+
+/**
+ * Constructor. If the constructor is unable to process the input mesh, then
+ * the internal valid flag (queryable through IsValid) is set false, and the
+ * errorReportCallback is invoked.
+ *
+ * @param mesh                  The patch mesh to construct a wrapper for.
+ * @param infoReportCallback    Callback for future informational messages.
+ * @param warningReportCallback Callback for future warning messages.
+ * @param errorReportCallback   Callback for future error messages.
+ */
+MeshEntity::MeshEntity(scene::Node& mesh,
+                       const MessageCallback& infoReportCallback,
+                       const MessageCallback& warningReportCallback,
+                       const MessageCallback& errorReportCallback) :
+   _mesh(mesh),
+   _infoReportCallback(infoReportCallback),
+   _warningReportCallback(warningReportCallback),
+   _errorReportCallback(errorReportCallback)
+{
+   // Get a handle on the control points, for future manipulation.
+   _meshData = GlobalPatchCreator().Patch_getControlPoints(_mesh);
+   // Record some useful characteristics of the mesh.
+   _numSlices[ROW_SLICE_TYPE] = static_cast<int>(_meshData.x());
+   _numSlices[COL_SLICE_TYPE] = static_cast<int>(_meshData.y());
+   const char *shaderName = GlobalPatchCreator().Patch_getShader(_mesh);
+   IShader *shader = GlobalShaderSystem().getShaderForName(shaderName);
+   qtexture_t *texture = shader->getTexture();
+   if (texture != NULL)
+   {
+      _naturalTexUnits[S_TEX_AXIS] = texture->width / 2.0f;
+      _naturalTexUnits[T_TEX_AXIS] = texture->height / 2.0f;
+   }
+   // We don't need the shader for anything else now.
+   shader->DecRef();
+   // Check for valid mesh; bail if not.
+   if (_numSlices[ROW_SLICE_TYPE] < 3 ||
+       _numSlices[COL_SLICE_TYPE] < 3 ||
+       texture == NULL)
+   {
+      _valid = false;
+      _errorReportCallback(ERROR_BAD_MESH);
+      return;
+   }
+   _valid = true;
+   // Find the worldspace extents of the mesh now... they won't change during
+   // the lifetime of this object.
+   UpdatePosMinMax(X_POS_AXIS);
+   UpdatePosMinMax(Y_POS_AXIS);
+   UpdatePosMinMax(Z_POS_AXIS);
+   // We'll calculate the S/T extents lazily.
+   _texMinMaxDirty[S_TEX_AXIS] = true;
+   _texMinMaxDirty[T_TEX_AXIS] = true;
+}
+
+/**
+ * Destructor. Note that this only destroys the wrapper object, not the patch
+ * mesh itself.
+ */
+MeshEntity::~MeshEntity()
+{
+}
+
+/**
+ * Query if the patch mesh is valid, in the characteristics that this wrapper
+ * class cares about. If not valid then the results of operations on this
+ * wrapper object are undefined.
+ *
+ * @return true if valid, false if not.
+ */
+bool
+MeshEntity::IsValid() const
+{
+   return _valid;
+}
+
+/**
+ * Get information about the patch mesh.
+ * 
+ * A message string describing general mesh information (number of rows/cols,
+ * min/max texture coords, extent in worldspace) will be composed and sent to
+ * the infoReportCallback that was specified when this wrapper object was
+ * constructed.
+ * 
+ * Optionally this method can do additional reporting on a specific
+ * "reference row" and "reference column". If a reference row and/or column
+ * is specified, then information about the reference slice(s) will be added
+ * to the information message. If a reference row/col is specified AND a
+ * corresponding row/col TexInfoCallback is specified, then the scale and
+ * tiling values for the reference slice will also be passed to the relevant
+ * callback.
+ *
+ * @param refRow             Pointer to reference row number; NULL if none.
+ * @param refCol             Pointer to reference column number; NULL if none.
+ * @param rowTexInfoCallback Pointer to callback for reference row info; NULL
+ *                           if none.
+ * @param colTexInfoCallback Pointer to callback for reference column info; NULL
+ *                           if none.
+ */
+void
+MeshEntity::GetInfo(const int *refRow,
+                    const int *refCol,
+                    const TexInfoCallback *rowTexInfoCallback,
+                    const TexInfoCallback *colTexInfoCallback)
+{
+   // Prep a message buffer to compose the response.
+   char messageBuffer[INFO_BUFFER_SIZE + 1];
+   messageBuffer[INFO_BUFFER_SIZE] = 0;
+   size_t bufferOffset = 0;
+   // Get reference row info if requested; this will be written into the message
+   // buffer as well as sent to the row callback (if any).
+   if (refRow != NULL)
+   {
+      ReportSliceTexInfo(ROW_SLICE_TYPE, *refRow, _naturalAxis[ROW_SLICE_TYPE],
+                         messageBuffer + bufferOffset,
+                         INFO_BUFFER_SIZE - bufferOffset,
+                         rowTexInfoCallback);
+      // Move the message buffer pointer along.
+      bufferOffset = strlen(messageBuffer);
+   }
+   // Get reference column info if requested; this will be written into the
+   // message buffer as well as sent to the column callback (if any).
+   if (refCol != NULL)
+   {
+      ReportSliceTexInfo(COL_SLICE_TYPE, *refCol, _naturalAxis[COL_SLICE_TYPE],
+                         messageBuffer + bufferOffset,
+                         INFO_BUFFER_SIZE - bufferOffset,
+                         colTexInfoCallback);
+      // Move the message buffer pointer along.
+      bufferOffset = strlen(messageBuffer);
+   }
+   // Make sure we have up-to-date S/T extents.
+   UpdateTexMinMax(S_TEX_AXIS);
+   UpdateTexMinMax(T_TEX_AXIS);
+   // Add general mesh info to the message.
+   snprintf(messageBuffer + bufferOffset, INFO_BUFFER_SIZE - bufferOffset,
+            INFO_MESH_FORMAT,
+            _numSlices[ROW_SLICE_TYPE],
+            SanitizeFloat(_texMin[S_TEX_AXIS]), SanitizeFloat(_texMax[S_TEX_AXIS]),
+            _numSlices[COL_SLICE_TYPE],
+            SanitizeFloat(_texMin[T_TEX_AXIS]), SanitizeFloat(_texMax[T_TEX_AXIS]),
+            SanitizeFloat(_posMin[X_POS_AXIS]), SanitizeFloat(_posMax[X_POS_AXIS]),
+            SanitizeFloat(_posMin[Y_POS_AXIS]), SanitizeFloat(_posMax[Y_POS_AXIS]),
+            SanitizeFloat(_posMin[Z_POS_AXIS]), SanitizeFloat(_posMax[Z_POS_AXIS]));
+   // Send the response.
+   _infoReportCallback(messageBuffer);
+}
+
+/**
+ * For each of the specified texture axes, shift the lowest-valued texture
+ * coordinates off of the mesh until an integral texture coordinate (texture
+ * boundary) is on the mesh edge.
+ *
+ * @param axes The texture axes to align.
+ */
+void
+MeshEntity::MinAlign(TextureAxisSelection axes)
+{
+   // Implement this by applying MinAlignInt to each specified axis.
+   ProcessForAxes(&MeshEntity::MinAlignInt, axes);
+}
+
+/**
+ * For each of the specified texture axes, shift the highest-valued texture
+ * coordinates off of the mesh until an integral texture coordinate (texture
+ * boundary) is on the mesh edge.
+ *
+ * @param axes The texture axes to align.
+ */
+void
+MeshEntity::MaxAlign(TextureAxisSelection axes)
+{
+   // Implement this by applying MaxAlignInt to each specified axis.
+   ProcessForAxes(&MeshEntity::MaxAlignInt, axes);
+}
+
+/**
+ * For each of the specified texture axes, perform either MinMaxAlignStretch
+ * or MinMaxAlignShrink; the chosen operation will be the one with the least
+ * absolute change in the value of the texture scale.
+ *
+ * @param axes The texture axes to align.
+ */
+void
+MeshEntity::MinMaxAlignAutoScale(TextureAxisSelection axes)
+{
+   // Implement this by applying MinMaxAlignAutoScaleInt to each specified axis.
+   ProcessForAxes(&MeshEntity::MinMaxAlignAutoScaleInt, axes);
+}
+
+/**
+ * For each of the specified texture axes, align a texture boundary to one
+ * edge of the mesh, then increase the texture scale to align a texture
+ * boundary to the other edge of the mesh as well.
+ *
+ * @param axes The texture axes to align.
+ */
+void
+MeshEntity::MinMaxAlignStretch(TextureAxisSelection axes)
+{
+   // Implement this by applying MinMaxAlignStretchInt to each specified axis.
+   ProcessForAxes(&MeshEntity::MinMaxAlignStretchInt, axes);
+}
+
+/**
+ * For each of the specified texture axes, align a texture boundary to one
+ * edge of the mesh, then decrease the texture scale to align a texture
+ * boundary to the other edge of the mesh as well.
+ *
+ * @param axes The texture axes to align.
+ */
+void
+MeshEntity::MinMaxAlignShrink(TextureAxisSelection axes)
+{
+   // Implement this by applying MinMaxAlignShrinkInt to each specified axis.
+   ProcessForAxes(&MeshEntity::MinMaxAlignShrinkInt, axes);
+}
+
+/**
+ * Set the texture scaling along the rows or columns of the mesh. This
+ * affects only the texture axis that is naturally associated with rows (S)
+ * or columns (T) according to the chosen sliceType.
+ * 
+ * The scaling may be input either as a multiple of the natural scale that
+ * Radiant would choose for this texture, or as the number of tiles of the
+ * texture that should fit on the mesh's row/column.
+ * 
+ * Among the slices perpendicular to the direction of scaling, an alignment
+ * slice is used to fix the position of the texture boundary.
+ * 
+ * A reference slice may optionally be chosen among the slices parallel to
+ * the scaling direction. If a reference slice is not specified, then the
+ * texture coordinates are independently determined for each slice. If a
+ * reference slice is specified, its texture coordinates are calculated first
+ * and used to affect the other slices. The reference slice's amount of
+ * texture tiling will be re-used for all other slices; optionally, the
+ * texture coordinate at each control point within the reference slice can be
+ * copied to the corresponding control point in every other slice.
+ *
+ * @param sliceType           Choose to scale along rows or columns.
+ * @param alignSlice          Pointer to alignment slice description; if NULL,
+ *                            slice 0 is assumed.
+ * @param refSlice            Pointer to reference slice description,
+ *                            including how to use the reference; NULL if no
+ *                            reference.
+ * @param naturalScale        true if naturalScaleOrTiles is a factor of the
+ *                            Radiant natural scale; false if
+ *                            naturalScaleOrTiles is a number of tiles.
+ * @param naturalScaleOrTiles Scaling determinant, interpreted according to
+ *                            the naturalScale parameter.
+ */
+void
+MeshEntity::SetScale(SliceType sliceType,
+                     const SliceDesignation *alignSlice,
+                     const RefSliceDescriptor *refSlice,
+                     bool naturalScale,
+                     float naturalScaleOrTiles)
+{
+   // We're about to make changes!
+   CreateUndoPoint();
+
+   // Check for bad inputs. Also convert from natural scale to raw scale.
+   if (alignSlice != NULL && !alignSlice->maxSlice)
+   {
+      if (alignSlice->index < 0 ||
+          alignSlice->index >= (int)SliceSize(sliceType))
+      {
+         _errorReportCallback(_errorBadSliceString[OtherSliceType(sliceType)]);
+         return;
+      }
+   }
+   if (refSlice != NULL && !refSlice->designation.maxSlice)
+   {
+      if (refSlice->designation.index < 0 ||
+          refSlice->designation.index >= (int)_numSlices[sliceType])
+      {
+         _errorReportCallback(_errorBadSliceString[sliceType]);
+         return;
+      }
+   }
+   TextureAxis axis = _naturalAxis[sliceType];
+   float rawScaleOrTiles = naturalScaleOrTiles;
+   if (naturalScale)
+   {
+      // In this case, naturalScaleOrTiles (copied to rawScaleOrTiles) was a
+      // natural-scale factor.
+      if (rawScaleOrTiles == 0)
+      {
+         _errorReportCallback(_errorSliceZeroscaleString[sliceType]);
+         return;
+      }
+      // If Radiant's internal orientation is backwards, account for that.
+      if (_radiantScaleInverted[sliceType])
+      {
+         rawScaleOrTiles = -rawScaleOrTiles;
+      }
+      // Raw scale is the divisor necessary to get texture coordinate from
+      // worldspace distance, so we can derive that from the "natural" scale.
+      rawScaleOrTiles *= _naturalTexUnits[axis];
+   }
+   else
+   {
+      // In this case, naturalScaleOrTiles (copied to rawScaleOrTiles) was a
+      // tiling amount.
+      if (rawScaleOrTiles == 0)
+      {
+         // XXX We could try to make zero-tiles work ("infinite scale": all
+         // values for this axis are the same along the slice). Need to sort
+         // out divide-by-zero dangers down the road.
+         _errorReportCallback(_errorSliceZerotilesString[sliceType]);
+         return;
+      }
+      // If Radiant's internal orientation is backwards, account for that.
+      if (_radiantTilesInverted[sliceType])
+      {
+         rawScaleOrTiles = -rawScaleOrTiles;
+      }
+   }
+
+   // Make sure we have a definite number for the alignment slice, and for the
+   // reference slice if any.
+   int alignSliceInt =
+      InternalSliceDesignation(alignSlice, (SliceType)OtherSliceType(sliceType));
+   RefSliceDescriptorInt descriptor;
+   RefSliceDescriptorInt *refSliceInt = // will be NULL if no reference
+      InternalRefSliceDescriptor(refSlice, sliceType, descriptor);
+
+   // Generate the surface texture coordinates using the mesh control points
+   // and the designated scaling/tiling.
+   AllocatedMatrix<float> surfaceValues(_meshData.x(), _meshData.y());
+   GenScaledDistanceValues(sliceType, alignSliceInt, refSliceInt,
+                           naturalScale, rawScaleOrTiles,
+                           surfaceValues);
+
+   // Derive the control point values necessary to achieve those surface values.
+   GenControlTexFromSurface(axis, surfaceValues);
+
+   // Done!
+   CommitChanges();
+}
+
+/**
+ * Set the mesh's texture coordinates according to a linear combination of
+ * factors. This equation can be used to set the texture coordinates at the
+ * control points themselves, or to directly set the texture coordinates at
+ * the locations on the mesh surface that correspond to each half-patch
+ * interval.
+ * 
+ * An alignment row is used as the zero-point for any calculations of row
+ * number or of distance along a column surface when processing the equation.
+ * An alignment column is similarly used. (Note that the number identifying
+ * the alignment row/column is the real number used to index into the mesh;
+ * it's not the modified number as affected by the alignment column/row when
+ * processing the equation. We don't want to be stuck in a chicken-and-egg
+ * situation.)
+ * 
+ * Calculations of distance along row/col surface may optionally be affected
+ * by a designated reference row/col. The reference row/col can be used as a
+ * source of end-to-end distance only, in which case the proportional spacing
+ * of the control points within the affected row/col will determine the
+ * distance value to be used for each control point. Or, the distance value
+ * for every control point in the reference row/col can be copied to each
+ * corresponding control point in the other rows/cols.
+ *
+ * @param sFactors      Factors to determine the S texture coords; NULL if S
+ *                      axis unaffected.
+ * @param tFactors      Factors to determine the T texture coords; NULL if T
+ *                      axis unaffected.
+ * @param alignRow      Pointer to zero-point row; if NULL, row 0 is assumed.
+ * @param alignCol      Pointer to zero-point column; if NULL, column 0 is
+ *                      assumed.
+ * @param refRow        Pointer to reference row description, including how
+ *                      to use the reference; NULL if no reference.
+ * @param refCol        Pointer to reference column description, including
+ *                      how to use the reference; NULL if no reference.
+ * @param surfaceValues true if calculations are for S/T values on the mesh
+ *                      surface; false if calculations are for S/T values at
+ *                      the control points.
+ */
+void
+MeshEntity::GeneralFunction(const GeneralFunctionFactors *sFactors,
+                            const GeneralFunctionFactors *tFactors,
+                            const SliceDesignation *alignRow,
+                            const SliceDesignation *alignCol,
+                            const RefSliceDescriptor *refRow,
+                            const RefSliceDescriptor *refCol,
+                            bool surfaceValues)
+{
+   // We're about to make changes!
+   CreateUndoPoint();
+
+   // Make sure we have a definite number for the alignment slices, and for the
+   // reference slices if any.
+   int alignRowInt = InternalSliceDesignation(alignRow, ROW_SLICE_TYPE);
+   int alignColInt = InternalSliceDesignation(alignRow, COL_SLICE_TYPE);
+   RefSliceDescriptorInt rowDescriptor;
+   RefSliceDescriptorInt *refRowInt = // will be NULL if no row reference
+      InternalRefSliceDescriptor(refRow, ROW_SLICE_TYPE, rowDescriptor);
+   RefSliceDescriptorInt colDescriptor;
+   RefSliceDescriptorInt *refColInt = // will be NULL if no column reference
+      InternalRefSliceDescriptor(refCol, COL_SLICE_TYPE, colDescriptor);
+
+   // Get the surface row/col distance values at each half-patch interval, if
+   // the input factors care about distances.
+   AllocatedMatrix<float> rowDistances(_meshData.x(), _meshData.y());
+   AllocatedMatrix<float> colDistances(_meshData.x(), _meshData.y());
+   if ((sFactors != NULL && sFactors->rowDistance != 0.0f) ||
+       (tFactors != NULL && tFactors->rowDistance != 0.0f))
+   {
+      GenScaledDistanceValues(ROW_SLICE_TYPE,
+                              alignColInt,
+                              refRowInt,
+                              true,
+                              1.0f,
+                              rowDistances);
+   }
+   if ((sFactors != NULL && sFactors->colDistance != 0.0f) ||
+       (tFactors != NULL && tFactors->colDistance != 0.0f))
+   {
+      GenScaledDistanceValues(COL_SLICE_TYPE,
+                              alignRowInt,
+                              refColInt,
+                              true,
+                              1.0f,
+                              colDistances);
+   }
+
+   // Modify the S axis if requested.
+   if (sFactors != NULL)
+   {
+      GeneralFunctionInt(*sFactors, S_TEX_AXIS, alignRowInt, alignColInt, surfaceValues,
+                         rowDistances, colDistances);
+   }
+
+   // Modify the T axis if requested.
+   if (tFactors != NULL)
+   {
+      GeneralFunctionInt(*tFactors, T_TEX_AXIS, alignRowInt, alignColInt, surfaceValues,
+                         rowDistances, colDistances);
+   }
+
+   // Done!
+   CommitChanges();
+}
+
+/**
+ * Update the internally stored information for the min and max extent of the
+ * mesh on the specified worldspace axis.
+ *
+ * @param axis The worldspace axis.
+ */
+void
+MeshEntity::UpdatePosMinMax(PositionAxis axis)
+{
+   // Iterate over all control points to find the min and max values.
+   _posMin[axis] = _meshData(0, 0).m_vertex[axis];
+   _posMax[axis] = _posMin[axis];
+   for (unsigned rowIndex = 0; rowIndex < _numSlices[ROW_SLICE_TYPE]; rowIndex++)
+   {
+      for (unsigned colIndex = 0; colIndex < _numSlices[COL_SLICE_TYPE]; colIndex++)
+      {
+         float current = _meshData(rowIndex, colIndex).m_vertex[axis];
+         if (current < _posMin[axis])
+         {
+            _posMin[axis] = current;
+         }
+         if (current > _posMax[axis])
+         {
+            _posMax[axis] = current;
+         }
+      }
+   }
+}
+
+/**
+ * Update the internally stored information for the min and max extent of the
+ * mesh on the specified texture axis.
+ *
+ * @param axis The texture axis.
+ */
+void
+MeshEntity::UpdateTexMinMax(TextureAxis axis)
+{
+   // Bail out if no operations have possibly changed these values.
+   if (!_texMinMaxDirty[axis])
+   {
+      return;
+   }
+
+   // Iterate over all control points to find the min and max values.
+   _texMin[axis] = _meshData(0, 0).m_texcoord[axis];
+   _texMax[axis] = _texMin[axis];
+   for (unsigned rowIndex = 0; rowIndex < _numSlices[ROW_SLICE_TYPE]; rowIndex++)
+   {
+      for (unsigned colIndex = 0; colIndex < _numSlices[COL_SLICE_TYPE]; colIndex++)
+      {
+         float current = _meshData(rowIndex, colIndex).m_texcoord[axis];
+         if (current < _texMin[axis])
+         {
+            _texMin[axis] = current;
+         }
+         if (current > _texMax[axis])
+         {
+            _texMax[axis] = current;
+         }
+      }
+   }
+
+   // See if the min and max are on texture boundaries.
+   _texMinAligned[axis] = (floorf(_texMin[axis]) == _texMin[axis]);
+   _texMaxAligned[axis] = (floorf(_texMax[axis]) == _texMax[axis]);
+
+   // Values are good until next relevant operation.
+   _texMinMaxDirty[axis] = false;
+}
+
+/**
+ * Interface to the Radiant undo buffer; save the current state of the mesh
+ * to allow rollback to this point by an undo operation.
+ */
+void
+MeshEntity::CreateUndoPoint()
+{
+   GlobalPatchCreator().Patch_undoSave(_mesh);
+}
+
+/**
+ * Commit the changes to the mesh so that they will be reflected in Radiant.
+ */
+void
+MeshEntity::CommitChanges()
+{
+   GlobalPatchCreator().Patch_controlPointsChanged(_mesh);
+   // Radiant undo-buffer behavior requires this:
+   CreateUndoPoint();
+}
+
+/**
+ * Convert from SliceDesignation to a slice number. Interpret max slice if
+ * necessary, and fall back to slice 0 if unspecified.
+ *
+ * @param sliceDesignation Pointer to slice description; may be NULL.
+ * @param sliceType        Slice kind (row or column).
+ *
+ * @return The slice number.
+ */
+int
+MeshEntity::InternalSliceDesignation(const SliceDesignation *sliceDesignation,
+                                     SliceType sliceType)
+{
+   if (sliceDesignation != NULL)
+   {
+      // Interpret "max slice" if necessary.
+      if (sliceDesignation->maxSlice)
+      {
+         return _numSlices[sliceType] - 1;
+      }
+      else
+      {
+         return sliceDesignation->index;
+      }
+   }
+   else
+   {
+      // 0 if unspecified.
+      return 0;
+   }
+}
+
+/**
+ * Convert from RefSliceDescriptor to RefSliceDescriptorInt. Interpret max
+ * slice if necessary. Populate specified RefSliceDescriptorInt if input is
+ * non-NULL and return pointer to it; otherwise return NULL.
+ *
+ * @param refSlice          Pointer to reference slice description; may be
+ *                          NULL.
+ * @param sliceType         Slice kind (row or column).
+ * @param [out] refSliceInt RefSliceDescriptorInt to populate.
+ *
+ * @return NULL if input RefSliceDescriptor is NULL; else, pointer to populated
+ *         RefSliceDescriptorInt.
+ */
+MeshEntity::RefSliceDescriptorInt *
+MeshEntity::InternalRefSliceDescriptor(const RefSliceDescriptor *refSlice,
+                                       SliceType sliceType,
+                                       RefSliceDescriptorInt& refSliceInt)
+{
+   if (refSlice != NULL)
+   {
+      // Preserve totalLengthOnly.
+      refSliceInt.totalLengthOnly = refSlice->totalLengthOnly;
+      // Convert slice designator to a slice number.
+      refSliceInt.index = InternalSliceDesignation(&(refSlice->designation), sliceType);
+      return &refSliceInt;
+   }
+   else
+   {
+      // NULL if unspecified.
+      return NULL;
+   }
+}
+
+/**
+ * Given a slice and a number of times that its texture should tile along it,
+ * find the appropriate texture scale. This result is determined by the
+ * surface length along the slice.
+ *
+ * @param sliceType Slice kind (row or column).
+ * @param slice     Slice number, among slices of that kind in mesh.
+ * @param axis      The texture axis of interest.
+ * @param tiles     Number of times the texture tiles.
+ *
+ * @return The texture scale corresponding to the tiling amount.
+ */
+float
+MeshEntity::GetSliceTexScale(SliceType sliceType,
+                             int slice,
+                             TextureAxis axis,
+                             float tiles)
+{
+   // XXX Similar to GenScaledDistanceValues; refactor for shared code?
+
+   // We're going to be walking patches along the mesh, choosing the patches
+   // that surround/affect the slice we are interested in. We'll calculate
+   // the length of the slice's surface across each patch & add those up.
+   
+   // A SlicePatchContext will contain all the necessary information to
+   // evaluate our slice's surface length within each patch. Some aspects of
+   // the SlicePatchContext will vary as we move from patch to patch, but we
+   // can go ahead and calculate now any stuff that is invariant along the
+   // slice's direction.
+   SlicePatchContext context;
+   context.sliceType = sliceType;
+   if (slice != 0)
+   {
+      // This is the position of the slice within each patch, in the direction
+      // orthogonal to the slice. Even-numbered slices are at the edge of the
+      // patch (position 1.0), while odd-numbered slices are in the middle
+      // (position 0.5).
+      context.position = 1.0f - ((float)(slice & 0x1) / 2.0f);
+   }
+   else
+   {
+      // For the first slice, we can't give it the usual treatment for even-
+      // numbered slices (since there is no patch "before" it), so it gets
+      // position 0.0 instead.
+      context.position = 0.0f;
+   }
+   // This is the slice of the same kind that defines the 0.0 edge of the
+   // patch. It will be the next lowest even-numbered slice. (Note the
+   // integer division here.)
+   context.edgeSlice[sliceType] = 2 * ((slice - 1) / 2);
+
+   // Now it's time to walk the patches.
+
+   // We start off with no cumulative distance yet.
+   float cumulativeDistance = 0.0f;
+
+   // By iterating over the number of control points in this slice by
+   // increments of 2, we'll be walking the slice in patch-sized steps. Since
+   // we are only interested in the total length, we don't need to check in at
+   // finer granularities.
+   for (unsigned halfPatch = 2; halfPatch < SliceSize(sliceType); halfPatch += 2)
+   {
+      // Find the slice-of-other-kind that defines the patch edge orthogonal
+      // to our slice.
+      context.edgeSlice[OtherSliceType(sliceType)] = 2 * ((halfPatch - 1) / 2);
+      // Estimate the slice length along the surface of the patch.
+      float segmentLengthEstimate = EstimateSegmentLength(0.0f, 1.0f, context);
+      // Recursively refine that estimate until it is good enough, then add it
+      // to our cumulative distance.
+      cumulativeDistance += RefineSegmentLength(0.0f, 1.0f, context,
+                                                segmentLengthEstimate,
+                                                UNITS_ERROR_BOUND);
+   }
+
+   // The scale along this slice is defined as the surface length divided by
+   // the "natural" number of texture units along that length.
+   return cumulativeDistance / (tiles * _naturalTexUnits[axis]);
+}
+
+/**
+ * Populate the SliceTexInfo for the indicated slice and texture axis.
+ *
+ * @param sliceType  Slice kind (row or column).
+ * @param slice      Slice number, among slices of that kind in mesh.
+ * @param axis       The texture axis of interest.
+ * @param [out] info Information on scale, tiles, and min/max for the
+ *                   specified texture axis.
+ *
+ * @return true on success, false if slice cannot be processed.
+ */
+bool
+MeshEntity::GetSliceTexInfo(SliceType sliceType,
+                            int slice,
+                            TextureAxis axis,
+                            SliceTexInfo& info)
+{
+   // Bail out now if slice # is bad.
+   if (slice < 0 ||
+       slice >= (int)_numSlices[sliceType])
+   {
+      _errorReportCallback(_errorBadSliceString[sliceType]);
+      return false;
+   }
+
+   // Calculate the # of times the texture is tiled along the specified axis
+   // on this slice, and find the min and max values for that axis.
+   float texBegin =
+      MatrixElement(_meshData, sliceType, slice, 0).m_texcoord[axis];
+   float texEnd =
+      MatrixElement(_meshData, sliceType, slice, SliceSize(sliceType) - 1).m_texcoord[axis];
+   info.tiles = texEnd - texBegin;
+   if (texBegin < texEnd)
+   {
+      info.min = texBegin;
+      info.max = texEnd;
+   }
+   else
+   {
+      info.min = texEnd;
+      info.max = texBegin;
+   }
+
+   // Calculate the texture scale along this slice, using the tiling info
+   // along with the texture size and the length of the slice's surface.
+   info.scale = GetSliceTexScale(sliceType, slice, axis, info.tiles);
+   return true;
+}
+
+/**
+ * Take the information from GetSliceTexInfo and sanitize it for reporting.
+ * Optionally print to a provided message buffer and/or supply data to a
+ * provided TexInfoCallback.
+ *
+ * @param sliceType         Slice kind (row or column).
+ * @param slice             Slice number, among slices of that kind in mesh.
+ * @param axis              The texture axis of interest.
+ * @param messageBuffer     Buffer for message data; NULL if none.
+ * @param messageBufferSize Size of the message buffer.
+ * @param texInfoCallback   Callback for passing texture scale/tiles info;
+ *                          NULL if none.
+ */
+void
+MeshEntity::ReportSliceTexInfo(SliceType sliceType,
+                               int slice,
+                               TextureAxis axis,
+                               char *messageBuffer,
+                               unsigned messageBufferSize,
+                               const TexInfoCallback *texInfoCallback)
+{
+   // Fetch the raw info.
+   SliceTexInfo info;
+   if (!GetSliceTexInfo(sliceType, slice, axis, info))
+   {
+      return;
+   }
+
+   // Account for Radiant-inverted.
+   if (_radiantScaleInverted[sliceType])
+   {
+      info.scale = -info.scale;
+   }
+   if (_radiantTilesInverted[sliceType])
+   {
+      info.tiles = -info.tiles;
+   }
+
+   // Send texture info to callback if one is provided.
+   bool infscale = (info.scale > FLT_MAX || info.scale < -FLT_MAX);
+   if (texInfoCallback != NULL)
+   {
+      if (!infscale)
+      {
+         (*texInfoCallback)(SanitizeFloat(info.scale), SanitizeFloat(info.tiles));
+      }
+      else
+      {
+         // "Infinite scale" prevents us from invoking the callback, so
+         // raise a warning about that.
+         _warningReportCallback(_warningSliceInfscaleFormatString[sliceType]);
+      }
+   }
+
+   // Write texture info to buffer if one is provided.
+   if (messageBuffer != NULL)
+   {
+      if (!infscale)
+      {
+         snprintf(messageBuffer, messageBufferSize,
+            _infoSliceFormatString[sliceType], slice,
+            SanitizeFloat(info.scale), SanitizeFloat(info.tiles),
+            SanitizeFloat(info.min), SanitizeFloat(info.max));
+      }
+      else
+      {
+         // Special handling for "infinite scale".
+         snprintf(messageBuffer, messageBufferSize,
+            _infoSliceInfscaleFormatString[sliceType], slice,
+            SanitizeFloat(info.tiles),
+            SanitizeFloat(info.min), SanitizeFloat(info.max));
+      }
+   }
+}
+
+/**
+ * Apply some function with the InternalImpl signature to each of the
+ * designated texture axes. The undo point and state commit operations
+ * are handled here for such functions.
+ *
+ * @param internalImpl The function to apply.
+ * @param axes         The texture axes to affect.
+ */
+void
+MeshEntity::ProcessForAxes(InternalImpl internalImpl,
+                           TextureAxisSelection axes)
+{
+   // We're about to make changes!
+   CreateUndoPoint();
+
+   // Apply the function to the requested axes.
+   bool sChanged = false;
+   bool tChanged = false;
+   if (axes != T_TEX_AXIS_ONLY)
+   {
+      sChanged = (*this.*internalImpl)(S_TEX_AXIS);
+   }
+   if (axes != S_TEX_AXIS_ONLY)
+   {
+      tChanged = (*this.*internalImpl)(T_TEX_AXIS);
+   }
+
+   // Done! Commit changes if necessary.
+   if (sChanged || tChanged)
+   {
+      CommitChanges();
+   }
+}
+
+/**
+ * Add an offset to all control point values for the given texture axis.
+ *
+ * @param axis  The texture axis to affect.
+ * @param shift The offset to add.
+ */
+void
+MeshEntity::Shift(TextureAxis axis,
+                  float shift)
+{
+   // Iterate over all control points and add the offset.
+   for (unsigned rowIndex = 0; rowIndex < _numSlices[ROW_SLICE_TYPE]; rowIndex++)
+   {
+      for (unsigned colIndex = 0; colIndex < _numSlices[COL_SLICE_TYPE]; colIndex++)
+      {
+         _meshData(rowIndex, colIndex).m_texcoord[axis] += shift;
+      }
+   }
+
+   // This operation might have changed texture min/max.
+   _texMinMaxDirty[axis] = true;
+}
+
+/**
+ * On the given texture axis, find the distance of all control point values
+ * from the current minimum value and multiply that distance by the given
+ * scale factor.
+ *
+ * @param axis  The texture axis to affect.
+ * @param scale The scale factor.
+ */
+void
+MeshEntity::Scale(TextureAxis axis,
+                  float scale)
+{
+   // Make sure the min value is updated; we'll need it below.
+   UpdateTexMinMax(axis);
+
+   // Iterate over all control points and apply the scale factor.
+   for (unsigned rowIndex = 0; rowIndex < _numSlices[ROW_SLICE_TYPE]; rowIndex++)
+   {
+      for (unsigned colIndex = 0; colIndex < _numSlices[COL_SLICE_TYPE]; colIndex++)
+      {
+         // Leave the current minimum edge in place and scale out from that.
+         _meshData(rowIndex, colIndex).m_texcoord[axis] =
+            ((_meshData(rowIndex, colIndex).m_texcoord[axis] - _texMin[axis]) * scale) +
+            _texMin[axis];
+      }
+   }
+
+   // This operation might have changed texture min/max.
+   _texMinMaxDirty[axis] = true;
+}
+
+/**
+ * Implementation of MinAlign for a single texture axis.
+ *
+ * @param axis The texture axis to affect.
+ *
+ * @return true if the mesh was changed, false if not.
+ */
+bool
+MeshEntity::MinAlignInt(TextureAxis axis)
+{
+   // Make sure the min-aligned value is updated.
+   UpdateTexMinMax(axis);
+
+   // If already aligned, we're done.
+   if (_texMinAligned[axis])
+   {
+      // Didn't make changes.
+      return false;
+   }
+
+   // Otherwise shift by the necessary amount to align.
+   Shift(axis, ceilf(_texMin[axis]) - _texMin[axis]);
+
+   // Made changes.
+   return true;
+}
+
+/**
+ * Implementation of MaxAlign for a single texture axis.
+ *
+ * @param axis The texture axis to affect.
+ *
+ * @return true if the mesh was changed, false if not.
+ */
+bool
+MeshEntity::MaxAlignInt(TextureAxis axis)
+{
+   // Make sure the max-aligned value is updated.
+   UpdateTexMinMax(axis);
+
+   // If already aligned, we're done.
+   if (_texMaxAligned[axis])
+   {
+      // Didn't make changes.
+      return false;
+   }
+
+   // Otherwise shift by the necessary amount to align.
+   Shift(axis, ceilf(_texMax[axis]) - _texMax[axis]);
+
+   // Made changes.
+   return true;
+}
+
+/**
+ * Implementation of MinMaxAlignAutoScale for a single texture axis.
+ *
+ * @param axis The texture axis to affect.
+ *
+ * @return true if the mesh was changed, false if not.
+ */
+bool
+MeshEntity::MinMaxAlignAutoScaleInt(TextureAxis axis)
+{
+   // Make sure the max value is updated.
+   UpdateTexMinMax(axis);
+
+   // Choose to stretch or shrink, based on which will cause less change.
+   if ((_texMax[axis] - floorf(_texMax[axis])) < 0.5)
+   {
+      return MinMaxAlignStretchInt(axis);
+   }
+   else
+   {
+      return MinMaxAlignShrinkInt(axis);
+   }
+}
+
+/**
+ * The meat of MinMaxAlignStretchInt and MinMaxAlignShrinkInt.
+ *
+ * @param axis The texture axis to affect.
+ * @param op   Whether to stretch or shrink.
+ *
+ * @return true if the mesh was changed, false if not.
+ */
+bool
+MeshEntity::MinMaxAlignScale(TextureAxis axis,
+                             ScaleOperation op)
+{
+   // First make sure we are min-aligned.
+   bool changed = MinAlignInt(axis);
+
+   // Make sure the min/max values are updated.
+   UpdateTexMinMax(axis);
+
+   // More work to do if not max-aligned.
+   if (!_texMaxAligned[axis])
+   {
+      // Find the current tiling.
+      float oldRepeats = _texMax[axis] - _texMin[axis];
+      // Find the desired tiling, depending on whether we are stretching or
+      // shrinking.
+      float newRepeats;
+      if (op == STRETCH_SCALE_OP)
+      {
+         newRepeats = floorf(_texMax[axis]) - _texMin[axis];
+      }
+      else
+      {
+         newRepeats = ceilf(_texMax[axis]) - _texMin[axis];
+      }
+      // Apply the necessary scaling to get the desired tiling.
+      Scale(axis, newRepeats / oldRepeats);
+      // Made changes.
+      changed = true;
+   }
+
+   return changed;
+}
+
+/**
+ * Implementation of MinMaxAlignStretch for a single texture axis.
+ *
+ * @param axis The texture axis to affect.
+ *
+ * @return true if the mesh was changed, false if not.
+ */
+bool
+MeshEntity::MinMaxAlignStretchInt(TextureAxis axis)
+{
+   // Hand off to MinMaxAlignScale.
+   return MinMaxAlignScale(axis, STRETCH_SCALE_OP);
+}
+
+/**
+ * Implementation of MinMaxAlignShrink for a single texture axis.
+ *
+ * @param axis The texture axis to affect.
+ *
+ * @return true if the mesh was changed, false if not.
+ */
+bool
+MeshEntity::MinMaxAlignShrinkInt(TextureAxis axis)
+{
+   // Hand off to MinMaxAlignScale.
+   return MinMaxAlignScale(axis, SHRINK_SCALE_OP);
+}
+
+/**
+ * Calculate the d(x, y, or z)/dt of a patch slice, evaluated at a given t
+ * (parameter for the Bezier function, between 0 and 1).
+ *
+ * @param axis    The worldspace axis of interest.
+ * @param t       Bezier parameter.
+ * @param context The slice and patch.
+ *
+ * @return d(x, y, or z)/dt at the given t.
+ */
+float
+MeshEntity::SliceParametricSpeedComponent(PositionAxis axis,
+                                          float t,
+                                          const SlicePatchContext& context)
+{
+   float a = 1.0f - context.position;
+   float b = 2.0f * context.position * a;
+   a *= a;
+   float c = context.position * context.position;
+   float d = 2.0f * t - 2.0f;
+   float e = 2.0f - 4.0f * t;
+   float f = 2.0f * t;
+   int patchStartCol = context.edgeSlice[COL_SLICE_TYPE];
+   int patchStartRow = context.edgeSlice[ROW_SLICE_TYPE];
+
+   if (context.sliceType == ROW_SLICE_TYPE)
+   {
+      return
+         _meshData(patchStartRow+0, patchStartCol+0).m_vertex[axis] * a * d +
+         _meshData(patchStartRow+0, patchStartCol+1).m_vertex[axis] * a * e +
+         _meshData(patchStartRow+0, patchStartCol+2).m_vertex[axis] * a * f +
+         _meshData(patchStartRow+1, patchStartCol+0).m_vertex[axis] * b * d +
+         _meshData(patchStartRow+1, patchStartCol+1).m_vertex[axis] * b * e +
+         _meshData(patchStartRow+1, patchStartCol+2).m_vertex[axis] * b * f +
+         _meshData(patchStartRow+2, patchStartCol+0).m_vertex[axis] * c * d +
+         _meshData(patchStartRow+2, patchStartCol+1).m_vertex[axis] * c * e +
+         _meshData(patchStartRow+2, patchStartCol+2).m_vertex[axis] * c * f;
+   }
+   else
+   {
+      return
+         _meshData(patchStartRow+0, patchStartCol+0).m_vertex[axis] * a * d +
+         _meshData(patchStartRow+1, patchStartCol+0).m_vertex[axis] * a * e +
+         _meshData(patchStartRow+2, patchStartCol+0).m_vertex[axis] * a * f +
+         _meshData(patchStartRow+0, patchStartCol+1).m_vertex[axis] * b * d +
+         _meshData(patchStartRow+1, patchStartCol+1).m_vertex[axis] * b * e +
+         _meshData(patchStartRow+2, patchStartCol+1).m_vertex[axis] * b * f +
+         _meshData(patchStartRow+0, patchStartCol+2).m_vertex[axis] * c * d +
+         _meshData(patchStartRow+1, patchStartCol+2).m_vertex[axis] * c * e +
+         _meshData(patchStartRow+2, patchStartCol+2).m_vertex[axis] * c * f;
+   }
+}
+
+/**
+ * Calculates the rate of change in worldspace units of a patch slice,
+ * evaluated at a given t (parameter for the Bezier function, between 0 and
+ * 1).
+ *
+ * @param t       Bezier parameter.
+ * @param context The slice and patch.
+ *
+ * @return Path length.
+ */
+float
+MeshEntity::SliceParametricSpeed(float t,
+                                 const SlicePatchContext& context)
+{
+   float xDotEval = SliceParametricSpeedComponent(X_POS_AXIS, t, context);
+   float yDotEval = SliceParametricSpeedComponent(Y_POS_AXIS, t, context);
+   float zDotEval = SliceParametricSpeedComponent(Z_POS_AXIS, t, context);
+   return sqrtf(xDotEval*xDotEval + yDotEval*yDotEval + zDotEval*zDotEval);
+}
+
+/**
+ * Estimate the surface length of a slice segment, using ten point
+ * Gauss-Legendre integration of the parametric speed function. The value
+ * returned will always be positive (absolute value).
+ *
+ * @param startPosition Bezier parameter value for the start point of the
+ *                      slice segment.
+ * @param endPosition   Bezier parameter value for the end point of the slice
+ *                      segment.
+ * @param context       The slice and patch.
+ *
+ * @return Estimate of segment length.
+ */
+float
+MeshEntity::EstimateSegmentLength(float startPosition,
+                                  float endPosition,
+                                  const SlicePatchContext& context)
+{
+   // Gauss-Legendre implementation taken from "Numerical Recipes in C".
+
+   static float x[] = {0.0f, 0.1488743389f, 0.4333953941f, 0.6794095682f, 0.8650633666f, 0.9739065285f};
+   static float w[] = {0.0f, 0.2955242247f, 0.2692667193f, 0.2190863625f, 0.1494513491f, 0.0666713443f};
+
+   float xm = 0.5f * (endPosition + startPosition);
+   float xr = 0.5f * (endPosition - startPosition);
+   float s = 0.0f;
+
+   for (unsigned j = 1; j <= 5; j++) {
+      float dx = xr * x[j];
+      s += w[j] * (SliceParametricSpeed(xm + dx, context) +
+                   SliceParametricSpeed(xm - dx, context));
+   }
+
+   return fabsf(s * xr);
+}
+
+/**
+ * Recursively improve the estimate of the surface length of a slice segment,
+ * by estimating the length of its halves, until the change between estimates
+ * is equal to or less than an acceptable error threshold.
+ *
+ * @param startPosition         Bezier parameter value for the start point of
+ *                              the slice segment.
+ * @param endPosition           Bezier parameter value for the end point of the
+ *                              slice segment.
+ * @param context               The slice and patch.
+ * @param segmentLengthEstimate Starting estimate for segment legnth.
+ * @param maxError              Max acceptable variance between estimates.
+ *
+ * @return Improved estimate of segment length.
+ */
+float
+MeshEntity::RefineSegmentLength(float startPosition,
+                                float endPosition,
+                                const SlicePatchContext& context,
+                                float segmentLengthEstimate,
+                                float maxError)
+{
+   // Estimate the lengths of the two halves of this segment.
+   float midPosition = (startPosition + endPosition) / 2.0f;
+   float leftLength = EstimateSegmentLength(startPosition, midPosition, context);
+   float rightLength = EstimateSegmentLength(midPosition, endPosition, context);
+
+   // If the sum of the half-segment estimates is too far off from the
+   // whole-segment estimate, then we're in a regime with too much error in
+   // the estimates. Recurse to refine the half-segment estimates.
+   if (fabsf(segmentLengthEstimate - (leftLength + rightLength)) > maxError)
+   {
+      leftLength = RefineSegmentLength(startPosition, midPosition,
+                                       context,
+                                       leftLength,
+                                       maxError / 2.0f);
+      rightLength = RefineSegmentLength(midPosition, endPosition,
+                                        context,
+                                        rightLength,
+                                        maxError / 2.0f);
+   }
+
+   // Return the sum of the (refined) half-segment estimates.
+   return (leftLength + rightLength);
+}
+
+/**
+ * Derive control point texture coordinates (on a given texture axis) from a
+ * set of mesh surface texture coordinates.
+ *
+ * @param axis          The texture axis of interest.
+ * @param surfaceValues The surface texture coordinates.
+ */
+void
+MeshEntity::GenControlTexFromSurface(TextureAxis axis,
+                                     const Matrix<float>& surfaceValues)
+{
+   // The control points on even rows & even columns (i.e. patch corners)
+   // have texture coordinates that match the surface values.
+   for (unsigned rowIndex = 0; rowIndex < _numSlices[ROW_SLICE_TYPE]; rowIndex += 2)
+   {
+      for (unsigned colIndex = 0; colIndex < _numSlices[COL_SLICE_TYPE]; colIndex += 2)
+      {
+         _meshData(rowIndex, colIndex).m_texcoord[axis] =
+            surfaceValues(rowIndex, colIndex);
+      }
+   }
+
+   // Set the control points on odd rows & even columns (i.e. the centers of
+   // columns that are patch edges).
+   for (unsigned rowIndex = 1; rowIndex < _numSlices[ROW_SLICE_TYPE]; rowIndex += 2)
+   {
+      for (unsigned colIndex = 0; colIndex < _numSlices[COL_SLICE_TYPE]; colIndex += 2)
+      {
+         _meshData(rowIndex, colIndex).m_texcoord[axis] =
+            2.0f * surfaceValues(rowIndex, colIndex) -
+            (surfaceValues(rowIndex - 1, colIndex) +
+             surfaceValues(rowIndex + 1, colIndex)) / 2.0f;
+      }
+   }
+
+   // Set the control points on even rows & odd columns (i.e. the centers of
+   // rows that are patch edges).
+   for (unsigned rowIndex = 0; rowIndex < _numSlices[ROW_SLICE_TYPE]; rowIndex += 2)
+   {
+      for (unsigned colIndex = 1; colIndex < _numSlices[COL_SLICE_TYPE]; colIndex += 2)
+      {
+         _meshData(rowIndex, colIndex).m_texcoord[axis] =
+            2.0f * surfaceValues(rowIndex, colIndex) -
+            (surfaceValues(rowIndex, colIndex - 1) +
+             surfaceValues(rowIndex, colIndex + 1)) / 2.0f;
+      }
+   }
+
+   // And finally on odd rows & odd columns (i.e. patch centers).
+   for (unsigned rowIndex = 1; rowIndex < _numSlices[ROW_SLICE_TYPE]; rowIndex += 2)
+   {
+      for (unsigned colIndex = 1; colIndex < _numSlices[COL_SLICE_TYPE]; colIndex += 2)
+      {
+         _meshData(rowIndex, colIndex).m_texcoord[axis] =
+            4.0f * surfaceValues(rowIndex, colIndex) -
+            (surfaceValues(rowIndex, colIndex - 1) +
+             surfaceValues(rowIndex, colIndex + 1) +
+             surfaceValues(rowIndex - 1, colIndex) +
+             surfaceValues(rowIndex + 1, colIndex)) / 2.0f -
+            (surfaceValues(rowIndex - 1, colIndex - 1) +
+             surfaceValues(rowIndex + 1, colIndex + 1) +
+             surfaceValues(rowIndex - 1, colIndex + 1) +
+             surfaceValues(rowIndex + 1, colIndex - 1)) / 4.0f;
+      }
+   }
+
+   // This operation might have changed texture min/max.
+   _texMinMaxDirty[axis] = true;
+}
+
+/**
+ * Overwrite control point texture coordinates (on a given texture axis) with
+ * the input texture coordinates.
+ *
+ * @param axis   The texture axis of interest.
+ * @param values The input texture coordinates.
+ */
+void
+MeshEntity::CopyControlTexFromValues(TextureAxis axis,
+                                     const Matrix<float>& values)
+{
+   // Iterate over all control points and just do a straight copy.
+   for (unsigned rowIndex = 0; rowIndex < _numSlices[ROW_SLICE_TYPE]; rowIndex++)
+   {
+      for (unsigned colIndex = 0; colIndex < _numSlices[COL_SLICE_TYPE]; colIndex++)
+      {
+         _meshData(rowIndex, colIndex).m_texcoord[axis] =
+            values(rowIndex, colIndex);
+      }
+   }
+
+   // This operation might have changed texture min/max.
+   _texMinMaxDirty[axis] = true;
+}
+
+/**
+ * Derive a set of surface texture coordinates (on a given texture axis) from
+ * the control point texture coordinates.
+ *
+ * @param axis                The texture axis of interest.
+ * @param [out] surfaceValues The surface texture coordinates.
+ */
+void
+MeshEntity::GenSurfaceFromControlTex(TextureAxis axis,
+                                     Matrix<float>& surfaceValues)
+{
+   // The surface values on even rows & even columns (i.e. patch corners)
+   // have texture coordinates that match the control points.
+   for (unsigned rowIndex = 0; rowIndex < _numSlices[ROW_SLICE_TYPE]; rowIndex += 2)
+   {
+      for (unsigned colIndex = 0; colIndex < _numSlices[COL_SLICE_TYPE]; colIndex += 2)
+      {
+         surfaceValues(rowIndex, colIndex) =
+            _meshData(rowIndex, colIndex).m_texcoord[axis];
+      }
+   }
+
+   // Set the surface values on odd rows & odd columns (i.e. patch centers).
+   for (unsigned rowIndex = 1; rowIndex < _numSlices[ROW_SLICE_TYPE]; rowIndex += 2)
+   {
+      for (unsigned colIndex = 1; colIndex < _numSlices[COL_SLICE_TYPE]; colIndex += 2)
+      {
+         surfaceValues(rowIndex, colIndex) =
+            _meshData(rowIndex, colIndex).m_texcoord[axis] / 4.0f +
+            (_meshData(rowIndex, colIndex - 1).m_texcoord[axis] +
+             _meshData(rowIndex, colIndex + 1).m_texcoord[axis] +
+             _meshData(rowIndex - 1, colIndex).m_texcoord[axis] +
+             _meshData(rowIndex + 1, colIndex).m_texcoord[axis]) / 8.0f +
+            (_meshData(rowIndex - 1, colIndex - 1).m_texcoord[axis] +
+             _meshData(rowIndex + 1, colIndex + 1).m_texcoord[axis] +
+             _meshData(rowIndex - 1, colIndex + 1).m_texcoord[axis] +
+             _meshData(rowIndex + 1, colIndex - 1).m_texcoord[axis]) / 16.0f;
+      }
+   }
+
+   // Set the surface values on even rows & odd columns (i.e. the centers of
+   // rows that are patch edges).
+   for (unsigned rowIndex = 0; rowIndex < _numSlices[ROW_SLICE_TYPE]; rowIndex += 2)
+   {
+      for (unsigned colIndex = 1; colIndex < _numSlices[COL_SLICE_TYPE]; colIndex += 2)
+      {
+         surfaceValues(rowIndex, colIndex) =
+            _meshData(rowIndex, colIndex).m_texcoord[axis] / 2.0f +
+            (_meshData(rowIndex, colIndex - 1).m_texcoord[axis] +
+             _meshData(rowIndex, colIndex + 1).m_texcoord[axis]) / 4.0f;
+      }
+   }
+
+   // And finally on odd rows & even columns (i.e. the centers of columns that
+   // are patch edges).
+   for (unsigned rowIndex = 1; rowIndex < _numSlices[ROW_SLICE_TYPE]; rowIndex += 2)
+   {
+      for (unsigned colIndex = 0; colIndex < _numSlices[COL_SLICE_TYPE]; colIndex += 2)
+      {
+         surfaceValues(rowIndex, colIndex) =
+            _meshData(rowIndex, colIndex).m_texcoord[axis] / 2.0f +
+            (_meshData(rowIndex - 1, colIndex).m_texcoord[axis] +
+             _meshData(rowIndex + 1, colIndex).m_texcoord[axis]) / 4.0f;
+      }
+   }
+}
+
+/**
+ * Copy the control point texture coordinates (on a given texture axis) to
+ * the output texture coordinates parameter.
+ *
+ * @param axis         The texture axis of interest.
+ * @param [out] values The output texture coordinates.
+ */
+void
+MeshEntity::CopyValuesFromControlTex(TextureAxis axis,
+                                     Matrix<float>& values)
+{
+   // Iterate over all control points and just do a straight copy.
+   for (unsigned rowIndex = 0; rowIndex < _numSlices[ROW_SLICE_TYPE]; rowIndex++)
+   {
+      for (unsigned colIndex = 0; colIndex < _numSlices[COL_SLICE_TYPE]; colIndex++)
+      {
+         values(rowIndex, colIndex) =
+            _meshData(rowIndex, colIndex).m_texcoord[axis];
+      }
+   }
+}
+
+/**
+ * Generate a set of values based on surface slice lengths and some amount of
+ * desired scaling or tiling.
+ * 
+ * This method does a great deal of the work for the SetScale public method;
+ * refer to that method's comment header for more details about the alignment
+ * slice and reference slice inputs. The main difference from the SetScale
+ * input parameters is that the scale/tiles factor has been processed some.
+ * It has been flipped if necessary to account for Radiant's internal
+ * scale/tiles orientation differing from the sensible external orientation.
+ * And natural scaling has been converted to raw scaling, which is the actual
+ * desired divisor to get texture coordinates from worldspace lengths.
+ *
+ * @param sliceType       Process rows or colums.
+ * @param alignSlice      Pointer to alignment slice description; if NULL,
+ *                        slice 0 is assumed.
+ * @param refSlice        Pointer to reference slice description, including how
+ *                        to use the reference; NULL if no reference.
+ * @param rawScale        true if rawScaleOrTiles is a scale factor; false if
+ *                        rawScaleOrTiles is a number of tiles.
+ * @param rawScaleOrTiles Scaling determinant, interpreted according to the
+ *                        rawScale parameter.
+ * @param [out] values    The generated values.
+ */
+void
+MeshEntity::GenScaledDistanceValues(SliceType sliceType,
+                                    int alignSlice,
+                                    const RefSliceDescriptorInt *refSlice,
+                                    bool rawScale,
+                                    float rawScaleOrTiles,
+                                    Matrix<float>& values)
+{
+   // For every half-patch interval along the surface, we want to generate a
+   // value based on the surface distance along the row (or column) to that
+   // spot. So, first we need to determine those distances.
+
+   // XXX Similar to GetSliceTexScale; refactor for shared code?
+
+   // We're going to be walking patches along the mesh, choosing the patches
+   // that surround/affect the slice we are interested in.
+   
+   // A SlicePatchContext will contain all the necessary information to
+   // evaluate our slice's surface length within each patch.
+   SlicePatchContext context;
+   context.sliceType = sliceType;
+
+   // Pick the slices that we will measure.
+   int firstSlice, lastSlice;
+   if (refSlice != NULL && !refSlice->totalLengthOnly)
+   {
+      // If a reference slice is provided, and totalLengthOnly is false, then we
+      // will only need to measure the reference slice. The values generated for
+      // it will later be copied to other slices.
+      firstSlice = lastSlice = refSlice->index;
+   }
+   else
+   {
+      // Otherwise we'll measure all of the slices.
+      firstSlice = 0;
+      lastSlice = _numSlices[sliceType] - 1;
+   }
+
+   // Iterate over the slices that need to be measured.
+   for (int slice = firstSlice; slice <= lastSlice; slice++)
+   {
+      // Some aspects of the SlicePatchContext will vary as we move from patch
+      // to patch, but we can go ahead and calculate now any stuff that is
+      // invariant along the slice's direction.
+      if (slice != 0)
+      {
+         // This is the position of the slice within each patch, in the
+         // direction orthogonal to the slice. Even-numbered slices are at the
+         // edge of the patch (position 1.0), while odd-numbered slices are in
+         // the middle (position 0.5).
+         context.position = 1.0f - ((float)(slice & 0x1) / 2.0f);
+      }
+      else
+      {
+         // For the first slice, we can't give it the usual treatment for even-
+         // numbered slices (since there is no patch "before" it), so it gets
+         // position 0.0 instead.
+         context.position = 0.0f;
+      }
+      // This is the slice of the same kind that defines the 0.0 edge of the
+      // patch. It will be the next lowest even-numbered slice. (Note the
+      // integer division here.)
+      context.edgeSlice[sliceType] = 2 * ((slice - 1) / 2);
+
+      // The alignment slice marks the zero-point from which we will be
+      // calculating the distances. So the cumulative distance there is zero.
+      MatrixElement(values, sliceType, slice, alignSlice) = 0.0f;
+
+      // Now we're going to calculate distances for control points "greater
+      // than" the one marked by the alignment slice.
+
+      // Start with zero cumulative distance.
+      float cumulativeDistance = 0.0f;
+      // Each pair of control points delineates a "half patch" (the middle
+      // control point corresponds to surface coords generated from t=0.5).
+      // Since distance measurements are done within each patch, and we want to
+      // measure the distance at half-patch increments, we need to alternate
+      // doing the segment measurements from 0 to 0.5 and from 0.5 to 1.0 (for
+      // values of t). We start with a t target of 0.5 or 1.0 depending on the
+      // even/odd nature of the alignment slice.
+      float slicewiseFraction = (float)((alignSlice & 0x1) + 1) / 2.0f;
+      // Iterate over the control points greater than the alignment point.
+      for (int halfPatch = alignSlice + 1; halfPatch < (int)SliceSize(sliceType); halfPatch++)
+      {
+         // Find the slice-of-other-kind that defines the patch edge orthogonal
+         // to our slice.
+         context.edgeSlice[OtherSliceType(sliceType)] = 2 * ((halfPatch - 1) / 2);
+         // Estimate the slice length along the surface of the half patch.
+         float segmentLengthEstimate =
+            EstimateSegmentLength(slicewiseFraction - 0.5f, slicewiseFraction, context);
+         // Recursively refine that estimate until it is good enough, then add it
+         // to our cumulative distance.
+         cumulativeDistance +=
+            RefineSegmentLength(slicewiseFraction - 0.5f, slicewiseFraction, context,
+                                segmentLengthEstimate, UNITS_ERROR_BOUND);
+         // Store that cumulative distance in the output array.
+         MatrixElement(values, sliceType, slice, halfPatch) = cumulativeDistance;
+         // Flip to measure the other half patch.
+         slicewiseFraction = 1.5f - slicewiseFraction;
+      }
+
+      // Now we're going to calculate distances for control points "less
+      // than" the one marked by the alignment slice.
+
+      // Start with zero cumulative distance.
+      cumulativeDistance = 0.0f;
+      // We need to alternate doing the segment measurements from 1.0 to 0.5 and
+      // from 0.5 to 0 (for values of t). We start with a t target of 0.5 or 0
+      // depending on the even/odd nature of the alignment slice.
+      slicewiseFraction = (float)((alignSlice - 1) & 0x1) / 2.0f;
+      // Iterate over the control points less than the alignment point.
+      for (int halfPatch = alignSlice - 1; halfPatch >= 0; halfPatch--)
+      {
+         // Find the slice-of-other-kind that defines the patch edge orthogonal
+         // to our slice.
+         context.edgeSlice[OtherSliceType(sliceType)] = 2 * ((halfPatch - 1) / 2);
+         // Estimate the slice length along the surface of the half patch.
+         float segmentLengthEstimate =
+            EstimateSegmentLength(slicewiseFraction + 0.5f, slicewiseFraction, context);
+         // Recursively refine that estimate until it is good enough, then add it
+         // to our cumulative distance. (Which is negative on this side!)
+         cumulativeDistance -=
+            RefineSegmentLength(slicewiseFraction + 0.5f, slicewiseFraction, context,
+                                segmentLengthEstimate, UNITS_ERROR_BOUND);
+         // Store that cumulative distance in the output array.
+         MatrixElement(values, sliceType, slice, halfPatch) = cumulativeDistance;
+         // Flip to measure the other half patch.
+         slicewiseFraction = 0.5f - slicewiseFraction;
+      }
+   }
+
+   // Now we may adjust the distance values based on scaling/tiling input.
+   // If there's a reference slice, we're going to need to know the total slice
+   // length, so save that away.
+   float refTotalLength;
+   if (refSlice != NULL)
+   {
+      refTotalLength =
+         MatrixElement(values, sliceType, refSlice->index, SliceSize(sliceType) - 1) -
+         MatrixElement(values, sliceType, refSlice->index, 0);
+   }
+   else
+   {
+      refTotalLength = 1.0f; // unused, but avoid uninitialized-var warning
+   }
+
+#if defined(_DEBUG)
+    ASSERT_MESSAGE(refTotalLength != 0.0f, "calculated length of reference slice is zero");
+    ASSERT_MESSAGE(rawScaleOrTiles != 0.0f, "internal scale or tiles value is zero");
+#endif
+
+   // Iterate over the slices we're processing and adjust the distance values
+   // (remember that this may just be the reference slice).
+   for (int slice = firstSlice; slice <= lastSlice; slice++)
+   {
+      // Figure out what we're going to divide the distances by.
+      float scaleFactor;
+      if (rawScale)
+      {
+         // In this case we've just been passed in the value to divide by.
+         scaleFactor = rawScaleOrTiles;
+         if (refSlice != NULL)
+         {
+            // However if there's a reference slice, adjust the divisor by the
+            // ratio of this slice's length to the reference slice's length.
+            // (Which is a NOP if this slice actually is the reference slice.)
+            // Example: if the ref slice is length 2, this slice is length 3,
+            // and the raw scale factor is 4... then all distances on the ref
+            // slice would be divided by 4 * 2 / 2 = 4, and distances on this
+            // slice would be divided by 4 * 3 / 2 = 6.
+            scaleFactor *=
+               ((MatrixElement(values, sliceType, slice, SliceSize(sliceType) - 1) -
+                 MatrixElement(values, sliceType, slice, 0)) /
+                refTotalLength);
+         }
+      }
+      else
+      {
+         // In this case we've been passed in a desired tiling value. We're
+         // going to want to eventually divide the distances by length / tiles.
+         // Example: if this slice is length 6 and the desired tiling is 3, we
+         // will divide the distances on this slice by 6 / 3 = 2.
+         scaleFactor =
+            (MatrixElement(values, sliceType, slice, SliceSize(sliceType) - 1) -
+             MatrixElement(values, sliceType, slice, 0)) /
+            rawScaleOrTiles;
+      }
+      // Adjust the distances for this slice by the divisor we calculated.
+      for (unsigned halfPatch = 0; halfPatch < SliceSize(sliceType); halfPatch++)
+      {
+         MatrixElement(values, sliceType, slice, halfPatch) /= scaleFactor;
+      }
+   }
+
+   // One final step if we have a reference slice and totalLengthOnly is false.
+   // In that case, up until this point we have only been processing the
+   // reference slice. Now we have to copy the reference slice's values to all
+   // other slices.
+   // (These loops also copy the reference slice to itself, which is fine.)
+   if (refSlice != NULL && !refSlice->totalLengthOnly)
+   {
+      for (unsigned slice = 0; slice < _numSlices[sliceType]; slice++)
+      {
+         for (unsigned halfPatch = 0; halfPatch < SliceSize(sliceType); halfPatch++)
+         {
+            MatrixElement(values, sliceType, slice, halfPatch) =
+               MatrixElement(values, sliceType, refSlice->index, halfPatch);
+         }
+      }
+   }
+}
+
+/**
+ * Generate coordinates for a specified texture axis based on a linear
+ * combination of factors. This method does the final work for the
+ * GeneralFunction public method.
+ *
+ * @param factors       Factors to determine the texture coords.
+ * @param axis          The texture axis to process.
+ * @param alignRow      Zero-point row.
+ * @param alignCol      Zero-point column.
+ * @param surfaceValues true if calculations are for S/T values on the mesh
+ *                      surface; false if calculations are for S/T values at
+ *                      the control points.
+ * @param rowDistances  Surface distance-along-row values (measured from
+ *                      alignment column) for spots corresponding to each
+ *                      control point.
+ * @param colDistances  Surface distance-along-column values (measured from
+ *                      alignment row) for spots corresponding to each
+ *                      control point.
+ */
+void
+MeshEntity::GeneralFunctionInt(const GeneralFunctionFactors& factors,
+                               TextureAxis axis,
+                               int alignRow,
+                               int alignCol,
+                               bool surfaceValues,
+                               const Matrix<float>& rowDistances,
+                               const Matrix<float>& colDistances)
+{
+   // Grab the "original value" info if the equation uses it.
+   AllocatedMatrix<float> oldValues(_meshData.x(), _meshData.y());
+   AllocatedMatrix<float> newValues(_meshData.x(), _meshData.y());
+   if (factors.oldValue != 0.0f)
+   {
+      if (surfaceValues)
+      {
+         // Will be manipulating surface values.
+         GenSurfaceFromControlTex(axis, oldValues);
+      }
+      else
+      {
+         // Will be manipulating control point values.
+         CopyValuesFromControlTex(axis, oldValues);
+      }
+   }
+
+   // Iterate over all values and apply the equation.
+   for (int rowIndex = 0; rowIndex < (int)_numSlices[ROW_SLICE_TYPE]; rowIndex++)
+   {
+      for (int colIndex = 0; colIndex < (int)_numSlices[COL_SLICE_TYPE]; colIndex++)
+      {
+         newValues(rowIndex, colIndex) =
+            factors.oldValue * oldValues(rowIndex, colIndex) +
+            factors.rowDistance * rowDistances(rowIndex, colIndex) +
+            factors.colDistance * colDistances(rowIndex, colIndex) +
+            factors.rowNumber * (rowIndex - alignRow) +
+            factors.colNumber * (colIndex - alignCol) +
+            factors.constant;
+      }
+   }
+
+   // Store the generated values.
+   if (surfaceValues)
+   {
+      // If we're manipulating surface values, figure the necessary control
+      // point values to make those.
+      GenControlTexFromSurface(axis, newValues);
+   }
+   else
+   {
+      // If we're manipulating control point values, store the new values.
+      CopyControlTexFromValues(axis, newValues);
+   }
+}
\ No newline at end of file
diff --git a/contrib/meshtex/MeshEntity.h b/contrib/meshtex/MeshEntity.h
new file mode 100644 (file)
index 0000000..2b74d8d
--- /dev/null
@@ -0,0 +1,467 @@
+/**
+ * @file MeshEntity.h
+ * Declares the MeshEntity class.
+ * @ingroup meshtex-core
+ */
+
+/*
+ * Copyright 2012 Joel Baxter
+ *
+ * This file is part of MeshTex.
+ *
+ * MeshTex is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MeshTex is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MeshTex.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#if !defined(INCLUDED_MESHENTITY_H)
+#define INCLUDED_MESHENTITY_H
+
+#include "AllocatedMatrix.h"
+
+#include "scenelib.h"
+#include "ipatch.h"
+#include "generic/callback.h"
+
+/**
+ * Wrapper for a biquadratic Bezier patch mesh entity from Radiant.
+ * Instantiate this for a given patch mesh, then use the methods to
+ * interrogate or modify the mesh. It is intended that this object be
+ * instantiated, used, and then discarded before resuming other Radiant
+ * operations, as the implementation assumes that several basic mesh
+ * characteristics will remain constant for the life of this object.
+ *
+ * @ingroup meshtex-core
+ */
+class MeshEntity
+{
+public: // public types
+
+   /**
+    * Values that represent the texture axes an operation should manipulate.
+    */
+   enum TextureAxisSelection
+   {
+      S_TEX_AXIS_ONLY,  ///< manipulate the S values
+      T_TEX_AXIS_ONLY,  ///< manipulate the T values
+      ALL_TEX_AXES      ///< manipulate both S and T values
+   };
+
+   /**
+    * Values that represent the kinds of patch mesh slices. Note that the
+    * assigned integer values are significant; do not change.
+    */
+   enum SliceType
+   {
+      ROW_SLICE_TYPE = 0,  ///< row 
+      COL_SLICE_TYPE = 1,  ///< column 
+      NUM_SLICE_TYPES = 2  ///< number of kinds of slice 
+   };
+
+   /**
+    * Type for info/warning/error callbacks. The callback takes a const
+    * char* argument (the message string); it has no return value.
+    */
+   typedef Callback1<const char *, void> MessageCallback;
+
+   /**
+    * Type for texture scale info callbacks. The callback takes two float
+    * arguments (scale and tiles); it has no return value.
+    */
+   typedef Callback2<float, float, void> TexInfoCallback;
+
+   /**
+    * Type for defining how to manipulate control point or surface values
+    * according to some linear combination of various values.
+    */
+   typedef struct {
+      float oldValue;     ///< coefficient for original value
+      float rowDistance;  ///< coefficient for surface distance along row
+      float colDistance;  ///< coefficient for surface distance along col
+      float rowNumber;    ///< coefficient for row number
+      float colNumber;    ///< coefficient for column number
+      float constant;     ///< constant
+   } GeneralFunctionFactors;
+
+   /**
+    * Type for choosing a particular slice of a known kind (row or column).
+    */
+   typedef struct {
+      bool maxSlice;  ///< if true, choose slice with highest index
+      int index;      ///< if maxSlice is false, choose slice with this index
+   } SliceDesignation;
+
+   /**
+    * Type for choosing a reference slice of a known kind (row or column) and
+    * indicating how to use it for reference. Reference can be made to the total
+    * slice surface length alone, or to each individual control point.
+    */
+   typedef struct {
+      SliceDesignation designation;  ///< the slice
+      bool totalLengthOnly;          ///< if true, reference total length only
+   } RefSliceDescriptor;
+
+   /**
+    * An instance of this class can be used as a MeshEntity::TexInfoCallback, in
+    * situations where the callback is a method to be invoked on a target
+    * object. When invoking this constructor, the target object is the
+    * constructor argument, and the target object class and method are template
+    * parameters. The target object's method must have an appropriate signature
+    * for TexInfoCallback: two float arguments, void return.
+    */
+   template<typename ObjectClass, void (ObjectClass::*member)(float, float)>
+   class TexInfoCallbackMethod :
+      public BindFirstOpaque2<Member2<ObjectClass, float, float, void, member> >
+   {
+   public:
+      /**
+       * Constructor.
+       *
+       * @param object The object on which to invoke the callback method.
+       */
+      TexInfoCallbackMethod(ObjectClass& object) :
+         BindFirstOpaque2<Member2<ObjectClass, float, float, void, member> >(object) {}
+   };
+
+public: // public methods
+
+   /// @name Lifecycle
+   //@{
+   MeshEntity(scene::Node& mesh,
+              const MessageCallback& infoReportCallback,
+              const MessageCallback& warningReportCallback,
+              const MessageCallback& errorReportCallback);
+   ~MeshEntity();
+   //@}
+   /// @name Interrogation
+   //@{
+   bool IsValid() const;
+   void GetInfo(const int *refRow,
+                const int *refCol,
+                const TexInfoCallback *rowTexInfoCallback,
+                const TexInfoCallback *colTexInfoCallback);
+   //@}
+   /// @name Simple modification
+   //@{
+   void MinAlign(TextureAxisSelection axes);
+   void MaxAlign(TextureAxisSelection axes);
+   void MinMaxAlignAutoScale(TextureAxisSelection axes);
+   void MinMaxAlignStretch(TextureAxisSelection axes);
+   void MinMaxAlignShrink(TextureAxisSelection axes);
+   //@}
+   /// @name Complex modification
+   //@{
+   void SetScale(SliceType sliceType,
+                 const SliceDesignation *alignSlice,
+                 const RefSliceDescriptor *refSlice,
+                 bool naturalScale,
+                 float naturalScaleOrTiles);
+   void GeneralFunction(const GeneralFunctionFactors *sFactors,
+                        const GeneralFunctionFactors *tFactors,
+                        const SliceDesignation *alignRow,
+                        const SliceDesignation *alignCol,
+                        const RefSliceDescriptor *refRow,
+                        const RefSliceDescriptor *refCol,
+                        bool surfaceValues);
+   //@}
+
+private: // private methods
+
+   /// @name Unimplemented to prevent copy/assignment
+   //@{
+   MeshEntity(const MeshEntity&);
+   const MeshEntity& operator=(const MeshEntity&);
+   //@}
+
+private: // private types
+
+   /**
+    * Values that represent the kinds of texture axis.
+    */
+   enum TextureAxis
+   {
+      S_TEX_AXIS = 0,   ///< S texture axis 
+      T_TEX_AXIS = 1,   ///< T texture axis
+      NUM_TEX_AXES = 2  ///< number of kinds of texture axis
+   };
+
+   /**
+    * Values that represent the kinds of position (spatial) axis.
+    */
+   enum PositionAxis
+   {
+      X_POS_AXIS = 0,   ///< X position axis 
+      Y_POS_AXIS = 1,   ///< Y position axis
+      Z_POS_AXIS = 2,   ///< Z position axis
+      NUM_POS_AXES = 3  ///< number of kinds of position axis
+   };
+
+   /**
+    * Values that represent ways of scaling a texture to make it aligned.
+    */
+   enum ScaleOperation
+   {
+      STRETCH_SCALE_OP,  ///< scale by stretching
+      SHRINK_SCALE_OP    ///< scale by shrinking
+   };
+
+   /**
+    * Type for orienting a slice within a particular patch.
+    */
+   typedef struct {
+      SliceType sliceType; ///< slice type (row or column)
+      float position;      ///< fractional dist from patch edge (0, 0.5, or 1)
+      int edgeSlice[NUM_SLICE_TYPES];  ///< indices of slices at patch edges
+   } SlicePatchContext;
+
+   /**
+    * Type for describing the application of a texture along a given slice,
+    * on a specified texture axis.
+    */
+   typedef struct {
+      float scale;  ///< texture scale along axis
+      float tiles;  ///< # of times the texture tiles along axis
+      float min;    ///< minimum value for that texture axis
+      float max;    ///< maximum value for that texture axis
+   } SliceTexInfo;
+
+   /**
+    * Type for internal representation of a reference slice of a given kind
+    * (row or column), specifying the slice and indicating how to use it for
+    * reference. Any external specification of "max slice" has been replaced
+    * with an explicit slice number. Reference can be made to the total slice
+    * length alone, or to the distance to each individual control point.
+    */
+   typedef struct {
+      unsigned index;        ///< choose slice with this number
+      bool totalLengthOnly;  ///< if true, reference total length only
+   } RefSliceDescriptorInt;
+
+   /**
+    * Function signature for a private method that applies a preset
+    * transformation on a given texture axis.
+    */
+   typedef bool(MeshEntity::*InternalImpl)(TextureAxis axis);
+
+private: // private template methods
+
+   /**
+    * Utility template function for accessing a matrix element from code that
+    * operates on either kind of slice.
+    *
+    * @param matrix    The matrix holding the mesh control points.
+    * @param sliceType Slice kind (row or column).
+    * @param slice     Slice number, among slices of that type in mesh.
+    * @param index     Element index along the slice.
+    *
+    * @return The matrix element; can be used as lvalue or rvalue.
+    */
+   template<typename Element>
+   inline static Element& MatrixElement(Matrix<Element>& matrix,
+                                        SliceType sliceType,
+                                        int slice,
+                                        int index) {
+      return (sliceType == ROW_SLICE_TYPE ? matrix(slice, index) : 
+                                            matrix(index, slice));
+   }
+
+private: // private methods
+
+   /// @name Internal state refresh
+   //@{
+   void UpdatePosMinMax(PositionAxis axis);
+   void UpdateTexMinMax(TextureAxis axis);
+   //@}
+   /// @name Radiant state management
+   //@{
+   void CreateUndoPoint();
+   void CommitChanges();
+   //@}
+   /// @name Argument resolution
+   //@{
+   int InternalSliceDesignation(const SliceDesignation *sliceDesignation,
+                                SliceType sliceType);
+   RefSliceDescriptorInt *InternalRefSliceDescriptor(const RefSliceDescriptor *refSlice,
+                                                     SliceType sliceType,
+                                                     RefSliceDescriptorInt& refSliceInt);
+   //@}
+   /// @name Subroutines for interrogation
+   //@{
+   float GetSliceTexScale(SliceType sliceType,
+                          int slice,
+                          TextureAxis axis,
+                          float tiles);
+   bool GetSliceTexInfo(SliceType sliceType,
+                        int slice,
+                        TextureAxis axis,
+                        SliceTexInfo& info);
+   void ReportSliceTexInfo(SliceType sliceType,
+                           int slice,
+                           TextureAxis axis,
+                           char *messageBuffer,
+                           unsigned messageBufferSize,
+                           const TexInfoCallback *texInfoCallback);
+   //@}
+   /// @name Subroutines for simple modification
+   //@{
+   void ProcessForAxes(InternalImpl internalImpl,
+                       TextureAxisSelection axes);
+   void Shift(TextureAxis axis,
+              float shift);
+   void Scale(TextureAxis axis,
+              float scale);
+   bool MinAlignInt(TextureAxis axis);
+   bool MaxAlignInt(TextureAxis axis);
+   bool MinMaxAlignAutoScaleInt(TextureAxis axis);
+   bool MinMaxAlignScale(TextureAxis axis,
+                         ScaleOperation op);
+   bool MinMaxAlignStretchInt(TextureAxis axis);
+   bool MinMaxAlignShrinkInt(TextureAxis axis);
+   //@}
+   /// @name Surface measurement
+   //@{
+   float SliceParametricSpeedComponent(PositionAxis axis,
+                                       float t,
+                                       const SlicePatchContext& context);
+   float SliceParametricSpeed(float t,
+                              const SlicePatchContext& context);
+   float EstimateSegmentLength(float startPosition,
+                               float endPosition,
+                               const SlicePatchContext& context);
+   float RefineSegmentLength(float startPosition,
+                             float endPosition,
+                             const SlicePatchContext &context,
+                             float segmentLengthEstimate,
+                             float maxError);
+   //@}
+   /// @name Subroutines for complex modification
+   //@{
+   void GenControlTexFromSurface(TextureAxis axis,
+                                 const Matrix<float>& surfaceValues);
+   void CopyControlTexFromValues(TextureAxis axis,
+                                 const Matrix<float>& values);
+   void GenSurfaceFromControlTex(TextureAxis axis,
+                                 Matrix<float>& surfaceValues);
+   void CopyValuesFromControlTex(TextureAxis axis,
+                                 Matrix<float>& values);
+   void GenScaledDistanceValues(SliceType sliceType,
+                                int alignSlice,
+                                const RefSliceDescriptorInt *refSlice,
+                                bool rawScale,
+                                float rawScaleOrTiles,
+                                Matrix<float>& values);
+   void GeneralFunctionInt(const GeneralFunctionFactors& factors,
+                           TextureAxis axis,
+                           int alignRow,
+                           int alignCol,
+                           bool surfaceValues,
+                           const Matrix<float>& rowDistances,
+                           const Matrix<float>& colDistances);
+   //@}
+
+private: // private static member vars
+
+   static TextureAxis _naturalAxis[NUM_SLICE_TYPES];
+   static bool _radiantScaleInverted[NUM_SLICE_TYPES];
+   static bool _radiantTilesInverted[NUM_SLICE_TYPES];
+   static const char *_infoSliceFormatString[NUM_SLICE_TYPES];
+   static const char *_infoSliceInfscaleFormatString[NUM_SLICE_TYPES];
+   static const char *_warningSliceInfscaleFormatString[NUM_SLICE_TYPES];
+   static const char *_errorBadSliceString[NUM_SLICE_TYPES];
+   static const char *_errorSliceZeroscaleString[NUM_SLICE_TYPES];
+   static const char *_errorSliceZerotilesString[NUM_SLICE_TYPES];
+
+private: // private member vars
+
+   /**
+    * Handle for the Node object in Radiant that is the patch mesh entity.
+    */
+   scene::Node& _mesh;
+
+   /**
+    * Flag to indicate whether this object was properly generated from the
+    * supplied entity.
+    */
+   bool _valid;
+
+   /**
+    * The control points of the mesh. Modifying the data in this matrix will
+    * modify the mesh entity directly; it is NOT a copy of the entity's data.
+    */
+   PatchControlMatrix _meshData;
+
+   /**
+    * Callback function used to report information about the mesh.
+    */
+   const MessageCallback _infoReportCallback;
+
+   /**
+    * Callback function used to deliver warning messages.
+    */
+   const MessageCallback _warningReportCallback;
+
+   /**
+    * Callback function used to deliver error messages when operations on the
+    * mesh fail.
+    */
+   const MessageCallback _errorReportCallback;
+
+   /**
+    * The number of grid units that would constitute a "natural" scale along
+    * each texture axis, using the mesh's current texture. Radiant's natural
+    * scale is 1/2 as many grid units as there are texture pixels.
+    */
+   float _naturalTexUnits[NUM_TEX_AXES];
+
+   /**
+    * The number of mesh slices of each kind (row or column).
+    */
+   unsigned _numSlices[NUM_SLICE_TYPES];
+
+   /**
+    * Whether the values for a texture axis have been modified since the last
+    * time their min/max/aligned state was calculated.
+    */
+   bool _texMinMaxDirty[NUM_TEX_AXES];
+
+   /**
+    * The minimum values, across the entire mesh, for each texture axis.
+    */
+   float _texMin[NUM_TEX_AXES];
+
+   /**
+    * The maximum values, across the entire mesh, for each texture axis.
+    */
+   float _texMax[NUM_TEX_AXES];
+
+   /**
+    * Whether the minimum value for a texture axis is on a texture boundary.
+    */
+   bool _texMinAligned[NUM_TEX_AXES];
+
+   /**
+    * Whether the maximum value for a texture axis is on a texture boundary.
+    */
+   bool _texMaxAligned[NUM_TEX_AXES];
+
+   /**
+    * The minimum values, across the entire mesh, for each position axis.
+    */
+   float _posMin[NUM_POS_AXES];
+
+   /**
+    * The maximum values, across the entire mesh, for each position axis.
+    */
+   float _posMax[NUM_POS_AXES];
+};
+
+#endif // #if !defined(INCLUDED_MESHENTITY_H)
\ No newline at end of file
diff --git a/contrib/meshtex/MeshEntityMessages.h b/contrib/meshtex/MeshEntityMessages.h
new file mode 100644 (file)
index 0000000..7300c75
--- /dev/null
@@ -0,0 +1,55 @@
+/**
+ * @file MeshEntityMessages.h
+ * String constants for messages shown in dialogs.
+ * @ingroup meshtex-core
+ */
+
+/*
+ * Copyright 2012 Joel Baxter
+ *
+ * This file is part of MeshTex.
+ *
+ * MeshTex is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MeshTex is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MeshTex.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#if !defined(INCLUDED_MESHENTITYMESSAGES_H)
+#define INCLUDED_MESHENTITYMESSAGES_H
+
+/// @name Informational messages
+//@{
+#define INFO_ROW_FORMAT "On row %d:\n  S natural scale: %f\n  S tiles: %f\n  S min: %f\n  S max: %f\n\n"
+#define INFO_ROW_INFSCALE_FORMAT "On row %d:\n  S scale: (infinite)\n  S tiles: %f\n  S min: %f\n  S max: %f\n\n"
+#define INFO_COL_FORMAT "On column %d:\n  T natural scale: %f\n  T tiles: %f\n  T min: %f\n  T max: %f\n\n"
+#define INFO_COL_INFSCALE_FORMAT "On column %d:\n  T scale: (infinite)\n  T tiles: %f\n  T min: %f\n  T max: %f\n\n"
+#define INFO_MESH_FORMAT "Over entire mesh:\n  Rows: %d\n  S min: %f\n  S max: %f\n  Columns: %d\n  T min: %f\n  T max: %f\n\nWorldspace extents: (%.2f/%.2f,%.2f/%.2f,%.2f/%.2f)"
+//@}
+
+/// @name Warning messages
+//@{
+#define WARNING_ROW_INFSCALE "The selected reference row has an infinite scale (S does not vary along the row). The row information cannot be automatically transferred to the Set S/T Scale dialog."
+#define WARNING_COL_INFSCALE "The selected reference column has an infinite scale (T does not vary along the column). The column information cannot be automatically transferred to the Set S/T Scale dialog."
+//@}
+
+/// @name Error messages
+//@{
+#define ERROR_BAD_MESH "Unable to read patch mesh."
+#define ERROR_BAD_ROW "Illegal row # specified."
+#define ERROR_BAD_COL "Illegal column # specified."
+#define ERROR_ROW_ZEROSCALE "A scale of zero cannot be applied; the S values of the row will not be changed."
+#define ERROR_COL_ZEROSCALE "A scale of zero cannot be applied; the T values of the column will not be changed."
+#define ERROR_ROW_ZEROTILES "A tile count of zero cannot be applied; the S values of the row will not be changed."
+#define ERROR_COL_ZEROTILES "A tile count of zero cannot be applied; the T values of the column will not be changed."
+//@}
+
+#endif // #if !defined(INCLUDED_MESHENTITYMESSAGES_H)
\ No newline at end of file
diff --git a/contrib/meshtex/MeshVisitor.cpp b/contrib/meshtex/MeshVisitor.cpp
new file mode 100644 (file)
index 0000000..5f2488f
--- /dev/null
@@ -0,0 +1,132 @@
+/**
+ * @file MeshVisitor.cpp
+ * Implements the MeshVisitor class.
+ * @ingroup meshtex-util
+ */
+
+/*
+ * Copyright 2012 Joel Baxter
+ *
+ * This file is part of MeshTex.
+ *
+ * MeshTex is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MeshTex is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MeshTex.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "MeshVisitor.h"
+#include "GenericPluginUI.h"
+#include "PluginUIMessages.h"
+
+
+/**
+ * Use GenericPluginUI::InfoReportDialog as MeshEntity info callback.
+ */
+const MeshEntity::MessageCallback MeshVisitor::_infoReportCallback(
+   PointerCaller1<const char,
+                  const char *,
+                  &GenericPluginUI::InfoReportDialog>(DIALOG_MESH_INFO_TITLE));
+
+/**
+ * Use GenericPluginUI::WarningReportDialog as MeshEntity warning callback.
+ */
+const MeshEntity::MessageCallback MeshVisitor::_warningReportCallback(
+   PointerCaller1<const char,
+                  const char *,
+                  &GenericPluginUI::WarningReportDialog>(DIALOG_WARNING_TITLE));
+
+/**
+ * Use GenericPluginUI::ErrorReportDialog as MeshEntity error callback.
+ */
+const MeshEntity::MessageCallback MeshVisitor::_errorReportCallback(
+   PointerCaller1<const char,
+                  const char *,
+                  &GenericPluginUI::ErrorReportDialog>(DIALOG_ERROR_TITLE));
+
+
+/**
+ * Default constructor.
+ */
+MeshVisitor::MeshVisitor() :
+   _visitedCount(0)
+{
+}
+
+/**
+ * Virtual destructor.
+ */
+MeshVisitor::~MeshVisitor()
+{
+}
+
+/**
+ * Reset the visited count to zero.
+ */
+void
+MeshVisitor::ResetVisitedCount()
+{
+   _visitedCount = 0;
+}
+
+/**
+ * Get the visited count. This is the number of times Execute has been
+ * invoked since visitor construction or the most recent reset of the count.
+ *
+ * @return The visited count.
+ */
+unsigned
+MeshVisitor::GetVisitedCount()
+{
+   return _visitedCount;
+}
+
+/**
+ * Visit a specified scene graph node.
+ *
+ * @param [in,out] instance The scene graph node.
+ */
+void
+MeshVisitor::visit(scene::Instance& instance) const
+{
+   if (Node_isPatch(instance.path().top()))
+   {
+      // If it's a patch mesh, try creating a MeshEntity.
+      MeshEntity meshEntity(instance.path().top(),
+                            _infoReportCallback,
+                            _warningReportCallback,
+                            _errorReportCallback);
+      if (meshEntity.IsValid())
+      {
+         // If we have a valid MeshEntity, invoke Execute.
+         if (Execute(meshEntity))
+         {
+            // Count the number of affected meshes.
+            _visitedCount++;
+         }
+      }
+   }
+}
+
+/**
+ * Execute function performed for visited meshes. This implementation does
+ * nothing; subclasses should override it.
+ *
+ * @param meshEntity The MeshEntity.
+ *
+ * @return true if the mesh was successfully visited; always the case in this
+ *         skeleton implementation.
+ */
+bool
+MeshVisitor::Execute(MeshEntity& meshEntity) const
+{
+   return true;
+}
diff --git a/contrib/meshtex/MeshVisitor.h b/contrib/meshtex/MeshVisitor.h
new file mode 100644 (file)
index 0000000..75438cf
--- /dev/null
@@ -0,0 +1,72 @@
+/**
+ * @file MeshVisitor.h
+ * Declares the MeshVisitor class.
+ * @ingroup meshtex-util
+ */
+
+/*
+ * Copyright 2012 Joel Baxter
+ *
+ * This file is part of MeshTex.
+ *
+ * MeshTex is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MeshTex is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MeshTex.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#if !defined(INCLUDED_MESHVISITOR_H)
+#define INCLUDED_MESHVISITOR_H
+
+#include "RefCounted.h"
+#include "MeshEntity.h"
+
+#include "iselection.h"
+
+/**
+ * Visitor that will invoke Execute with a MeshEntity argument if the visited
+ * node is a valid mesh. Subclasses should override Execute to perform
+ * operations on the MeshEntity.
+ *
+ * @ingroup meshtex-util
+ */
+class MeshVisitor : public SelectionSystem::Visitor, public RefCounted
+{
+public: // public methods
+
+   MeshVisitor();
+   virtual ~MeshVisitor();
+   void ResetVisitedCount();
+   unsigned GetVisitedCount();
+   void visit(scene::Instance& instance) const;
+
+protected: // protected methods
+
+   virtual bool Execute(MeshEntity& meshEntity) const;
+
+private: // private static member vars
+
+   /// @name Callbacks to use when constructing the MeshEntity
+   //@{
+   static const MeshEntity::MessageCallback _infoReportCallback;
+   static const MeshEntity::MessageCallback _warningReportCallback;
+   static const MeshEntity::MessageCallback _errorReportCallback;
+   //@}
+
+private: // private member vars
+
+   /**
+    * Track the number of Execute invocations.
+    */
+   mutable unsigned _visitedCount;
+};
+
+#endif // #if !defined(INCLUDED_MESHVISITOR_H)
\ No newline at end of file
diff --git a/contrib/meshtex/PluginModule.cpp b/contrib/meshtex/PluginModule.cpp
new file mode 100644 (file)
index 0000000..6a2032e
--- /dev/null
@@ -0,0 +1,159 @@
+/**
+ * @file PluginModule.cpp
+ * Implements the PluginModule class.
+ * @ingroup generic-plugin
+ */
+
+/*
+ * Copyright 2012 Joel Baxter
+ *
+ * This file is part of MeshTex.
+ *
+ * MeshTex is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MeshTex is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MeshTex.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "PluginModule.h"
+#include "GenericPluginUI.h"
+
+
+/**
+ * Plugin function table.
+ */
+_QERPluginTable PluginModule::_pluginAPI;
+
+/**
+ * Default constructor. Initialize the function table.
+ */
+PluginModule::PluginModule()
+{
+   _pluginAPI.m_pfnQERPlug_Init = &QERPluginInit;
+   _pluginAPI.m_pfnQERPlug_GetName = &QERPluginGetName;
+   _pluginAPI.m_pfnQERPlug_GetCommandList = &QERPluginGetCommandList;
+   _pluginAPI.m_pfnQERPlug_GetCommandTitleList = &QERPluginGetCommandTitleList;
+   _pluginAPI.m_pfnQERPlug_Dispatch = &QERPluginDispatch;
+}
+
+/**
+ * Destructor.
+ */
+PluginModule::~PluginModule()
+{
+}
+
+/**
+ * Fetch a pointer to the function table.
+ */
+_QERPluginTable *
+PluginModule::getTable()
+{
+   return &_pluginAPI;
+}
+
+/**
+ * Initialize plugin.
+ *
+ * @param hApp        Dummy arg; ignored.
+ * @param pMainWidget Main window widget.
+ *
+ * @return The plugin name.
+ */
+const char *
+PluginModule::QERPluginInit(void *hApp,
+                            void *pMainWidget)
+{
+   // Inform the UI of the main app window.
+   UIInstance().SetWindow((GtkWidget *)pMainWidget);
+   // Return the plugin name.
+   return PLUGIN_NAME;
+}
+
+/**
+ * Get the plugin's name.
+ *
+ * @return The plugin name.
+ */
+const char *
+PluginModule::QERPluginGetName()
+{
+   // Return the plugin name.
+   return PLUGIN_NAME;
+}
+
+/**
+ * Get the command list for the plugin menu, as a semicolon-separated string
+ * of tokens representing each command.
+ *
+ * @return The command list string.
+ */
+const char *
+PluginModule::QERPluginGetCommandList()
+{
+   // Bail out if the plugin menu doesn't exist.
+   if (UIInstance().MainMenu() == NULL)
+   {
+      return "";
+   }
+   // Get the command list from the menu.
+   return UIInstance().MainMenu()->GetCommandList().c_str();
+}
+
+/**
+ * Get the command label list for the plugin menu, as a semicolon-separated
+ * string of labels to appear in the menu.
+ *
+ * @return The command label list string.
+ */
+const char *
+PluginModule::QERPluginGetCommandTitleList()
+{
+   // Bail out if the plugin menu doesn't exist.
+   if (UIInstance().MainMenu() == NULL)
+   {
+      return "";
+   }
+   // Get the command label list from the menu.
+   return UIInstance().MainMenu()->GetCommandLabelList().c_str();
+}
+
+/**
+ * Invoke a plugin command.
+ *
+ * @param command      The command token.
+ * @param vMin         3-element float vector definining min corner of
+ *                     selection.
+ * @param vMax         3-element float vector definining max corner of
+ *                     selection.
+ * @param bSingleBrush Dummy arg; ignored.
+ */
+void
+PluginModule::QERPluginDispatch(const char *command,
+                                float *vMin,
+                                float *vMax,
+                                bool bSingleBrush)
+{
+   // Bail out if the plugin menu doesn't exist.
+   if (UIInstance().MainMenu() == NULL)
+   {
+      // XXX This shouldn't happen; might as well drop an ASSERT or error
+      // message in here. First make sure there's no odd Radiant-exiting
+      // corner case race that could trigger it though.
+      return;
+   }
+   // Send the command dispatch to the menu.
+   // XXX For my particular use case I don't need vMin or vMax, but for
+   // generality's sake those values should be passed along here, and then I
+   // can drop them when the flow gets to MeshTex-specific code... that will
+   // require changes for several types/signatures though.
+   UIInstance().MainMenu()->Dispatch(command);
+}
diff --git a/contrib/meshtex/PluginModule.h b/contrib/meshtex/PluginModule.h
new file mode 100644 (file)
index 0000000..fc8c802
--- /dev/null
@@ -0,0 +1,88 @@
+/**
+ * @file PluginModule.h
+ * Declares the PluginModule class.
+ * @ingroup generic-plugin
+ */
+
+/*
+ * Copyright 2012 Joel Baxter
+ *
+ * This file is part of MeshTex.
+ *
+ * MeshTex is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MeshTex is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MeshTex.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#if !defined(INCLUDED_PLUGINMODULE_H)
+#define INCLUDED_PLUGINMODULE_H
+
+#include "PluginProperties.h"
+
+#include "iplugin.h"
+#include "typesystem.h"
+#include "qerplugin.h"
+
+/**
+ * A singleton object that handles registering as a plugin with Radiant.
+ *
+ * @ingroup generic-plugin
+ */
+class PluginModule : public TypeSystemRef
+{
+public: // public types
+
+   /// @cond DOXYGEN_INTERNAL_RADIANT_ODDITIES_SKIP
+
+   /**
+    * Prepare for uses of the token Type in singletonmodule.h; indicate
+    * that _QERPluginTable should be substituted there.
+    */
+   typedef _QERPluginTable Type;
+
+   /**
+    * Radiant constant wrapper for the plugin's name string.
+    */
+   STRING_CONSTANT(Name, PLUGIN_NAME);
+
+   /// @endcond
+
+public: // public methods
+
+   /// @name Lifecycle
+   //@{
+   PluginModule();
+   ~PluginModule();
+   //@}
+   /// @name Plugin function table interface
+   //@{
+   _QERPluginTable *getTable();
+   //@}
+   /// @name Plugin function table members
+   //@{
+   static const char *QERPluginInit(void *hApp,
+                                    void *pMainWidget);
+   static const char *QERPluginGetName();
+   static const char *QERPluginGetCommandList();
+   static const char *QERPluginGetCommandTitleList();
+   static void QERPluginDispatch(const char *command,
+                                 float *vMin,
+                                 float *vMax,
+                                 bool bSingleBrush);
+   //@}
+
+private: // private member vars
+
+   static _QERPluginTable _pluginAPI;
+};
+
+#endif // #if !defined(INCLUDED_PLUGINMODULE_H)
diff --git a/contrib/meshtex/PluginProperties.h b/contrib/meshtex/PluginProperties.h
new file mode 100644 (file)
index 0000000..deae699
--- /dev/null
@@ -0,0 +1,45 @@
+/**
+ * @file PluginProperties.h
+ * Information about this plugin used in areas like plugin registration and
+ * generating the About dialog.
+ * @ingroup meshtex-plugin
+ */
+
+/*
+ * Copyright 2012 Joel Baxter
+ *
+ * This file is part of MeshTex.
+ *
+ * MeshTex is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MeshTex is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MeshTex.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#if !defined(INCLUDED_PLUGINPROPERTIES_H)
+#define INCLUDED_PLUGINPROPERTIES_H
+
+#include "UtilityMacros.h"
+//#include "CodeVersion.h"
+
+#define PLUGIN_NAME "MeshTex"
+#define PLUGIN_VERSION_MAJOR_NUMERIC 3
+#define PLUGIN_VERSION_MINOR_NUMERIC 0
+#define PLUGIN_VERSION STRINGIFY_MACRO(PLUGIN_VERSION_MAJOR_NUMERIC) "." STRINGIFY_MACRO(PLUGIN_VERSION_MINOR_NUMERIC) " beta" \
+            ", commit "
+#define PLUGIN_AUTHOR "Joel Baxter"
+#define PLUGIN_AUTHOR_EMAIL "jl@neogeographica.com"
+#define PLUGIN_COPYRIGHT_DATE "2012"
+#define PLUGIN_DESCRIPTION "Align and scale textures on patch meshes"
+#define PLUGIN_FILE_BASENAME "meshtex"
+#define PLUGIN_FILE_DESCRIPTION "patch mesh texturing plugin for GtkRadiant 1.5"
+
+#endif // #if !defined(INCLUDED_PLUGINPROPERTIES_H)
diff --git a/contrib/meshtex/PluginRegistration.cpp b/contrib/meshtex/PluginRegistration.cpp
new file mode 100644 (file)
index 0000000..218f358
--- /dev/null
@@ -0,0 +1,90 @@
+/**
+ * @file PluginRegistration.cpp
+ * Declares and implements the MeshTexPluginDependencies class, and implements
+ * the plugin library's exported function Radiant_RegisterModules.
+ * @ingroup meshtex-plugin
+ */
+
+/*
+ * Copyright 2012 Joel Baxter
+ *
+ * This file is part of MeshTex.
+ *
+ * MeshTex is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MeshTex is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MeshTex.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "PluginModule.h"
+
+#include "iundo.h"
+#include "iscenegraph.h"
+#include "iselection.h"
+#include "ishaders.h"
+#include "ipatch.h"
+#include "modulesystem/singletonmodule.h"
+
+
+/**
+ * Definition (in the declared superclasses) of the Radiant systems that this
+ * plugin depends on. GlobalRadiantModule, GlobalUndoModule,
+ * GlobalSceneGraphModule, GlobalSelectionModule, GlobalShadersModule, and of
+ * course GlobalPatchModule.
+ *
+ * @ingroup meshtex-plugin.
+ */
+class MeshTexPluginDependencies :
+   public GlobalRadiantModuleRef,
+   public GlobalUndoModuleRef,
+   public GlobalSceneGraphModuleRef,
+   public GlobalSelectionModuleRef,
+   public GlobalShadersModuleRef,
+   public GlobalPatchModuleRef
+{
+public:
+   /**
+    * Default constructor. This function's only responsibility is to pass
+    * arguments to superclass constructors.
+    */
+   MeshTexPluginDependencies() :
+      GlobalShadersModuleRef(GlobalRadiant().getRequiredGameDescriptionKeyValue("shaders")),
+      GlobalPatchModuleRef(GlobalRadiant().getRequiredGameDescriptionKeyValue("patchtypes"))
+   {
+   }
+};
+
+
+/**
+ * Register as a plugin with Radiant.
+ *
+ * @param server Radiant's module (library) manager.
+ *
+ * @relatesalso MeshTexPluginDependencies
+ */
+
+ typedef SingletonModule<PluginModule, MeshTexPluginDependencies> SingletonMeshTexPluginModule;
+
+SingletonMeshTexPluginModule g_MeshTexPluginModule;
+
+extern "C" void RADIANT_DLLEXPORT
+Radiant_RegisterModules(ModuleServer& server)
+{
+   // Set ourselves up as a plugin with the necessary dependences.
+   //static SingletonModule<PluginModule, MeshTexPluginDependencies> singleton;
+   // Alert Radiant that there's at least one module to be managed, and
+   // initialize some necessary stuff.
+   // XXX As far as I can tell it's not necessary for EVERY library to do this
+   // but it doesn't hurt, and this way we ensure it gets done.
+   initialiseModule(server);
+   // Register this library. Now we're active as a plugin.
+   g_MeshTexPluginModule.selfRegister();
+}
diff --git a/contrib/meshtex/PluginUI.cpp b/contrib/meshtex/PluginUI.cpp
new file mode 100644 (file)
index 0000000..b0f6ad8
--- /dev/null
@@ -0,0 +1,94 @@
+/**
+ * @file PluginUI.cpp
+ * Implements the PluginUI class.
+ * @ingroup meshtex-ui
+ */
+
+/*
+ * Copyright 2012 Joel Baxter
+ *
+ * This file is part of MeshTex.
+ *
+ * MeshTex is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MeshTex is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MeshTex.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "PluginUI.h"
+#include "SetScaleDialog.h"
+#include "GetInfoDialog.h"
+#include "GeneralFunctionDialog.h"
+#include "MainMenu.h"
+
+
+/**
+ * Default constructor. Instantiate and register the UI elements (main menu
+ * and dialogs)
+ */
+PluginUI::PluginUI()
+{
+   // Instantiate and register the Set S/T Scale dialog. We need a non-generic
+   // handle on this one too, because it will be used as input to the Get Info
+   // dialog constructor below.
+   SmartPointer<SetScaleDialog> setScaleDialog(
+      new SetScaleDialog("SetScale"));
+   SmartPointer<GenericDialog> setScaleDialogGeneric(setScaleDialog);
+   RegisterDialog(setScaleDialogGeneric);
+   // Instantiate and register the Get Info dialog. Constructor needs a handle
+   // on the Set S/T Scale dialog (since it may need to send texture info to
+   // it).
+   SmartPointer<GenericDialog> getInfoDialogGeneric(
+      new GetInfoDialog("GetInfo", setScaleDialog));
+   RegisterDialog(getInfoDialogGeneric);
+   // Instantiate and register the General Function dialog.
+   SmartPointer<GenericDialog> genFuncDialogGeneric(
+      new GeneralFunctionDialog("GeneralFunction"));
+   RegisterDialog(genFuncDialogGeneric);
+   // Instantiate and register the main menu. Constructor needs generic
+   // handles on all dialogs (since it may need to raise them).
+   SmartPointer<GenericMainMenu> mainMenuGeneric(
+      new ::MainMenu(setScaleDialogGeneric,
+                     getInfoDialogGeneric,
+                     genFuncDialogGeneric));
+   RegisterMainMenu(mainMenuGeneric);
+}
+
+/**
+ * Destructor.
+ */
+PluginUI::~PluginUI()
+{
+}
+
+/**
+ * Get the singleton instance of the UI manager. Note that callers should
+ * almost certainly invoke the UIInstance global function instead of using
+ * this method.
+ *
+ * @return Handle to the UI manager instance.
+ */
+PluginUI&
+PluginUI::Instance()
+{
+   static PluginUI singleton;
+   return singleton;
+}
+
+/**
+ * Get the singleton instance of the UI manager.
+ *
+ * @return Reference to a singleton that implements GenericPluginUI.
+ */
+GenericPluginUI& UIInstance()
+{
+   return PluginUI::Instance();
+}
diff --git a/contrib/meshtex/PluginUI.h b/contrib/meshtex/PluginUI.h
new file mode 100644 (file)
index 0000000..6d9e08f
--- /dev/null
@@ -0,0 +1,52 @@
+/**
+ * @file PluginUI.h
+ * Declares the PluginUI class.
+ * @ingroup meshtex-ui
+ */
+
+/*
+ * Copyright 2012 Joel Baxter
+ *
+ * This file is part of MeshTex.
+ *
+ * MeshTex is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MeshTex is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MeshTex.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#if !defined(INCLUDED_PLUGINUI_H)
+#define INCLUDED_PLUGINUI_H
+
+#include "GenericPluginUI.h"
+
+/**
+ * Subclass of GenericPluginUI that instantiates and registers the UI
+ * elements (main menu and dialogs).
+ *
+ * @ingroup meshtex-ui
+ */
+class PluginUI : public GenericPluginUI
+{
+private: // private methods
+
+   /// @name Private to prevent external instantiation
+   //@{
+   PluginUI();
+   ~PluginUI();
+   //@}
+
+public: // public methods
+
+   static PluginUI& Instance();
+};
+
+#endif // #if !defined(INCLUDED_PLUGINUI_H)
\ No newline at end of file
diff --git a/contrib/meshtex/PluginUIMessages.h b/contrib/meshtex/PluginUIMessages.h
new file mode 100644 (file)
index 0000000..7d8066d
--- /dev/null
@@ -0,0 +1,92 @@
+/**
+ * @file PluginUIMessages.h
+ * String constants for messages shown in dialogs.
+ * @ingroup meshtex-ui
+ */
+
+/*
+ * Copyright 2012 Joel Baxter
+ *
+ * This file is part of MeshTex.
+ *
+ * MeshTex is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MeshTex is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MeshTex.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#if !defined(INCLUDED_PLUGINUIMESSAGES_H)
+#define INCLUDED_PLUGINUIMESSAGES_H
+
+#include "GenericPluginUIMessages.h"
+#include "PluginProperties.h"
+
+/// @name Window titles
+//@{
+#define DIALOG_GET_INFO_TITLE "Get Info"
+#define DIALOG_MESH_INFO_TITLE "Mesh Info"
+#define DIALOG_SET_SCALE_TITLE "Set S/T Scale"
+#define DIALOG_GEN_FUNC_TITLE "General Function"
+#define DIALOG_ABOUT_TITLE "About"
+#define DIALOG_HELP_TITLE "Help"
+//@}
+
+/// @name Popups
+//@{
+#define DIALOG_MULTIMESHES_ERROR "Must select only one patch mesh for this function."
+#define DIALOG_NOMESHES_MSG "No valid patch meshes selected."
+#define DIALOG_ABOUT_MSG PLUGIN_NAME " " PLUGIN_VERSION "\n\n" PLUGIN_DESCRIPTION "\n\n" PLUGIN_AUTHOR " (" PLUGIN_AUTHOR_EMAIL ")"
+#define DIALOG_HELP_MSG "The Set S/T Scale, Get Info, and General Function dialogs will affect patch meshes that are selected when OK or Apply is clicked. For the other menu options, select the mesh(es) before selecting the option."
+//@}
+
+/// @name Get Info
+//@{
+#define DIALOG_GET_INFO_S_ROW_HEADER " S ref row:"
+#define DIALOG_GET_INFO_T_COL_HEADER " T ref col:"
+#define DIALOG_GET_INFO_XFER_OPT_LABEL "Transfer reference scale to Set S/T Scale"
+//@}
+
+/// @name Set S/T Scale
+//@{
+#define DIALOG_SET_SCALE_S_ACTIVE_OPT_LABEL "Set S"
+#define DIALOG_SET_SCALE_T_ACTIVE_OPT_LABEL "Set T"
+#define DIALOG_SET_SCALE_METHOD_FRAME_TITLE "Scaling"
+#define DIALOG_SET_SCALE_TILES_OPT_LABEL "# Tiles"
+#define DIALOG_SET_SCALE_NATURAL_OPT_LABEL "Natural *"
+#define DIALOG_SET_SCALE_MAX_OPT_LABEL "Max"
+#define DIALOG_SET_SCALE_S_ALIGN_FRAME_TITLE "\"Zero\" col"
+#define DIALOG_SET_SCALE_T_ALIGN_FRAME_TITLE "\"Zero\" row"
+#define DIALOG_SET_SCALE_S_REF_ROW_OPT_LABEL "Use reference row"
+#define DIALOG_SET_SCALE_T_REF_COL_OPT_LABEL "Use reference col"
+#define DIALOG_SET_SCALE_REF_TOTAL_OPT_LABEL "Total length only"
+//@}
+
+/// @name General Function
+//@{
+#define DIALOG_GEN_FUNC_SURFACE_VALUES "Surface values"
+#define DIALOG_GEN_FUNC_CONTROL_VALUES "Control values"
+#define DIALOG_GEN_FUNC_S_FUNC_LABEL " S =  "
+#define DIALOG_GEN_FUNC_T_FUNC_LABEL " T =  "
+#define DIALOG_GEN_FUNC_OLD_S_LABEL " * old_S  + "
+#define DIALOG_GEN_FUNC_OLD_T_LABEL " * old_T  + "
+#define DIALOG_GEN_FUNC_ROW_DIST_LABEL " * row_dist  + "
+#define DIALOG_GEN_FUNC_COL_DIST_LABEL " * col_dist  + "
+#define DIALOG_GEN_FUNC_ROW_NUM_LABEL " * row_num  + "
+#define DIALOG_GEN_FUNC_COL_NUM_LABEL " * col_num  + "
+#define DIALOG_GEN_FUNC_MAX_OPT_LABEL DIALOG_SET_SCALE_MAX_OPT_LABEL
+#define DIALOG_GEN_FUNC_COL_ALIGN_FRAME_LABEL DIALOG_SET_SCALE_S_ALIGN_FRAME_TITLE
+#define DIALOG_GEN_FUNC_ROW_ALIGN_FRAME_LABEL DIALOG_SET_SCALE_T_ALIGN_FRAME_TITLE
+#define DIALOG_GEN_FUNC_REF_ROW_FRAME_LABEL DIALOG_SET_SCALE_S_REF_ROW_OPT_LABEL " (for distances)"
+#define DIALOG_GEN_FUNC_REF_COL_FRAME_LABEL DIALOG_SET_SCALE_T_REF_COL_OPT_LABEL " (for distances)"
+#define DIALOG_GEN_FUNC_REF_TOTAL_OPT_LABEL DIALOG_SET_SCALE_REF_TOTAL_OPT_LABEL
+//@}
+
+#endif // #if !defined(INCLUDED_PLUGINUIMESSAGES_H)
diff --git a/contrib/meshtex/README.md b/contrib/meshtex/README.md
new file mode 100644 (file)
index 0000000..a47d9e9
--- /dev/null
@@ -0,0 +1,7 @@
+MeshTex is a plugin for GtkRadiant 1.5.  More interesting user documentation at [neogeographica.com](http://neogeographica.com/).
+
+Doxygen-generated code documentation is in the docs/html folder; viewable online at [rawgithub.com](https://rawgithub.com/neogeographica/MeshTex/master/docs/html/index.html).
+
+Build instructions are in the COMPILING file.
+
+MeshTex is licensed under the GNU GPL v2.  The LICENSE file contains a copy of the GPL.
diff --git a/contrib/meshtex/RefCounted.cpp b/contrib/meshtex/RefCounted.cpp
new file mode 100644 (file)
index 0000000..25270b7
--- /dev/null
@@ -0,0 +1,63 @@
+/**
+ * @file RefCounted.cpp
+ * Implements the RefCounted class.
+ * @ingroup generic-util
+ */
+
+/*
+ * Copyright 2012 Joel Baxter
+ *
+ * This file is part of MeshTex.
+ *
+ * MeshTex is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MeshTex is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MeshTex.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "RefCounted.h"
+
+
+/**
+ * Default constructor. Initialize reference count to zero.
+ */
+RefCounted::RefCounted() :
+   _refCount(0)
+{
+}
+
+/**
+ * Virtual destructor.
+ */
+RefCounted::~RefCounted()
+{
+}
+
+/**
+ * Increment reference count.
+ */
+void
+RefCounted::IncRef()
+{
+   ++_refCount;
+}
+
+/**
+ * Decrement reference count, and self-delete if count is <= 0.
+ */
+void
+RefCounted::DecRef()
+{
+   if (--_refCount <= 0)
+   {
+      delete this;
+   }
+}
diff --git a/contrib/meshtex/RefCounted.h b/contrib/meshtex/RefCounted.h
new file mode 100644 (file)
index 0000000..0f10848
--- /dev/null
@@ -0,0 +1,62 @@
+/**
+ * @file RefCounted.h
+ * Declares the RefCounted class.
+ * @ingroup generic-util
+ */
+
+/*
+ * Copyright 2012 Joel Baxter
+ *
+ * This file is part of MeshTex.
+ *
+ * MeshTex is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MeshTex is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MeshTex.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#if !defined(INCLUDED_REFCOUNTED_H)
+#define INCLUDED_REFCOUNTED_H
+
+/**
+ * A mixin for maintaining a reference count associated with an object, and
+ * destroying that object when the count falls to zero. Since this class
+ * implements the IncRef and DecRef interfaces used by the Radiant
+ * SmartPointer and SmartReference templates, those templates can
+ * automatically handle the reference counting for classes that inherit from
+ * RefCounted.
+ *
+ * @ingroup generic-util
+ */
+class RefCounted
+{
+public: // public methods
+
+   /// @name Lifecycle
+   //@{
+   RefCounted();
+   virtual ~RefCounted();
+   //@}
+   /// @name Reference counting
+   //@{
+   void IncRef();
+   void DecRef();
+   //@}
+
+private: // private member vars
+
+   /**
+    * Reference count.
+    */
+   int _refCount;
+};
+
+#endif // #if !defined(INCLUDED_REFCOUNTED_H)
\ No newline at end of file
diff --git a/contrib/meshtex/SetScaleDialog.cpp b/contrib/meshtex/SetScaleDialog.cpp
new file mode 100644 (file)
index 0000000..2634578
--- /dev/null
@@ -0,0 +1,704 @@
+/**
+ * @file SetScaleDialog.cpp
+ * Implements the SetScaleDialog class.
+ * @ingroup meshtex-ui
+ */
+
+/*
+ * Copyright 2012 Joel Baxter
+ *
+ * This file is part of MeshTex.
+ *
+ * MeshTex is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MeshTex is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MeshTex.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <gtk/gtk.h>
+
+#include "GenericPluginUI.h"
+#include "SetScaleDialog.h"
+#include "PluginUIMessages.h"
+
+#include "iundo.h"
+
+
+/**
+ * Size of buffer for the text conversion of float values written to various
+ * widgets.
+ */
+#define ENTRY_BUFFER_SIZE 128
+
+
+/**
+ * Constructor.
+ *
+ * @param rowArgs The row (S axis) arguments; NULL if none.
+ * @param colArgs The column (T axis) arguments; NULL if none.
+ */
+SetScaleDialog::SetScaleVisitor::SetScaleVisitor(
+   const SliceArgs *rowArgs,
+   const SliceArgs *colArgs) :
+   _rowArgs(rowArgs),
+   _colArgs(colArgs)
+{
+}
+
+/**
+ * Visitor action; invoke MeshEntity::SetScale on a mesh.
+ *
+ * @param [in,out] meshEntity The mesh entity.
+ *
+ * @return true.
+ */
+bool
+SetScaleDialog::SetScaleVisitor::Execute(MeshEntity& meshEntity) const
+{
+   if (_rowArgs != NULL)
+   {
+      meshEntity.SetScale(MeshEntity::ROW_SLICE_TYPE,
+                          _rowArgs->alignSlice, _rowArgs->refSlice,
+                          _rowArgs->naturalScale, _rowArgs->scaleOrTiles);
+   }
+   if (_colArgs != NULL)
+   {
+      meshEntity.SetScale(MeshEntity::COL_SLICE_TYPE,
+                          _colArgs->alignSlice, _colArgs->refSlice,
+                          _colArgs->naturalScale, _colArgs->scaleOrTiles);
+   }
+   return true;
+}
+
+/**
+ * Constructor. Configure the dialog window and create all the contained
+ * widgets. Connect widgets to callbacks as necessary.
+ *
+ * @param key The unique key identifying this dialog.
+ */
+SetScaleDialog::SetScaleDialog(const std::string& key) :
+   GenericDialog(key),
+   _nullVisitor(new MeshVisitor())
+{
+   // Enable the usual handling of the close event.
+   CreateWindowCloseCallback();
+
+   // Configure the dialog window.
+   gtk_window_set_resizable(GTK_WINDOW(_dialog), FALSE);
+   gtk_window_set_title(GTK_WINDOW(_dialog), DIALOG_SET_SCALE_TITLE);
+   gtk_container_set_border_width(GTK_CONTAINER(_dialog), 10);
+
+   // Create the contained widgets.
+
+   GtkWidget *table;
+   GtkWidget *entry;
+   GtkWidget *applybutton, *refbutton, *button;
+   GtkWidget *label;
+   GtkWidget *mainvbox, *vbox, *hbox;
+   GtkWidget *frame;
+
+   table = gtk_table_new(2, 2, FALSE);
+   gtk_table_set_row_spacing(GTK_TABLE(table), 0, 15);
+   gtk_table_set_col_spacing(GTK_TABLE(table), 0, 10);
+   gtk_container_add(GTK_CONTAINER(_dialog), table);
+   gtk_widget_show(table);
+
+   // Checkbox for the "S" grouping of widgets. All the widgets in that
+   // grouping will have a dependence registered on this checkbox; i.e. they
+   // will only be active when it is checked.
+
+   applybutton = gtk_check_button_new_with_label(DIALOG_SET_SCALE_S_ACTIVE_OPT_LABEL);
+   gtk_object_set_data(GTK_OBJECT(_dialog), "s_apply", applybutton);
+   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(applybutton), TRUE);
+   gtk_widget_show(applybutton);
+
+   frame = gtk_frame_new(NULL);
+   gtk_frame_set_label_widget(GTK_FRAME(frame), applybutton);
+   gtk_table_attach_defaults(GTK_TABLE(table), frame, 0, 1, 0, 1);
+   gtk_widget_show(frame);
+
+   mainvbox = gtk_vbox_new(FALSE, 0);
+   gtk_container_add(GTK_CONTAINER(frame), mainvbox);
+   gtk_widget_show(mainvbox);
+
+   hbox = gtk_hbox_new(FALSE, 0);
+   gtk_box_pack_start(GTK_BOX(mainvbox), hbox, TRUE, TRUE, 5);
+   gtk_widget_show(hbox);
+
+   // Widgets for specifying S scaling.
+
+   label = gtk_label_new(DIALOG_SET_SCALE_METHOD_FRAME_TITLE);
+   gtk_widget_show(label);
+
+   UIInstance().RegisterWidgetDependence(applybutton, label);
+
+   frame = gtk_frame_new(NULL);
+   gtk_frame_set_label_widget(GTK_FRAME(frame), label);
+   gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, 5);
+   gtk_widget_show(frame);
+
+   vbox = gtk_vbox_new(FALSE, 0);
+   gtk_container_add(GTK_CONTAINER(frame), vbox);
+   gtk_widget_show(vbox);
+
+   hbox = gtk_hbox_new(FALSE, 0);
+   gtk_box_pack_end(GTK_BOX(vbox), hbox, TRUE, TRUE, 5);
+   gtk_widget_show(hbox);
+
+   button = gtk_radio_button_new_with_label(NULL, DIALOG_SET_SCALE_TILES_OPT_LABEL);
+   gtk_object_set_data(GTK_OBJECT(_dialog), "s_tiling", button);
+   gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 5);
+   gtk_widget_show(button);
+
+   UIInstance().RegisterWidgetDependence(applybutton, button);
+
+   entry = gtk_entry_new();
+   gtk_object_set_data(GTK_OBJECT(_dialog), "s_tiles", entry);
+   gtk_entry_set_text(GTK_ENTRY(entry), "1");
+   gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 5);
+   gtk_widget_set_usize(entry, 50, -2);
+   gtk_widget_set_sensitive(entry, FALSE);
+   gtk_widget_show(entry);
+
+   UIInstance().RegisterWidgetDependence(applybutton, entry);
+   UIInstance().RegisterWidgetDependence(button, entry);
+
+   hbox = gtk_hbox_new(FALSE, 0);
+   gtk_box_pack_end(GTK_BOX(vbox), hbox, TRUE, TRUE, 5);
+   gtk_widget_show(hbox);
+
+   button = gtk_radio_button_new_with_label(
+      gtk_radio_button_group(GTK_RADIO_BUTTON(button)),
+                             DIALOG_SET_SCALE_NATURAL_OPT_LABEL);
+   gtk_object_set_data(GTK_OBJECT(_dialog), "s_natural", button);
+   gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 5);
+   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
+   gtk_widget_show(button);
+
+   UIInstance().RegisterWidgetDependence(applybutton, button);
+
+   entry = gtk_entry_new();
+   gtk_object_set_data(GTK_OBJECT(_dialog), "s_scale", entry);
+   gtk_entry_set_text(GTK_ENTRY(entry), "1");
+   gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 5);
+   gtk_widget_set_usize(entry, 50, -2);
+   gtk_widget_set_sensitive(entry, TRUE);
+   gtk_widget_show(entry);
+
+   UIInstance().RegisterWidgetDependence(applybutton, entry);
+   UIInstance().RegisterWidgetDependence(button, entry);
+
+   hbox = gtk_hbox_new(FALSE, 0);
+   gtk_box_pack_start(GTK_BOX(mainvbox), hbox, TRUE, TRUE, 5);
+   gtk_widget_show(hbox);
+
+   // Widgets for specifying the alignment column.
+
+   label = gtk_label_new(DIALOG_SET_SCALE_S_ALIGN_FRAME_TITLE);
+   gtk_widget_show(label);
+
+   UIInstance().RegisterWidgetDependence(applybutton, label);
+
+   frame = gtk_frame_new(NULL);
+   gtk_frame_set_label_widget(GTK_FRAME(frame), label);
+   gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, 5);
+   gtk_widget_show(frame);
+
+   vbox = gtk_vbox_new(FALSE, 0);
+   gtk_container_add(GTK_CONTAINER(frame), vbox);
+   gtk_widget_show(vbox);
+
+   hbox = gtk_hbox_new(FALSE, 0);
+   gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 5);
+   gtk_widget_show(hbox);
+
+   button = gtk_radio_button_new(NULL);
+   gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 5);
+   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
+   gtk_widget_show(button);
+
+   UIInstance().RegisterWidgetDependence(applybutton, button);
+
+   entry = gtk_entry_new();
+   gtk_object_set_data(GTK_OBJECT(_dialog), "col_num_align", entry);
+   gtk_entry_set_text(GTK_ENTRY(entry), "0");
+   gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 5);
+   gtk_widget_set_usize(entry, 25, -2);
+   gtk_widget_show(entry);
+
+   UIInstance().RegisterWidgetDependence(applybutton, entry);
+   UIInstance().RegisterWidgetDependence(button, entry);
+
+   button = gtk_radio_button_new_with_label(
+      gtk_radio_button_group(GTK_RADIO_BUTTON(button)),
+                             DIALOG_SET_SCALE_MAX_OPT_LABEL);
+   gtk_object_set_data(GTK_OBJECT(_dialog), "col_max_align", button);
+   gtk_box_pack_end(GTK_BOX(hbox), button, TRUE, FALSE, 5);
+   gtk_widget_show(button);
+
+   UIInstance().RegisterWidgetDependence(applybutton, button);
+
+   hbox = gtk_hbox_new(FALSE, 0);
+   gtk_box_pack_start(GTK_BOX(mainvbox), hbox, TRUE, TRUE, 5);
+   gtk_widget_show(hbox);
+
+   // Widgets for specifying the reference row & usage.
+
+   refbutton = gtk_check_button_new_with_label(DIALOG_SET_SCALE_S_REF_ROW_OPT_LABEL);
+   gtk_object_set_data(GTK_OBJECT(_dialog), "row_ref", refbutton);
+   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(refbutton), TRUE);
+   gtk_widget_show(refbutton);
+
+   UIInstance().RegisterWidgetDependence(applybutton, refbutton);
+
+   frame = gtk_frame_new(NULL);
+   gtk_frame_set_label_widget(GTK_FRAME(frame), refbutton);
+   gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, 5);
+   gtk_widget_show(frame);
+
+   vbox = gtk_vbox_new(FALSE, 0);
+   gtk_container_add(GTK_CONTAINER(frame), vbox);
+   gtk_widget_show(vbox);
+
+   hbox = gtk_hbox_new(FALSE, 0);
+   gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 5);
+   gtk_widget_show(hbox);
+
+   button = gtk_radio_button_new(NULL);
+   gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 5);
+   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
+   gtk_widget_show(button);
+
+   UIInstance().RegisterWidgetDependence(applybutton, button);
+   UIInstance().RegisterWidgetDependence(refbutton, button);
+
+   entry = gtk_entry_new();
+   gtk_object_set_data(GTK_OBJECT(_dialog), "row_num_ref", entry);
+   gtk_entry_set_text(GTK_ENTRY(entry), "0");
+   gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 5);
+   gtk_widget_set_usize(entry, 25, -2);
+   gtk_widget_show(entry);
+
+   UIInstance().RegisterWidgetDependence(applybutton, entry);
+   UIInstance().RegisterWidgetDependence(refbutton, entry);
+   UIInstance().RegisterWidgetDependence(button, entry);
+
+   button = gtk_radio_button_new_with_label(
+      gtk_radio_button_group(GTK_RADIO_BUTTON(button)),
+                             DIALOG_SET_SCALE_MAX_OPT_LABEL);
+   gtk_object_set_data(GTK_OBJECT(_dialog), "row_max_ref", button);
+   gtk_box_pack_end(GTK_BOX(hbox), button, TRUE, FALSE, 5);
+   gtk_widget_show(button);
+
+   UIInstance().RegisterWidgetDependence(applybutton, button);
+   UIInstance().RegisterWidgetDependence(refbutton, button);
+
+   hbox = gtk_hbox_new(FALSE, 0);
+   gtk_box_pack_end(GTK_BOX(vbox), hbox, TRUE, TRUE, 5);
+   gtk_widget_show(hbox);
+
+   button = gtk_check_button_new_with_label(DIALOG_SET_SCALE_REF_TOTAL_OPT_LABEL);
+   gtk_object_set_data(GTK_OBJECT(_dialog), "row_ref_total", button);
+   gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 5);
+   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
+   gtk_widget_show(button);
+
+   UIInstance().RegisterWidgetDependence(applybutton, button);
+   UIInstance().RegisterWidgetDependence(refbutton, button);
+
+   // Checkbox for the "T" grouping of widgets. All the widgets in that
+   // grouping will have a dependence registered on this checkbox; i.e. they
+   // will only be active when it is checked.
+
+   applybutton = gtk_check_button_new_with_label(DIALOG_SET_SCALE_T_ACTIVE_OPT_LABEL);
+   gtk_object_set_data(GTK_OBJECT(_dialog), "t_apply", applybutton);
+   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(applybutton), TRUE);
+   gtk_widget_show(applybutton);
+
+   frame = gtk_frame_new(NULL);
+   gtk_frame_set_label_widget(GTK_FRAME(frame), applybutton);
+   gtk_table_attach_defaults(GTK_TABLE(table), frame, 1, 2, 0, 1);
+   gtk_widget_show(frame);
+
+   mainvbox = gtk_vbox_new(FALSE, 0);
+   gtk_container_add(GTK_CONTAINER(frame), mainvbox);
+   gtk_widget_show(mainvbox);
+
+   hbox = gtk_hbox_new(FALSE, 0);
+   gtk_box_pack_start(GTK_BOX(mainvbox), hbox, TRUE, TRUE, 5);
+   gtk_widget_show(hbox);
+
+   // Widgets for specifying T scaling.
+
+   label = gtk_label_new(DIALOG_SET_SCALE_METHOD_FRAME_TITLE);
+   gtk_widget_show(label);
+
+   UIInstance().RegisterWidgetDependence(applybutton, label);
+
+   frame = gtk_frame_new(NULL);
+   gtk_frame_set_label_widget(GTK_FRAME(frame), label);
+   gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, 5);
+   gtk_widget_show(frame);
+
+   vbox = gtk_vbox_new(FALSE, 0);
+   gtk_container_add(GTK_CONTAINER(frame), vbox);
+   gtk_widget_show(vbox);
+
+   hbox = gtk_hbox_new(FALSE, 0);
+   gtk_box_pack_end(GTK_BOX(vbox), hbox, TRUE, TRUE, 5);
+   gtk_widget_show(hbox);
+
+   button = gtk_radio_button_new_with_label(NULL, DIALOG_SET_SCALE_TILES_OPT_LABEL);
+   gtk_object_set_data(GTK_OBJECT(_dialog), "t_tiling", button);
+   gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 5);
+   gtk_widget_show(button);
+
+   UIInstance().RegisterWidgetDependence(applybutton, button);
+
+   entry = gtk_entry_new();
+   gtk_object_set_data(GTK_OBJECT(_dialog), "t_tiles", entry);
+   gtk_entry_set_text(GTK_ENTRY(entry), "1");
+   gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 5);
+   gtk_widget_set_usize(entry, 50, -2);
+   gtk_widget_set_sensitive(entry, FALSE);
+   gtk_widget_show(entry);
+
+   UIInstance().RegisterWidgetDependence(applybutton, entry);
+   UIInstance().RegisterWidgetDependence(button, entry);
+
+   hbox = gtk_hbox_new(FALSE, 0);
+   gtk_box_pack_end(GTK_BOX(vbox), hbox, TRUE, TRUE, 5);
+   gtk_widget_show(hbox);
+
+   button = gtk_radio_button_new_with_label(
+      gtk_radio_button_group(GTK_RADIO_BUTTON(button)),
+                             DIALOG_SET_SCALE_NATURAL_OPT_LABEL);
+   gtk_object_set_data(GTK_OBJECT(_dialog), "t_natural", button);
+   gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 5);
+   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
+   gtk_widget_show(button);
+
+   UIInstance().RegisterWidgetDependence(applybutton, button);
+
+   entry = gtk_entry_new();
+   gtk_object_set_data(GTK_OBJECT(_dialog), "t_scale", entry);
+   gtk_entry_set_text(GTK_ENTRY(entry), "1");
+   gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 5);
+   gtk_widget_set_usize(entry, 50, -2);
+   gtk_widget_set_sensitive(entry, TRUE);
+   gtk_widget_show(entry);
+
+   UIInstance().RegisterWidgetDependence(applybutton, entry);
+   UIInstance().RegisterWidgetDependence(button, entry);
+
+   hbox = gtk_hbox_new(FALSE, 0);
+   gtk_box_pack_start(GTK_BOX(mainvbox), hbox, TRUE, TRUE, 5);
+   gtk_widget_show(hbox);
+
+   // Widgets for specifying the alignment row.
+
+   label = gtk_label_new(DIALOG_SET_SCALE_T_ALIGN_FRAME_TITLE);
+   gtk_widget_show(label);
+
+   UIInstance().RegisterWidgetDependence(applybutton, label);
+
+   frame = gtk_frame_new(NULL);
+   gtk_frame_set_label_widget(GTK_FRAME(frame), label);
+   gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, 5);
+   gtk_widget_show(frame);
+
+   vbox = gtk_vbox_new(FALSE, 0);
+   gtk_container_add(GTK_CONTAINER(frame), vbox);
+   gtk_widget_show(vbox);
+
+   hbox = gtk_hbox_new(FALSE, 0);
+   gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 5);
+   gtk_widget_show(hbox);
+
+   button = gtk_radio_button_new(NULL);
+   gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 5);
+   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
+   gtk_widget_show(button);
+
+   UIInstance().RegisterWidgetDependence(applybutton, button);
+
+   entry = gtk_entry_new();
+   gtk_object_set_data(GTK_OBJECT(_dialog), "row_num_align", entry);
+   gtk_entry_set_text(GTK_ENTRY(entry), "0");
+   gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 5);
+   gtk_widget_set_usize(entry, 25, -2);
+   gtk_widget_show(entry);
+
+   UIInstance().RegisterWidgetDependence(applybutton, entry);
+   UIInstance().RegisterWidgetDependence(button, entry);
+
+   button = gtk_radio_button_new_with_label(
+      gtk_radio_button_group(GTK_RADIO_BUTTON(button)),
+                             DIALOG_SET_SCALE_MAX_OPT_LABEL);
+   gtk_object_set_data(GTK_OBJECT(_dialog), "row_max_align", button);
+   gtk_box_pack_end(GTK_BOX(hbox), button, TRUE, FALSE, 5);
+   gtk_widget_show(button);
+
+   UIInstance().RegisterWidgetDependence(applybutton, button);
+
+   hbox = gtk_hbox_new(FALSE, 0);
+   gtk_box_pack_start(GTK_BOX(mainvbox), hbox, TRUE, TRUE, 5);
+   gtk_widget_show(hbox);
+
+   // Widgets for specifying the reference column & usage.
+
+   refbutton = gtk_check_button_new_with_label(DIALOG_SET_SCALE_T_REF_COL_OPT_LABEL);
+   gtk_object_set_data(GTK_OBJECT(_dialog), "col_ref", refbutton);
+   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(refbutton), TRUE);
+   gtk_widget_show(refbutton);
+
+   UIInstance().RegisterWidgetDependence(applybutton, refbutton);
+
+   frame = gtk_frame_new(NULL);
+   gtk_frame_set_label_widget(GTK_FRAME(frame), refbutton);
+   gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, 5);
+   gtk_widget_show(frame);
+
+   vbox = gtk_vbox_new(FALSE, 0);
+   gtk_container_add(GTK_CONTAINER(frame), vbox);
+   gtk_widget_show(vbox);
+
+   hbox = gtk_hbox_new(FALSE, 0);
+   gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 5);
+   gtk_widget_show(hbox);
+
+   button = gtk_radio_button_new(NULL);
+   gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 5);
+   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
+   gtk_widget_show(button);
+
+   UIInstance().RegisterWidgetDependence(applybutton, button);
+   UIInstance().RegisterWidgetDependence(refbutton, button);
+
+   entry = gtk_entry_new();
+   gtk_object_set_data(GTK_OBJECT(_dialog), "col_num_ref", entry);
+   gtk_entry_set_text(GTK_ENTRY(entry), "0");
+   gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 5);
+   gtk_widget_set_usize(entry, 25, -2);
+   gtk_widget_show(entry);
+
+   UIInstance().RegisterWidgetDependence(applybutton, entry);
+   UIInstance().RegisterWidgetDependence(refbutton, entry);
+   UIInstance().RegisterWidgetDependence(button, entry);
+
+   button = gtk_radio_button_new_with_label(
+      gtk_radio_button_group(GTK_RADIO_BUTTON(button)),
+                             DIALOG_SET_SCALE_MAX_OPT_LABEL);
+   gtk_object_set_data(GTK_OBJECT(_dialog), "col_max_ref", button);
+   gtk_box_pack_end(GTK_BOX(hbox), button, TRUE, FALSE, 5);
+   gtk_widget_show(button);
+
+   UIInstance().RegisterWidgetDependence(applybutton, button);
+   UIInstance().RegisterWidgetDependence(refbutton, button);
+
+   hbox = gtk_hbox_new(FALSE, 0);
+   gtk_box_pack_end(GTK_BOX(vbox), hbox, TRUE, TRUE, 5);
+   gtk_widget_show(hbox);
+
+   button = gtk_check_button_new_with_label(DIALOG_SET_SCALE_REF_TOTAL_OPT_LABEL);
+   gtk_object_set_data(GTK_OBJECT(_dialog), "col_ref_total", button);
+   gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 5);
+   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
+   gtk_widget_show(button);
+
+   UIInstance().RegisterWidgetDependence(applybutton, button);
+   UIInstance().RegisterWidgetDependence(refbutton, button);
+
+   hbox = gtk_hbox_new(FALSE, 0);
+   gtk_table_attach_defaults(GTK_TABLE(table), hbox, 0, 2, 1, 2);
+   gtk_widget_show(hbox);
+
+   // Create Cancel button and hook it to callback.
+
+   button = gtk_button_new_with_label(DIALOG_CANCEL_BUTTON);
+   gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
+   gtk_widget_set_usize(button, 60, -2);
+   gtk_widget_show(button);
+
+   CreateCancelButtonCallback(button);
+
+   // Create Apply button and hook it to callback.
+
+   button = gtk_button_new_with_label(DIALOG_APPLY_BUTTON);
+   gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 10);
+   gtk_widget_set_usize (button, 60, -2);
+   gtk_widget_show(button);
+
+   CreateApplyButtonCallback(button);
+
+   // Create OK button and hook it to callback.
+
+   button = gtk_button_new_with_label(DIALOG_OK_BUTTON);
+   gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
+   gtk_widget_set_usize (button, 60, -2);
+   gtk_widget_show(button);
+
+   CreateOkButtonCallback(button);
+}
+
+/**
+ * Destructor.
+ */
+SetScaleDialog::~SetScaleDialog()
+{
+}
+
+/**
+ * Handler for the Apply logic for this dialog. Apply the specified scaling to
+ * the selected mesh entities.
+ *
+ * @return true if any meshes are selected, false otherwise.
+ */
+bool
+SetScaleDialog::Apply()
+{
+   // Before doing anything, check to see if there are some meshes selected.
+   _nullVisitor->ResetVisitedCount();
+   GlobalSelectionSystem().foreachSelected(*_nullVisitor);
+   if (_nullVisitor->GetVisitedCount() == 0)
+   {
+      // Nope. Warn and bail out.
+      GenericPluginUI::WarningReportDialog(DIALOG_WARNING_TITLE,
+                                           DIALOG_NOMESHES_MSG);
+      return false;
+   }
+
+   // See if we're going to be affecting the S and/or T texture axis.
+   bool sApply = NamedToggleWidgetActive("s_apply");
+   bool tApply = NamedToggleWidgetActive("t_apply");
+
+   if (!sApply && !tApply)
+   {
+      // Not affecting either, so bail out.
+      return true;
+   }
+
+   // OK read the remaining info from the widgets.
+
+   MeshEntity::SliceDesignation alignCol, alignRow;
+   MeshEntity::RefSliceDescriptor refRow, refCol;
+   SetScaleVisitor::SliceArgs row, col;
+   SetScaleVisitor::SliceArgs *rowArgs = NULL;
+   SetScaleVisitor::SliceArgs *colArgs = NULL;
+   if (sApply)
+   {
+      // S axis is affected, so read the S info.
+      row.naturalScale = NamedToggleWidgetActive("s_natural");
+      if (row.naturalScale)
+      {
+         row.scaleOrTiles = (float)atof(NamedEntryWidgetText("s_scale"));
+      }
+      else
+      {
+         row.scaleOrTiles = (float)atof(NamedEntryWidgetText("s_tiles"));
+      }
+      alignCol.maxSlice = NamedToggleWidgetActive("col_max_align");
+      alignCol.index = atoi(NamedEntryWidgetText("col_num_align"));
+      row.alignSlice = &alignCol;
+      row.refSlice = NULL;
+      if (NamedToggleWidgetActive("row_ref"))
+      {
+         // Reference row is specified, so get that info.
+         refRow.designation.maxSlice = NamedToggleWidgetActive("row_max_ref");
+         refRow.designation.index = atoi(NamedEntryWidgetText("row_num_ref"));
+         refRow.totalLengthOnly = NamedToggleWidgetActive("row_ref_total");
+         row.refSlice = &refRow;
+      }
+      rowArgs = &row;
+   }
+   if (tApply)
+   {
+      // T axis is affected, so read the T info.
+      col.naturalScale = NamedToggleWidgetActive("t_natural");
+      if (col.naturalScale)
+      {
+         col.scaleOrTiles = (float)atof(NamedEntryWidgetText("t_scale"));
+      }
+      else
+      {
+         col.scaleOrTiles = (float)atof(NamedEntryWidgetText("t_tiles"));
+      }
+      alignRow.maxSlice = NamedToggleWidgetActive("row_max_align");
+      alignRow.index = atoi(NamedEntryWidgetText("row_num_align"));
+      col.alignSlice = &alignRow;
+      col.refSlice = NULL;
+      if (NamedToggleWidgetActive("col_ref"))
+      {
+         // Reference column is specified, so get that info.
+         refCol.designation.maxSlice = NamedToggleWidgetActive("col_max_ref");
+         refCol.designation.index = atoi(NamedEntryWidgetText("col_num_ref"));
+         refCol.totalLengthOnly = NamedToggleWidgetActive("col_ref_total");
+         col.refSlice = &refCol;
+      }
+      colArgs = &col;
+   }
+
+   // Let Radiant know the name of the operation responsible for the changes
+   // that are about to happen.
+   UndoableCommand undo(_triggerCommand.c_str());
+
+   // Apply the specified scaling to every selected mesh.
+   SmartPointer<SetScaleVisitor> scaleVisitor(new SetScaleVisitor(rowArgs, colArgs));
+   GlobalSelectionSystem().foreachSelected(*scaleVisitor);
+
+   // Done!
+   return true;
+}
+
+/**
+ * Allow an external caller to set some of the S-axis entries.
+ *
+ * @param scale Texture scaling.
+ * @param tiles Texture tiles.
+ */
+void
+SetScaleDialog::PopulateSWidgets(float scale,
+                                 float tiles)
+{
+   // Use the texture info to populate some of our widgets.
+   PopulateEntry("s_scale", scale);
+   PopulateEntry("s_tiles", tiles);
+}
+
+/**
+ * Allow an external caller to set some of the T-axis entries.
+ *
+ * @param scale Texture scaling.
+ * @param tiles Texture tiles.
+ */
+void
+SetScaleDialog::PopulateTWidgets(float scale,
+                                 float tiles)
+{
+   // Use the texture info to populate some of our widgets.
+   PopulateEntry("t_scale", scale);
+   PopulateEntry("t_tiles", tiles);
+}
+
+/**
+ * Populate a text widget with a floating point number.
+ *
+ * @param widgetName Name of the widget.
+ * @param value      The number to write to the widget.
+ */
+void
+SetScaleDialog::PopulateEntry(const char *widgetName,
+                              float value)
+{
+   static char entryBuffer[ENTRY_BUFFER_SIZE + 1] = { 0 };
+   snprintf(entryBuffer, ENTRY_BUFFER_SIZE, "%f", value);
+   gtk_entry_set_text(GTK_ENTRY(NamedWidget(widgetName)), entryBuffer);
+}
diff --git a/contrib/meshtex/SetScaleDialog.h b/contrib/meshtex/SetScaleDialog.h
new file mode 100644 (file)
index 0000000..605cf6b
--- /dev/null
@@ -0,0 +1,110 @@
+/**
+ * @file SetScaleDialog.h
+ * Declares the SetScaleDialog class.
+ * @ingroup meshtex-ui
+ */
+
+/*
+ * Copyright 2012 Joel Baxter
+ *
+ * This file is part of MeshTex.
+ *
+ * MeshTex is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MeshTex is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MeshTex.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#if !defined(INCLUDED_SETSCALEDIALOG_H)
+#define INCLUDED_SETSCALEDIALOG_H
+
+#include "GenericDialog.h"
+#include "MeshVisitor.h"
+
+/**
+ * Subclass of GenericDialog that implements the window summoned by selecting
+ * the Set S/T Scale menu entry. This window is used to control the scaling
+ * of the S and/or T texture axes.
+ * 
+ * @image html setscale.png
+ *
+ * @ingroup meshtex-ui
+ */
+class SetScaleDialog : public GenericDialog
+{
+private: // private types
+
+   /**
+    * Visitor for applying the chosen scaling to a mesh.
+    */
+   class SetScaleVisitor : public MeshVisitor
+   {
+   public:
+      /**
+       * Encapsulation of all the arguments that can affect either the S or T
+       * texture axis. See MeshEntity::SetScale for details of how these arguments
+       * are interpreted.
+       */
+      typedef struct {
+         /**
+          * Pointer to alignment slice description; if NULL, slice 0 is assumed.
+          */
+         const MeshEntity::SliceDesignation *alignSlice;
+         /**
+          * Pointer to reference slice description, including how to use the reference;
+          * NULL if no reference.
+          */
+         const MeshEntity::RefSliceDescriptor *refSlice;
+         /**
+          * true if naturalScaleOrTiles is a factor of the Radiant natural scale;
+          * false if naturalScaleOrTiles is a number of tiles.
+          */
+         bool naturalScale;
+         /**
+          * Scaling determinant, interpreted according to the naturalScale parameter.
+          */
+         float scaleOrTiles;
+      } SliceArgs;
+   public:
+      SetScaleVisitor(const SliceArgs *rowArgs,
+                      const SliceArgs *colArgs);
+   private:
+      bool Execute(MeshEntity& meshEntity) const;
+   private:
+      const SliceArgs *_rowArgs;
+      const SliceArgs *_colArgs;
+   };
+
+public: // public methods
+
+   SetScaleDialog(const std::string& key);
+   ~SetScaleDialog();
+   bool Apply();
+   void PopulateSWidgets(float scale,
+                         float tiles);
+   void PopulateTWidgets(float scale,
+                         float tiles);
+
+private: // private methods
+
+   void PopulateEntry(const char *widgetName,
+                      float value);
+
+private: // private member vars
+
+   /**
+    * Action-less mesh visitor used purely to count the number of selected mesh
+    * entities.
+    */
+   SmartPointer<MeshVisitor> _nullVisitor;
+};
+
+#endif // #if !defined(INCLUDED_SETSCALEDIALOG_H)
\ No newline at end of file
diff --git a/contrib/meshtex/UtilityMacros.h b/contrib/meshtex/UtilityMacros.h
new file mode 100644 (file)
index 0000000..9f670b7
--- /dev/null
@@ -0,0 +1,43 @@
+/**
+ * @file UtilityMacros.h
+ * Basic macros.
+ * @ingroup generic-util
+ */
+
+/*
+ * Copyright 2012 Joel Baxter
+ *
+ * This file is part of MeshTex.
+ *
+ * MeshTex is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MeshTex is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MeshTex.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#if !defined(INCLUDED_UTILITYMACROS_H)
+#define INCLUDED_UTILITYMACROS_H
+
+/**
+ * Convert a token to a string at compile-time.
+ *
+ * @param A The token to stringify.
+ */
+#define STRINGIFY(A) #A
+
+/**
+ * Convert a macro's value to a string at compile-time.
+ *
+ * @param A The name of the macro to process.
+ */
+#define STRINGIFY_MACRO(A) STRINGIFY(A)
+
+#endif // #if !defined(INCLUDED_UTILITYMACROS_H)
diff --git a/contrib/meshtex/docs/docs.7z b/contrib/meshtex/docs/docs.7z
new file mode 100644 (file)
index 0000000..21c96bf
Binary files /dev/null and b/contrib/meshtex/docs/docs.7z differ
diff --git a/contrib/meshtex/localdirs.vsprops b/contrib/meshtex/localdirs.vsprops
new file mode 100644 (file)
index 0000000..2458475
--- /dev/null
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+       ProjectType="Visual C++"
+       Version="8.00"
+       Name="localdirs"
+       >
+       <UserMacro
+               Name="RadiantExeDir"
+               Value="C:\Program Files (x86)\GtkRadiant 1.5.0"
+               PerformEnvironmentSet="true"
+       />
+       <UserMacro
+               Name="RadiantSrcDir"
+               Value="D:/GtkRadiant 1.5.0 source"
+               PerformEnvironmentSet="true"
+       />
+       <UserMacro
+               Name="StlportDir"
+               Value="D:/STLPort-5.2.1"
+               PerformEnvironmentSet="true"
+       />
+       <UserMacro
+               Name="GtkDir"
+               Value="D:/gtk2-2.24.10"
+               PerformEnvironmentSet="true"
+       />
+       <UserMacro
+               Name="GitDir"
+               Value="C:\Users\Joel Baxter\AppData\Local\GitHub\PortableGit_015aa71ef18c047ce8509ffb2f9e4bb0e3e73f13\cmd"
+       />
+</VisualStudioPropertySheet>
diff --git a/contrib/meshtex/mainpage.dox b/contrib/meshtex/mainpage.dox
new file mode 100644 (file)
index 0000000..b518258
--- /dev/null
@@ -0,0 +1,62 @@
+/**
+ * @mainpage
+ *
+ * @section org Organization
+ *
+ * At a high level this design separates code specific to MeshTex functionality
+ * from code that could apply to Radiant plugins in general, especially plugins
+ * that have similar interface needs (i.e. accept some numbers/choices from user
+ * input and apply to selected objects). Within both of those broad categories,
+ * further separation is enforced between the plugin framework, patch mesh
+ * manipulation, and UI. See the Modules page of this documentation for
+ * specifics.
+ *
+ * @section flow Control Flow
+ *
+ * A Radiant plugin is a library that exports only one function:
+ * Radiant_RegisterModules. This returns a function table that Radiant will
+ * use to identify the plugin, populate the main menu for the plugin, and notify
+ * the plugin when one of those menu entries is selected.
+ *
+ * When a menu entry is selected, the plugin code is sent a string token that
+ * identifies the entry, and it must use that token to decide what to do.
+ *
+ * The MeshTex menu entries lead to three kinds of operations:
+ *   - Raise a popup message dialog with fixed text, such as the Help dialog.
+ *   - Execute an operation on selected patch mesh entities. This operation is
+ *     completely specified by the selected menu entry.
+ *   - Raise a window that accepts further input. When the OK or Apply button is
+ *     clicked on that window, execute an operation on selected patch mesh
+ *     entities, using values read from the window's input widgets as arguments.
+ *
+ * Most MeshTex operations follow this general flow:
+ *   - Create a visitor object that understands how to execute the operation on
+ *     any input that is a valid patch mesh.
+ *   - Instantiate the Radiant class UndoableCommand to identify the operation.
+ *   - Use the Radiant function GlobalSelectionSystem().foreachSelected to
+ *     iterate over the currently selected objects and pass them to the visitor
+ *     object.
+ *   - Destroy the UndoableCommand object (implicitly on scope exit).
+ *
+ * The visitor object follows these steps when processing a mesh:
+ *   - Use the Radiant function GlobalPatchCreator().Patch_undoSave if it is
+ *     about to modify the mesh.
+ *   - Read mesh characteristics and control point data, and possibly modify
+ *     the texture coordinates in the control point data.
+ *   - If the mesh was modified, use the Radiant functions
+ *     GlobalPatchCreator().Patch_controlPointsChanged and
+ *     GlobalPatchCreator().Patch_undoSave.
+ *
+ * The complete list of Radiant systems used by MeshTex is defined in the
+ * MeshTexPluginDependencies class declaration.
+ *
+ * @section external External Dependences
+ *
+ * This version of MeshTex uses types and functions from these other sources:
+ *   - GtkRadiant 1.5: https://github.com/TTimo/GtkRadiant/tree/1.5-release
+ *   - GTK+ 2 stack: http://www.gtk.org/download/index.php
+ *   - STLport 5: http://sourceforge.net/projects/stlport/files/STLport/
+ *
+ * The specific minor versions last used to build MeshTex are GtkRadiant 1.5.0,
+ * GTK+ 2.24.10, and STLport 5.2.1.
+ */
\ No newline at end of file
diff --git a/contrib/meshtex/meshtex.def b/contrib/meshtex/meshtex.def
new file mode 100644 (file)
index 0000000..cac5dd7
--- /dev/null
@@ -0,0 +1,3 @@
+LIBRARY        "meshtex"
+EXPORTS
+       Radiant_RegisterModules @1
\ No newline at end of file
diff --git a/contrib/meshtex/meshtex.rc b/contrib/meshtex/meshtex.rc
new file mode 100644 (file)
index 0000000..1e0eef0
--- /dev/null
@@ -0,0 +1,101 @@
+// Microsoft Visual C++ generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+#include "PluginProperties.h"
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE 
+BEGIN
+    "resource.h\0"
+END
+
+2 TEXTINCLUDE 
+BEGIN
+    "#include ""afxres.h""\r\n"
+    "#include ""PluginProperties.h\0"
+END
+
+3 TEXTINCLUDE 
+BEGIN
+    "\r\0"
+END
+
+#endif    // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION PLUGIN_VERSION_MAJOR_NUMERIC,PLUGIN_VERSION_MINOR_NUMERIC,0,0
+ PRODUCTVERSION PLUGIN_VERSION_MAJOR_NUMERIC,PLUGIN_VERSION_MINOR_NUMERIC,0,0
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x2L
+ FILESUBTYPE 0x0L
+BEGIN
+    BLOCK "StringFileInfo"
+    BEGIN
+        BLOCK "040904b0"
+        BEGIN
+            VALUE "CompanyName", " "
+            VALUE "FileDescription", PLUGIN_FILE_DESCRIPTION
+            VALUE "FileVersion", PLUGIN_VERSION
+            VALUE "InternalName", PLUGIN_FILE_BASENAME
+            VALUE "LegalCopyright", "Copyright " PLUGIN_COPYRIGHT_DATE " " PLUGIN_AUTHOR
+            VALUE "OriginalFilename", PLUGIN_FILE_BASENAME ".dll"
+            VALUE "ProductName", PLUGIN_NAME
+            VALUE "ProductVersion", PLUGIN_VERSION
+        END
+    END
+    BLOCK "VarFileInfo"
+    BEGIN
+        VALUE "Translation", 0x409, 1200
+    END
+END
+
+#endif    // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif    // not APSTUDIO_INVOKED
+
diff --git a/contrib/meshtex/meshtex.sln b/contrib/meshtex/meshtex.sln
new file mode 100644 (file)
index 0000000..bc754ad
--- /dev/null
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "meshtex", "meshtex.vcproj", "{C8DA1D8D-EB09-4367-9023-5DE6FBF52E37}"
+EndProject
+Global
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution
+               Debug|Win32 = Debug|Win32
+               Release|Win32 = Release|Win32
+       EndGlobalSection
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution
+               {C8DA1D8D-EB09-4367-9023-5DE6FBF52E37}.Debug|Win32.ActiveCfg = Debug|Win32
+               {C8DA1D8D-EB09-4367-9023-5DE6FBF52E37}.Debug|Win32.Build.0 = Debug|Win32
+               {C8DA1D8D-EB09-4367-9023-5DE6FBF52E37}.Release|Win32.ActiveCfg = Release|Win32
+               {C8DA1D8D-EB09-4367-9023-5DE6FBF52E37}.Release|Win32.Build.0 = Release|Win32
+       EndGlobalSection
+       GlobalSection(SolutionProperties) = preSolution
+               HideSolutionNode = FALSE
+       EndGlobalSection
+EndGlobal
diff --git a/contrib/meshtex/meshtex.vcproj b/contrib/meshtex/meshtex.vcproj
new file mode 100644 (file)
index 0000000..d21c817
--- /dev/null
@@ -0,0 +1,385 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+       ProjectType="Visual C++"
+       Version="9.00"
+       Name="meshtex"
+       ProjectGUID="{C8DA1D8D-EB09-4367-9023-5DE6FBF52E37}"
+       RootNamespace="meshtex"
+       Keyword="Win32Proj"
+       TargetFrameworkVersion="196613"
+       >
+       <Platforms>
+               <Platform
+                       Name="Win32"
+               />
+       </Platforms>
+       <ToolFiles>
+       </ToolFiles>
+       <Configurations>
+               <Configuration
+                       Name="Debug|Win32"
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+                       IntermediateDirectory="$(ConfigurationName)"
+                       ConfigurationType="2"
+                       InheritedPropertySheets=".\localdirs.vsprops"
+                       CharacterSet="2"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                               Description="Capturing git commit hash (if known)"
+                               CommandLine="set GitCommit=n/a&#x0D;&#x0A;for /f &quot;delims=&quot; %%a in (&apos;&quot;$(GitDir)\git&quot; rev-parse --short HEAD 2^&gt;NUL&apos;) do (set GitCommit=%%a)&#x0D;&#x0A;echo #define CODE_ID %GitCommit% &gt; &quot;$(ProjectDir)CodeVersion.h&quot;&#x0D;&#x0A;exit /b 0&#x0D;&#x0A;"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="0"
+                               AdditionalIncludeDirectories="$(RadiantSrcDir)/include;$(RadiantSrcDir)/libs;$(StlportDir)/stlport;$(GtkDir)/include/glib-2.0;$(GtkDir)/include/gtk-2.0;$(GtkDir)/lib/glib-2.0/include;$(GtkDir)/lib/gtk-2.0/include;$(GtkDir)/include/cairo;$(GtkDir)/include/pango-1.0;$(GtkDir)/include/atk-1.0;$(GtkDir)/include/gdk-pixbuf-2.0"
+                               PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MESHTEX_EXPORTS"
+                               StringPooling="true"
+                               MinimalRebuild="true"
+                               ExceptionHandling="0"
+                               BasicRuntimeChecks="3"
+                               RuntimeLibrary="3"
+                               BufferSecurityCheck="false"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="4"
+                               DebugInformationFormat="4"
+                               DisableSpecificWarnings="4100;4127;4512;4996"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               AdditionalDependencies="glib-2.0.lib gdk-win32-2.0.lib gtk-win32-2.0.lib gobject-2.0.lib"
+                               LinkIncremental="2"
+                               AdditionalLibraryDirectories="$(GtkDir)/lib"
+                               IgnoreDefaultLibraryNames=""
+                               ModuleDefinitionFile="meshtex.def"
+                               GenerateDebugInformation="true"
+                               SubSystem="2"
+                               RandomizedBaseAddress="0"
+                               DataExecutionPrevention="0"
+                               TargetMachine="1"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                               Description="Copy to GtkRadiant plugins directory"
+                               CommandLine="copy /Y &quot;$(TargetDir)$(TargetFileName)&quot; &quot;$(RadiantExeDir)\plugins\$(TargetFileName)&quot;"
+                       />
+               </Configuration>
+               <Configuration
+                       Name="Release|Win32"
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+                       IntermediateDirectory="$(ConfigurationName)"
+                       ConfigurationType="2"
+                       InheritedPropertySheets=".\localdirs.vsprops"
+                       CharacterSet="2"
+                       WholeProgramOptimization="1"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                               Description="Capturing git commit hash (if known)"
+                               CommandLine="set GitCommit=n/a&#x0D;&#x0A;for /f &quot;delims=&quot; %%a in (&apos;&quot;$(GitDir)\git&quot; rev-parse --short HEAD 2^&gt;NUL&apos;) do (set GitCommit=%%a)&#x0D;&#x0A;echo #define CODE_ID %GitCommit% &gt; &quot;$(ProjectDir)CodeVersion.h&quot;&#x0D;&#x0A;exit /b 0&#x0D;&#x0A;"
+                               ExcludedFromBuild="false"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="4"
+                               InlineFunctionExpansion="2"
+                               EnableIntrinsicFunctions="true"
+                               FavorSizeOrSpeed="1"
+                               AdditionalIncludeDirectories="$(RadiantSrcDir)/include;$(RadiantSrcDir)/libs;$(StlportDir)/stlport;$(GtkDir)/include/glib-2.0;$(GtkDir)/include/gtk-2.0;$(GtkDir)/lib/glib-2.0/include;$(GtkDir)/lib/gtk-2.0/include;$(GtkDir)/include/cairo;$(GtkDir)/include/pango-1.0;$(GtkDir)/include/atk-1.0;$(GtkDir)/include/gdk-pixbuf-2.0"
+                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MESHTEX_EXPORTS"
+                               StringPooling="true"
+                               ExceptionHandling="0"
+                               RuntimeLibrary="2"
+                               BufferSecurityCheck="false"
+                               EnableFunctionLevelLinking="true"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="4"
+                               DebugInformationFormat="3"
+                               DisableSpecificWarnings="4100;4127;4512;4996"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               AdditionalDependencies="glib-2.0.lib gdk-win32-2.0.lib gtk-win32-2.0.lib gobject-2.0.lib"
+                               LinkIncremental="1"
+                               AdditionalLibraryDirectories="$(GtkDir)/lib"
+                               ModuleDefinitionFile="meshtex.def"
+                               GenerateDebugInformation="true"
+                               SubSystem="2"
+                               OptimizeReferences="2"
+                               EnableCOMDATFolding="2"
+                               RandomizedBaseAddress="0"
+                               DataExecutionPrevention="0"
+                               TargetMachine="1"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                               Description="Copy to GtkRadiant plugins directory"
+                               CommandLine="copy /Y &quot;$(TargetDir)$(TargetFileName)&quot; &quot;$(RadiantExeDir)\plugins\$(TargetFileName)&quot;"
+                       />
+               </Configuration>
+       </Configurations>
+       <References>
+       </References>
+       <Files>
+               <Filter
+                       Name="src"
+                       >
+                       <Filter
+                               Name="generic"
+                               >
+                               <Filter
+                                       Name="util"
+                                       >
+                                       <File
+                                               RelativePath=".\RefCounted.cpp"
+                                               >
+                                       </File>
+                                       <File
+                                               RelativePath=".\RefCounted.h"
+                                               >
+                                       </File>
+                                       <File
+                                               RelativePath=".\UtilityMacros.h"
+                                               >
+                                       </File>
+                               </Filter>
+                               <Filter
+                                       Name="plugin"
+                                       >
+                                       <File
+                                               RelativePath=".\PluginModule.cpp"
+                                               >
+                                       </File>
+                                       <File
+                                               RelativePath=".\PluginModule.h"
+                                               >
+                                       </File>
+                               </Filter>
+                               <Filter
+                                       Name="ui"
+                                       >
+                                       <File
+                                               RelativePath=".\GenericDialog.cpp"
+                                               >
+                                       </File>
+                                       <File
+                                               RelativePath=".\GenericDialog.h"
+                                               >
+                                       </File>
+                                       <File
+                                               RelativePath=".\GenericMainMenu.cpp"
+                                               >
+                                       </File>
+                                       <File
+                                               RelativePath=".\GenericMainMenu.h"
+                                               >
+                                       </File>
+                                       <File
+                                               RelativePath=".\GenericPluginUI.cpp"
+                                               >
+                                       </File>
+                                       <File
+                                               RelativePath=".\GenericPluginUI.h"
+                                               >
+                                       </File>
+                                       <File
+                                               RelativePath=".\GenericPluginUIMessages.h"
+                                               >
+                                       </File>
+                               </Filter>
+                       </Filter>
+                       <Filter
+                               Name="meshtex"
+                               >
+                               <Filter
+                                       Name="util"
+                                       >
+                                       <File
+                                               RelativePath=".\AllocatedMatrix.h"
+                                               >
+                                       </File>
+                                       <File
+                                               RelativePath=".\MeshVisitor.cpp"
+                                               >
+                                       </File>
+                                       <File
+                                               RelativePath=".\MeshVisitor.h"
+                                               >
+                                       </File>
+                               </Filter>
+                               <Filter
+                                       Name="ui"
+                                       >
+                                       <File
+                                               RelativePath=".\GeneralFunctionDialog.cpp"
+                                               >
+                                       </File>
+                                       <File
+                                               RelativePath=".\GeneralFunctionDialog.h"
+                                               >
+                                       </File>
+                                       <File
+                                               RelativePath=".\GetInfoDialog.cpp"
+                                               >
+                                       </File>
+                                       <File
+                                               RelativePath=".\GetInfoDialog.h"
+                                               >
+                                       </File>
+                                       <File
+                                               RelativePath=".\MainMenu.cpp"
+                                               >
+                                       </File>
+                                       <File
+                                               RelativePath=".\MainMenu.h"
+                                               >
+                                       </File>
+                                       <File
+                                               RelativePath=".\PluginUI.cpp"
+                                               >
+                                       </File>
+                                       <File
+                                               RelativePath=".\PluginUI.h"
+                                               >
+                                       </File>
+                                       <File
+                                               RelativePath=".\PluginUIMessages.h"
+                                               >
+                                       </File>
+                                       <File
+                                               RelativePath=".\SetScaleDialog.cpp"
+                                               >
+                                       </File>
+                                       <File
+                                               RelativePath=".\SetScaleDialog.h"
+                                               >
+                                       </File>
+                               </Filter>
+                               <Filter
+                                       Name="plugin"
+                                       >
+                                       <File
+                                               RelativePath=".\PluginProperties.h"
+                                               >
+                                       </File>
+                                       <File
+                                               RelativePath=".\PluginRegistration.cpp"
+                                               >
+                                       </File>
+                               </Filter>
+                               <Filter
+                                       Name="core"
+                                       >
+                                       <File
+                                               RelativePath=".\MeshEntity.cpp"
+                                               >
+                                       </File>
+                                       <File
+                                               RelativePath=".\MeshEntity.h"
+                                               >
+                                       </File>
+                                       <File
+                                               RelativePath=".\MeshEntityMessages.h"
+                                               >
+                                       </File>
+                               </Filter>
+                       </Filter>
+                       <Filter
+                               Name="windows"
+                               >
+                               <File
+                                       RelativePath=".\meshtex.def"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath=".\meshtex.rc"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath=".\resource.h"
+                                       >
+                               </File>
+                       </Filter>
+               </Filter>
+       </Files>
+       <Globals>
+       </Globals>
+</VisualStudioProject>
diff --git a/contrib/meshtex/modules.dox b/contrib/meshtex/modules.dox
new file mode 100644 (file)
index 0000000..d99cedf
--- /dev/null
@@ -0,0 +1,31 @@
+/** @defgroup generic Generic
+ *  Broadly applicable to Radiant plugin implementation.
+ *  @{
+ */
+   /** @defgroup generic-plugin Generic Plugin
+    *  Framework for defining and registering a plugin.
+    */
+   /** @defgroup generic-ui Generic UI
+    *  Framework for implementing and managing a main menu and dialog windows.
+    */
+   /** @defgroup generic-util Generic Util
+    *  Universal utility classes.
+    */
+/** @} */
+/** @defgroup meshtex MeshTex
+ *  Specific to the MeshTex plugin.
+ *  @{
+ */
+   /** @defgroup meshtex-core MeshTex Core
+    *  Logic for manipulating patch mesh entities.
+    */
+   /** @defgroup meshtex-plugin MeshTex Plugin
+    *  Defining and registering the MeshTex plugin.
+    */
+   /** @defgroup meshtex-ui MeshTex UI
+    *  Implementing and managing the MeshTex main menu and dialog windows.
+    */
+   /** @defgroup meshtex-util MeshTex Util
+    *  Utility classes for patch mesh manipulation.
+    */
+/** @} */
\ No newline at end of file
diff --git a/contrib/meshtex/resource.h b/contrib/meshtex/resource.h
new file mode 100644 (file)
index 0000000..4752599
--- /dev/null
@@ -0,0 +1,14 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by meshtex.rc
+
+// Next default values for new objects
+// 
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE        101
+#define _APS_NEXT_COMMAND_VALUE         40001
+#define _APS_NEXT_CONTROL_VALUE         1001
+#define _APS_NEXT_SYMED_VALUE           101
+#endif
+#endif