]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - radiant/feedback.h
Merge branch 'TimePath/gtk++' into 'master'
[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 {
41 public:
42 // Increment the number of references to this object
43 virtual void IncRef() = 0;
44 // Decrement the reference count
45 virtual void DecRef() = 0;
46 virtual void Draw2D( VIEWTYPE vt ) = 0;
47 };
48
49 // 3D window
50 class IGL3DWindow
51 {
52 public:
53 // Increment the number of references to this object
54 virtual void IncRef() = 0;
55 // Decrement the reference count
56 virtual void DecRef() = 0;
57 virtual void Draw3D() = 0;
58 };
59
60 // a select message with a brush/entity select information
61 class CSelectMsg : public ISAXHandler
62 {
63 enum { SELECT_MESSAGE, SELECT_BRUSH } ESelectState;
64 StringOutputStream message;
65 StringOutputStream brush;
66 public:
67 CSelectMsg() { ESelectState = SELECT_MESSAGE; }
68 // SAX interface
69 void saxStartElement( message_info_t *ctx, const xmlChar *name, const xmlChar **attrs );
70 void saxEndElement( message_info_t *ctx, const xmlChar *name );
71 void saxCharacters( message_info_t *ctx, const xmlChar *ch, int len );
72 // for use in the dialog window
73 const char* getName() { return message.c_str(); }
74 IGL2DWindow* Highlight();
75 void DropHighlight() { }
76 };
77
78 class CPointMsg : public ISAXHandler, public IGL2DWindow
79 {
80 enum { POINT_MESSAGE, POINT_POINT } EPointState;
81 StringOutputStream message;
82 StringOutputStream point;
83 Vector3 pt;
84 int refCount;
85 public:
86 CPointMsg() { EPointState = POINT_MESSAGE; refCount = 0; }
87 // SAX interface
88 void Release(){
89         delete this;
90 }
91 void saxStartElement( message_info_t *ctx, const xmlChar *name, const xmlChar **attrs );
92 void saxEndElement( message_info_t *ctx, const xmlChar *name );
93 void saxCharacters( message_info_t *ctx, const xmlChar *ch, int len );
94 // for use in the dialog window
95 const char* getName() { return message.c_str(); }
96 IGL2DWindow* Highlight();
97 void DropHighlight();
98
99 // IGL2DWindow interface --------------------------------
100 // Increment the number of references to this object
101 void IncRef() { refCount++; }
102 // Decrement the reference count
103 void DecRef() {
104         refCount--; if ( refCount <= 0 ) {
105                 delete this;
106         }
107 }
108 void Draw2D( VIEWTYPE vt );
109 };
110
111 class CWindingMsg : public ISAXHandler, public IGL2DWindow
112 {
113 enum { WINDING_MESSAGE, WINDING_WINDING } EPointState;
114 StringOutputStream message;
115 StringOutputStream winding;
116 Vector3 wt[256];
117 int numpoints;
118 int refCount;
119 public:
120 CWindingMsg() { EPointState = WINDING_MESSAGE; refCount = 0; numpoints = 0; }
121 // SAX interface
122 void Release(){
123         delete this;
124 }
125 void saxStartElement( message_info_t *ctx, const xmlChar *name, const xmlChar **attrs );
126 void saxEndElement( message_info_t *ctx, const xmlChar *name );
127 void saxCharacters( message_info_t *ctx, const xmlChar *ch, int len );
128 // for use in the dialog window
129 const char* getName() { return message.c_str(); }
130 IGL2DWindow* Highlight();
131 void DropHighlight();
132
133 // IGL2DWindow interface --------------------------------
134 // Increment the number of references to this object
135 void IncRef() { refCount++; }
136 // Decrement the reference count
137 void DecRef() {
138         refCount--; if ( refCount <= 0 ) {
139                 delete this;
140         }
141 }
142 void Draw2D( VIEWTYPE vt );
143 };
144
145
146 class CDbgDlg : public Dialog
147 {
148 GPtrArray *m_pFeedbackElements;
149 // the list widget we use in the dialog
150 ui::ListStore m_clist{ui::null};
151 ISAXHandler *m_pHighlight;
152 IGL2DWindow* m_pDraw2D;
153 public:
154 CDbgDlg(){
155         m_pFeedbackElements = g_ptr_array_new();
156         m_pHighlight = NULL;
157         m_pDraw2D = NULL;
158 }
159 // refresh items
160 void Push( ISAXHandler * );
161 // clean the debug window, release all ISAXHanlders we have
162 void Init();
163 ISAXHandler *GetElement( std::size_t row );
164 void SetHighlight( gint row );
165 void DropHighlight();
166 void draw2D( VIEWTYPE viewType ){
167         if ( m_pDraw2D != 0 ) {
168                 m_pDraw2D->Draw2D( viewType );
169         }
170 }
171 void destroyWindow(){
172         if ( GetWidget() ) {
173                 Destroy();
174         }
175 }
176 //  void HideDlg();
177 protected:
178 ui::Window BuildDialog();
179 };
180
181 extern CDbgDlg g_DbgDlg;
182
183 void Feedback_draw2D( VIEWTYPE viewType );
184
185 #endif