Version: 9.15.0
GLViewer_Drawer Class Referenceabstract

#include <GLViewer_Drawer.h>

Inheritance diagram for GLViewer_Drawer:
Inheritance graph

Public Types

enum  {
  GLText_Center = 0 , GLText_Left , GLText_Right , GLText_Top ,
  GLText_Bottom
}
 Text position relatively object. More...
 

Public Member Functions

 GLViewer_Drawer ()
 A constructor. More...
 
virtual ~GLViewer_Drawer ()
 A destructor. More...
 
virtual void create (float xScale, float yScale, bool onlyUpdate)=0
 Main method which drawing object in GLViewer. More...
 
virtual void addObject (GLViewer_Object *theObject)
 Adds object to drawer display list. More...
 
virtual void clear ()
 Clears drawer display list. More...
 
QString getObjectType () const
 Returns object type (needs for dynamic search of right drawer ) More...
 
int getPriority () const
 Returns object priority. More...
 
void setAntialiasing (const bool on)
 The function enables and disables antialiasing in Open GL (for points, lines and polygons). More...
 
virtual bool translateToHPGL (QFile &hFile, GLViewer_CoordSystem *aViewerCS, GLViewer_CoordSystem *aHPGLCS)
 A function translate object in to HPGL file on disk. More...
 
virtual bool translateToPS (QFile &hFile, GLViewer_CoordSystem *aViewerCS, GLViewer_CoordSystem *aPSCS)
 A function translate object in to PostScript file on disk. More...
 
void drawTexture (GLuint texture, GLint size, GLfloat x, GLfloat y)
 Draw square texture. More...
 
void drawTexture (GLuint texture, GLint x_size, GLint y_size, GLfloat x, GLfloat y)
 Draw texture. More...
 
void drawTexturePart (GLuint texture, GLfloat x_ratio, GLfloat y_ratio, GLfloat x_size, GLfloat y_size, GLfloat x, GLfloat y, GLfloat scale=0)
 Draw texture part. More...
 
void drawText (const QString &text, GLfloat xPos, GLfloat yPos, const QColor &color, QFont *aFont, int theSeparator, DisplayTextFormat=DTF_BITMAP)
 Draw text string. More...
 
void drawGLText (QString text, float x, float y, int hPosition=GLText_Center, int vPosition=GLText_Center, QColor color=Qt::black, bool smallFont=false)
 Draw text string. More...
 
void setFont (const QFont &font)
 Sets a default font to be used by drawGLText method. More...
 
QFont font () const
 Returns a default font used by drawGLText method. More...
 
void setTextFormat (const DisplayTextFormat format)
 Sets a default text displaying format to be used by drawGLText method. More...
 
DisplayTextFormat textFormat () const
 Returns a default text displaying format used by drawGLText method. More...
 
void setTextScale (const GLfloat factor)
 Sets a text string displaying scale factor (used only with text format DTF_TEXTURE_SCALABLE) More...
 
GLfloat textScale () const
 Returns a text string displaying scale factor. More...
 
GLViewer_Rect textRect (const QString &) const
 Returns a rectangle of text (without viewer scale) More...
 

Static Public Member Functions

static void destroyAllTextures ()
 Clears all generated textures. More...
 
static GLuint loadTexture (const QString &fileName, GLint *x_size=0, GLint *y_size=0, GLint *t_size=0)
 Loads texture from file. More...
 
static void drawRectangle (GLViewer_Rect *theRect, QColor=Qt::black)
 Draw rectangle with predefined color. More...
 

Protected Member Functions

virtual void drawText (GLViewer_Object *theObject)
 Draw object text. More...
 

Static Protected Member Functions

static void drawRectangle (GLViewer_Rect *, GLfloat, GLfloat=0, QColor=Qt::black, bool=false, QColor=Qt::white)
 Draw basic primitives: rectangle, contour, polygon, vertex, cross, arrow. More...
 
static void drawContour (GLViewer_Rect *, QColor, GLfloat, GLushort, bool)
 
static void drawContour (const GLViewer_PntList &, QColor, GLfloat)
 
static void drawPolygon (GLViewer_Rect *, QColor, GLushort, bool)
 
static void drawPolygon (const GLViewer_PntList &, QColor)
 
static void drawVertex (GLfloat, GLfloat, QColor)
 
static void drawCross (GLfloat, GLfloat, QColor)
 
static void drawArrow (const GLfloat red, const GLfloat green, const GLfloat blue, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLboolean=GL_FALSE)
 

Protected Attributes

float myXScale
 X Scale factor. More...
 
float myYScale
 Y scale factor. More...
 
QList< GLViewer_Object * > myObjects
 List of objects. More...
 
GLuint myTextList
 List generated textures. More...
 
QString myObjectType
 Type of supporting object. More...
 
int myPriority
 Dislay priority. More...
 
