1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
|
/* Copyright (C) 2004 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/**
* @file myx_gc_primitives.h
* @brief Implementation of the primitive layer and its associated classes and structures.
*
*/
#ifndef __GC_PRIMITIVES_H__
#define __GC_PRIMITIVES_H__
#include "myx_gc_base.h"
#include "myx_gc_layer.h"
/*
#include <hash_set>
using namespace stdext;
*/
//----------------- Primitive layer and associated structures ----------------------------------------------------------
class CPrimitiveLayer;
/**
* Abstract ancestor class for all primitives.
*/
class GENERIC_CANVAS_API CPrimitive
{
friend class CPrimitiveLayer;
private:
CPrimitiveLayer* FLayer; // The owner of the primitive.
protected:
GLuint FListId;
TBoundingBox FBounds;
GLfloat FColor[4];
bool FFilled;
virtual GLuint renderList(void);
virtual void render(void) = 0;
public:
CPrimitive(const TBoundingBox& bounds, GLfloat* color, bool filled);
virtual ~CPrimitive(void);
virtual void __cdecl release(void) { delete this; };
virtual void __cdecl setEndPoint(const TVertex& end);
};
typedef vector<CPrimitive*> CPrimitives;
class GENERIC_CANVAS_API CLine: public CPrimitive
{
private:
float FWidth;
GLushort FStipple;
protected:
virtual void render(void);
public:
CLine(const TVertex& begin, const TVertex& end, GLfloat* color, GLfloat width, GLushort stipple);
};
class GENERIC_CANVAS_API CPolyLine: public CPrimitive
{
protected:
float FWidth;
vector<TVertex> FPoints;
virtual void render(void);
public:
CPolyLine(GLfloat* color, GLfloat width);
void addPoint(const TVertex &point);
};
class GENERIC_CANVAS_API CRectangle: public CPrimitive
{
protected:
virtual void render(void);
public:
CRectangle(const TBoundingBox& bounds, GLfloat* color, bool filled);
};
class GENERIC_CANVAS_API CCircle: public CPrimitive
{
private:
TVertex FCenter;
float FOuterRadius;
float FInnerRadius;
protected:
virtual void render(void);
public:
CCircle(const TVertex& center, float outerRadius, float innerRadius, GLfloat* color, bool filled);
virtual void __cdecl setCenter(const TVertex& center);
virtual void __cdecl setInnerRadius(float radius);
virtual void __cdecl setOuterRadius(float radius);
};
class GENERIC_CANVAS_API CTextLine: public CPrimitive
{
private:
wstring FText;
string FFont;
protected:
virtual void render(void);
public:
CTextLine(const TVertex& start, const wstring &text, GLfloat* color, const string &fontId);
};
//----------------------------------------------------------------------------------------------------------------------
/**
* The primitive layer is a special layer variant that renders simple graphical elements like lines and circles.
* This way it is not necessary to build a full figure. Once a primitive has been created it cannot be modified
* anymore. For changable graphic elements use figures.
*/
class GENERIC_CANVAS_API CPrimitiveLayer: public CLayer
{
private:
CPrimitives FPrimitives; // The primitives to render.
vector<GLuint> FLists;
protected:
virtual void renderLayerContent(TBoundingBox bounds);
public:
CPrimitiveLayer(CGenericCanvas* canvas);
virtual ~CPrimitiveLayer(void);
void addPrimitive(CPrimitive* primitive);
virtual void __cdecl clear(void);
void removePrimitive(CPrimitive* primitive);
void updatePrimitive(CPrimitive* primitive);
};
//----------------------------------------------------------------------------------------------------------------------
#endif // __GC_PRIMITIVES_H__
|