1 
2 ///////////////////////////////////////////////////////////
3 //                                                       //
4 //                         SAGA                          //
5 //                                                       //
6 //      System for Automated Geoscientific Analyses      //
7 //                                                       //
8 //                    User Interface                     //
9 //                                                       //
10 //                    Program: SAGA                      //
11 //                                                       //
12 //-------------------------------------------------------//
13 //                                                       //
14 //                 wksp_tool_control.cpp                 //
15 //                                                       //
16 //          Copyright (C) 2005 by Olaf Conrad            //
17 //                                                       //
18 //-------------------------------------------------------//
19 //                                                       //
20 // This file is part of 'SAGA - System for Automated     //
21 // Geoscientific Analyses'. SAGA is free software; you   //
22 // can redistribute it and/or modify it under the terms  //
23 // of the GNU General Public License as published by the //
24 // Free Software Foundation, either version 2 of the     //
25 // License, or (at your option) any later version.       //
26 //                                                       //
27 // SAGA is distributed in the hope that it will be       //
28 // useful, but WITHOUT ANY WARRANTY; without even the    //
29 // implied warranty of MERCHANTABILITY or FITNESS FOR A  //
30 // PARTICULAR PURPOSE. See the GNU General Public        //
31 // License for more details.                             //
32 //                                                       //
33 // You should have received a copy of the GNU General    //
34 // Public License along with this program; if not, see   //
35 // <http://www.gnu.org/licenses/>.                       //
36 //                                                       //
37 //-------------------------------------------------------//
38 //                                                       //
39 //    contact:    Olaf Conrad                            //
40 //                Institute of Geography                 //
41 //                University of Goettingen               //
42 //                Goldschmidtstr. 5                      //
43 //                37077 Goettingen                       //
44 //                Germany                                //
45 //                                                       //
46 //    e-mail:     oconrad@saga-gis.org                   //
47 //                                                       //
48 ///////////////////////////////////////////////////////////
49 
50 //---------------------------------------------------------
51 #include <wx/image.h>
52 #include <wx/imaglist.h>
53 
54 #include "res_controls.h"
55 #include "res_images.h"
56 
57 #include "helper.h"
58 
59 #include "wksp_tool_control.h"
60 #include "wksp_tool_manager.h"
61 #include "wksp_tool_library.h"
62 #include "wksp_tool_menu.h"
63 #include "wksp_tool.h"
64 
65 
66 ///////////////////////////////////////////////////////////
67 //														 //
68 //														 //
69 //														 //
70 ///////////////////////////////////////////////////////////
71 
72 //---------------------------------------------------------
73 enum
74 {
75 	IMG_MANAGER		= 1,
76 	IMG_GROUP,
77 	IMG_LIBRARY,
78 	IMG_CHAIN,
79 	IMG_TOOL
80 };
81 
82 
83 ///////////////////////////////////////////////////////////
84 //														 //
85 //														 //
86 //														 //
87 ///////////////////////////////////////////////////////////
88 
89 //---------------------------------------------------------
90 IMPLEMENT_CLASS(CWKSP_Tool_Control, CWKSP_Base_Control)
91 
92 //---------------------------------------------------------
93 BEGIN_EVENT_TABLE(CWKSP_Tool_Control, CWKSP_Base_Control)
94 END_EVENT_TABLE()
95 
96 
97 ///////////////////////////////////////////////////////////
98 //														 //
99 ///////////////////////////////////////////////////////////
100 
101 //---------------------------------------------------------
102 CWKSP_Tool_Control	*g_pTool_Ctrl	= NULL;
103 
104 
105 ///////////////////////////////////////////////////////////
106 //														 //
107 //														 //
108 //														 //
109 ///////////////////////////////////////////////////////////
110 
111 //---------------------------------------------------------
CWKSP_Tool_Control(wxWindow * pParent)112 CWKSP_Tool_Control::CWKSP_Tool_Control(wxWindow *pParent)
113 	: CWKSP_Base_Control(pParent, ID_WND_WKSP_TOOLS)
114 {
115 	g_pTool_Ctrl	= this;
116 
117 	//-----------------------------------------------------
118 	IMG_ADD_TO_TREECTRL(ID_IMG_WKSP_TOOL_MANAGER)
119 	IMG_ADD_TO_TREECTRL(ID_IMG_WKSP_TOOL_GROUP);
120 	IMG_ADD_TO_TREECTRL(ID_IMG_WKSP_TOOL_LIBRARY);
121 	IMG_ADD_TO_TREECTRL(ID_IMG_WKSP_TOOL_CHAIN);
122 	IMG_ADD_TO_TREECTRL(ID_IMG_WKSP_TOOL);
123 
124 	//-----------------------------------------------------
125 	_Set_Manager(new CWKSP_Tool_Manager);
126 
127 	Get_Manager()->Initialise();
128 }
129 
130 //---------------------------------------------------------
~CWKSP_Tool_Control(void)131 CWKSP_Tool_Control::~CWKSP_Tool_Control(void)
132 {
133 //	Get_Manager()->Finalise();
134 
135 	g_pTool_Ctrl	= NULL;
136 
137 	_Del_Item(m_pManager, true);
138 }
139 
140 
141 ///////////////////////////////////////////////////////////
142 //														 //
143 ///////////////////////////////////////////////////////////
144 
145 //---------------------------------------------------------
On_Execute(wxCommandEvent & event)146 void CWKSP_Tool_Control::On_Execute(wxCommandEvent &event)
147 {
148 	Get_Manager()->On_Execute(event);
149 }
150 
151 //---------------------------------------------------------
On_Execute_UI(wxUpdateUIEvent & event)152 void CWKSP_Tool_Control::On_Execute_UI(wxUpdateUIEvent &event)
153 {
154 	Get_Manager()->On_Execute_UI(event);
155 }
156 
157 
158 ///////////////////////////////////////////////////////////
159 //														 //
160 ///////////////////////////////////////////////////////////
161 
162 //---------------------------------------------------------
Add_Group(CWKSP_Tool_Group * pGroup)163 void CWKSP_Tool_Control::Add_Group(CWKSP_Tool_Group *pGroup)
164 {
165 	_Add_Item(pGroup, IMG_GROUP, IMG_GROUP);
166 }
167 
168 //---------------------------------------------------------
Add_Library(const wxTreeItemId & Group,CWKSP_Tool_Library * pLibrary)169 void CWKSP_Tool_Control::Add_Library(const wxTreeItemId &Group, CWKSP_Tool_Library *pLibrary)
170 {
171 	if( pLibrary != NULL )
172 	{
173 		wxString	Name	= pLibrary->Get_Name();
174 
175 		if( Name.IsEmpty() )
176 		{
177 			Name	= pLibrary->Get_Name();
178 		}
179 		else
180 		{
181 			Name.Trim(false);
182 		}
183 
184 		AppendItem(Group, Name, IMG_LIBRARY, IMG_LIBRARY, pLibrary);
185 
186 		for(int i=0; i<pLibrary->Get_Count(); i++)
187 		{
188 			Add_Tool(pLibrary->GetId(), pLibrary->Get_Tool(i));
189 		}
190 
191 		SortChildren(pLibrary->GetId());
192 	}
193 
194 	SortChildren(Group);
195 }
196 
197 //---------------------------------------------------------
Add_Tool(const wxTreeItemId & Library,CWKSP_Tool * pTool)198 void CWKSP_Tool_Control::Add_Tool(const wxTreeItemId &Library, CWKSP_Tool *pTool)
199 {
200 	if( pTool != NULL )
201 	{
202 		AppendItem(Library, pTool->Get_Name(), IMG_TOOL, IMG_TOOL, pTool);
203 	}
204 }
205 
206 
207 ///////////////////////////////////////////////////////////
208 //														 //
209 //														 //
210 //														 //
211 ///////////////////////////////////////////////////////////
212 
213 //---------------------------------------------------------
214