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_Data_Menu_Files.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 Hamburg //
42 // Germany //
43 // //
44 // e-mail: oconrad@saga-gis.org //
45 // //
46 ///////////////////////////////////////////////////////////
47
48 //---------------------------------------------------------
49 #include <wx/menu.h>
50
51 #include <saga_api/saga_api.h>
52
53 #include "res_commands.h"
54
55 #include "wksp_data_menu_files.h"
56 #include "wksp_data_menu_file.h"
57
58 #include "saga_frame.h"
59
60
61 ///////////////////////////////////////////////////////////
62 // //
63 // //
64 // //
65 ///////////////////////////////////////////////////////////
66
67 //---------------------------------------------------------
CWKSP_Data_Menu_Files(void)68 CWKSP_Data_Menu_Files::CWKSP_Data_Menu_Files(void)
69 {
70 m_bUpdate = true;
71 m_pMenu = new wxMenu;
72
73 CMD_Menu_Add_Item(m_pMenu, false, ID_CMD_DATA_OPEN);
74
75 m_pMenu->AppendSeparator();
76 m_pMenu->Append(ID_CMD_DATA_FIRST , _TL("Project" ), m_Project .Create(SG_DATAOBJECT_TYPE_Undefined ));
77 m_pMenu->Append(ID_CMD_TABLE_FIRST , _TL("Table" ), m_Table .Create(SG_DATAOBJECT_TYPE_Table ));
78 m_pMenu->Append(ID_CMD_SHAPES_FIRST , _TL("Shapes" ), m_Shapes .Create(SG_DATAOBJECT_TYPE_Shapes ));
79 m_pMenu->Append(ID_CMD_POINTCLOUD_FIRST, _TL("Point Cloud" ), m_PointCloud.Create(SG_DATAOBJECT_TYPE_PointCloud));
80 m_pMenu->Append(ID_CMD_TIN_FIRST , _TL("TIN" ), m_TIN .Create(SG_DATAOBJECT_TYPE_TIN ));
81 m_pMenu->Append(ID_CMD_GRID_FIRST , _TL("Grid" ), m_Grid .Create(SG_DATAOBJECT_TYPE_Grid ));
82 m_pMenu->Append(ID_CMD_GRIDS_FIRST , _TL("Grid Collection"), m_Grids .Create(SG_DATAOBJECT_TYPE_Grids ));
83 m_pMenu->AppendSeparator();
84
85 CMD_Menu_Add_Item(m_pMenu, false, ID_CMD_FRAME_QUIT);
86 }
87
88 //---------------------------------------------------------
~CWKSP_Data_Menu_Files(void)89 CWKSP_Data_Menu_Files::~CWKSP_Data_Menu_Files(void)
90 {}
91
92
93 ///////////////////////////////////////////////////////////
94 // //
95 ///////////////////////////////////////////////////////////
96
97 //---------------------------------------------------------
Recent_Open(int Cmd_ID)98 bool CWKSP_Data_Menu_Files::Recent_Open(int Cmd_ID)
99 {
100 return( m_Project .Open(Cmd_ID)
101 || m_Table .Open(Cmd_ID)
102 || m_Shapes .Open(Cmd_ID)
103 || m_TIN .Open(Cmd_ID)
104 || m_PointCloud.Open(Cmd_ID)
105 || m_Grid .Open(Cmd_ID)
106 || m_Grids .Open(Cmd_ID)
107 );
108 }
109
110 //---------------------------------------------------------
Recent_Add(int DataType,const wxString & FileName)111 void CWKSP_Data_Menu_Files::Recent_Add(int DataType, const wxString &FileName)
112 {
113 CWKSP_Data_Menu_File *pMenu = m_bUpdate ? _Get_Menu(DataType) : NULL;
114
115 if( pMenu )
116 {
117 pMenu->Add(FileName);
118 pMenu->Update();
119 }
120 }
121
122 //---------------------------------------------------------
Recent_Del(int DataType,const wxString & FileName)123 void CWKSP_Data_Menu_Files::Recent_Del(int DataType, const wxString &FileName)
124 {
125 CWKSP_Data_Menu_File *pMenu = m_bUpdate ? _Get_Menu(DataType) : NULL;
126
127 if( pMenu )
128 {
129 pMenu->Del(FileName);
130 pMenu->Update();
131 }
132 }
133
134 //---------------------------------------------------------
Recent_Get(int DataType,wxArrayString & FileNames,bool bAppend)135 bool CWKSP_Data_Menu_Files::Recent_Get(int DataType, wxArrayString &FileNames, bool bAppend)
136 {
137 if( _Get_Menu(DataType) )
138 {
139 return( _Get_Menu(DataType)->Get(FileNames, bAppend) );
140 }
141
142 return( false );
143 }
144
145 //---------------------------------------------------------
_Get_Menu(int DataType)146 inline CWKSP_Data_Menu_File * CWKSP_Data_Menu_Files::_Get_Menu(int DataType)
147 {
148 switch( DataType )
149 {
150 case SG_DATAOBJECT_TYPE_Undefined : return( &m_Project );
151 case SG_DATAOBJECT_TYPE_Table : return( &m_Table );
152 case SG_DATAOBJECT_TYPE_Shapes : return( &m_Shapes );
153 case SG_DATAOBJECT_TYPE_TIN : return( &m_TIN );
154 case SG_DATAOBJECT_TYPE_PointCloud: return( &m_PointCloud );
155 case SG_DATAOBJECT_TYPE_Grid : return( &m_Grid );
156 case SG_DATAOBJECT_TYPE_Grids : return( &m_Grids );
157 }
158
159 return( NULL );
160 }
161
162
163 ///////////////////////////////////////////////////////////
164 // //
165 // //
166 // //
167 ///////////////////////////////////////////////////////////
168
169 //---------------------------------------------------------
170