QFont myFont
 Default font for drawGLText() method. More...
 
DisplayTextFormat myTextFormat
 Default text displaying format for drawGLText() method. More...
 
GLfloat myTextScale
 Scale factor for text string draw, by default 0.125 (used only with text format DTF_TEXTURE_SCALABLE) More...
 

Detailed Description

Drawer for GLViewer_Objects. Drawer creates only one times per one type of object

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Text position relatively object.

Enumerator
GLText_Center 
GLText_Left 
GLText_Right 
GLText_Top 
GLText_Bottom 

Constructor & Destructor Documentation

◆ GLViewer_Drawer()

GLViewer_Drawer::GLViewer_Drawer ( )

A constructor.

Default constructor

References DTF_BITMAP, myObjects, myObjectType, myPriority, myTextFormat, myTextList, myTextScale, myXScale, and myYScale.

◆ ~GLViewer_Drawer()

GLViewer_Drawer::~GLViewer_Drawer ( )
virtual

A destructor.

Destructor

References myObjects, and myTextList.

Member Function Documentation

◆ addObject()

virtual void GLViewer_Drawer::addObject ( GLViewer_Object theObject)
inlinevirtual

Adds object to drawer display list.

◆ clear()

virtual void GLViewer_Drawer::clear ( )
inlinevirtual

Clears drawer display list.

◆ create()

virtual void GLViewer_Drawer::create ( float  xScale,
float  yScale,
bool  onlyUpdate 
)
pure virtual

Main method which drawing object in GLViewer.

Implemented in GLViewer_TextDrawer, GLViewer_PolylineDrawer, and GLViewer_MarkerDrawer.

◆ destroyAllTextures()

void GLViewer_Drawer::destroyAllTextures ( )
static

Clears all generated textures.

Clears all generated textures

References GLViewer_TexFont::TexFontBase.

◆ drawArrow()

void GLViewer_Drawer::drawArrow ( const GLfloat  red,
const GLfloat  green,
const GLfloat  blue,
GLfloat  lineWidth,
GLfloat  staff,
GLfloat  length,
GLfloat  width,
GLfloat  x,
GLfloat  y,
GLfloat  angle,
GLboolean  filled = GL_FALSE 
)
staticprotected

Draws arrow

Parameters
red,green,blue- components of color
lineWidth- width of line
staff-
length- length of arrow
width- width of arrow
x- x position
y- y position
angle- angle of arrow
filled- drawn as filled

◆ drawContour() [1/2]

void GLViewer_Drawer::drawContour ( const GLViewer_PntList pntList,
QColor  color,
GLfloat  lineWidth 
)
staticprotected

Draws contour

Parameters
pntList- list of points
color- color of contour
lineWidth- width of line

References OCCViewer::color().

◆ drawContour() [2/2]

void GLViewer_Drawer::drawContour ( GLViewer_Rect rect,
QColor  color,
GLfloat  lineWidth,
GLushort  pattern,
bool  isStripe 
)
staticprotected

Draws rectangular contour

Parameters
rect- instance of rectangle
color- color of primitive
lineWidth- width of line
pattern- pattern of line
isStripe- enables line stipple

References GLViewer_Rect::bottom(), OCCViewer::color(), GLViewer_Rect::left(), GLViewer_Rect::right(), and GLViewer_Rect::top().

◆ drawCross()

void GLViewer_Drawer::drawCross ( GLfloat  x,
GLfloat  y,
QColor  color 
)
staticprotected

Draws cross

Parameters
x- x position
y- y position
color- color of cross

References OCCViewer::color(), and rasterCross.

◆ drawGLText()

void GLViewer_Drawer::drawGLText ( QString  text,
float  x,
float  y,
int  hPosition = GLText_Center,
int  vPosition = GLText_Center,
QColor  color = Qt::black,
bool  smallFont = false 
)

Draw text string.

Parameters
text- the text string
x- x coord
y- y coord
hPosition- horizontal alignment
vPosition- vertical alignment
color- text color
smallFont- font format

Draw text

Parameters
text- the text string
x- x coord
y- y coord
hPosition- horizontal alignment
vPosition- vertical alignment
color- text color
smallFont- font format

References OCCViewer::color(), drawText(), DTF_TEXTURE_SCALABLE, GLText_Bottom, GLText_Center, GLText_Left, GLText_Right, GLText_Top, myFont, myTextFormat, myXScale, myYScale, and textScale().

◆ drawPolygon() [1/2]

void GLViewer_Drawer::drawPolygon ( const GLViewer_PntList pntList,
QColor  color 
)
staticprotected

Draws polygon

Parameters
pntList- list of points
color- color of polygon

References OCCViewer::color().

◆ drawPolygon() [2/2]

