/opt/ros/diamondback/stacks/graspit_simulator/graspit/graspit_source/include/mytools.h File Reference

Various useful macros and functions for dealing with errors and other common operations. More...

#include <qmessagebox.h>
#include <qpixmap.h>
#include <QString>
#include <QTextStream>
#include <iostream>
Include dependency graph for mytools.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define FAILURE   -1
#define INLINE_RELEASE
#define MAX(A, B)   ((A) > (B) ? (A) : (B))
#define MIN(A, B)   ((A) < (B) ? (A) : (B))
#define pr_errArgs(EXPR_)
#define pr_error(EXPR_)
#define QTWARNING(MSG_)
 Puts up a QT warning box with the given message.
#define ROUND(A)   ((A) >= 0 ? (int)((A)+.5) : -(int)(.5-(A)))
#define SUCCESS   0
#define TERMINAL_FAILURE   -2

Functions

int countXmlElements (const TiXmlElement *root, QString defStr)
 Returns the number of chilren in the XML node root of the type specified in defStr.
std::list< const TiXmlElement * > findAllXmlElements (const TiXmlElement *root, QString defStr)
 Returns the children of the XML node root of the type specified in defStr.
int findString (QTextStream *stream, QString target)
 Finds a keyword on a line in a stream and positions the stream after it.
const TiXmlElementfindXmlElement (const TiXmlElement *root, QString defStr)
 Returns the child of the XML node root of the type specified in defStr.
bool getDouble (const TiXmlElement *root, QString defStr, double &val)
 Returns the double value in the child f the XML node root of the type specified in defStr.
bool getInt (const TiXmlElement *root, QString defStr, int &val)
 Returns the int value in the child f the XML node root of the type specified in defStr.
bool getPosition (const TiXmlElement *root, vec3 &pos)
 Returns the position vector specified by the XML node root.
bool getTransform (const TiXmlElement *root, transf &totalTran)
 Returns the total transformation specified by the XML node root.
QPixmap load_pixmap (const QString &name)
int nextCommentLine (QTextStream *stream, QString *line)
 Finds the next line that is an Inventor comment (starts with a #).
int nextValidLine (QTextStream *stream, QString *line)
 Finds the next line in a stream that is not blank or a comment.
void printQString (QString q)
QString relativePath (QString absolutePath, QString relativeToDir)
 Returns the path absolutePath made relative to the path relativeTo.
void show_errors (int, char *=NULL)

Detailed Description

Various useful macros and functions for dealing with errors and other common operations.

Definition in file mytools.h.


Define Documentation

#define FAILURE   -1

Definition at line 45 of file mytools.h.

#define INLINE_RELEASE

Definition at line 87 of file mytools.h.

#define MAX ( A,
 )     ((A) > (B) ? (A) : (B))

Definition at line 51 of file mytools.h.

#define MIN ( A,
 )     ((A) < (B) ? (A) : (B))

Definition at line 55 of file mytools.h.

#define pr_errArgs ( EXPR_   ) 
Value:
{                                               \
    fprintf(stderr,">>!>> ");                   \
    fprintf EXPR_;                              \
    fprintf(stderr,"\n");                       \
}

Definition at line 101 of file mytools.h.

#define pr_error ( EXPR_   ) 
Value:
{                                               \
    fprintf(stderr,">>!>> ");                   \
    fprintf(stderr,EXPR_);                      \
    fprintf(stderr,"\n");                       \
}

Definition at line 93 of file mytools.h.

#define QTWARNING ( MSG_   ) 
Value:
QMessageBox::warning(NULL,"GraspIt!",MSG_,QMessageBox::Ok, \
                                                                                         Qt::NoButton,Qt::NoButton)

Puts up a QT warning box with the given message.

Definition at line 75 of file mytools.h.

#define ROUND (  )     ((A) >= 0 ? (int)((A)+.5) : -(int)(.5-(A)))

Definition at line 59 of file mytools.h.

#define SUCCESS   0

Definition at line 44 of file mytools.h.

#define TERMINAL_FAILURE   -2

Definition at line 46 of file mytools.h.


Function Documentation

int countXmlElements ( const TiXmlElement root,
QString  defStr 
)

Returns the number of chilren in the XML node root of the type specified in defStr.

Given a pointer to an XML node root, this will cycle through all the children and count how many children whose definition string matches defStr. If no such child is found, returns 0.

Definition at line 188 of file mytools.cpp.

std::list<const TiXmlElement*> findAllXmlElements ( const TiXmlElement root,
QString  defStr 
)

Returns the children of the XML node root of the type specified in defStr.

Given a pointer to an XML node root, this will cycle through all the children and return all children whose definition string matches defStr. If no such child is found, returns NULL.

Definition at line 169 of file mytools.cpp.

int findString ( QTextStream *  stream,
QString  target 
)

Finds a keyword on a line in a stream and positions the stream after it.

Definition at line 77 of file mytools.cpp.

const TiXmlElement* findXmlElement ( const TiXmlElement root,
QString  defStr 
)

Returns the child of the XML node root of the type specified in defStr.

Given a pointer to an XML node root, this will cycle through all the children and return the first whose definition string matches defStr. If no such child is found, returns NULL.

Definition at line 152 of file mytools.cpp.

bool getDouble ( const TiXmlElement root,
QString  defStr,
double &  val 
)

Returns the double value in the child f the XML node root of the type specified in defStr.

Given a pointer to an XML node root, this will cycle through all the children and return true if such child whose definition string matches defStr exists. If such child exists, this will set val to the double value in the first child it found. If no such child is found, returns false.

Definition at line 206 of file mytools.cpp.

bool getInt ( const TiXmlElement root,
QString  defStr,
int &  val 
)

Returns the int value in the child f the XML node root of the type specified in defStr.

Given a pointer to an XML node root, this will cycle through all the children and return true if such child whose definition string matches defStr exists. If such child exists, this will set val to the int value in the first child it found. If no such child is found, returns false.

Definition at line 227 of file mytools.cpp.

bool getPosition ( const TiXmlElement root,
vec3 pos 
)

Returns the position vector specified by the XML node root.

Definition at line 239 of file mytools.cpp.

bool getTransform ( const TiXmlElement root,
transf totalTran 
)

Returns the total transformation specified by the XML node root.

Definition at line 271 of file mytools.cpp.

QPixmap load_pixmap ( const QString &  name  ) 

Read, decode, and return the pixmap of the given name from the QMimeSourceFactory.

Definition at line 45 of file mytools.cpp.

int nextCommentLine ( QTextStream *  stream,
QString *  line 
)

Finds the next line that is an Inventor comment (starts with a #).

Definition at line 66 of file mytools.cpp.

int nextValidLine ( QTextStream *  stream,
QString *  line 
)

Finds the next line in a stream that is not blank or a comment.

Definition at line 55 of file mytools.cpp.

void printQString ( QString  q  )  [inline]

Definition at line 67 of file mytools.h.

QString relativePath ( QString  absolutePath,
QString  relativeToDir 
)

Returns the path absolutePath made relative to the path relativeTo.

If the two paths have no common root, the returned path is identical to absolutePath. Code adapted from; http://mrpmorris.blogspot.com/2007/05/convert-absolute-path-to-relative-path.html

Definition at line 94 of file mytools.cpp.

void show_errors ( int  ,
char *  = NULL 
)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


graspit
Author(s):
autogenerated on Wed Jan 25 10:59:15 2012