00001 #ifndef TRAFUPOINT_H
00002 #define TRAFUPOINT_H
00003
00004 #include <wx/colour.h>
00005
00006 #include <list>
00007 #include <algorithm>
00008
00010 struct tfRGB
00011 {
00013 tfRGB(int tf_red = 0, int tf_green = 0, int tf_blue = 0)
00014 {
00015 red = tf_red;
00016 green = tf_green;
00017 blue = tf_blue;
00018 }
00019
00020 wxColour wx()
00021 {
00022 return wxColour(red, green, blue);
00023 }
00024
00027 friend tfRGB operator -(const tfRGB &first, const tfRGB &second)
00028 {
00029 return tfRGB(first.red - second.red,
00030 first.green - second.green,
00031 first.blue - second.blue);
00032 }
00033
00034 friend tfRGB operator +(const tfRGB &first, const tfRGB &second)
00035 {
00036 return tfRGB(first.red + second.red,
00037 first.green + second.green,
00038 first.blue + second.blue);
00039 }
00040
00041 friend tfRGB operator *(const tfRGB &point, const float scalar)
00042 {
00043 return tfRGB(point.red * scalar,
00044 point.green * scalar,
00045 point.blue * scalar);
00046 }
00047
00048 friend tfRGB operator /(const tfRGB &point, const float scalar)
00049 {
00050 return tfRGB(point.red / scalar,
00051 point.green / scalar,
00052 point.blue / scalar);
00053 }
00055
00058 int red;
00059 int green;
00060 int blue;
00062 };
00063
00066 const unsigned TFP_NONE = 0;
00067 const unsigned TFP_START = 1;
00068 const unsigned TFP_END = 2;
00069 const unsigned TFP_SPECIAL = TFP_START | TFP_END;
00070
00071
00073 class Mapping_data
00074 {
00075 public:
00077 Mapping_data()
00078 {
00079 this->m_density = 0;
00080 this->m_opacity = 0;
00081 this->m_colour = tfRGB(0, 0, 0);
00082 }
00083
00085 Mapping_data(float density, float opacity, int red, int green, int blue, unsigned flags=TFP_NONE)
00086 : m_density(density)
00087 , m_opacity(opacity)
00088 , m_flags(flags)
00089 {
00090 this->m_colour = tfRGB(red, green, blue);
00091 }
00092
00094 Mapping_data(float density, float opacity, tfRGB colour, unsigned flags=TFP_NONE)
00095 : m_density(density)
00096 , m_opacity(opacity)
00097 , m_colour(colour)
00098 , m_flags(flags)
00099 {
00100 }
00101
00103 Mapping_data(float density, float opacity, wxColour colour, unsigned flags=TFP_NONE)
00104 : m_density(density)
00105 , m_opacity(opacity)
00106 , m_flags(flags)
00107 {
00108 this->m_colour = tfRGB(colour.Red(), colour.Green(), colour.Blue());
00109 }
00110
00111 private:
00114 friend bool operator <(const Mapping_data &first, const Mapping_data &second)
00115 {
00116 return first.m_density < second.m_density;
00117 }
00119
00121
00124 friend Mapping_data operator -(const Mapping_data &first, const Mapping_data &second)
00125 {
00126 return Mapping_data(first.m_density - second.m_density,
00127 first.m_opacity - second.m_opacity,
00128 first.m_colour - second.m_colour);
00129 }
00130
00131 friend Mapping_data operator +(const Mapping_data &first, const Mapping_data &second)
00132 {
00133 return Mapping_data(first.m_density + second.m_density,
00134 first.m_opacity + second.m_opacity,
00135 first.m_colour + second.m_colour);
00136 }
00137
00138 friend Mapping_data operator *(const Mapping_data &point, const float scalar)
00139 {
00140 return Mapping_data(point.m_density * scalar, point.m_opacity * scalar,
00141 point.m_colour * scalar);
00142 }
00143
00144 friend Mapping_data operator /(const Mapping_data &point, const float scalar)
00145 {
00146 return Mapping_data(point.m_density / scalar, point.m_opacity * scalar,
00147 point.m_colour / scalar);
00148 }
00150
00151 public:
00154
00155 float m_density;
00156 float m_opacity;
00157 tfRGB m_colour;
00158 unsigned m_flags;
00159
00161 };
00162
00163 #endif //TRAFUPOINT_H