@ -17,14 +17,26 @@
namespace cv {
namespace viz {
/*!
* In general please refere to https : //github.com/memononen/nanovg/blob/master/src/nanovg.h for reference.
*/
namespace nvg {
/*!
* Equivalent of a NVGtextRow .
*/
struct TextRow : public NVGtextRow {
} ;
/*!
* Equivalent of a NVGglyphPosition .
*/
struct GlyphPosition : public NVGglyphPosition {
} ;
/*!
* Equivalent of a NVGPaint . Converts back and forth between the two representations ( Paint / NVGPaint ) .
*/
struct Paint {
Paint ( ) {
}
@ -64,26 +76,38 @@ struct Paint {
} ;
namespace detail {
/*!
* Internal NanoVG singleton that wraps all NanoVG functions .
*/
class NVG {
private :
friend class Viz2D ;
static NVG * nvg_instance_ ;
NVGcontext * ctx_ = nullptr ;
public :
NVG ( NVGcontext * ctx ) :
ctx_ ( ctx ) {
}
static void setCurrentContext ( NVGcontext * ctx ) ;
public :
/*!
* Initialize the current NVG object ;
* @ param ctx The NVGcontext to create the NVG object from .
*/
static void initializeContext ( NVGcontext * ctx ) ;
/*!
* Get the current NVGcontext .
* @ return The current NVGcontext context .
*/
static NVG * getCurrentContext ( ) ;
/*!
* Get the underlying NVGcontext .
* @ return The underlying NVGcontext .
*/
NVGcontext * getContext ( ) {
assert ( ctx_ ! = nullptr ) ;
return ctx_ ;
}
public :
int createFont ( const char * name , const char * filename ) ;
int createFontMem ( const char * name , unsigned char * data , int ndata , int freeData ) ;
int findFont ( const char * name ) ;
@ -175,93 +199,316 @@ public:
} ;
} // namespace detail
/*!
* A forward to nvgCreateFont . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
int createFont ( const char * name , const char * filename ) ;
/*!
* A forward to nvgCreateFontMem . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
int createFontMem ( const char * name , unsigned char * data , int ndata , int freeData ) ;
/*!
* A forward to nvgFindFont . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
int findFont ( const char * name ) ;
/*!
* A forward to nvgAddFallbackFontId . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
int addFallbackFontId ( int baseFont , int fallbackFont ) ;
/*!
* A forward to nvgAddFallbackFont . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
int addFallbackFont ( const char * baseFont , const char * fallbackFont ) ;
/*!
* A forward to nvgFontSize . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void fontSize ( float size ) ;
/*!
* A forward to nvgFontBlur . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void fontBlur ( float blur ) ;
/*!
* A forward to nvgTextLetterSpacing . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void textLetterSpacing ( float spacing ) ;
/*!
* A forward to nvgTextLineHeight . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void textLineHeight ( float lineHeight ) ;
/*!
* A forward to nvgTextAlign . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void textAlign ( int align ) ;
/*!
* A forward to nvgFontFaceId . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void fontFaceId ( int font ) ;
/*!
* A forward to nvgFontFace . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void fontFace ( const char * font ) ;
/*!
* A forward to nvgText . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
float text ( float x , float y , const char * string , const char * end ) ;
/*!
* A forward to nvgTextBox . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void textBox ( float x , float y , float breakRowWidth , const char * string , const char * end ) ;
/*!
* A forward to nvgTextBounds . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
float textBounds ( float x , float y , const char * string , const char * end , float * bounds ) ;
/*!
* A forward to nvgTextBoxBounds . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void textBoxBounds ( float x , float y , float breakRowWidth , const char * string , const char * end ,
float * bounds ) ;
/*!
* A forward to nvgTextGlyphPositions . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
int textGlyphPositions ( float x , float y , const char * string , const char * end ,
GlyphPosition * positions , int maxPositions ) ;
/*!
* A forward to nvgTextMetrics . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void textMetrics ( float * ascender , float * descender , float * lineh ) ;
/*!
* A forward to nvgTextBreakLines . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
int textBreakLines ( const char * string , const char * end , float breakRowWidth , TextRow * rows ,
int maxRows ) ;
/*!
* A forward to nvgSave . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void save ( ) ;
/*!
* A forward to nvgRestore . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void restore ( ) ;
/*!
* A forward to nvgReset . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void reset ( ) ;
/*!
* A forward to nvgShapeAntiAlias . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void shapeAntiAlias ( int enabled ) ;
/*!
* A forward to nvgStrokeColor . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void strokeColor ( const cv : : Scalar & bgra ) ;
/*!
* A forward to nvgStrokePaint . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void strokePaint ( Paint paint ) ;
/*!
* A forward to nvgFillColor . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void fillColor ( const cv : : Scalar & color ) ;
/*!
* A forward to nvgFillPaint . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void fillPaint ( Paint paint ) ;
/*!
* A forward to nvgMiterLimit . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void miterLimit ( float limit ) ;
/*!
* A forward to nvgStrokeWidth . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void strokeWidth ( float size ) ;
/*!
* A forward to nvgLineCap . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void lineCap ( int cap ) ;
/*!
* A forward to nvgLineJoin . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void lineJoin ( int join ) ;
/*!
* A forward to nvgGlobalAlpha . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void globalAlpha ( float alpha ) ;
/*!
* A forward to nvgResetTransform . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void resetTransform ( ) ;
/*!
* A forward to nvgTransform . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void transform ( float a , float b , float c , float d , float e , float f ) ;
/*!
* A forward to nvgTranslate . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void translate ( float x , float y ) ;
/*!
* A forward to nvgRotate . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void rotate ( float angle ) ;
/*!
* A forward to nvgSkewX . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void skewX ( float angle ) ;
/*!
* A forward to nvgSkewY . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void skewY ( float angle ) ;
/*!
* A forward to nvgScale . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void scale ( float x , float y ) ;
/*!
* A forward to nvgCurrentTransform . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void currentTransform ( float * xform ) ;
/*!
* A forward to nvgTransformIdentity . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void transformIdentity ( float * dst ) ;
/*!
* A forward to nvgTransformTranslate . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void transformTranslate ( float * dst , float tx , float ty ) ;
/*!
* A forward to nvgTransformScale . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void transformScale ( float * dst , float sx , float sy ) ;
/*!
* A forward to nvgTransformRotate . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void transformRotate ( float * dst , float a ) ;
/*!
* A forward to nvgTransformSkewX . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void transformSkewX ( float * dst , float a ) ;
/*!
* A forward to nvgTransformSkewY . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void transformSkewY ( float * dst , float a ) ;
/*!
* A forward to nvgTransformMultiply . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void transformMultiply ( float * dst , const float * src ) ;
/*!
* A forward to nvgTransformPremultiply . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void transformPremultiply ( float * dst , const float * src ) ;
/*!
* A forward to nvgTransformInverse . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
int transformInverse ( float * dst , const float * src ) ;
/*!
* A forward to nvgTransformPoint . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void transformPoint ( float * dstx , float * dsty , const float * xform , float srcx , float srcy ) ;
/*!
* A forward to nvgDegToRad . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
float degToRad ( float deg ) ;
/*!
* A forward to nvgRadToDeg . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
float radToDeg ( float rad ) ;
/*!
* A forward to nvgBeginPath . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void beginPath ( ) ;
/*!
* A forward to nvgMoveTo . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void moveTo ( float x , float y ) ;
/*!
* A forward to nvgLineTo . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void lineTo ( float x , float y ) ;
/*!
* A forward to nvgBezierTo . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void bezierTo ( float c1x , float c1y , float c2x , float c2y , float x , float y ) ;
/*!
* A forward to nvgQuadTo . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void quadTo ( float cx , float cy , float x , float y ) ;
/*!
* A forward to nvgArcTo . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void arcTo ( float x1 , float y1 , float x2 , float y2 , float radius ) ;
/*!
* A forward to nvgClosePath . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void closePath ( ) ;
/*!
* A forward to nvgPathWinding . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void pathWinding ( int dir ) ;
/*!
* A forward to nvgArc . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void arc ( float cx , float cy , float r , float a0 , float a1 , int dir ) ;
/*!
* A forward to nvgRect . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void rect ( float x , float y , float w , float h ) ;
/*!
* A forward to nvgRoundedRect . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void roundedRect ( float x , float y , float w , float h , float r ) ;
/*!
* A forward to nvgRoundedRectVarying . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void roundedRectVarying ( float x , float y , float w , float h , float radTopLeft , float radTopRight ,
float radBottomRight , float radBottomLeft ) ;
/*!
* A forward to nvgEllipse . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void ellipse ( float cx , float cy , float rx , float ry ) ;
/*!
* A forward to nvgCircle . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void circle ( float cx , float cy , float r ) ;
/*!
* A forward to nvgFill . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void fill ( ) ;
/*!
* A forward to nvgStroke . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void stroke ( ) ;
/*!
* A forward to nvgLinearGradient . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
Paint linearGradient ( float sx , float sy , float ex , float ey , const cv : : Scalar & icol ,
const cv : : Scalar & ocol ) ;
/*!
* A forward to nvgBoxGradient . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
Paint boxGradient ( float x , float y , float w , float h , float r , float f , const cv : : Scalar & icol ,
const cv : : Scalar & ocol ) ;
/*!
* A forward to nvgRadialGradient . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
Paint radialGradient ( float cx , float cy , float inr , float outr , const cv : : Scalar & icol ,
const cv : : Scalar & ocol ) ;
/*!
* A forward to nvgImagePattern . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
Paint imagePattern ( float ox , float oy , float ex , float ey , float angle , int image , float alpha ) ;
/*!
* A forward to nvgScissor . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void scissor ( float x , float y , float w , float h ) ;
/*!
* A forward to nvgIntersectScissor . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void intersectScissor ( float x , float y , float w , float h ) ;
/*!
* A forward to nvgRresetScissor . See https : //github.com/memononen/nanovg/blob/master/src/nanovg.h
*/
void resetScissor ( ) ;
}
}