A
download objectlist.h
Language: C++
License: GPL
Copyright: (C) 2000-2005 Vincent LE PRINCE
LOC: 181
Project Info
Truevision
Server: SourceForge
Type: cvs
...evision\Truevision\include\
   atmosphere.h
   bicubic.h
   blob.h
   box.h
   camera.h
   cone.h
   cylinder.h
   density.h
   disc.h
   dlgutils.h
   fnintern.h
   fog.h
   function.h
   glview.h
   glview2d.h
   glview3d.h
   heightfield.h
   impsurface.h
   interface.h
   interior.h
   isosurface.h
   julia.h
   lathe.h
   lights.h
   linkobj.h
   main.h
   mapedit.h
   material.h
   matlib.h
   matlist.h
   matpov.h
   media.h
   mesh.h
   meshrotate.h
   meshscale.h
   meshtool.h
   meshtranslate.h
   obj3dcsg.h
   obj3ddef.h
   object3d.h
   objectlayer.h
   objectlist.h
   parametric.h
   plane.h
   polygon.h
   povfe.h
   povpreview.h
   povscript.h
   preferences.h
   prism.h
   proppanel.h
   pycamera.h
   pyengine.h
   pylights.h
   pyobjects.h
   pyscriptdb.h
   pyscriptobj.h
   pyutils.h
   rotation.h
   scene.h
   scriptobj.h
   slopemap.h
   sphere.h
   spheresweep.h
   spline2d.h
   spline3d.h
   superellipsoid.h
   texfinish.h
   texnormal.h
   texpigment.h
   text.h
   torus.h
   tvio.h
   tvwidgets.h
   undo.h
   utils3d.h
   vertex.h
   viewmanager.h

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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
//*****************************************************************************************
// Truevision - a 3d modeler for povray
//
// objectlist.h
//
// Vincent LE PRINCE <vincentleprince@users.sourceforge.net>
// Copyright (C) 2000-2005 Vincent LE PRINCE
// This file is part of the TRUEVISION Package

//   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., 675 Mass Ave, Cambridge, MA 02139, USA.  */ 
//*******************************************************************************************
#ifndef TV_OBJLIST_H
#define TV_OBJLIST_H
using namespace std;
#include <vector>
#include "main.h"
#include "object3d.h"
#include "glview.h"
#include "camera.h"
#include "objectlayer.h"
#include "include/viewmanager.h"

class MeshTool;

//************************************************************
// Constants
//************************************************************
#define OBJLIST_DEF ObjectList *objlist = (ObjectList*)(app_ref->obj3dlist);

// Object manipulation buttons count
#define OBJ_BUTTONS 10

// Layer manipulation buttons count
#define LAY_BUTTONS 6


//************************************************************
// 3D objects definition structure
//
// Object defiintion for creation tree
//************************************************************
struct obj3ddef {
	const char *name;
	Object3DType type;
	const char *icon;
	const char *description;
	int subtype;
	//bool from_library;
	//const char *path;
	//const char *filename;
	//bool from_plugin;
};
typedef obj3ddef Object3DDef;
#define OBJ3D_INLINE_DEF( name, type, icon, description ) { N_(name), type, icon, N_(description) }




//************************************************************
// Class Object List
//
// Manage a layer list
// plus a global list of all objects
// plus a list of linkable objects names ( references )
// plus a list of available lights for opengl lightning preview
//************************************************************
class ObjectList : public app_object {
	#define SENDER ((ObjectList*)data)
	friend void sign_layer_select( GtkTreeSelection *selection, gpointer data ) { SENDER->select_layer( selection ); }	
	friend void sign_select_lbuttons_clicked( GtkWidget *wid, gpointer data ) { SENDER->layers_buttons_clicked(wid); }	
	friend gboolean sign_layer_view_clicked( GtkWidget *wid, GdkEventButton *ev, gpointer data ) { SENDER->layer_view_clicked(ev); return FALSE; }
	
	friend void sign_object_select( GtkTreeSelection *selection, gpointer data ) { SENDER->select_object( selection ); }
	friend void sign_select_buttons_clicked( GtkWidget *wid, gpointer data ) { SENDER->select_buttons_clicked(wid); }	
	friend gboolean sign_object_view_clicked( GtkWidget *wid, GdkEventButton *ev, gpointer data ) { SENDER->object_view_clicked(ev); return FALSE; }
	friend void sign_object_view_double_clicked( GtkTreeView *View, GtkTreePath *path, GtkTreeViewColumn *col, gpointer data) { SENDER->object_view_double_clicked();  }

	friend void sign_create_button_clicked( GtkWidget *wid, gpointer data ) { SENDER->create_button_clicked(); }	
	friend void sign_create_tree_select( GtkTreeSelection *selection, gpointer data ) { SENDER->create_tree_select(selection); }		
	friend void sign_create_tree_click( GtkTreeView *View, GtkTreePath *path, GtkTreeViewColumn *col, gpointer data ) { SENDER->create_tree_click(  ); }		
	
