00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef ARCHON_X3D_TEXT_H
00021 #define ARCHON_X3D_TEXT_H
00022
00029 #include <archon/x3d/server/geometry.H>
00030
00031 namespace Archon
00032 {
00033 namespace X3D
00034 {
00035 void addFontPath(string);
00036
00040 struct FontStyleNode: GeometricPropertyNode
00041 {
00042 static const NodeType *type;
00043
00044 protected:
00045 FontStyleNode() {}
00046 };
00047
00048
00052 struct FontStyle: FontStyleNode
00053 {
00054 static Ref<NodeBase> instantiate(BackRef<ExecutionContext> c)
00055 {
00056 return new FontStyle(c);
00057 }
00058
00059 static const NodeType *type;
00060 const NodeType *getType() const { return type; }
00061
00062 FontStyle(BackRef<ExecutionContext> c):
00063 NodeBase(c),
00064 horizontal(true),
00065 leftToRight(true),
00066 size(1),
00067 spacing(1),
00068 topToBottom(true) {}
00069
00070 const vector<string> &getFamily() const { return family; }
00071 bool getHorizontal() const { return horizontal; }
00072 const vector<string> &getJustify() const { return justify; }
00073 string getLanguage() const { return language; }
00074 bool getLeftToRight() const { return leftToRight; }
00075 double getSize() const { return size; }
00076 double getSpacing() const { return spacing; }
00077 string getStyle() const { return style; }
00078 bool getTopToBottom() const { return topToBottom; }
00079
00080 private:
00081 friend void initializeTextComponent();
00082
00083 vector<string> family;
00084 bool horizontal;
00085 vector<string> justify;
00086 string language;
00087 bool leftToRight;
00088 double size;
00089 double spacing;
00090 string style;
00091 bool topToBottom;
00092 };
00093
00097 struct TextNode: GeometryNode
00098 {
00099 static const NodeType *type;
00100
00101 protected:
00102 TextNode() {}
00103 };
00104
00108 struct Text: TextNode
00109 {
00110 static Ref<NodeBase> instantiate(BackRef<ExecutionContext> c)
00111 {
00112 return new Text(c);
00113 }
00114
00115 static const NodeType *type;
00116 const NodeType *getType() const { return type; }
00117
00118 Text(BackRef<ExecutionContext> c):
00119 NodeBase(c),
00120 maxExtent(0),
00121 solid(false) {}
00122
00123 vector<string> getString() const { return _string; }
00124 Ref<const FontStyleNode> getFontStyle() const { return fontStyle; }
00125 vector<double> getLength() const { return length; }
00126 double getMaxExtent() const { return maxExtent; }
00127 bool getSolid() const { return solid; }
00128
00129 int intersect(const Math::Ray3 &, double &dist) const;
00130
00131 void getNormalAndTexCoord(Vector3 hitPoint, int where,
00132 const Shape *,
00133 Vector3 *hitNormal,
00134 Vector2 *hitTexCoord) const;
00135
00136 void render(bool texture,
00137 const Shape *shape,
00138 const RenderConfig *);
00139
00140 private:
00141 friend void initializeTextComponent();
00142
00143 vector<string> _string;
00144 Ref<FontStyleNode> fontStyle;
00145 vector<double> length;
00146 double maxExtent;
00147 bool solid;
00148
00149 EventSource stringChanged;
00150 EventSource fontStyleChanged;
00151 EventSource lengthChanged;
00152 EventSource maxExtentChanged;
00153
00154 Time stringStamp;
00155 Time fontStyleStamp;
00156 Time lengthStamp;
00157 Time maxExtentStamp;
00158 };
00159 }
00160 }
00161
00162 #endif // ARCHON_X3D_TEXT_H