1 // CUSTOM_APP.CPP
2 
3 // Copyright (C) 2006 Tommi Hassinen.
4 
5 // This package is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 
10 // This package is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 
15 // You should have received a copy of the GNU General Public License
16 // along with this package; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 
19 /*################################################################################################*/
20 
21 #include "custom_app.h"
22 
23 #include "local_i18n.h"
24 
25 #include <stdlib.h>	// the definition for NULL...
26 
27 /*################################################################################################*/
28 
29 project * custom_app::prj = NULL;
30 
31 custom_app::mtool custom_app::current_mouse_tool = custom_app::mtOrbitXY;
32 custom_app::select_mode custom_app::current_select_mode = custom_app::smAtom;
33 
custom_app(void)34 custom_app::custom_app(void) :
35 	base_app()
36 {
37 }
38 
~custom_app(void)39 custom_app::~custom_app(void)
40 {
41 }
42 
SetNewProject(void)43 void custom_app::SetNewProject(void)
44 {
45 	// just reset the custom camera counter...
46 	// this is for graphical user interface only.
47 
48 	custom_camera::ccam_counter = 0;
49 }
50 
GetAppC(void)51 custom_app * custom_app::GetAppC(void)
52 {
53 	return dynamic_cast<custom_app *>(base_app::GetAppB());
54 }
55 
GetPrj(void)56 project * custom_app::GetPrj(void)
57 {
58 	return prj;
59 }
60 
GetCurrentMouseTool(void)61 custom_app::mtool custom_app::GetCurrentMouseTool(void)
62 {
63 	return current_mouse_tool;
64 }
65 
GetCurrentSelectMode(void)66 custom_app::select_mode custom_app::GetCurrentSelectMode(void)
67 {
68 	return current_select_mode;
69 }
70 
AddCamera(ogl_camera * cam)71 void custom_app::AddCamera(ogl_camera * cam)
72 {
73 	base_app::AddCamera(cam);
74 
75 	custom_camera * ccam = dynamic_cast<custom_camera *>(cam);
76 	if (ccam != NULL) CameraAdded(ccam);
77 }
78 
RemoveCamera(ogl_camera * cam)79 bool custom_app::RemoveCamera(ogl_camera * cam)
80 {
81 	bool success = base_app::RemoveCamera(cam);
82 
83 	if (success)
84 	{
85 		custom_camera * ccam = dynamic_cast<custom_camera *>(cam);
86 		if (ccam != NULL) CameraRemoved(ccam);
87 	}
88 
89 	return success;
90 }
91 
AddGlobalLight(ogl_light * light)92 bool custom_app::AddGlobalLight(ogl_light * light)
93 {
94 	bool success = base_app::AddGlobalLight(light);
95 
96 	if (success)
97 	{
98 		LightAdded(light);
99 		project::selected_object = light;
100 		cout << _("Added global light.") << endl;
101 	}
102 
103 	return success;
104 }
105 
AddLocalLight(ogl_light * light,ogl_camera * cam)106 bool custom_app::AddLocalLight(ogl_light * light, ogl_camera * cam)
107 {
108 	bool success = base_app::AddLocalLight(light, cam);
109 
110 	if (success)
111 	{
112 		LightAdded(light);
113 		project::selected_object = light;
114 		cout << _("Added local light.") << endl;
115 	}
116 
117 	return success;
118 }
119 
RemoveLight(ogl_dummy_object * light)120 bool custom_app::RemoveLight(ogl_dummy_object * light)
121 {
122 	int n1 = IsLight(light);
123 	if (n1 < 0) return false;
124 
125 	LightRemoved((ogl_light *) light);
126 
127 	base_app::RemoveLight(light);
128 
129 	return true;
130 }
131 
SelectLight(const ogl_dummy_object * obj)132 bool custom_app::SelectLight(const ogl_dummy_object * obj)
133 {
134 	int n1 = IsLight(obj);
135 	if (n1 < 0) return false;
136 
137 	prj->selected_object = light_vector[n1];
138 
139 	return true;
140 }
141 
142 /*################################################################################################*/
143 
144 // eof
145