void GLViewer_Drawer::drawPolygon ( GLViewer_Rect rect,
QColor  color,
GLushort  pattern,
bool  isStripe 
)
staticprotected

Draws rectangle

Parameters
rect- instance of rectangle
color- color of polygon
pattern- pattern of line
isStripe- enables line stipple

References GLViewer_Rect::bottom(), OCCViewer::color(), GLViewer_Rect::left(), GLViewer_Rect::right(), and GLViewer_Rect::top().

◆ drawRectangle() [1/2]

void GLViewer_Drawer::drawRectangle ( GLViewer_Rect rect,
GLfloat  lineWidth,
GLfloat  gap = 0,
QColor  color = Qt::black,
bool  filled = false,
QColor  fillingColor = Qt::white 
)
staticprotected

Draw basic primitives: rectangle, contour, polygon, vertex, cross, arrow.

Draws rectangle

Parameters
rect- instance of primitive
lineWidth- width of line
gap- gap of rectangle
color- color of primitive
filled- if it is true, then rectangle will be drawn filled with color "fillingColor"
fillingColor- color of filling

References GLViewer_Rect::bottom(), OCCViewer::color(), GLViewer_Rect::left(), GLViewer_Rect::right(), and GLViewer_Rect::top().

◆ drawRectangle() [2/2]

void GLViewer_Drawer::drawRectangle ( GLViewer_Rect rect,
QColor  color = Qt::black 
)
static

Draw rectangle with predefined color.

Draws rectangle

Parameters
rect- instance of primitive
color- color of primitive

References GLViewer_Rect::bottom(), OCCViewer::color(), GLViewer_Rect::left(), GLViewer_Rect::right(), and GLViewer_Rect::top().

◆ drawText() [1/2]

void GLViewer_Drawer::drawText ( const QString &  text,
GLfloat  xPos,
GLfloat  yPos,
const QColor &  color,
QFont *  theFont,
int  theSeparator,
DisplayTextFormat  theFormat = DTF_BITMAP 
)

Draw text string.

Parameters
text- the text string
xPos- x coord
yPos- y coord
color- text color
aFont- base font of text
theSeparator- letter separator
DisplayTextFormat- text format

Draw text

Parameters
text- text to be drawn
xPos- x position
yPos- y position
color- color of text
theFont- font of text
theSeparator- letter separator
theFormat- text format (by default DTF_BITMAP)

References OCCViewer::color(), displayListBase(), GLViewer_TexFont::drawString(), DTF_BITMAP, DTF_TEXTURE_SCALABLE, GLViewer_TexFont::generateTexture(), and textScale().

◆ drawText() [2/2]

◆ drawTexture() [1/2]

void GLViewer_Drawer::drawTexture ( GLuint  texture,
GLint  size,
GLfloat  x,
GLfloat  y 
)

Draw square texture.

Parameters
texture- the texture ID
size- the size of square texture
x- x coord
y- y coord

Draw square texture

Parameters
texture- the texture ID
size- the size of square texture
x- x coord
y- y coord

◆ drawTexture() [2/2]

void GLViewer_Drawer::drawTexture ( GLuint  texture,
GLint  x_size,
GLint  y_size,
GLfloat  x,
GLfloat  y 
)

Draw texture.

Parameters
texture- the texture ID
x_size- the horizontal size of texture
y_size- the vertical size of texture
x- x coord
y- y coord

Draw texture

Parameters
texture- the texture ID
x_size- the horizontal size of texture
y_size- the vertical size of texture
x- x coord
y- y coord

References drawTexturePart().

◆ drawTexturePart()

void GLViewer_Drawer::drawTexturePart ( GLuint  texture,
GLfloat  x_ratio,
GLfloat  y_ratio,
GLfloat  x_size,
GLfloat  y_size,
GLfloat  x,
GLfloat  y,
GLfloat  scale = 0 
)

Draw texture part.

Parameters
texture- the texture ID
x_ratio- the horizontal ratio of texture part
y_ratio- the vertical ratio of texture part
x_size- the horizontal size of texture
y_size- the vertical size of texture
x- x coord
y- y coord
scale- common scale factor ( if = 0, use drawer scales )

Draw texture part

Parameters
texture- the texture ID
x_ratio- the horizontal ratio of texture part
y_ratio- the vertical ratio of texture part
x_size- the horizontal size of texture
y_size- the vertical size of texture
x- x coord
y- y coord
scale- common scale factor ( if = 0, use drawer scales )

References myXScale, and myYScale.

◆ drawVertex()

void GLViewer_Drawer::drawVertex ( GLfloat  x,
GLfloat  y,
QColor  color 
)
staticprotected

Draws vertex

Parameters
x- x position
y- y position
color- color of vertex

References OCCViewer::color(), and rasterVertex.

◆ font()

QFont GLViewer_Drawer::font ( ) const
inline

Returns a default font used by drawGLText method.

