File: myx_gc_layer.h

package info (click to toggle)
mysql-query-browser 1.1.6-1sarge0
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 36,320 kB
  • ctags: 24,680
  • sloc: pascal: 203,479; xml: 136,561; ansic: 47,502; cpp: 28,926; sh: 12,433; objc: 4,823; java: 1,849; php: 1,485; python: 1,225; sql: 1,128; makefile: 872
file content (160 lines) | stat: -rw-r--r-- 6,030 bytes parent folder | download
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
149
150
151
152
153
154
155
156
157
158
159
160
/* 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_layer.h 
 * @brief Implementation of the GC layer class.
 * 
 */

#ifndef __GC_LAYER_H__
#define __GC_LAYER_H__

#ifdef MAKEDLL
  #define GENERIC_CANVAS_API  __declspec(dllexport)
#else
  #define GENERIC_CANVAS_API  __declspec(dllimport)
#endif

#include "myx_gc_datatypes.h"

#include <hash_map>
#include <hash_set>

using namespace stdext;

typedef enum tagLayerType
{
  GC_LAYER_NORMAL,
  GC_LAYER_GRID
} TGCLayerType;

//----------------------------------------------------------------------------------------------------------------------

class CGenericCanvas;
class CFigureInstance;
class CFigure;

#pragma warning(disable: 4251) // Disable warning about DLL interface for template classes.

typedef hash_set<CFigureInstance*> CFigureInstances;
typedef hash_set<CFigureInstance*>::iterator CInstanceIterator;

class GENERIC_CANVAS_API CLayer
{
  friend class CGenericCanvas;
  friend class CFigureInstance;
private:
  wstring FName;                  // The name of the layer.
  GLuint FList;                   // The display list that represents this layer in OpenGL.
  CGenericCanvas* FCanvas;        // The canvas to which this layer belongs.
  bool FDirty;                    // True if any of the properties changed that affect the display list.
  double FScaling[3];             // The factors to scale the layer in each direction.
  double FTranslation[3];         // The factors to move the layer.
  CFigureInstances FInstances;    // A list of figures instances.
  int FUpdateCount;               // See CGenericCanvas.
  bool FVisible;                  // true if the layer is visible, otherwise false. Default is true.
  bool FEnabled;                  // True if the layer answers to mouse and keyboard actions.
protected:
  void ApplyTransformations();
  void CheckError(void);
  void MakeDirty(void);
  void RenderFeedback(CFigureInstance* Instance);
  virtual void RenderLayerContent(void);
  void ValidateDisplayList(void);
  virtual void ValidateLayerContent(void);
public:
  CLayer(CGenericCanvas* Owner);
  ~CLayer(void);

  virtual void __cdecl AddInstance(CFigureInstance* Instance);
  virtual void __cdecl BeginUpdate(void);
  virtual void __cdecl Clear();
  virtual CFigureInstance* __cdecl CreateInstance(CFigure* Figure);
  virtual void __cdecl EndUpdate(void);
  virtual CGenericCanvas* __cdecl GetCanvas(void);
  virtual bool __cdecl GetVisible(void);
  virtual bool __cdecl IsUpdating(void);
  virtual void __cdecl Release(void);
  virtual void __cdecl RemoveInstance(CFigureInstance* Instance);
  virtual void __cdecl Render(void);
  virtual void __cdecl Translate(double Tx, double Ty, double Tz, bool Accumulative = false);
  virtual void __cdecl TranslateV(const double Factor[3], bool Accumulative = false);
  virtual void __cdecl Scale(double Sx, double Sy, double Sz, bool Accumulative = false);
  virtual void __cdecl ScaleV(const double Factor[3], bool Accumulative = false);
  virtual void __cdecl SetEnabled(bool IsEnabled);
  virtual void __cdecl SetVisible(bool IsVisible);
};

//----------------------------------------------------------------------------------------------------------------------

/**
 * The grid layer is a special layer variant that renders itself as grid.
 */
class GENERIC_CANVAS_API CGridLayer: public CLayer
{
private:
protected:
  virtual void RenderLayerContent(void);
public:
  CGridLayer(CGenericCanvas* Owner);
};

//----------------- Selection layer and associated structures ----------------------------------------------------------

typedef struct tagSelectionEntry
{
  CFigureInstance* Instance;
  bool Dirty;
  TBounds Bounds;
  GLuint DisplayList;
} TSelectionEntry;

typedef hash_map<CFigureInstance*, TSelectionEntry> CSelection;
typedef hash_map<CFigureInstance*, TSelectionEntry>::iterator CSelectionIterator;
typedef hash_map<CFigureInstance*, TSelectionEntry>::reverse_iterator CSelectionIteratorReverse;

/**
 * The selection layer is a special layer variant that renders decorations for selected figures and can be queried
 * for quick hit tests and lists of selected figures.
 */
class GENERIC_CANVAS_API CSelectionLayer: public CLayer
{
private:
  CSelection FSelection;     // The list of currently selected figure instances.
  float FHandleSize;         // The size of the decoration handles.
protected:
  void CreateDecoration(CSelectionIterator Iterator);
  virtual void RenderLayerContent(void);
  virtual void ValidateLayerContent(void);
public:
  CSelectionLayer(CGenericCanvas* Owner);
  ~CSelectionLayer(void);

  virtual void __cdecl AddToSelection(CFigureInstance* Instance);
  virtual void __cdecl ClearSelection(void);
  virtual bool __cdecl GetProperty(TProperty Property, double& Value);
  virtual bool __cdecl GetProperty(TProperty Property, int& Value);
  virtual TGCSelectionInfo __cdecl GetSelectionInfo(double X, double Y);
  virtual void __cdecl InvalidateBounds(CFigureInstance* Instance);
  virtual void __cdecl RemoveFromSelection(CFigureInstance* Instance);
  virtual bool __cdecl SetProperty(TProperty Property, double Value);
  virtual bool __cdecl SetProperty(TProperty Property, int Value);
};

//----------------------------------------------------------------------------------------------------------------------

#endif // __GC_LAYER_H__