]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - radiant/feedback.h
Fix the build on my system
[xonotic/netradiant.git] / radiant / feedback.h
1 /*
2    Copyright (C) 1999-2006 Id Software, Inc. and contributors.
3    For a list of contributors, see the accompanying CONTRIBUTORS file.
4
5    This file is part of GtkRadiant.
6
7    GtkRadiant is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11
12    GtkRadiant is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with GtkRadiant; if not, write to the Free Software
19    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20  */
21
22 //-----------------------------------------------------------------------------
23 //
24 // DESCRIPTION:
25 // classes used for describing geometry information from q3map feedback
26 //
27
28 #ifndef __Q3MAP_FEEDBACK__
29 #define __Q3MAP_FEEDBACK__
30
31 #include "math/vector.h"
32 #include "stream/stringstream.h"
33 #include <glib.h>
34 #include "xmlstuff.h"
35 #include "dialog.h"
36 #include "xywindow.h"
37
38 // we use these classes to let plugins draw inside the Radiant windows
39 // 2D window like YZ XZ XY
40 class IGL2DWindow
41 {
42 public:
43 // Increment the number of references to this object
44 virtual void IncRef() = 0;
45 // Decrement the reference count
46 virtual void DecRef() = 0;
47 virtual void Draw2D( VIEWTYPE vt ) = 0;
48 };
49
50 // 3D window
51 class IGL3DWindow
52 {
53 public:
54 // Increment the number of references to this object
55 virtual void IncRef() = 0;
56 // Decrement the reference count
57 virtual void DecRef() = 0;
58 virtual void Draw3D() = 0;
59 };
60
61 // a select message with a brush/entity select information
62 class CSelectMsg : public ISAXHandler
63 {
64 enum { SELECT_MESSAGE, SELECT_BRUSH } ESelectState;
65 StringOutputStream message;
66 StringOutputStream brush;
67 public:
68 CSelectMsg() { ESelectState = SELECT_MESSAGE; }
69 // SAX interface
70 void saxStartElement( message_info_t *ctx, const xmlChar *name, const xmlChar **attrs );
71 void saxEndElement( message_info_t *ctx, const xmlChar *name );
72 void saxCharacters( message_info_t *ctx, const xmlChar *ch, int len );
73 // for use in the dialog window
74 const char* getName() { return message.c_str(); }
75 IGL2DWindow* Highlight();
76 void DropHighlight() { }
77 };
78
79 class CPointMsg : public ISAXHandler, public IGL2DWindow
80 {
81 enum { POINT_MESSAGE, POINT_POINT } EPointState;
82 StringOutputStream message;
83 StringOutputStream point;
84 Vector3 pt;
85 int refCount;
86 public:
87 CPointMsg() { EPointState = POINT_MESSAGE; refCount = 0; }
88 // SAX interface
89 void Release(){
90         delete this;
91 }
92 void saxStartElement( message_info_t *ctx, const xmlChar *name, const xmlChar **attrs );
93 void saxEndElement( message_info_t *ctx, const xmlChar *name );
94 void saxCharacters( message_info_t *ctx, const xmlChar *ch, int len );
95 // for use in the dialog window
96 const char* getName() { return message.c_str(); }
97 IGL2DWindow* Highlight();
98 void DropHighlight();
99
100 // IGL2DWindow interface --------------------------------
101 // Increment the number of references to this object
102 void IncRef() { refCount++; }
103 // Decrement the reference count
104 void DecRef() {
105         refCount--; if ( refCount <= 0 ) {
106                 delete this;
107         }
108 }
109 void Draw2D( VIEWTYPE vt );
110 };
111
112 class CWindingMsg : public ISAXHandler, public IGL2DWindow
113 {
114 enum { WINDING_MESSAGE, WINDING_WINDING } EPointState;
115 StringOutputStream message;
116 StringOutputStream winding;
117 Vector3 wt[256];
118 int numpoints;
119 int refCount;
120 public:
121 CWindingMsg() { EPointState = WINDING_MESSAGE; refCount = 0; numpoints = 0; }
122 // SAX interface
123 void Release(){
124         delete this;
125 }
126 void saxStartElement( message_info_t *ctx, const xmlChar *name, const xmlChar **attrs );
127 void saxEndElement( message_info_t *ctx, const xmlChar *name );
128 void saxCharacters( message_info_t *ctx, const xmlChar *ch, int len );
129 // for use in the dialog window
130 const char* getName() { return message.c_str(); }
131 IGL2DWindow* Highlight();
132 void DropHighlight();
133
134 // IGL2DWindow interface --------------------------------
135 // Increment the number of references to this object
136 void IncRef() { refCount++; }
137 // Decrement the reference count
138 void DecRef() {
139         refCount--; if ( refCount <= 0 ) {
140                 delete this;
141         }
142 }
143 void Draw2D( VIEWTYPE vt );
144 };
145
146 typedef struct _GtkListStore GtkListStore;
147
148 class CDbgDlg : public Dialog
149 {
150 GPtrArray *m_pFeedbackElements;
151 // the list widget we use in the dialog
152 GtkListStore* m_clist;
153 ISAXHandler *m_pHighlight;
154 IGL2DWindow* m_pDraw2D;
155 public:
156 CDbgDlg(){
157         m_pFeedbackElements = g_ptr_array_new();
158         m_pHighlight = NULL;
159         m_pDraw2D = NULL;
160 }
161 // refresh items
162 void Push( ISAXHandler * );
163 // clean the debug window, release all ISAXHanlders we have
164 void Init();
165 ISAXHandler *GetElement( std::size_t row );
166 void SetHighlight( gint row );
167 void DropHighlight();
168 void draw2D( VIEWTYPE viewType ){
169         if ( m_pDraw2D != 0 ) {
170                 m_pDraw2D->Draw2D( viewType );
171         }
172 }
173 void destroyWindow(){
174         if ( GetWidget() != 0 ) {
175                 Destroy();
176         }
177 }
178 //  void HideDlg();
179 protected:
180 GtkWindow* BuildDialog();
181 };
182
183 extern CDbgDlg g_DbgDlg;
184
185 void Feedback_draw2D( VIEWTYPE viewType );
186
187 #endif