	friend void sign_object_drag(GtkWidget *widget, GdkDragContext *dc, GtkSelectionData *selection_data, guint info, guint t, gpointer data  ) { SENDER->object_drag( dc, selection_data ); }			
	friend void sign_object_drop_on_layer( GtkWidget *widget, GdkDragContext *dc, gint x, gint y, GtkSelectionData *selection_data, guint info, guint t, gpointer data ) { SENDER->object_drop_on_layer( dc, x, y, selection_data, info );  }
	friend void sign_object_motion_on_layer( GtkWidget *widget, GdkDragContext *dc, gint x, gint y, guint t, gpointer data ) { SENDER->object_motion_on_layer( dc, x, y );  }	
	friend void sign_object_drop_on_tree( GtkWidget *widget, GdkDragContext *dc, gint x, gint y, GtkSelectionData *selection_data, guint info, guint t, gpointer data ) { SENDER->object_drop_on_tree( dc, x, y, selection_data, info );  }	
	friend void sign_object_motion_on_tree( GtkWidget *widget, GdkDragContext *dc, gint x, gint y, guint t, gpointer data ) { SENDER->object_motion_on_tree( dc, x, y );  }	
	
	friend void sign_objlist_load_object( GtkWidget *wid, gpointer data ) { SENDER->load_object(); }		
	friend void sign_objlist_save_object( GtkWidget *wid, gpointer data ) { SENDER->save_object(); }		

	friend void sign_objlist_cut_object( GtkWidget *wid, gpointer data ) { SENDER->cut_current_object(); }		
	friend void sign_objlist_copy_object( GtkWidget *wid, gpointer data ) { SENDER->copy_current_object(); }		
	friend void sign_objlist_paste_object( GtkWidget *wid, gpointer data ) { SENDER->paste_current_object(); }		
	
	friend void sign_help_on_obj( GtkWidget *wid, gpointer data ) { SENDER->help_on_current_object(); }
	#undef SENDER


	private:
		app_objs *app_ref;
		vector<ObjectLayer*> Layers;
		ObjectLayer *selected_layer;
		vector<Object3D*> object_liste;
		Camera *MainCamera;
		GtkWidget *filebox;
		unsigned int current_pick_name;
		char **obj_name_list;
		int obj_name_list_size;
		vector<TvWidget_objref*> current_ref;

		Object3D *drag_focus;
		int drag_layer_focus;

		// Edition de l'objet courrant
		Object3D* current;
		Object3D *cut_or_copied;
		bool is_cut;
		TvWidget* current_param;
		void refresh_edit();
		GtkWidget *edit_widget, *edit_box;
		
		// Mesh tools
		MeshTool *current_tool;
		
		// Layers selection tree
		GtkListStore *layer_list_store;
		GtkWidget *layer_list_view;
		GtkTreeSelection *layer_list_selection;
		GtkTreeViewColumn *layer_list_column2, *layer_list_column3, *layer_list_column4;
		void select_layer( GtkTreeSelection *selection );
		void select_layer_in_list( int pos ) { gtk_tree_selection_select_iter( layer_list_selection, Layers[pos]->get_node_iter() ); }
		void layer_view_clicked( GdkEventButton *ev );
		
		// Layers manipulation buttons
		GtkWidget *select_lbuttons[LAY_BUTTONS];
		GtkTooltips *select_ltooltips[LAY_BUTTONS];		
 		void layers_buttons_clicked( GtkWidget *wid );
		
		// Objects selection tree
		GtkTreeStore *object_tree_store;
		GtkWidget *object_tree_view, *select_widget;
		GtkTreeSelection *object_tree_selection;
		GtkTreeViewColumn *object_tree_column1, *object_tree_column2;
		void select_object( GtkTreeSelection *selection );
		void object_view_clicked( GdkEventButton *ev );
		void object_view_double_clicked();
		
		// Objects manipulation buttons
		GtkWidget *select_buttons[OBJ_BUTTONS];
		GtkTooltips *select_tooltips[OBJ_BUTTONS];
		void select_buttons_clicked( GtkWidget *wid );
		
		void cut_current_object() { select_buttons_clicked( select_buttons[6] ); }
		void copy_current_object() { select_buttons_clicked( select_buttons[7] ); }
		void paste_current_object() { select_buttons_clicked( select_buttons[8] ); }

		// Create Tree
		GtkWidget *create_tree;
		GtkTreeStore *create_tree_store;
		GtkTreeSelection *create_tree_selection;
		Object3DDef *current_objdef;
		void add_subtree( const char *name, const char *icon, Object3DDef *defs, const int def_num );
		void create_tree_select( GtkTreeSelection *selection );
		void create_button_clicked();
		void create_tree_click(  );

		// Lampes
		bool *light_list;
		GLint light_num;
		
