1 #include "SceneText.hh"
2 #include <GLviewer/ContextWX.hh>
4 #ifdef BIAS_HAVE_OPENGL
5 # include <Gui/biasgl.h>
7 # include <OpenGL/glu.h>
11 # include <Utils/StatekeeperGL.hh>
19 SceneText::SceneText(
bool MakeDemoText): isInitialized_(false) {
28 fontName_ =
"-*-helvetica-bold-r-normal--12-*-*-*-p-*-iso8859-1";
45 const std::vector<std::string>& textContents,
46 const std::vector<BIAS::RGBf>& colors)
48 for (
unsigned int i=0;i<textPositions.size();i++)
49 AddText(textPositions[i],textContents[i],colors[i]);
62 const std::string& textContents,
79 #ifdef BIAS_HAVE_OPENGL
83 void *handleDC = NULL;
87 BIASASSERT(CWX != NULL);
88 handleDC = GetDC(HWND(CWX->GetHandle()));
91 #ifdef BIAS_HAVE_FONTGL
93 cerr<<
"init of font failed ..."<<endl;
97 BIASWARNONCE(
"FontGL is disabled in BIAS.");
103 map<unsigned int,BIAS::HomgPoint3D>::iterator p3dit=
textPositions_.begin();
104 map<unsigned int,std::string>::iterator textit=
textContents_.begin();
105 map<unsigned int,BIAS::RGBf>::iterator colorit=
textColors_.begin();
109 glColor3f(colorit->second[0], colorit->second[1], colorit->second[2]);
110 #ifdef BIAS_HAVE_FONTGL
112 p3dit->second[1],p3dit->second[2]);
119 glVertex3f(p3dit->second[0], p3dit->second[1],p3dit->second[2]);
135 #ifdef BIAS_HAVE_XML2
138 double& Version)
const {
139 TopLevelTag =
"SceneText";
145 std::map<unsigned int,BIAS::HomgPoint3D>::const_iterator itP=
textPositions_.begin();
146 std::map<unsigned int,std::string>::const_iterator itC=
textContents_.begin();
147 std::map<unsigned int,BIAS::RGBf>::const_iterator itCC=
textColors_.begin();
149 xmlNodePtr childNode = XMLObject.
addChildNode(mainNode,
"Text");
151 XMLObject.
addAttribute(childNode,
"r", itCC->second[0]);
152 XMLObject.
addAttribute(childNode,
"g", itCC->second[1]);
153 XMLObject.
addAttribute(childNode,
"b", itCC->second[2]);
173 while (!(childNode==NULL)) {
187 AddText(theposition,theContent,thecolor);
188 cout<<
"Found "<<theContent<<
" at "<<theposition<<
" with color "
198 #endif // BIAS_HAVE_XML2
void addAttribute(const xmlNodePtr Node, const std::string &AttributeName, bool AttributeValue)
Add an attribute to a node.
virtual int XMLGetClassName(std::string &TopLevelTag, double &Version) const
specialization of XML block name function
void Print3D(const std::string &text, const float &xpos, const float &ypos, const float &zpos) const
xmlNodePtr getNextChild()
Get the next child of the parent specified in the last getFirstChild() call, the class remembers the ...
unsigned int AddText(const BIAS::HomgPoint3D &textPositions, const std::string &textContents, const BIAS::RGBf &colors)
void SetText(const std::vector< BIAS::HomgPoint3D > &textPositions, const std::vector< std::string > &textContents, const std::vector< BIAS::RGBf > &colors)
void UpdateText(unsigned int, const BIAS::HomgPoint3D &textPositions, const std::string &textContents, const BIAS::RGBf &colors)
void RemoveText(unsigned int)
int InitFont(void *handleDC, const std::string theFontname=std::string(DrawTextGL_DEFAULT_FONTNAME), const int fontHeight=DrawTextGL_DEFAULT_FONTSIZE)
set the font up
void addContent(const xmlNodePtr Node, const std::string &Content)
Add content to a node.
BIAS::Vector3< float > RGBf
Wrapper class for reading and writing XML files based on the XML library libxml2. ...
Context implementation for wxWidgets.
xmlNodePtr addChildNode(const xmlNodePtr ParentNode, const std::string &NewNodeName)
Add a child node to an incoming node with the given name.
std::map< unsigned int, BIAS::HomgPoint3D > textPositions_
xmlNodePtr getFirstChild(const xmlNodePtr ParentNode)
Get the first child of a given parent, or NULL for no childs.
virtual int XMLIn(const xmlNodePtr Node, BIAS::XMLIO &XMLObject)
specialization of XML read function
class HomgPoint3D describes a point with 3 degrees of freedom in projective coordinates.
std::map< unsigned int, std::string > textContents_
virtual int XMLOut(const xmlNodePtr Node, BIAS::XMLIO &XMLObject) const
specialization of XML write function
double getAttributeValueDouble(const xmlAttrPtr Attribute) const
std::map< unsigned int, BIAS::RGBf > textColors_
RenderContextBase * Context_
std::string getNodeName(const xmlNodePtr Node) const
Get the name of a given Node.
virtual void Draw()
To do anything usefull, overload this method, assume context is ready and draw.
std::string getNodeContentString(const xmlNodePtr Node) const
Get the content of a given Node.
class BIASGeometryBase_EXPORT HomgPoint3D