]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - radiant/feedback.h
uncrustify iqmmodel code
[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 "xmlstuff.h"
34 #include "dialog.h"
35 #include "xywindow.h"
36
37 // we use these classes to let plugins draw inside the Radiant windows
38 // 2D window like YZ XZ XY
39 class IGL2DWindow {
40 public:
41     virtual ~IGL2DWindow() = default;
42
43 // Increment the number of references to this object
44     virtual void IncRef() = 0;
45
46 // Decrement the reference count
47     virtual void DecRef() = 0;
48
49     virtual void Draw2D(VIEWTYPE vt) = 0;
50 };
51
52 // 3D window
53 class IGL3DWindow {
54 public:
55 // Increment the number of references to this object
56     virtual void IncRef() = 0;
57
58 // Decrement the reference count
59     virtual void DecRef() = 0;
60
61     virtual void Draw3D() = 0;
62 };
63
64 // a select message with a brush/entity select information
65 class CSelectMsg : public ISAXHandler {
66     enum { SELECT_MESSAGE, SELECT_BRUSH } ESelectState;
67     StringOutputStream message;
68     StringOutputStream brush;
69 public:
70     CSelectMsg()
71     { ESelectState = SELECT_MESSAGE; }
72
73 // SAX interface
74     void saxStartElement(message_info_t *ctx, const xmlChar *name, const xmlChar **attrs);
75
76     void saxEndElement(message_info_t *ctx, const xmlChar *name);
77
78     void saxCharacters(message_info_t *ctx, const xmlChar *ch, int len);
79
80 // for use in the dialog window
81     const char *getName()
82     { return message.c_str(); }
83
84     IGL2DWindow *Highlight();
85
86     void DropHighlight()
87     {}
88 };
89
90 class CPointMsg : public ISAXHandler, public IGL2DWindow {
91     enum { POINT_MESSAGE, POINT_POINT } EPointState;
92     StringOutputStream message;
93     StringOutputStream point;
94     Vector3 pt;
95     int refCount;
96 public:
97     CPointMsg()
98     {
99         EPointState = POINT_MESSAGE;
100         refCount = 0;
101     }
102
103 // SAX interface
104     void Release()
105     {
106         delete this;
107     }
108
109     void saxStartElement(message_info_t *ctx, const xmlChar *name, const xmlChar **attrs);
110
111     void saxEndElement(message_info_t *ctx, const xmlChar *name);
112
113     void saxCharacters(message_info_t *ctx, const xmlChar *ch, int len);
114
115 // for use in the dialog window
116     const char *getName()
117     { return message.c_str(); }
118
119     IGL2DWindow *Highlight();
120
121     void DropHighlight();
122
123 // IGL2DWindow interface --------------------------------
124 // Increment the number of references to this object
125     void IncRef()
126     { refCount++; }
127
128 // Decrement the reference count
129     void DecRef()
130     {
131         refCount--;
132         if (refCount <= 0) {
133             delete this;
134         }
135     }
136
137     void Draw2D(VIEWTYPE vt);
138 };
139
140 class CWindingMsg : public ISAXHandler, public IGL2DWindow {
141     enum { WINDING_MESSAGE, WINDING_WINDING } EPointState;
142     StringOutputStream message;
143     StringOutputStream winding;
144     Vector3 wt[256];
145     int numpoints;
146     int refCount;
147 public:
148     CWindingMsg()
149     {
150         EPointState = WINDING_MESSAGE;
151         refCount = 0;
152         numpoints = 0;
153     }
154
155 // SAX interface
156     void Release()
157     {
158         delete this;
159     }
160
161     void saxStartElement(message_info_t *ctx, const xmlChar *name, const xmlChar **attrs);
162
163     void saxEndElement(message_info_t *ctx, const xmlChar *name);
164
165     void saxCharacters(message_info_t *ctx, const xmlChar *ch, int len);
166
167 // for use in the dialog window
168     const char *getName()
169     { return message.c_str(); }
170
171     IGL2DWindow *Highlight();
172
173     void DropHighlight();
174
175 // IGL2DWindow interface --------------------------------
176 // Increment the number of references to this object
177     void IncRef()
178     { refCount++; }
179
180 // Decrement the reference count
181     void DecRef()
182     {
183         refCount--;
184         if (refCount <= 0) {
185             delete this;
186         }
187     }
188
189     void Draw2D(VIEWTYPE vt);
190 };
191
192
193 class CDbgDlg : public Dialog {
194     GPtrArray *m_pFeedbackElements;
195 // the list widget we use in the dialog
196     ui::ListStore m_clist{ui::null};
197     ISAXHandler *m_pHighlight;
198     IGL2DWindow *m_pDraw2D;
199 public:
200     CDbgDlg()
201     {
202         m_pFeedbackElements = g_ptr_array_new();
203         m_pHighlight = NULL;
204         m_pDraw2D = NULL;
205     }
206
207 // refresh items
208     void Push(ISAXHandler *);
209
210 // clean the debug window, release all ISAXHanlders we have
211     void Init();
212
213     ISAXHandler *GetElement(std::size_t row);
214
215     void SetHighlight(gint row);
216
217     void DropHighlight();
218
219     void draw2D(VIEWTYPE viewType)
220     {
221         if (m_pDraw2D != 0) {
222             m_pDraw2D->Draw2D(viewType);
223         }
224     }
225
226     void destroyWindow()
227     {
228         if (GetWidget()) {
229             Destroy();
230         }
231     }
232 //  void HideDlg();
233 protected:
234     ui::Window BuildDialog();
235 };
236
237 extern CDbgDlg g_DbgDlg;
238
239 void Feedback_draw2D(VIEWTYPE viewType);
240
241 #endif