		// Drag & Drop
		void object_drag( GdkDragContext *dc, GtkSelectionData *selection_data );
		void object_drop_on_layer( GdkDragContext *dc, gint x, gint y, GtkSelectionData *selection_data, guint info );
		void object_motion_on_layer( GdkDragContext *dc, gint x, gint y );
		void object_drop_on_tree( GdkDragContext *dc, gint x, gint y, GtkSelectionData *selection_data, guint info );
		void object_motion_on_tree( GdkDragContext *dc, gint x, gint y );
		
		// Save & load objects
		char *default_path;
		void store_default_path( char *path );
		

	public:
		ObjectList( app_objs *app_ref );
		~ObjectList() { delete light_list; }
		void pref_changed();

		void output_to_povray( ofstream & file );
		void unselect_object();
		
		// Object list management
		int get_size() { return object_liste.size(); }
		void add_object( Object3D *obj );
		void remove_object( Object3D *obj );
		Object3D *get_object( int num ) { return object_liste[num]; }
		
		// Object reference list management
		void update_ref_list();
		int get_index_by_pointer( Object3D *obj );
		Object3D *get_pointer_by_index( int index );
		Object3D *get_pointer_by_name( char *str );

		// Objects & layers name management
		bool test_name_exist( char *name );
		char *create_name( char *name );
		bool layer_name_exist( char *name, ObjectLayer *layer );

		// OpenGL preview display
		void display( glview *view );
		void display_current( glview *view );
		void invalidate_lists();

		// Boite de selection
		void set_edit_widget( GtkWidget *wid ) { edit_widget = wid; refresh_edit(); }
		void set_select_widget( GtkWidget *wid );
		void set_create_widget( GtkWidget *wid );
		gint get_layer_index( ObjectLayer *layer );

		// Parametre courrant
		TvWidget* get_current_param() { return current_param; }
		void set_current_param( TvWidget* param );
		void clear_current_param() { current_param = NULL; }
		void display_current_param( glview *view ) { if ( current_param != NULL ) current_param->display( view ); }
		void flush() { if ( current != NULL ) current->flush(); }

		// Manipulation de l'objet courant
		Object3D* get_current() { return current; }
		void clear_current_object() { current = NULL; }
		
		void apply_transformations() { if ( current!= NULL ) current->apply_transformations(); }
		void mesh_convert() { if ( current!= NULL ) current->mesh_convert(); }
		
		// Layer Manipulation
		ObjectLayer *get_current_layer() { return selected_layer; }
		void remove_layer( ObjectLayer *layer );
		void insert_layer( ObjectLayer *layer, int position );
		void move_layer( ObjectLayer *layer, int sens );

		// Interaction avec l'objet courant
		void mouse_interact_drag( struct drag_info *drag ) { if ( current != NULL ) current->mouse_drag( drag ); }

		// Lampes
		int light_request();
		void light_release( int light_id ) { if ( light_id != -1 ) light_list[light_id] = false; }
		void light_set_properties( int light_id, float *location, float *color );
		void light_set_properties( int light_id, float *location, float *direction, float cutoff, float *color );
		void light_enable( int light_id );
		void light_disable( int light_id );
		void light_disable_all();
		
		
		void save( ofstream & file );
		bool load( ifstream & file, char * tag );
		Object3D *create_object( char *tag );
		void clear();
		void new_scene();
		
		void init_pick_names();
		unsigned int get_pick_name() { return current_pick_name++; }
		void select_picked( int name );
		void select_param_picked( int name, bool ctrl );
		
		Object3D *get_camera() { return MainCamera; }
		void set_camera( Object3D *cam ) { MainCamera = (Camera*)cam; }
		
		void load_object();
		void save_object();
		
		char **get_obj_name_list() { return obj_name_list; }
		int get_obj_name_list_size() { return obj_name_list_size; }
		void set_current_objref( TvWidget_objref *ref ) { if ( ref == NULL ) current_ref.clear(); else current_ref.push_back( ref ); }
		
		void help_on_current_object() { if ( current != NULL ) current->help_on_object(); }

		void delete_polygons() { if ( current != NULL ) current->delete_polygons(); }
		void tesselate() { if ( current != NULL ) current->tesselate(); }
		void flatten() { if ( current != NULL ) current->flatten(); }
		void flatten_region() { if ( current != NULL ) current->flatten_region(); }
		void select_all_poly() { if ( current != NULL ) current->select_all_poly(); }
		void unselect_all_poly() { if ( current != NULL ) current->unselect_all_poly(); }
		void invert_selection_poly() { if ( current != NULL ) current->invert_selection_poly(); }

		// Mesh tools
		void set_current_tool( ToolMode tmode );
		void tool_mouse_drag( Object3D *mesh, struct drag_info *drag );
};

//********************************************************
// Mesh creator definition
// implemented in meshcreate.cc
//********************************************************
Object3D *create_mesh( app_objs *appref, int subtype );

#endif

About Koders | Resources | Downloads | Support | Black Duck | Terms of Service | DMCA | Privacy Policy | Contact Us