◆ getObjectType()

QString GLViewer_Drawer::getObjectType ( ) const
inline

Returns object type (needs for dynamic search of right drawer )

◆ getPriority()

int GLViewer_Drawer::getPriority ( ) const
inline

Returns object priority.

◆ loadTexture()

GLuint GLViewer_Drawer::loadTexture ( const QString &  fileName,
GLint *  x_size = 0,
GLint *  y_size = 0,
GLint *  t_size = 0 
)
static

Loads texture from file.

Parameters
fileName- the name of texture file
x_size- the horizontal size of picture ( less or equal texture horizontal size )
y_size- the vertical size of picture ( less or equal texture vertical size )
t_size- the size of texture ( texture vertical size equals texture horizontal size )

Loads texture from file

Parameters
fileName- the name of texture file
x_size- the horizontal size of picture ( less or equal texture horizontal size )
y_size- the vertical size of picture ( less or equal texture vertical size )
t_size- the size of texture ( texture vertical size equals texture horizontal size )

◆ setAntialiasing()

void GLViewer_Drawer::setAntialiasing ( const bool  on)

The function enables and disables antialiasing in Open GL (for points, lines and polygons).

Enables and disables antialiasing in Open GL (for points, lines and polygons).

Parameters
on- if it is true, antialiasing is enabled

◆ setFont()

void GLViewer_Drawer::setFont ( const QFont &  font)
inline

Sets a default font to be used by drawGLText method.

Parameters
font- the default font

◆ setTextFormat()

void GLViewer_Drawer::setTextFormat ( const DisplayTextFormat  format)
inline

Sets a default text displaying format to be used by drawGLText method.

Parameters
format- the default text displaying format

◆ setTextScale()

void GLViewer_Drawer::setTextScale ( const GLfloat  factor)
inline

Sets a text string displaying scale factor (used only with text format DTF_TEXTURE_SCALABLE)

Parameters
factor- scale factor

◆ textFormat()

DisplayTextFormat GLViewer_Drawer::textFormat ( ) const
inline

Returns a default text displaying format used by drawGLText method.

◆ textRect()

GLViewer_Rect GLViewer_Drawer::textRect ( const QString &  text) const

Returns a rectangle of text (without viewer scale)

Returns
a rectangle of text (without viewer scale)

References DTF_TEXTURE_SCALABLE, myFont, myTextFormat, and textScale().

◆ textScale()

GLfloat GLViewer_Drawer::textScale ( ) const
inline

Returns a text string displaying scale factor.

◆ translateToHPGL()

bool GLViewer_Drawer::translateToHPGL ( QFile hFile,
GLViewer_CoordSystem aViewerCS,
GLViewer_CoordSystem aHPGLCS 
)
virtual

A function translate object in to HPGL file on disk.

Parameters
hFilethe name of PostScript file chosen by user
aViewerCSthe GLViewer_CoordSystem of window
aHPGLCSthe GLViewer_CoordSystem of PostScript page

Saves object to file with format of HPGL

Parameters
hFile- file
aViewerCS- viewer co-ordinate system
aHPGLCS- paper co-ordinate system

References myObjects.

◆ translateToPS()

bool GLViewer_Drawer::translateToPS ( QFile hFile,
GLViewer_CoordSystem aViewerCS,
GLViewer_CoordSystem aPSCS 
)
virtual

A function translate object in to PostScript file on disk.

Parameters
hFilethe name of PostScript file chosen by user
aViewerCSthe GLViewer_CoordSystem of window
aPSCSthe GLViewer_CoordSystem of PostScript page

Saves object to file with format of PostScript

Parameters
hFile- file
aViewerCS- viewer co-ordinate system
aPSCS- paper co-ordinate system

References myObjects.

Member Data Documentation

◆ myFont

QFont GLViewer_Drawer::myFont
protected

Default font for drawGLText() method.

◆ myObjects

QList<GLViewer_Object*> GLViewer_Drawer::myObjects
protected

List of objects.

◆ myObjectType

QString GLViewer_Drawer::myObjectType
protected

Type of supporting object.

◆ myPriority

int GLViewer_Drawer::myPriority
protected

Dislay priority.

◆ myTextFormat

DisplayTextFormat GLViewer_Drawer::myTextFormat
protected

Default text displaying format for drawGLText() method.

◆ myTextList

GLuint GLViewer_Drawer::myTextList
protected

List generated textures.

◆ myTextScale

GLfloat GLViewer_Drawer::myTextScale
protected

Scale factor for text string draw, by default 0.125 (used only with text format DTF_TEXTURE_SCALABLE)

◆ myXScale

float GLViewer_Drawer::myXScale
protected

X Scale factor.

◆ myYScale

float GLViewer_Drawer::myYScale
protected

Y scale factor.


The documentation for this class was generated from the following files: