Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Difference From 360acb727dbc921e To 80a1ab14a287da4c
|
2011-11-10
| ||
| 17:01 | switching to version 1.2.1 check-in: 740a9a5992 user: sandro tags: trunk | |
| 16:52 | switching to version 2.3.0 check-in: 80a1ab14a2 user: sandro tags: trunk | |
| 16:37 | switching to version 1.1 check-in: 360acb727d user: sandro tags: trunk | |
| 16:29 | initial repository set up check-in: 1cd01d9029 user: sandro tags: trunk | |
Changes to BlobExplorer.cpp.
1 1 /* 2 2 / BlobExplorer.cpp 3 3 / a dialog to explore a BLOB value 4 4 / 5 -/ version 1.1, 2008 September 13 5 +/ version 1.2, 2008 October 9 6 6 / 7 7 / Author: Sandro Furieri a-furieri@lqt.it 8 8 / 9 9 / Copyright (C) 2008 Alessandro Furieri 10 10 / 11 11 / This program is free software: you can redistribute it and/or modify 12 12 / it under the terms of the GNU General Public License as published by ................................................................................ 24 24 */ 25 25 26 26 #include "Classdef.h" 27 27 28 28 #include "wx/mstream.h" 29 29 #include "wx/clipbrd.h" 30 30 31 -BlobExplorerDialog::BlobExplorerDialog (MyFrame * parent, int blob_size, 32 - unsigned char *blob) 31 +BlobExplorerDialog::BlobExplorerDialog(MyFrame * parent, int blob_size, 32 + unsigned char *blob) 33 33 { 34 34 // 35 35 // constructor; just calls Create() 36 36 // 37 - Create (parent, blob_size, blob); 37 + Create(parent, blob_size, blob); 38 38 } 39 39 40 -bool 41 -BlobExplorerDialog::Create (MyFrame * parent, int blob_size, 42 - unsigned char *blob) 40 +bool BlobExplorerDialog::Create(MyFrame * parent, int blob_size, 41 + unsigned char *blob) 43 42 { 44 43 // 45 44 // creating the dialog 46 45 // 47 - MainFrame = parent; 48 - BlobSize = blob_size; 49 - Blob = blob; 50 - BlobType = MainFrame->GuessBlobType (BlobSize, Blob); 51 - Geometry = NULL; 52 - Image = NULL; 53 - if (BlobType == MyFrame::BLOB_GEOMETRY) 54 - Geometry = gaiaFromSpatiaLiteBlobWkb (Blob, BlobSize); 55 - if (BlobType == MyFrame::BLOB_JPEG || BlobType == MyFrame::BLOB_PNG 56 - || BlobType == MyFrame::BLOB_GIF) 57 - { 58 - ::wxInitAllImageHandlers (); 59 - wxMemoryInputStream reader (Blob, BlobSize); 60 - Image = new wxImage (reader); 61 - } 62 - if (wxPropertySheetDialog::Create 63 - (parent, wxID_ANY, wxT ("BLOB explorer"), wxDefaultPosition, 64 - wxDefaultSize, 65 - wxDEFAULT_DIALOG_STYLE | (int) wxPlatform::IfNot (wxOS_WINDOWS_CE, 66 - wxRESIZE_BORDER)) 67 - == false) 68 - return false; 69 - wxBookCtrlBase *book = GetBookCtrl (); 46 + MainFrame = parent; 47 + BlobSize = blob_size; 48 + Blob = blob; 49 + BlobType = gaiaGuessBlobType(Blob, BlobSize); 50 + Geometry = NULL; 51 + Image = NULL; 52 + if (BlobType == GAIA_GEOMETRY_BLOB) 53 + Geometry = gaiaFromSpatiaLiteBlobWkb(Blob, BlobSize); 54 + if (BlobType == GAIA_JPEG_BLOB || BlobType == GAIA_EXIF_BLOB 55 + || BlobType == GAIA_EXIF_GPS_BLOB || BlobType == GAIA_PNG_BLOB 56 + || BlobType == GAIA_GIF_BLOB) 57 + { 58 + ::wxInitAllImageHandlers(); 59 + wxMemoryInputStream reader(Blob, BlobSize); 60 + Image = new wxImage(reader); 61 + } 62 + if (wxPropertySheetDialog::Create(parent, wxID_ANY, wxT("BLOB explorer")) == 63 + false) 64 + return false; 65 + wxBookCtrlBase *book = GetBookCtrl(); 70 66 // creates individual panels 71 - wxPanel *hexadecimal = CreateHexadecimalPage (book); 72 - book->AddPage (hexadecimal, wxT ("Hexadecimal dump"), true); 73 - if (BlobType == MyFrame::BLOB_GEOMETRY) 74 - { 75 - wxPanel *geometry = CreateGeometryPage (book); 76 - book->AddPage (geometry, wxT ("Geometry explorer"), false); 77 - } 78 - if (BlobType == MyFrame::BLOB_JPEG || BlobType == MyFrame::BLOB_PNG 79 - || BlobType == MyFrame::BLOB_GIF) 80 - { 81 - wxPanel *image = CreateImagePage (book); 82 - book->AddPage (image, wxT ("Image"), false); 83 - } 84 - CreateButtons (wxOK); 85 - LayoutDialog (); 67 + wxPanel *hexadecimal = CreateHexadecimalPage(book); 68 + book->AddPage(hexadecimal, wxT("Hexadecimal dump"), true); 69 + if (BlobType == GAIA_GEOMETRY_BLOB) 70 + { 71 + wxPanel *geometry = CreateGeometryPage(book); 72 + book->AddPage(geometry, wxT("Geometry explorer"), false); 73 + } 74 + if (BlobType == GAIA_JPEG_BLOB || BlobType == GAIA_EXIF_BLOB 75 + || BlobType == GAIA_EXIF_GPS_BLOB || BlobType == GAIA_PNG_BLOB 76 + || BlobType == GAIA_GIF_BLOB) 77 + { 78 + wxPanel *image = CreateImagePage(book); 79 + book->AddPage(image, wxT("Image"), false); 80 + } 81 + CreateButtons(wxOK); 82 + LayoutDialog(); 86 83 // appends event handler for TAB/PAGE changing 87 - Connect (wxID_ANY, wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, 88 - (wxObjectEventFunction) & BlobExplorerDialog::OnPageChanged); 84 + Connect(wxID_ANY, wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, 85 + (wxObjectEventFunction) & BlobExplorerDialog::OnPageChanged); 89 86 // appends event handler for OK button 90 - Connect (wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, 91 - (wxObjectEventFunction) & BlobExplorerDialog::OnOk); 87 + Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, 88 + (wxObjectEventFunction) & BlobExplorerDialog::OnOk); 92 89 // centers the dialog window 93 - Centre (); 94 - UpdateHexadecimalPage (); 95 - return true; 90 + Centre(); 91 + UpdateHexadecimalPage(); 92 + return true; 96 93 } 97 94 98 -wxPanel * 99 -BlobExplorerDialog::CreateHexadecimalPage (wxWindow * parent) 95 +wxPanel *BlobExplorerDialog::CreateHexadecimalPage(wxWindow * parent) 100 96 { 101 97 // 102 98 // creating the HEXADECIMAL page 103 99 // 104 - wxPanel *panel = new wxPanel (parent, ID_PANE_HEXADECIMAL); 105 - wxBoxSizer *topSizer = new wxBoxSizer (wxVERTICAL); 106 - panel->SetSizer (topSizer); 107 - wxBoxSizer *boxSizer = new wxBoxSizer (wxVERTICAL); 108 - topSizer->Add (boxSizer, 0, wxALIGN_CENTER | wxALL, 5); 100 + wxPanel *panel = new wxPanel(parent, ID_PANE_HEXADECIMAL); 101 + wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL); 102 + panel->SetSizer(topSizer); 103 + wxBoxSizer *boxSizer = new wxBoxSizer(wxVERTICAL); 104 + topSizer->Add(boxSizer, 0, wxALIGN_CENTER | wxALL, 5); 109 105 // creating a control to show the hexadecimal dump 110 - wxBoxSizer *hexSizer = new wxBoxSizer (wxHORIZONTAL); 111 - boxSizer->Add (hexSizer, 0, wxALIGN_LEFT | wxALL, 0); 112 - MyHexList *hexCtrl = new MyHexList (this, Blob, BlobSize, panel, 113 - ID_HEX, wxDefaultPosition, 114 - wxSize (560, 115 - 320), 116 - wxLC_REPORT | wxLC_VIRTUAL); 117 - wxFont font (9, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, 118 - wxFONTWEIGHT_NORMAL); 119 - hexCtrl->SetFont (font); 120 - wxListItem column0; 121 - hexCtrl->InsertColumn (0, wxT ("Address")); 122 - hexCtrl->SetColumnWidth (0, 90); 123 - hexCtrl->InsertColumn (1, wxT ("Hexadecimal")); 124 - hexCtrl->SetColumnWidth (1, 340); 125 - hexCtrl->InsertColumn (2, wxT ("ASCII")); 126 - hexCtrl->SetColumnWidth (2, 90); 127 - hexSizer->Add (hexCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 128 - panel->SetSizer (topSizer); 129 - topSizer->Fit (panel); 130 - return panel; 131 -} 132 - 133 -wxPanel * 134 -BlobExplorerDialog::CreateGeometryPage (wxWindow * parent) 106 + wxBoxSizer *hexSizer = new wxBoxSizer(wxHORIZONTAL); 107 + boxSizer->Add(hexSizer, 0, wxALIGN_LEFT | wxALL, 0); 108 + MyHexList *hexCtrl = new MyHexList(this, Blob, BlobSize, panel, 109 + ID_HEX, wxDefaultPosition, 110 + wxSize(620, 320), 111 + wxLC_REPORT | wxLC_VIRTUAL); 112 + wxFont font(9, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); 113 + hexCtrl->SetFont(font); 114 + wxListItem column0; 115 + hexCtrl->InsertColumn(0, wxT("Address")); 116 + hexCtrl->SetColumnWidth(0, 90); 117 + hexCtrl->InsertColumn(1, wxT("Hexadecimal")); 118 + hexCtrl->SetColumnWidth(1, 370); 119 + hexCtrl->InsertColumn(2, wxT("ASCII")); 120 + hexCtrl->SetColumnWidth(2, 130); 121 + hexSizer->Add(hexCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 122 + panel->SetSizer(topSizer); 123 + topSizer->Fit(panel); 124 + return panel; 125 +} 126 + 127 +wxPanel *BlobExplorerDialog::CreateGeometryPage(wxWindow * parent) 135 128 { 136 129 // 137 130 // creating the GEOMETRY page 138 131 // 139 - wxPanel *panel = new wxPanel (parent, ID_PANE_HEXADECIMAL); 140 - wxBoxSizer *topSizer = new wxBoxSizer (wxVERTICAL); 141 - panel->SetSizer (topSizer); 142 - wxBoxSizer *boxSizer = new wxBoxSizer (wxVERTICAL); 143 - topSizer->Add (boxSizer, 0, wxALIGN_CENTER | wxALL, 5); 132 + wxPanel *panel = new wxPanel(parent, ID_PANE_HEXADECIMAL); 133 + wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL); 134 + panel->SetSizer(topSizer); 135 + wxBoxSizer *boxSizer = new wxBoxSizer(wxVERTICAL); 136 + topSizer->Add(boxSizer, 0, wxALIGN_CENTER | wxALL, 5); 144 137 // creating a control to show the geometry as a text table 145 - wxBoxSizer *geomSizer = new wxBoxSizer (wxHORIZONTAL); 146 - boxSizer->Add (geomSizer, 0, wxALIGN_LEFT | wxALL, 0); 147 - wxTextCtrl *geomCtrl = new wxTextCtrl (panel, ID_GEOM_TABLE, wxT (""), 148 - wxDefaultPosition, wxSize (270, 149 - 320), 150 - wxTE_MULTILINE | wxTE_RICH | 151 - wxTE_READONLY | wxHSCROLL); 152 - geomSizer->Add (geomCtrl, 0, wxALIGN_LEFT | wxALL, 5); 138 + wxBoxSizer *geomSizer = new wxBoxSizer(wxHORIZONTAL); 139 + boxSizer->Add(geomSizer, 0, wxALIGN_LEFT | wxALL, 0); 140 + wxTextCtrl *geomCtrl = new wxTextCtrl(panel, ID_GEOM_TABLE, wxT(""), 141 + wxDefaultPosition, wxSize(270, 142 + 320), 143 + wxTE_MULTILINE | wxTE_RICH | 144 + wxTE_READONLY | wxHSCROLL); 145 + geomSizer->Add(geomCtrl, 0, wxALIGN_LEFT | wxALL, 5); 153 146 // creating a control to show the geometry in a graphical fashion 154 - wxStaticBox *exBox = new wxStaticBox (panel, wxID_STATIC, 155 - wxT ("Geometry preview"), 156 - wxDefaultPosition, wxDefaultSize); 157 - wxBoxSizer *exampleSizer = new wxStaticBoxSizer (exBox, wxHORIZONTAL); 158 - geomSizer->Add (exampleSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 159 - DrawGeometry (270, 270); 160 - GraphicsGeometry *geomGraph = 161 - new GraphicsGeometry (this, panel, ID_GEOM_GRAPH, 162 - GeomPreview, wxSize (270, 270)); 163 - exampleSizer->Add (geomGraph, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0); 164 - panel->SetSizer (topSizer); 165 - topSizer->Fit (panel); 166 - return panel; 147 + wxStaticBox *exBox = new wxStaticBox(panel, wxID_STATIC, 148 + wxT("Geometry preview"), 149 + wxDefaultPosition, wxDefaultSize); 150 + wxBoxSizer *exampleSizer = new wxStaticBoxSizer(exBox, wxHORIZONTAL); 151 + geomSizer->Add(exampleSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 152 + DrawGeometry(300, 300); 153 + GraphicsGeometry *geomGraph = new GraphicsGeometry(this, panel, ID_GEOM_GRAPH, 154 + GeomPreview, wxSize(300, 155 + 300)); 156 + exampleSizer->Add(geomGraph, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0); 157 + panel->SetSizer(topSizer); 158 + topSizer->Fit(panel); 159 + return panel; 167 160 } 168 161 169 -wxPanel * 170 -BlobExplorerDialog::CreateImagePage (wxWindow * parent) 162 +wxPanel *BlobExplorerDialog::CreateImagePage(wxWindow * parent) 171 163 { 172 164 // 173 165 // creating the IMAGE page 174 166 // 175 - wxPanel *panel = new wxPanel (parent, ID_PANE_IMAGE); 176 - wxBoxSizer *topSizer = new wxBoxSizer (wxVERTICAL); 177 - panel->SetSizer (topSizer); 178 - wxBoxSizer *boxSizer = new wxBoxSizer (wxVERTICAL); 179 - topSizer->Add (boxSizer, 0, wxALIGN_CENTER | wxALL, 5); 167 + wxPanel *panel = new wxPanel(parent, ID_PANE_IMAGE); 168 + wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL); 169 + panel->SetSizer(topSizer); 170 + wxBoxSizer *boxSizer = new wxBoxSizer(wxVERTICAL); 171 + topSizer->Add(boxSizer, 0, wxALIGN_CENTER | wxALL, 5); 180 172 // creating a control to show the image title 181 - wxBoxSizer *imgSizer = new wxBoxSizer (wxVERTICAL); 182 - boxSizer->Add (imgSizer, 0, wxALIGN_TOP | wxALL, 0); 183 - wxStaticText *imageTitle = new wxStaticText (panel, ID_IMAGE_TITLE, 184 - wxT ("Image"), 185 - wxDefaultPosition, 186 - wxSize (560, 187 - 10)); 188 - imgSizer->Add (imageTitle, 0, wxALIGN_LEFT | wxALL, 5); 173 + wxBoxSizer *imgSizer = new wxBoxSizer(wxVERTICAL); 174 + boxSizer->Add(imgSizer, 0, wxALIGN_TOP | wxALL, 0); 175 + wxStaticText *imageTitle = new wxStaticText(panel, ID_IMAGE_TITLE, 176 + wxT("Image"), 177 + wxDefaultPosition, 178 + wxSize(560, 179 + 10)); 180 + imgSizer->Add(imageTitle, 0, wxALIGN_LEFT | wxALL, 5); 189 181 // creating a control to show the image 190 - wxStaticBox *exBox = new wxStaticBox (panel, ID_IMG_BOX, 191 - wxT ("Image preview"), 192 - wxDefaultPosition, wxDefaultSize); 193 - wxBoxSizer *exampleSizer = new wxStaticBoxSizer (exBox, wxHORIZONTAL); 194 - imgSizer->Add (exampleSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 195 - ImageShow *imgShow = new ImageShow (this, panel, ID_IMAGE, 196 - wxBitmap (), wxSize (560, 300)); 197 - exampleSizer->Add (imgShow, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0); 198 - panel->SetSizer (topSizer); 199 - topSizer->Fit (panel); 200 - return panel; 182 + wxStaticBox *exBox = new wxStaticBox(panel, ID_IMG_BOX, 183 + wxT("Image preview"), 184 + wxDefaultPosition, wxDefaultSize); 185 + wxBoxSizer *exampleSizer = new wxStaticBoxSizer(exBox, wxHORIZONTAL); 186 + imgSizer->Add(exampleSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 187 + ImageShow *imgShow = new ImageShow(this, panel, ID_IMAGE, 188 + wxBitmap(), wxSize(560, 300)); 189 + exampleSizer->Add(imgShow, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0); 190 + panel->SetSizer(topSizer); 191 + topSizer->Fit(panel); 192 + return panel; 201 193 } 202 194 203 -void 204 -BlobExplorerDialog::OnPageChanged (wxNotebookEvent & event) 195 +void BlobExplorerDialog::OnPageChanged(wxNotebookEvent & event) 205 196 { 206 197 // 207 198 // TAB/PAGE selection changed 208 199 // 209 - switch (event.GetSelection ()) 210 - { 200 + switch (event.GetSelection()) 201 + { 211 202 case 0: 212 - UpdateHexadecimalPage (); 213 - break; 203 + UpdateHexadecimalPage(); 204 + break; 214 205 case 1: 215 - if (BlobType == MyFrame::BLOB_GEOMETRY) 216 - UpdateGeometryPage (); 217 - else 218 - UpdateImagePage (); 219 - break; 220 - }; 206 + if (BlobType == GAIA_GEOMETRY_BLOB) 207 + UpdateGeometryPage(); 208 + else 209 + UpdateImagePage(); 210 + break; 211 + }; 221 212 } 222 213 223 -void 224 -BlobExplorerDialog::UpdateHexadecimalPage () 214 +void BlobExplorerDialog::UpdateHexadecimalPage() 225 215 { 226 216 // 227 217 // updating the HEXADECIMAL page 228 218 // 229 - MyHexList *hexCtrl = (MyHexList *) FindWindow (ID_HEX); 230 - hexCtrl->EnsureVisible (0); 219 + MyHexList *hexCtrl = (MyHexList *) FindWindow(ID_HEX); 220 + hexCtrl->EnsureVisible(0); 231 221 } 232 222 233 -void 234 -BlobExplorerDialog::UpdateGeometryPage () 223 +void BlobExplorerDialog::UpdateGeometryPage() 235 224 { 236 225 // 237 226 // updating the GEOMETRY page 238 227 // 239 - gaiaPointPtr pt; 240 - gaiaLinestringPtr ln; 241 - gaiaPolygonPtr pg; 242 - gaiaRingPtr rng; 243 - int points = 0; 244 - int linestrings = 0; 245 - int polygons = 0; 246 - int ib; 247 - wxString strValue; 248 - wxTextAttr attrBold (wxColour (0, 0, 0), wxColour (255, 255, 255), 249 - wxFont (9, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, 250 - wxFONTWEIGHT_BOLD)); 251 - wxTextAttr attrNorm (wxColour (0, 0, 0), wxColour (255, 255, 255), 252 - wxFont (9, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, 253 - wxFONTWEIGHT_NORMAL)); 254 - wxTextCtrl *geomCtrl = (wxTextCtrl *) FindWindow (ID_GEOM_TABLE); 255 - if (geomCtrl->GetValue ().Len () < 1) 256 - { 257 - ::wxBeginBusyCursor (); 258 - pt = Geometry->FirstPoint; 259 - while (pt) 260 - { 261 - // counting how many points are into this Geometry 262 - points++; 263 - pt = pt->Next; 264 - } 265 - ln = Geometry->FirstLinestring; 266 - while (ln) 267 - { 268 - // counting how many linestrings are into this Geometry 269 - linestrings++; 270 - ln = ln->Next; 271 - } 272 - pg = Geometry->FirstPolygon; 273 - while (pg) 274 - { 275 - // counting how many polygons are into this Geometry 276 - polygons++; 277 - pg = pg->Next; 278 - } 279 - // determining the Geometry type 280 - geomCtrl->SetDefaultStyle (attrNorm); 281 - geomCtrl->AppendText (wxT ("SRID: ")); 282 - geomCtrl->SetDefaultStyle (attrBold); 283 - strValue.Printf (wxT ("%d"), Geometry->Srid); 284 - geomCtrl->AppendText (strValue); 285 - geomCtrl->SetDefaultStyle (attrNorm); 286 - geomCtrl->AppendText (wxT ("\n\n")); 287 - strValue = wxT ("UNKNOWN GEOMETRY TYPE"); 288 - if (points == 1 && linestrings == 0 && polygons == 0) 289 - strValue = wxT ("POINT"); 290 - else if (points == 0 && linestrings == 1 && polygons == 0) 291 - strValue = wxT ("LINESTRING"); 292 - else if (points == 0 && linestrings == 0 && polygons == 1) 293 - strValue = wxT ("POLYGON"); 294 - else if (points > 1 && linestrings == 0 && polygons == 0) 295 - strValue = wxT ("MULTIPOINT"); 296 - else if (points == 0 && linestrings > 1 && polygons == 0) 297 - strValue = wxT ("MULTILINESTRING"); 298 - else if (points == 0 && linestrings == 0 && polygons > 1) 299 - strValue = wxT ("MULTIPOLYGON"); 300 - else 301 - strValue = wxT ("GEOMETRYCOLLECTION"); 302 - geomCtrl->SetDefaultStyle (attrNorm); 303 - geomCtrl->AppendText (wxT ("Geometry type: ")); 304 - geomCtrl->SetDefaultStyle (attrBold); 305 - geomCtrl->AppendText (strValue); 306 - geomCtrl->SetDefaultStyle (attrNorm); 307 - geomCtrl->AppendText (wxT ("\n\n")); 308 - if (points) 309 - { 310 - // printing the Points list 311 - strValue.Printf (wxT ("#%d POINT"), points); 312 - if (points > 1) 313 - strValue += wxT ("s:"); 314 - else 315 - strValue += wxT (":"); 316 - geomCtrl->SetDefaultStyle (attrBold); 317 - geomCtrl->AppendText (strValue); 318 - geomCtrl->SetDefaultStyle (attrNorm); 319 - pt = Geometry->FirstPoint; 320 - points = 0; 321 - while (pt) 322 - { 323 - // printing each Point 324 - points++; 325 - strValue.Printf (wxT ("\n %d) "), points); 326 - geomCtrl->SetDefaultStyle (attrBold); 327 - geomCtrl->AppendText (strValue); 328 - geomCtrl->SetDefaultStyle (attrNorm); 329 - strValue.Printf (wxT ("%1.4lf %1.4lf"), pt->X, pt->Y); 330 - geomCtrl->AppendText (strValue); 331 - pt = pt->Next; 332 - } 333 - geomCtrl->AppendText (wxT ("\n\n\n")); 334 - } 335 - if (linestrings) 336 - { 337 - // printing the Linestrings list 338 - strValue.Printf (wxT ("#%d LINESTRING"), linestrings); 339 - if (linestrings > 1) 340 - strValue += wxT ("s:"); 341 - else 342 - strValue += wxT (":"); 343 - geomCtrl->SetDefaultStyle (attrBold); 344 - geomCtrl->AppendText (strValue); 345 - geomCtrl->SetDefaultStyle (attrNorm); 346 - ln = Geometry->FirstLinestring; 347 - linestrings = 0; 348 - while (ln) 349 - { 350 - // printing each Linestring 351 - linestrings++; 352 - strValue.Printf (wxT ("\n %d) "), linestrings); 353 - geomCtrl->SetDefaultStyle (attrBold); 354 - geomCtrl->AppendText (strValue); 355 - geomCtrl->SetDefaultStyle (attrNorm); 356 - strValue.Printf (wxT ("%d vertices"), ln->Points); 357 - geomCtrl->AppendText (strValue); 358 - ln = ln->Next; 359 - } 360 - geomCtrl->AppendText (wxT ("\n\n\n")); 361 - } 362 - if (polygons) 363 - { 364 - // printing the Polygons list 365 - strValue.Printf (wxT ("#%d POLYGON"), polygons); 366 - if (polygons > 1) 367 - strValue += wxT ("s:"); 368 - else 369 - strValue += wxT (":"); 370 - geomCtrl->SetDefaultStyle (attrBold); 371 - geomCtrl->AppendText (strValue); 372 - geomCtrl->SetDefaultStyle (attrNorm); 373 - pg = Geometry->FirstPolygon; 374 - polygons = 0; 375 - while (pg) 376 - { 377 - // printing each Polygon 378 - polygons++; 379 - strValue.Printf (wxT ("\n %d) exterior ring"), 380 - polygons); 381 - geomCtrl->SetDefaultStyle (attrBold); 382 - geomCtrl->AppendText (strValue); 383 - geomCtrl->SetDefaultStyle (attrNorm); 384 - rng = pg->Exterior; 385 - strValue.Printf (wxT (": %d vertices"), rng->Points); 386 - geomCtrl->AppendText (strValue); 387 - for (ib = 0; ib < pg->NumInteriors; ib++) 388 - { 389 - // printing each interior ring 390 - strValue.Printf (wxT ("\n %d.%d) "), polygons, 391 - ib + 1); 392 - geomCtrl->SetDefaultStyle (attrBold); 393 - geomCtrl->AppendText (strValue); 394 - geomCtrl->SetDefaultStyle (attrNorm); 395 - rng = pg->Interiors + ib; 396 - strValue.Printf (wxT 397 - (" interior ring: %d vertices"), 398 - rng->Points); 399 - geomCtrl->AppendText (strValue); 400 - } 401 - pg = pg->Next; 402 - } 403 - geomCtrl->AppendText (wxT ("\n\n\n")); 404 - } 405 - ::wxEndBusyCursor (); 406 - } 407 - GraphicsGeometry *geomGraph = 408 - (GraphicsGeometry *) FindWindow (ID_GEOM_GRAPH); 409 - geomGraph->SetBitmap (GeomPreview); 228 + gaiaPointPtr pt; 229 + gaiaLinestringPtr ln; 230 + gaiaPolygonPtr pg; 231 + gaiaRingPtr rng; 232 + int points = 0; 233 + int linestrings = 0; 234 + int polygons = 0; 235 + int ib; 236 + wxString strValue; 237 + char dummy[1024]; 238 + wxTextAttr attrBold(wxColour(0, 0, 0), wxColour(255, 255, 255), 239 + wxFont(9, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, 240 + wxFONTWEIGHT_BOLD)); 241 + wxTextAttr attrNorm(wxColour(0, 0, 0), wxColour(255, 255, 255), 242 + wxFont(9, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, 243 + wxFONTWEIGHT_NORMAL)); 244 + wxTextCtrl *geomCtrl = (wxTextCtrl *) FindWindow(ID_GEOM_TABLE); 245 + if (geomCtrl->GetValue().Len() < 1) 246 + { 247 + ::wxBeginBusyCursor(); 248 + pt = Geometry->FirstPoint; 249 + while (pt) 250 + { 251 + // counting how many points are into this Geometry 252 + points++; 253 + pt = pt->Next; 254 + } 255 + ln = Geometry->FirstLinestring; 256 + while (ln) 257 + { 258 + // counting how many linestrings are into this Geometry 259 + linestrings++; 260 + ln = ln->Next; 261 + } 262 + pg = Geometry->FirstPolygon; 263 + while (pg) 264 + { 265 + // counting how many polygons are into this Geometry 266 + polygons++; 267 + pg = pg->Next; 268 + } 269 + // determining the Geometry type 270 + geomCtrl->SetDefaultStyle(attrNorm); 271 + geomCtrl->AppendText(wxT("SRID: ")); 272 + geomCtrl->SetDefaultStyle(attrBold); 273 + sprintf(dummy, "%d", Geometry->Srid); 274 + strValue = wxString::FromUTF8(dummy); 275 + geomCtrl->AppendText(strValue); 276 + geomCtrl->SetDefaultStyle(attrNorm); 277 + geomCtrl->AppendText(wxT("\n\n")); 278 + strValue = wxT("UNKNOWN GEOMETRY TYPE"); 279 + if (points == 1 && linestrings == 0 && polygons == 0) 280 + { 281 + if (Geometry->DeclaredType == GAIA_MULTIPOINT) 282 + strValue = wxT("MULTIPOINT"); 283 + else if (Geometry->DeclaredType == GAIA_GEOMETRYCOLLECTION) 284 + strValue = wxT("GEOMETRYCOLLECTION"); 285 + else 286 + strValue = wxT("POINT"); 287 + } else if (points == 0 && linestrings == 1 && polygons == 0) 288 + { 289 + if (Geometry->DeclaredType == GAIA_MULTILINESTRING) 290 + strValue = wxT("MULTILINESTRING"); 291 + else if (Geometry->DeclaredType == GAIA_GEOMETRYCOLLECTION) 292 + strValue = wxT("GEOMETRYCOLLECTION"); 293 + else 294 + strValue = wxT("LINESTRING"); 295 + } else if (points == 0 && linestrings == 0 && polygons == 1) 296 + { 297 + if (Geometry->DeclaredType == GAIA_MULTIPOLYGON) 298 + strValue = wxT("MULTIPOLYGON"); 299 + else if (Geometry->DeclaredType == GAIA_GEOMETRYCOLLECTION) 300 + strValue = wxT("GEOMETRYCOLLECTION"); 301 + else 302 + strValue = wxT("POLYGON"); 303 + } else if (points > 1 && linestrings == 0 && polygons == 0) 304 + { 305 + if (Geometry->DeclaredType == GAIA_GEOMETRYCOLLECTION) 306 + strValue = wxT("GEOMETRYCOLLECTION"); 307 + else 308 + strValue = wxT("MULTIPOINT"); 309 + } else if (points == 0 && linestrings > 1 && polygons == 0) 310 + { 311 + if (Geometry->DeclaredType == GAIA_GEOMETRYCOLLECTION) 312 + strValue = wxT("GEOMETRYCOLLECTION"); 313 + else 314 + strValue = wxT("MULTILINESTRING"); 315 + } else if (points == 0 && linestrings == 0 && polygons > 1) 316 + { 317 + if (Geometry->DeclaredType == GAIA_GEOMETRYCOLLECTION) 318 + strValue = wxT("GEOMETRYCOLLECTION"); 319 + else 320 + strValue = wxT("MULTIPOLYGON"); 321 + } else 322 + strValue = wxT("GEOMETRYCOLLECTION"); 323 + geomCtrl->SetDefaultStyle(attrNorm); 324 + geomCtrl->AppendText(wxT("Geometry type: ")); 325 + geomCtrl->SetDefaultStyle(attrBold); 326 + geomCtrl->AppendText(strValue); 327 + geomCtrl->SetDefaultStyle(attrNorm); 328 + geomCtrl->AppendText(wxT("\n\n")); 329 + if (points) 330 + { 331 + // printing the Points list 332 + sprintf(dummy, "#%d POINT", points); 333 + strValue = wxString::FromUTF8(dummy); 334 + if (points > 1) 335 + strValue += wxT("s:"); 336 + else 337 + strValue += wxT(":"); 338 + geomCtrl->SetDefaultStyle(attrBold); 339 + geomCtrl->AppendText(strValue); 340 + geomCtrl->SetDefaultStyle(attrNorm); 341 + pt = Geometry->FirstPoint; 342 + points = 0; 343 + while (pt) 344 + { 345 + // printing each Point 346 + points++; 347 + sprintf(dummy, "\n %d) ", points); 348 + strValue = wxString::FromUTF8(dummy); 349 + geomCtrl->SetDefaultStyle(attrBold); 350 + geomCtrl->AppendText(strValue); 351 + geomCtrl->SetDefaultStyle(attrNorm); 352 + sprintf(dummy, "%1.4lf %1.4lf", pt->X, pt->Y); 353 + strValue = wxString::FromUTF8(dummy); 354 + geomCtrl->AppendText(strValue); 355 + pt = pt->Next; 356 + } 357 + geomCtrl->AppendText(wxT("\n\n\n")); 358 + } 359 + if (linestrings) 360 + { 361 + // printing the Linestrings list 362 + sprintf(dummy, "#%d LINESTRING", linestrings); 363 + strValue = wxString::FromUTF8(dummy); 364 + if (linestrings > 1) 365 + strValue += wxT("s:"); 366 + else 367 + strValue += wxT(":"); 368 + geomCtrl->SetDefaultStyle(attrBold); 369 + geomCtrl->AppendText(strValue); 370 + geomCtrl->SetDefaultStyle(attrNorm); 371 + ln = Geometry->FirstLinestring; 372 + linestrings = 0; 373 + while (ln) 374 + { 375 + // printing each Linestring 376 + linestrings++; 377 + sprintf(dummy, "\n %d) ", linestrings); 378 + strValue = wxString::FromUTF8(dummy); 379 + geomCtrl->SetDefaultStyle(attrBold); 380 + geomCtrl->AppendText(strValue); 381 + geomCtrl->SetDefaultStyle(attrNorm); 382 + sprintf(dummy, "%d vertices", ln->Points); 383 + strValue = wxString::FromUTF8(dummy); 384 + geomCtrl->AppendText(strValue); 385 + ln = ln->Next; 386 + } 387 + geomCtrl->AppendText(wxT("\n\n\n")); 388 + } 389 + if (polygons) 390 + { 391 + // printing the Polygons list 392 + sprintf(dummy, "#%d POLYGON", polygons); 393 + strValue = wxString::FromUTF8(dummy); 394 + if (polygons > 1) 395 + strValue += wxT("s:"); 396 + else 397 + strValue += wxT(":"); 398 + geomCtrl->SetDefaultStyle(attrBold); 399 + geomCtrl->AppendText(strValue); 400 + geomCtrl->SetDefaultStyle(attrNorm); 401 + pg = Geometry->FirstPolygon; 402 + polygons = 0; 403 + while (pg) 404 + { 405 + // printing each Polygon 406 + polygons++; 407 + sprintf(dummy, "\n %d) exterior ring", polygons); 408 + strValue = wxString::FromUTF8(dummy); 409 + geomCtrl->SetDefaultStyle(attrBold); 410 + geomCtrl->AppendText(strValue); 411 + geomCtrl->SetDefaultStyle(attrNorm); 412 + rng = pg->Exterior; 413 + sprintf(dummy, ": %d vertices", rng->Points); 414 + strValue = wxString::FromUTF8(dummy); 415 + geomCtrl->AppendText(strValue); 416 + for (ib = 0; ib < pg->NumInteriors; ib++) 417 + { 418 + // printing each interior ring 419 + sprintf(dummy, "\n %d.%d) ", polygons, ib + 1); 420 + strValue = wxString::FromUTF8(dummy); 421 + geomCtrl->SetDefaultStyle(attrBold); 422 + geomCtrl->AppendText(strValue); 423 + geomCtrl->SetDefaultStyle(attrNorm); 424 + rng = pg->Interiors + ib; 425 + sprintf(dummy, " interior ring: %d vertices", rng->Points); 426 + strValue = wxString::FromUTF8(dummy); 427 + geomCtrl->AppendText(strValue); 428 + } 429 + pg = pg->Next; 430 + } 431 + geomCtrl->AppendText(wxT("\n\n\n")); 432 + } 433 + ::wxEndBusyCursor(); 434 + } 435 + GraphicsGeometry *geomGraph = (GraphicsGeometry *) FindWindow(ID_GEOM_GRAPH); 436 + geomGraph->SetBitmap(GeomPreview); 410 437 } 411 438 412 -void 413 -BlobExplorerDialog::UpdateImagePage () 439 +void BlobExplorerDialog::UpdateImagePage() 414 440 { 415 441 // 416 442 // updating the IMAGE page 417 443 // 418 - double horz; 419 - double vert; 420 - wxImage scaledImg; 421 - wxSize sz; 422 - wxSize box; 423 - int boxX; 424 - int boxY; 425 - int posX; 426 - int posY; 427 - wxString title = wxT ("Invalid Image"); 428 - wxStaticBox *imgBox = (wxStaticBox *) FindWindow (ID_IMG_BOX); 429 - ImageShow *imgShow = (ImageShow *) FindWindow (ID_IMAGE); 430 - wxStaticText *imageTitle = (wxStaticText *) FindWindow (ID_IMAGE_TITLE); 431 - if (Image) 432 - { 433 - ::wxBeginBusyCursor (); 434 - if (Image->IsOk () == true) 435 - { 436 - horz = Image->GetWidth (); 437 - vert = Image->GetHeight (); 438 - sz = imgShow->GetSize (); 439 - box = imgBox->GetSize (); 440 - while (horz > sz.GetWidth () || vert > sz.GetHeight ()) 441 - { 442 - horz *= 0.9; 443 - vert *= 0.9; 444 - } 445 - if (horz == Image->GetWidth () && vert == Image->GetHeight ()) 446 - scaledImg = Image->Copy (); 447 - else 448 - scaledImg = 449 - Image->Scale ((int) horz, (int) vert, 450 - wxIMAGE_QUALITY_HIGH); 451 - wxBitmap bmp (scaledImg); 452 - imgBox->GetPosition (&boxX, &boxY); 453 - posX = (box.GetWidth () - (int) horz) / 2; 454 - posY = (box.GetHeight () - (int) vert) / 2; 455 - imgShow->SetSize (boxX + posX, boxY + posY, (int) horz, 456 - (int) vert); 457 - imgShow->SetBitmap (bmp); 458 - imgShow->Show (true); 459 - switch (BlobType) 460 - { 461 - case MyFrame::BLOB_JPEG: 462 - title.Printf (wxT 463 - ("JPEG image resolution: %d x %d %d bytes"), 464 - Image->GetWidth (), Image->GetHeight (), 465 - BlobSize); 466 - break; 467 - case MyFrame::BLOB_PNG: 468 - title.Printf (wxT 469 - ("PNG image resolution: %d x %d %d bytes"), 470 - Image->GetWidth (), Image->GetHeight (), 471 - BlobSize); 472 - break; 473 - case MyFrame::BLOB_GIF: 474 - title.Printf (wxT 475 - ("GIF image resolution: %d x %d %d bytes"), 476 - Image->GetWidth (), Image->GetHeight (), 477 - BlobSize); 478 - break; 479 - } 480 - } 481 - ::wxEndBusyCursor (); 482 - } 483 - imageTitle->SetLabel (title); 444 + double horz; 445 + double vert; 446 + wxImage scaledImg; 447 + wxSize sz; 448 + wxSize box; 449 + int boxX; 450 + int boxY; 451 + int posX; 452 + int posY; 453 + char latlong[1024]; 454 + char dummy[1024]; 455 + wxString ll; 456 + wxString title = wxT("Invalid Image"); 457 + wxStaticBox *imgBox = (wxStaticBox *) FindWindow(ID_IMG_BOX); 458 + ImageShow *imgShow = (ImageShow *) FindWindow(ID_IMAGE); 459 + wxStaticText *imageTitle = (wxStaticText *) FindWindow(ID_IMAGE_TITLE); 460 + if (Image) 461 + { 462 + ::wxBeginBusyCursor(); 463 + if (Image->IsOk() == true) 464 + { 465 + horz = Image->GetWidth(); 466 + vert = Image->GetHeight(); 467 + sz = imgShow->GetSize(); 468 + box = imgBox->GetSize(); 469 + while (horz > sz.GetWidth() || vert > sz.GetHeight()) 470 + { 471 + horz *= 0.9; 472 + vert *= 0.9; 473 + } 474 + if (horz == Image->GetWidth() && vert == Image->GetHeight()) 475 + scaledImg = Image->Copy(); 476 + else 477 + scaledImg = 478 + Image->Scale((int) horz, (int) vert, wxIMAGE_QUALITY_HIGH); 479 + wxBitmap bmp(scaledImg); 480 + imgBox->GetPosition(&boxX, &boxY); 481 + posX = (box.GetWidth() - (int) horz) / 2; 482 + posY = (box.GetHeight() - (int) vert) / 2; 483 + imgShow->SetSize(boxX + posX, boxY + posY, (int) horz, (int) vert); 484 + imgShow->SetBitmap(bmp); 485 + imgShow->Show(true); 486 + switch (BlobType) 487 + { 488 + case GAIA_JPEG_BLOB: 489 + sprintf(dummy, 490 + "JPEG image resolution: %d x %d %d bytes", 491 + Image->GetWidth(), Image->GetHeight(), BlobSize); 492 + title = wxString::FromUTF8(dummy); 493 + break; 494 + case GAIA_EXIF_BLOB: 495 + sprintf(dummy, 496 + "EXIF image resolution: %d x %d %d bytes", 497 + Image->GetWidth(), Image->GetHeight(), BlobSize); 498 + title = wxString::FromUTF8(dummy); 499 + break; 500 + case GAIA_EXIF_GPS_BLOB: 501 + if (gaiaGetGpsLatLong(Blob, BlobSize, latlong, 1024)) 502 + ll = wxString::FromUTF8(latlong); 503 + else 504 + ll = wxT("NOT AVAILABLE"); 505 + sprintf(dummy, 506 + "EXIF-GPS image resolution: %d x %d %d bytes GPS: ", 507 + Image->GetWidth(), Image->GetHeight(), BlobSize); 508 + title = wxString::FromUTF8(dummy); 509 + title += ll; 510 + break; 511 + case GAIA_PNG_BLOB: 512 + sprintf(dummy, 513 + "PNG image resolution: %d x %d %d bytes", 514 + Image->GetWidth(), Image->GetHeight(), BlobSize); 515 + title = wxString::FromUTF8(dummy); 516 + break; 517 + case GAIA_GIF_BLOB: 518 + sprintf(dummy, 519 + "GIF image resolution: %d x %d %d bytes", 520 + Image->GetWidth(), Image->GetHeight(), BlobSize); 521 + title = wxString::FromUTF8(dummy); 522 + break; 523 + } 524 + } 525 + ::wxEndBusyCursor(); 526 + } 527 + imageTitle->SetLabel(title); 484 528 } 485 529 486 -void 487 -BlobExplorerDialog::OnOk (wxCommandEvent & event) 530 +void BlobExplorerDialog::OnOk(wxCommandEvent & event) 488 531 { 489 532 // 490 533 // all done: exiting 491 534 // 492 - wxDialog::EndModal (wxID_OK); 535 + wxDialog::EndModal(wxID_OK); 493 536 } 494 537 495 -void 496 -BlobExplorerDialog::DrawGeometry (int horz, int vert) 538 +void BlobExplorerDialog::DrawGeometry(int horz, int vert) 497 539 { 498 540 // 499 541 // drawing graphic representation for current Geometry 500 542 // 501 - gaiaPointPtr pt; 502 - gaiaLinestringPtr ln; 503 - gaiaPolygonPtr pg; 504 - gaiaRingPtr rng; 505 - double minx; 506 - double miny; 507 - double maxx; 508 - double maxy; 509 - double ext_x; 510 - double ext_y; 511 - double cx; 512 - double cy; 513 - double pixelRatioX; 514 - double pixelRatioY; 515 - double pixelRatio; 516 - double span_x; 517 - double span_y; 518 - double baseX; 519 - double baseY; 520 - double x; 521 - double y; 522 - double xx; 523 - double yy; 524 - int iv; 525 - int ib; 526 - int pts; 527 - int *borders; 528 - wxPoint *points; 529 - GeomPreview.Create (horz, vert); 530 - wxMemoryDC dc (GeomPreview); 543 + gaiaPointPtr pt; 544 + gaiaLinestringPtr ln; 545 + gaiaPolygonPtr pg; 546 + gaiaRingPtr rng; 547 + double minx; 548 + double miny; 549 + double maxx; 550 + double maxy; 551 + double ext_x; 552 + double ext_y; 553 + double cx; 554 + double cy; 555 + double pixelRatioX; 556 + double pixelRatioY; 557 + double pixelRatio; 558 + double span_x; 559 + double span_y; 560 + double baseX; 561 + double baseY; 562 + double x; 563 + double y; 564 + double xx; 565 + double yy; 566 + int iv; 567 + int ib; 568 + int pts; 569 + int *borders; 570 + wxPoint *points; 571 + GeomPreview.Create(horz, vert); 572 + wxMemoryDC dc(GeomPreview); 531 573 // 532 574 // background filling 533 575 // 534 - dc.SetBrush (wxBrush (wxColour (255, 255, 255))); 535 - dc.DrawRectangle (0, 0, horz, vert); 576 + dc.SetBrush(wxBrush(wxColour(255, 255, 255))); 577 + dc.DrawRectangle(0, 0, horz, vert); 536 578 // 537 579 // prepearing the drawing pen and brush 538 580 // 539 - dc.SetBrush (wxBrush (wxColour (240, 240, 192))); 540 - dc.SetPen (wxPen (wxColour (64, 64, 192), 1)); 581 + dc.SetBrush(wxBrush(wxColour(240, 240, 192))); 582 + dc.SetPen(wxPen(wxColour(64, 64, 192), 1)); 541 583 // 542 584 // computing the pixel ratio, center position and so on 543 585 // 544 - minx = Geometry->MinX; 545 - miny = Geometry->MinY; 546 - maxx = Geometry->MaxX; 547 - maxy = Geometry->MaxY; 548 - ext_x = maxx - minx; 549 - ext_y = maxy - miny; 550 - if (ext_x < 1.0) 551 - ext_x = 1.0; 552 - if (ext_y < 1.0) 553 - ext_y = 1.0; 554 - minx = Geometry->MinX - (ext_x / 20.0); 555 - miny = Geometry->MinY - (ext_y / 20.0); 556 - maxx = Geometry->MaxX + (ext_x / 20.0); 557 - maxy = Geometry->MaxY + (ext_y / 20.0); 558 - ext_x = maxx - minx; 559 - ext_y = maxy - miny; 560 - cx = minx + (ext_x / 2.0); 561 - cy = miny + (ext_y / 2.0); 562 - pixelRatioX = ext_x / horz; 563 - pixelRatioY = ext_y / vert; 564 - if (pixelRatioX > pixelRatioY) 565 - pixelRatio = pixelRatioX; 566 - else 567 - pixelRatio = pixelRatioY; 586 + minx = Geometry->MinX; 587 + miny = Geometry->MinY; 588 + maxx = Geometry->MaxX; 589 + maxy = Geometry->MaxY; 590 + ext_x = maxx - minx; 591 + ext_y = maxy - miny; 592 + if (ext_x < 1.0) 593 + ext_x = 1.0; 594 + if (ext_y < 1.0) 595 + ext_y = 1.0; 596 + minx = Geometry->MinX - (ext_x / 20.0); 597 + miny = Geometry->MinY - (ext_y / 20.0); 598 + maxx = Geometry->MaxX + (ext_x / 20.0); 599 + maxy = Geometry->MaxY + (ext_y / 20.0); 600 + ext_x = maxx - minx; 601 + ext_y = maxy - miny; 602 + cx = minx + (ext_x / 2.0); 603 + cy = miny + (ext_y / 2.0); 604 + pixelRatioX = ext_x / horz; 605 + pixelRatioY = ext_y / vert; 606 + if (pixelRatioX > pixelRatioY) 607 + pixelRatio = pixelRatioX; 608 + else 609 + pixelRatio = pixelRatioY; 568 610 // 569 611 // centering the Y axis 570 612 // 571 - span_y = vert * pixelRatio; 572 - baseY = cy - (span_y / 2.0); 613 + span_y = vert * pixelRatio; 614 + baseY = cy - (span_y / 2.0); 573 615 // 574 616 // centering the X axis 575 617 // 576 - span_x = horz * pixelRatio; 577 - baseX = cx - (span_x / 2.0); 578 - pg = Geometry->FirstPolygon; 579 - while (pg) 580 - { 581 - // 582 - // drawing polygons 583 - // 584 - pts = pg->Exterior->Points; 585 - for (ib = 0; ib < pg->NumInteriors; ib++) 586 - { 587 - rng = pg->Interiors + ib; 588 - pts += rng->Points; 589 - } 590 - borders = new int[pg->NumInteriors + 1]; 591 - points = new wxPoint[pts]; 592 - pts = 0; 593 - rng = pg->Exterior; 594 - borders[0] = rng->Points; 595 - for (iv = 0; iv < rng->Points; iv++) 596 - { 597 - gaiaGetPoint (rng->Coords, iv, &x, &y); 598 - xx = (x - baseX) / pixelRatio; 599 - yy = (y - baseY) / pixelRatio; 600 - yy = vert - yy; 601 - points[pts].x = (int) xx; 602 - points[pts].y = (int) yy; 603 - pts++; 604 - } 605 - for (ib = 0; ib < pg->NumInteriors; ib++) 606 - { 607 - rng = pg->Interiors + ib; 608 - borders[1 + ib] = rng->Points; 609 - for (iv = 0; iv < rng->Points; iv++) 610 - { 611 - gaiaGetPoint (rng->Coords, iv, &x, &y); 612 - xx = (x - baseX) / pixelRatio; 613 - yy = (y - baseY) / pixelRatio; 614 - yy = vert - yy; 615 - points[pts].x = (int) xx; 616 - points[pts].y = (int) yy; 617 - pts++; 618 - } 619 - } 620 - dc.DrawPolyPolygon (pg->NumInteriors + 1, borders, points); 621 - delete[]points; 622 - delete[]borders; 623 - pg = pg->Next; 624 - } 625 - ln = Geometry->FirstLinestring; 626 - while (ln) 627 - { 628 - // 629 - // drawing linestrings 630 - // 631 - points = new wxPoint[ln->Points]; 632 - for (iv = 0; iv < ln->Points; iv++) 633 - { 634 - gaiaGetPoint (ln->Coords, iv, &x, &y); 635 - xx = (x - baseX) / pixelRatio; 636 - yy = (y - baseY) / pixelRatio; 637 - yy = vert - yy; 638 - points[iv].x = (int) xx; 639 - points[iv].y = (int) yy; 640 - } 641 - dc.DrawLines (ln->Points, points); 642 - delete[]points; 643 - ln = ln->Next; 644 - } 645 - pt = Geometry->FirstPoint; 646 - while (pt) 647 - { 648 - // 649 - // drawing points 650 - // 651 - xx = (pt->X - baseX) / pixelRatio; 652 - yy = (pt->Y - baseY) / pixelRatio; 653 - yy = vert - yy; 654 - dc.DrawCircle ((int) xx, (int) yy, 2); 655 - pt = pt->Next; 656 - } 618 + span_x = horz * pixelRatio; 619 + baseX = cx - (span_x / 2.0); 620 + pg = Geometry->FirstPolygon; 621 + while (pg) 622 + { 623 + // 624 + // drawing polygons 625 + // 626 + pts = pg->Exterior->Points; 627 + for (ib = 0; ib < pg->NumInteriors; ib++) 628 + { 629 + rng = pg->Interiors + ib; 630 + pts += rng->Points; 631 + } 632 + borders = new int[pg->NumInteriors + 1]; 633 + points = new wxPoint[pts]; 634 + pts = 0; 635 + rng = pg->Exterior; 636 + borders[0] = rng->Points; 637 + for (iv = 0; iv < rng->Points; iv++) 638 + { 639 + gaiaGetPoint(rng->Coords, iv, &x, &y); 640 + xx = (x - baseX) / pixelRatio; 641 + yy = (y - baseY) / pixelRatio; 642 + yy = vert - yy; 643 + points[pts].x = (int) xx; 644 + points[pts].y = (int) yy; 645 + pts++; 646 + } 647 + for (ib = 0; ib < pg->NumInteriors; ib++) 648 + { 649 + rng = pg->Interiors + ib; 650 + borders[1 + ib] = rng->Points; 651 + for (iv = 0; iv < rng->Points; iv++) 652 + { 653 + gaiaGetPoint(rng->Coords, iv, &x, &y); 654 + xx = (x - baseX) / pixelRatio; 655 + yy = (y - baseY) / pixelRatio; 656 + yy = vert - yy; 657 + points[pts].x = (int) xx; 658 + points[pts].y = (int) yy; 659 + pts++; 660 + } 661 + } 662 + dc.DrawPolyPolygon(pg->NumInteriors + 1, borders, points); 663 + delete[]points; 664 + delete[]borders; 665 + pg = pg->Next; 666 + } 667 + ln = Geometry->FirstLinestring; 668 + while (ln) 669 + { 670 + // 671 + // drawing linestrings 672 + // 673 + points = new wxPoint[ln->Points]; 674 + for (iv = 0; iv < ln->Points; iv++) 675 + { 676 + gaiaGetPoint(ln->Coords, iv, &x, &y); 677 + xx = (x - baseX) / pixelRatio; 678 + yy = (y - baseY) / pixelRatio; 679 + yy = vert - yy; 680 + points[iv].x = (int) xx; 681 + points[iv].y = (int) yy; 682 + } 683 + dc.DrawLines(ln->Points, points); 684 + delete[]points; 685 + ln = ln->Next; 686 + } 687 + pt = Geometry->FirstPoint; 688 + while (pt) 689 + { 690 + // 691 + // drawing points 692 + // 693 + xx = (pt->X - baseX) / pixelRatio; 694 + yy = (pt->Y - baseY) / pixelRatio; 695 + yy = vert - yy; 696 + dc.DrawCircle((int) xx, (int) yy, 2); 697 + pt = pt->Next; 698 + } 699 +} 700 + 701 +GraphicsGeometry::GraphicsGeometry(BlobExplorerDialog * parent, 702 + wxWindow * panel, wxWindowID id, 703 + const wxBitmap & bmp, 704 + const wxSize & size):wxStaticBitmap(panel, 705 + id, bmp, 706 + wxDefaultPosition, 707 + size) 708 +{ 709 + Parent = parent; 710 +} 711 + 712 +ImageShow::ImageShow(BlobExplorerDialog * parent, wxWindow * panel, 713 + wxWindowID id, const wxBitmap & bmp, 714 + const wxSize & size):wxStaticBitmap(panel, id, bmp, 715 + wxDefaultPosition, 716 + size) 717 +{ 718 + Parent = parent; 719 +// appends event handler 720 + Connect(ID_IMAGE, wxEVT_RIGHT_DOWN, 721 + (wxObjectEventFunction) & ImageShow::OnRightClick); 722 + Connect(Image_Copy, wxEVT_COMMAND_MENU_SELECTED, 723 + (wxObjectEventFunction) & ImageShow::OnCmdCopy); 657 724 } 658 725 659 -GraphicsGeometry::GraphicsGeometry (BlobExplorerDialog * parent, 660 - wxWindow * panel, wxWindowID id, 661 - const wxBitmap & bmp, const wxSize & size): 662 -wxStaticBitmap (panel, id, bmp, wxDefaultPosition, size) 663 -{ 664 - Parent = parent; 665 -} 666 - 667 -ImageShow::ImageShow (BlobExplorerDialog * parent, wxWindow * panel, 668 - wxWindowID id, const wxBitmap & bmp, const wxSize & size): 669 -wxStaticBitmap (panel, id, bmp, wxDefaultPosition, size) 670 -{ 671 - Parent = parent; 672 -// appends event handler 673 - Connect (ID_IMAGE, wxEVT_RIGHT_DOWN, 674 - (wxObjectEventFunction) & ImageShow::OnRightClick); 675 - Connect (Image_Copy, wxEVT_COMMAND_MENU_SELECTED, 676 - (wxObjectEventFunction) & ImageShow::OnCmdCopy); 677 -} 678 - 679 -void 680 -ImageShow::OnRightClick (wxMouseEvent & event) 726 +void ImageShow::OnRightClick(wxMouseEvent & event) 681 727 { 682 728 // 683 729 // right click on the Image 684 730 // 685 - wxMenu menu; 686 - wxMenuItem *menuItem; 687 - wxImage *Image = Parent->GetImage (); 688 - if (Image) 689 - { 690 - if (Image->IsOk () == true) 691 - { 692 - wxPoint pt = event.GetPosition (); 693 - menuItem = new wxMenuItem (&menu, Image_Copy, wxT ("&Copy")); 694 - menu.Append (menuItem); 695 - PopupMenu (&menu, pt); 696 - } 697 - } 731 + wxMenu *menu = new wxMenu(); 732 + wxMenuItem *menuItem; 733 + wxImage *Image = Parent->GetImage(); 734 + if (Image) 735 + { 736 + if (Image->IsOk() == true) 737 + { 738 + wxPoint pt = event.GetPosition(); 739 + menuItem = new wxMenuItem(menu, Image_Copy, wxT("&Copy")); 740 + menu->Append(menuItem); 741 + PopupMenu(menu, pt); 742 + } 743 + } 698 744 } 699 745 700 -void 701 -ImageShow::OnCmdCopy (wxCommandEvent & event) 746 +void ImageShow::OnCmdCopy(wxCommandEvent & event) 702 747 { 703 748 // 704 749 // copying the Image into the clipboard 705 750 // 706 - wxImage *Image = Parent->GetImage (); 707 - if (wxTheClipboard->Open ()) 708 - { 709 - wxTheClipboard->SetData (new wxBitmapDataObject (*Image)); 710 - wxTheClipboard->Close (); 711 - } 751 + wxImage *Image = Parent->GetImage(); 752 + if (wxTheClipboard->Open()) 753 + { 754 + wxTheClipboard->SetData(new wxBitmapDataObject(*Image)); 755 + wxTheClipboard->Close(); 756 + } 712 757 } 713 758 714 -MyHexList::MyHexList (BlobExplorerDialog * parent, unsigned char *blob, 715 - int blob_size, wxWindow * panel, wxWindowID id, 716 - const wxPoint & pos, const wxSize & size, long style): 717 -wxListCtrl (panel, id, pos, size, style) 759 +MyHexList::MyHexList(BlobExplorerDialog * parent, unsigned char *blob, 760 + int blob_size, wxWindow * panel, wxWindowID id, 761 + const wxPoint & pos, const wxSize & size, 762 + long style):wxListCtrl(panel, id, pos, size, style) 718 763 { 719 764 // constructor - the blob hexadecimal dump 720 - int i = 0; 721 - int rows = 0; 722 - Parent = parent; 723 - Blob = blob; 724 - BlobSize = blob_size; 725 - while (i < BlobSize) 726 - { 727 - // counting how many rows are there 728 - rows++; 729 - i += 16; 730 - } 731 - SetItemCount (rows); 765 + int i = 0; 766 + int rows = 0; 767 + Parent = parent; 768 + Blob = blob; 769 + BlobSize = blob_size; 770 + while (i < BlobSize) 771 + { 772 + // counting how many rows are there 773 + rows++; 774 + i += 16; 775 + } 776 + SetItemCount(rows); 732 777 } 733 778 734 -MyHexList::~MyHexList () 779 +MyHexList::~MyHexList() 735 780 { 736 781 // does nothing 737 782 } 738 783 739 -wxString MyHexList::OnGetItemText (long item, long column) const 784 +wxString MyHexList::OnGetItemText(long item, long column) const 740 785 { 741 786 // return a column value 742 - int 743 - i; 744 - int 745 - c; 746 - int 747 - base = item * 16; 748 - wxString 749 - value; 750 - wxString 751 - hex; 752 - if (column == 0) 753 - value.Printf (wxT ("%08xd"), base); 754 - else if (column == 1) 755 - { 756 - // prepearing the hex-dump 757 - c = 0; 758 - for (i = base; i < BlobSize; i++) 759 - { 760 - if (c >= 16) 761 - break; 762 - hex.Printf (wxT ("%02x"), *(Blob + i)); 763 - if (c == 8) 764 - value += wxT (" "); 765 - else 766 - value += wxT (" "); 767 - value += hex; 768 - c++; 769 - } 770 - } 771 - else 772 - { 773 - // prepearing the ascii dump 774 - c = 0; 775 - for (i = base; i < BlobSize; i++) 776 - { 777 - if (c >= 16) 778 - break; 779 - if (isprint (*(Blob + i))) 780 - hex.Printf (wxT ("%c"), *(Blob + i)); 781 - else 782 - hex = wxT ("."); 783 - value += hex; 784 - c++; 785 - } 786 - } 787 - return value; 787 + int i; 788 + int c; 789 + int base = item * 16; 790 + wxString value; 791 + char dummy[64]; 792 + wxString hex; 793 + if (column == 0) 794 + { 795 + sprintf(dummy, "%08xd", base); 796 + value = wxString::FromUTF8(dummy); 797 + } else if (column == 1) 798 + { 799 + // prepearing the hex-dump 800 + c = 0; 801 + for (i = base; i < BlobSize; i++) 802 + { 803 + if (c >= 16) 804 + break; 805 + sprintf(dummy, "%02x", *(Blob + i)); 806 + hex = wxString::FromUTF8(dummy); 807 + if (c == 8) 808 + value += wxT(" "); 809 + else 810 + value += wxT(" "); 811 + value += hex; 812 + c++; 813 + } 814 + } else 815 + { 816 + // prepearing the ascii dump 817 + c = 0; 818 + for (i = base; i < BlobSize; i++) 819 + { 820 + if (c >= 16) 821 + break; 822 + if (isprint(*(Blob + i))) 823 + { 824 + sprintf(dummy, "%c", *(Blob + i)); 825 + hex = wxString::FromUTF8(dummy); 826 + } else 827 + hex = wxT("."); 828 + value += hex; 829 + c++; 830 + } 831 + } 832 + return value; 788 833 }
Added COPYING.
1 + GNU GENERAL PUBLIC LICENSE 2 + Version 3, 29 June 2007 3 + 4 + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> 5 + Everyone is permitted to copy and distribute verbatim copies 6 + of this license document, but changing it is not allowed. 7 + 8 + Preamble 9 + 10 + The GNU General Public License is a free, copyleft license for 11 +software and other kinds of works. 12 + 13 + The licenses for most software and other practical works are designed 14 +to take away your freedom to share and change the works. By contrast, 15 +the GNU General Public License is intended to guarantee your freedom to 16 +share and change all versions of a program--to make sure it remains free 17 +software for all its users. We, the Free Software Foundation, use the 18 +GNU General Public License for most of our software; it applies also to 19 +any other work released this way by its authors. You can apply it to 20 +your programs, too. 21 + 22 + When we speak of free software, we are referring to freedom, not 23 +price. Our General Public Licenses are designed to make sure that you 24 +have the freedom to distribute copies of free software (and charge for 25 +them if you wish), that you receive source code or can get it if you 26 +want it, that you can change the software or use pieces of it in new 27 +free programs, and that you know you can do these things. 28 + 29 + To protect your rights, we need to prevent others from denying you 30 +these rights or asking you to surrender the rights. Therefore, you have 31 +certain responsibilities if you distribute copies of the software, or if 32 +you modify it: responsibilities to respect the freedom of others. 33 + 34 + For example, if you distribute copies of such a program, whether 35 +gratis or for a fee, you must pass on to the recipients the same 36 +freedoms that you received. You must make sure that they, too, receive 37 +or can get the source code. And you must show them these terms so they 38 +know their rights. 39 + 40 + Developers that use the GNU GPL protect your rights with two steps: 41 +(1) assert copyright on the software, and (2) offer you this License 42 +giving you legal permission to copy, distribute and/or modify it. 43 + 44 + For the developers' and authors' protection, the GPL clearly explains 45 +that there is no warranty for this free software. For both users' and 46 +authors' sake, the GPL requires that modified versions be marked as 47 +changed, so that their problems will not be attributed erroneously to 48 +authors of previous versions. 49 + 50 + Some devices are designed to deny users access to install or run 51 +modified versions of the software inside them, although the manufacturer 52 +can do so. This is fundamentally incompatible with the aim of 53 +protecting users' freedom to change the software. The systematic 54 +pattern of such abuse occurs in the area of products for individuals to 55 +use, which is precisely where it is most unacceptable. Therefore, we 56 +have designed this version of the GPL to prohibit the practice for those 57 +products. If such problems arise substantially in other domains, we 58 +stand ready to extend this provision to those domains in future versions 59 +of the GPL, as needed to protect the freedom of users. 60 + 61 + Finally, every program is threatened constantly by software patents. 62 +States should not allow patents to restrict development and use of 63 +software on general-purpose computers, but in those that do, we wish to 64 +avoid the special danger that patents applied to a free program could 65 +make it effectively proprietary. To prevent this, the GPL assures that 66 +patents cannot be used to render the program non-free. 67 + 68 + The precise terms and conditions for copying, distribution and 69 +modification follow. 70 + 71 + TERMS AND CONDITIONS 72 + 73 + 0. Definitions. 74 + 75 + "This License" refers to version 3 of the GNU General Public License. 76 + 77 + "Copyright" also means copyright-like laws that apply to other kinds of 78 +works, such as semiconductor masks. 79 + 80 + "The Program" refers to any copyrightable work licensed under this 81 +License. Each licensee is addressed as "you". "Licensees" and 82 +"recipients" may be individuals or organizations. 83 + 84 + To "modify" a work means to copy from or adapt all or part of the work 85 +in a fashion requiring copyright permission, other than the making of an 86 +exact copy. The resulting work is called a "modified version" of the 87 +earlier work or a work "based on" the earlier work. 88 + 89 + A "covered work" means either the unmodified Program or a work based 90 +on the Program. 91 + 92 + To "propagate" a work means to do anything with it that, without 93 +permission, would make you directly or secondarily liable for 94 +infringement under applicable copyright law, except executing it on a 95 +computer or modifying a private copy. Propagation includes copying, 96 +distribution (with or without modification), making available to the 97 +public, and in some countries other activities as well. 98 + 99 + To "convey" a work means any kind of propagation that enables other 100 +parties to make or receive copies. Mere interaction with a user through 101 +a computer network, with no transfer of a copy, is not conveying. 102 + 103 + An interactive user interface displays "Appropriate Legal Notices" 104 +to the extent that it includes a convenient and prominently visible 105 +feature that (1) displays an appropriate copyright notice, and (2) 106 +tells the user that there is no warranty for the work (except to the 107 +extent that warranties are provided), that licensees may convey the 108 +work under this License, and how to view a copy of this License. If 109 +the interface presents a list of user commands or options, such as a 110 +menu, a prominent item in the list meets this criterion. 111 + 112 + 1. Source Code. 113 + 114 + The "source code" for a work means the preferred form of the work 115 +for making modifications to it. "Object code" means any non-source 116 +form of a work. 117 + 118 + A "Standard Interface" means an interface that either is an official 119 +standard defined by a recognized standards body, or, in the case of 120 +interfaces specified for a particular programming language, one that 121 +is widely used among developers working in that language. 122 + 123 + The "System Libraries" of an executable work include anything, other 124 +than the work as a whole, that (a) is included in the normal form of 125 +packaging a Major Component, but which is not part of that Major 126 +Component, and (b) serves only to enable use of the work with that 127 +Major Component, or to implement a Standard Interface for which an 128 +implementation is available to the public in source code form. A 129 +"Major Component", in this context, means a major essential component 130 +(kernel, window system, and so on) of the specific operating system 131 +(if any) on which the executable work runs, or a compiler used to 132 +produce the work, or an object code interpreter used to run it. 133 + 134 + The "Corresponding Source" for a work in object code form means all 135 +the source code needed to generate, install, and (for an executable 136 +work) run the object code and to modify the work, including scripts to 137 +control those activities. However, it does not include the work's 138 +System Libraries, or general-purpose tools or generally available free 139 +programs which are used unmodified in performing those activities but 140 +which are not part of the work. For example, Corresponding Source 141 +includes interface definition files associated with source files for 142 +the work, and the source code for shared libraries and dynamically 143 +linked subprograms that the work is specifically designed to require, 144 +such as by intimate data communication or control flow between those 145 +subprograms and other parts of the work. 146 + 147 + The Corresponding Source need not include anything that users 148 +can regenerate automatically from other parts of the Corresponding 149 +Source. 150 + 151 + The Corresponding Source for a work in source code form is that 152 +same work. 153 + 154 + 2. Basic Permissions. 155 + 156 + All rights granted under this License are granted for the term of 157 +copyright on the Program, and are irrevocable provided the stated 158 +conditions are met. This License explicitly affirms your unlimited 159 +permission to run the unmodified Program. The output from running a 160 +covered work is covered by this License only if the output, given its 161 +content, constitutes a covered work. This License acknowledges your 162 +rights of fair use or other equivalent, as provided by copyright law. 163 + 164 + You may make, run and propagate covered works that you do not 165 +convey, without conditions so long as your license otherwise remains 166 +in force. You may convey covered works to others for the sole purpose 167 +of having them make modifications exclusively for you, or provide you 168 +with facilities for running those works, provided that you comply with 169 +the terms of this License in conveying all material for which you do 170 +not control copyright. Those thus making or running the covered works 171 +for you must do so exclusively on your behalf, under your direction 172 +and control, on terms that prohibit them from making any copies of 173 +your copyrighted material outside their relationship with you. 174 + 175 + Conveying under any other circumstances is permitted solely under 176 +the conditions stated below. Sublicensing is not allowed; section 10 177 +makes it unnecessary. 178 + 179 + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 + 181 + No covered work shall be deemed part of an effective technological 182 +measure under any applicable law fulfilling obligations under article 183 +11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 +similar laws prohibiting or restricting circumvention of such 185 +measures. 186 + 187 + When you convey a covered work, you waive any legal power to forbid 188 +circumvention of technological measures to the extent such circumvention 189 +is effected by exercising rights under this License with respect to 190 +the covered work, and you disclaim any intention to limit operation or 191 +modification of the work as a means of enforcing, against the work's 192 +users, your or third parties' legal rights to forbid circumvention of 193 +technological measures. 194 + 195 + 4. Conveying Verbatim Copies. 196 + 197 + You may convey verbatim copies of the Program's source code as you 198 +receive it, in any medium, provided that you conspicuously and 199 +appropriately publish on each copy an appropriate copyright notice; 200 +keep intact all notices stating that this License and any 201 +non-permissive terms added in accord with section 7 apply to the code; 202 +keep intact all notices of the absence of any warranty; and give all 203 +recipients a copy of this License along with the Program. 204 + 205 + You may charge any price or no price for each copy that you convey, 206 +and you may offer support or warranty protection for a fee. 207 + 208 + 5. Conveying Modified Source Versions. 209 + 210 + You may convey a work based on the Program, or the modifications to 211 +produce it from the Program, in the form of source code under the 212 +terms of section 4, provided that you also meet all of these conditions: 213 + 214 + a) The work must carry prominent notices stating that you modified 215 + it, and giving a relevant date. 216 + 217 + b) The work must carry prominent notices stating that it is 218 + released under this License and any conditions added under section 219 + 7. This requirement modifies the requirement in section 4 to 220 + "keep intact all notices". 221 + 222 + c) You must license the entire work, as a whole, under this 223 + License to anyone who comes into possession of a copy. This 224 + License will therefore apply, along with any applicable section 7 225 + additional terms, to the whole of the work, and all its parts, 226 + regardless of how they are packaged. This License gives no 227 + permission to license the work in any other way, but it does not 228 + invalidate such permission if you have separately received it. 229 + 230 + d) If the work has interactive user interfaces, each must display 231 + Appropriate Legal Notices; however, if the Program has interactive 232 + interfaces that do not display Appropriate Legal Notices, your 233 + work need not make them do so. 234 + 235 + A compilation of a covered work with other separate and independent 236 +works, which are not by their nature extensions of the covered work, 237 +and which are not combined with it such as to form a larger program, 238 +in or on a volume of a storage or distribution medium, is called an 239 +"aggregate" if the compilation and its resulting copyright are not 240 +used to limit the access or legal rights of the compilation's users 241 +beyond what the individual works permit. Inclusion of a covered work 242 +in an aggregate does not cause this License to apply to the other 243 +parts of the aggregate. 244 + 245 + 6. Conveying Non-Source Forms. 246 + 247 + You may convey a covered work in object code form under the terms 248 +of sections 4 and 5, provided that you also convey the 249 +machine-readable Corresponding Source under the terms of this License, 250 +in one of these ways: 251 + 252 + a) Convey the object code in, or embodied in, a physical product 253 + (including a physical distribution medium), accompanied by the 254 + Corresponding Source fixed on a durable physical medium 255 + customarily used for software interchange. 256 + 257 + b) Convey the object code in, or embodied in, a physical product 258 + (including a physical distribution medium), accompanied by a 259 + written offer, valid for at least three years and valid for as 260 + long as you offer spare parts or customer support for that product 261 + model, to give anyone who possesses the object code either (1) a 262 + copy of the Corresponding Source for all the software in the 263 + product that is covered by this License, on a durable physical 264 + medium customarily used for software interchange, for a price no 265 + more than your reasonable cost of physically performing this 266 + conveying of source, or (2) access to copy the 267 + Corresponding Source from a network server at no charge. 268 + 269 + c) Convey individual copies of the object code with a copy of the 270 + written offer to provide the Corresponding Source. This 271 + alternative is allowed only occasionally and noncommercially, and 272 + only if you received the object code with such an offer, in accord 273 + with subsection 6b. 274 + 275 + d) Convey the object code by offering access from a designated 276 + place (gratis or for a charge), and offer equivalent access to the 277 + Corresponding Source in the same way through the same place at no 278 + further charge. You need not require recipients to copy the 279 + Corresponding Source along with the object code. If the place to 280 + copy the object code is a network server, the Corresponding Source 281 + may be on a different server (operated by you or a third party) 282 + that supports equivalent copying facilities, provided you maintain 283 + clear directions next to the object code saying where to find the 284 + Corresponding Source. Regardless of what server hosts the 285 + Corresponding Source, you remain obligated to ensure that it is 286 + available for as long as needed to satisfy these requirements. 287 + 288 + e) Convey the object code using peer-to-peer transmission, provided 289 + you inform other peers where the object code and Corresponding 290 + Source of the work are being offered to the general public at no 291 + charge under subsection 6d. 292 + 293 + A separable portion of the object code, whose source code is excluded 294 +from the Corresponding Source as a System Library, need not be 295 +included in conveying the object code work. 296 + 297 + A "User Product" is either (1) a "consumer product", which means any 298 +tangible personal property which is normally used for personal, family, 299 +or household purposes, or (2) anything designed or sold for incorporation 300 +into a dwelling. In determining whether a product is a consumer product, 301 +doubtful cases shall be resolved in favor of coverage. For a particular 302 +product received by a particular user, "normally used" refers to a 303 +typical or common use of that class of product, regardless of the status 304 +of the particular user or of the way in which the particular user 305 +actually uses, or expects or is expected to use, the product. A product 306 +is a consumer product regardless of whether the product has substantial 307 +commercial, industrial or non-consumer uses, unless such uses represent 308 +the only significant mode of use of the product. 309 + 310 + "Installation Information" for a User Product means any methods, 311 +procedures, authorization keys, or other information required to install 312 +and execute modified versions of a covered work in that User Product from 313 +a modified version of its Corresponding Source. The information must 314 +suffice to ensure that the continued functioning of the modified object 315 +code is in no case prevented or interfered with solely because 316 +modification has been made. 317 + 318 + If you convey an object code work under this section in, or with, or 319 +specifically for use in, a User Product, and the conveying occurs as 320 +part of a transaction in which the right of possession and use of the 321 +User Product is transferred to the recipient in perpetuity or for a 322 +fixed term (regardless of how the transaction is characterized), the 323 +Corresponding Source conveyed under this section must be accompanied 324 +by the Installation Information. But this requirement does not apply 325 +if neither you nor any third party retains the ability to install 326 +modified object code on the User Product (for example, the work has 327 +been installed in ROM). 328 + 329 + The requirement to provide Installation Information does not include a 330 +requirement to continue to provide support service, warranty, or updates 331 +for a work that has been modified or installed by the recipient, or for 332 +the User Product in which it has been modified or installed. Access to a 333 +network may be denied when the modification itself materially and 334 +adversely affects the operation of the network or violates the rules and 335 +protocols for communication across the network. 336 + 337 + Corresponding Source conveyed, and Installation Information provided, 338 +in accord with this section must be in a format that is publicly 339 +documented (and with an implementation available to the public in 340 +source code form), and must require no special password or key for 341 +unpacking, reading or copying. 342 + 343 + 7. Additional Terms. 344 + 345 + "Additional permissions" are terms that supplement the terms of this 346 +License by making exceptions from one or more of its conditions. 347 +Additional permissions that are applicable to the entire Program shall 348 +be treated as though they were included in this License, to the extent 349 +that they are valid under applicable law. If additional permissions 350 +apply only to part of the Program, that part may be used separately 351 +under those permissions, but the entire Program remains governed by 352 +this License without regard to the additional permissions. 353 + 354 + When you convey a copy of a covered work, you may at your option 355 +remove any additional permissions from that copy, or from any part of 356 +it. (Additional permissions may be written to require their own 357 +removal in certain cases when you modify the work.) You may place 358 +additional permissions on material, added by you to a covered work, 359 +for which you have or can give appropriate copyright permission. 360 + 361 + Notwithstanding any other provision of this License, for material you 362 +add to a covered work, you may (if authorized by the copyright holders of 363 +that material) supplement the terms of this License with terms: 364 + 365 + a) Disclaiming warranty or limiting liability differently from the 366 + terms of sections 15 and 16 of this License; or 367 + 368 + b) Requiring preservation of specified reasonable legal notices or 369 + author attributions in that material or in the Appropriate Legal 370 + Notices displayed by works containing it; or 371 + 372 + c) Prohibiting misrepresentation of the origin of that material, or 373 + requiring that modified versions of such material be marked in 374 + reasonable ways as different from the original version; or 375 + 376 + d) Limiting the use for publicity purposes of names of licensors or 377 + authors of the material; or 378 + 379 + e) Declining to grant rights under trademark law for use of some 380 + trade names, trademarks, or service marks; or 381 + 382 + f) Requiring indemnification of licensors and authors of that 383 + material by anyone who conveys the material (or modified versions of 384 + it) with contractual assumptions of liability to the recipient, for 385 + any liability that these contractual assumptions directly impose on 386 + those licensors and authors. 387 + 388 + All other non-permissive additional terms are considered "further 389 +restrictions" within the meaning of section 10. If the Program as you 390 +received it, or any part of it, contains a notice stating that it is 391 +governed by this License along with a term that is a further 392 +restriction, you may remove that term. If a license document contains 393 +a further restriction but permits relicensing or conveying under this 394 +License, you may add to a covered work material governed by the terms 395 +of that license document, provided that the further restriction does 396 +not survive such relicensing or conveying. 397 + 398 + If you add terms to a covered work in accord with this section, you 399 +must place, in the relevant source files, a statement of the 400 +additional terms that apply to those files, or a notice indicating 401 +where to find the applicable terms. 402 + 403 + Additional terms, permissive or non-permissive, may be stated in the 404 +form of a separately written license, or stated as exceptions; 405 +the above requirements apply either way. 406 + 407 + 8. Termination. 408 + 409 + You may not propagate or modify a covered work except as expressly 410 +provided under this License. Any attempt otherwise to propagate or 411 +modify it is void, and will automatically terminate your rights under 412 +this License (including any patent licenses granted under the third 413 +paragraph of section 11). 414 + 415 + However, if you cease all violation of this License, then your 416 +license from a particular copyright holder is reinstated (a) 417 +provisionally, unless and until the copyright holder explicitly and 418 +finally terminates your license, and (b) permanently, if the copyright 419 +holder fails to notify you of the violation by some reasonable means 420 +prior to 60 days after the cessation. 421 + 422 + Moreover, your license from a particular copyright holder is 423 +reinstated permanently if the copyright holder notifies you of the 424 +violation by some reasonable means, this is the first time you have 425 +received notice of violation of this License (for any work) from that 426 +copyright holder, and you cure the violation prior to 30 days after 427 +your receipt of the notice. 428 + 429 + Termination of your rights under this section does not terminate the 430 +licenses of parties who have received copies or rights from you under 431 +this License. If your rights have been terminated and not permanently 432 +reinstated, you do not qualify to receive new licenses for the same 433 +material under section 10. 434 + 435 + 9. Acceptance Not Required for Having Copies. 436 + 437 + You are not required to accept this License in order to receive or 438 +run a copy of the Program. Ancillary propagation of a covered work 439 +occurring solely as a consequence of using peer-to-peer transmission 440 +to receive a copy likewise does not require acceptance. However, 441 +nothing other than this License grants you permission to propagate or 442 +modify any covered work. These actions infringe copyright if you do 443 +not accept this License. Therefore, by modifying or propagating a 444 +covered work, you indicate your acceptance of this License to do so. 445 + 446 + 10. Automatic Licensing of Downstream Recipients. 447 + 448 + Each time you convey a covered work, the recipient automatically 449 +receives a license from the original licensors, to run, modify and 450 +propagate that work, subject to this License. You are not responsible 451 +for enforcing compliance by third parties with this License. 452 + 453 + An "entity transaction" is a transaction transferring control of an 454 +organization, or substantially all assets of one, or subdividing an 455 +organization, or merging organizations. If propagation of a covered 456 +work results from an entity transaction, each party to that 457 +transaction who receives a copy of the work also receives whatever 458 +licenses to the work the party's predecessor in interest had or could 459 +give under the previous paragraph, plus a right to possession of the 460 +Corresponding Source of the work from the predecessor in interest, if 461 +the predecessor has it or can get it with reasonable efforts. 462 + 463 + You may not impose any further restrictions on the exercise of the 464 +rights granted or affirmed under this License. For example, you may 465 +not impose a license fee, royalty, or other charge for exercise of 466 +rights granted under this License, and you may not initiate litigation 467 +(including a cross-claim or counterclaim in a lawsuit) alleging that 468 +any patent claim is infringed by making, using, selling, offering for 469 +sale, or importing the Program or any portion of it. 470 + 471 + 11. Patents. 472 + 473 + A "contributor" is a copyright holder who authorizes use under this 474 +License of the Program or a work on which the Program is based. The 475 +work thus licensed is called the contributor's "contributor version". 476 + 477 + A contributor's "essential patent claims" are all patent claims 478 +owned or controlled by the contributor, whether already acquired or 479 +hereafter acquired, that would be infringed by some manner, permitted 480 +by this License, of making, using, or selling its contributor version, 481 +but do not include claims that would be infringed only as a 482 +consequence of further modification of the contributor version. For 483 +purposes of this definition, "control" includes the right to grant 484 +patent sublicenses in a manner consistent with the requirements of 485 +this License. 486 + 487 + Each contributor grants you a non-exclusive, worldwide, royalty-free 488 +patent license under the contributor's essential patent claims, to 489 +make, use, sell, offer for sale, import and otherwise run, modify and 490 +propagate the contents of its contributor version. 491 + 492 + In the following three paragraphs, a "patent license" is any express 493 +agreement or commitment, however denominated, not to enforce a patent 494 +(such as an express permission to practice a patent or covenant not to 495 +sue for patent infringement). To "grant" such a patent license to a 496 +party means to make such an agreement or commitment not to enforce a 497 +patent against the party. 498 + 499 + If you convey a covered work, knowingly relying on a patent license, 500 +and the Corresponding Source of the work is not available for anyone 501 +to copy, free of charge and under the terms of this License, through a 502 +publicly available network server or other readily accessible means, 503 +then you must either (1) cause the Corresponding Source to be so 504 +available, or (2) arrange to deprive yourself of the benefit of the 505 +patent license for this particular work, or (3) arrange, in a manner 506 +consistent with the requirements of this License, to extend the patent 507 +license to downstream recipients. "Knowingly relying" means you have 508 +actual knowledge that, but for the patent license, your conveying the 509 +covered work in a country, or your recipient's use of the covered work 510 +in a country, would infringe one or more identifiable patents in that 511 +country that you have reason to believe are valid. 512 + 513 + If, pursuant to or in connection with a single transaction or 514 +arrangement, you convey, or propagate by procuring conveyance of, a 515 +covered work, and grant a patent license to some of the parties 516 +receiving the covered work authorizing them to use, propagate, modify 517 +or convey a specific copy of the covered work, then the patent license 518 +you grant is automatically extended to all recipients of the covered 519 +work and works based on it. 520 + 521 + A patent license is "discriminatory" if it does not include within 522 +the scope of its coverage, prohibits the exercise of, or is 523 +conditioned on the non-exercise of one or more of the rights that are 524 +specifically granted under this License. You may not convey a covered 525 +work if you are a party to an arrangement with a third party that is 526 +in the business of distributing software, under which you make payment 527 +to the third party based on the extent of your activity of conveying 528 +the work, and under which the third party grants, to any of the 529 +parties who would receive the covered work from you, a discriminatory 530 +patent license (a) in connection with copies of the covered work 531 +conveyed by you (or copies made from those copies), or (b) primarily 532 +for and in connection with specific products or compilations that 533 +contain the covered work, unless you entered into that arrangement, 534 +or that patent license was granted, prior to 28 March 2007. 535 + 536 + Nothing in this License shall be construed as excluding or limiting 537 +any implied license or other defenses to infringement that may 538 +otherwise be available to you under applicable patent law. 539 + 540 + 12. No Surrender of Others' Freedom. 541 + 542 + If conditions are imposed on you (whether by court order, agreement or 543 +otherwise) that contradict the conditions of this License, they do not 544 +excuse you from the conditions of this License. If you cannot convey a 545 +covered work so as to satisfy simultaneously your obligations under this 546 +License and any other pertinent obligations, then as a consequence you may 547 +not convey it at all. For example, if you agree to terms that obligate you 548 +to collect a royalty for further conveying from those to whom you convey 549 +the Program, the only way you could satisfy both those terms and this 550 +License would be to refrain entirely from conveying the Program. 551 + 552 + 13. Use with the GNU Affero General Public License. 553 + 554 + Notwithstanding any other provision of this License, you have 555 +permission to link or combine any covered work with a work licensed 556 +under version 3 of the GNU Affero General Public License into a single 557 +combined work, and to convey the resulting work. The terms of this 558 +License will continue to apply to the part which is the covered work, 559 +but the special requirements of the GNU Affero General Public License, 560 +section 13, concerning interaction through a network will apply to the 561 +combination as such. 562 + 563 + 14. Revised Versions of this License. 564 + 565 + The Free Software Foundation may publish revised and/or new versions of 566 +the GNU General Public License from time to time. Such new versions will 567 +be similar in spirit to the present version, but may differ in detail to 568 +address new problems or concerns. 569 + 570 + Each version is given a distinguishing version number. If the 571 +Program specifies that a certain numbered version of the GNU General 572 +Public License "or any later version" applies to it, you have the 573 +option of following the terms and conditions either of that numbered 574 +version or of any later version published by the Free Software 575 +Foundation. If the Program does not specify a version number of the 576 +GNU General Public License, you may choose any version ever published 577 +by the Free Software Foundation. 578 + 579 + If the Program specifies that a proxy can decide which future 580 +versions of the GNU General Public License can be used, that proxy's 581 +public statement of acceptance of a version permanently authorizes you 582 +to choose that version for the Program. 583 + 584 + Later license versions may give you additional or different 585 +permissions. However, no additional obligations are imposed on any 586 +author or copyright holder as a result of your choosing to follow a 587 +later version. 588 + 589 + 15. Disclaimer of Warranty. 590 + 591 + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 + 600 + 16. Limitation of Liability. 601 + 602 + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 +SUCH DAMAGES. 611 + 612 + 17. Interpretation of Sections 15 and 16. 613 + 614 + If the disclaimer of warranty and limitation of liability provided 615 +above cannot be given local legal effect according to their terms, 616 +reviewing courts shall apply local law that most closely approximates 617 +an absolute waiver of all civil liability in connection with the 618 +Program, unless a warranty or assumption of liability accompanies a 619 +copy of the Program in return for a fee. 620 + 621 + END OF TERMS AND CONDITIONS 622 + 623 + How to Apply These Terms to Your New Programs 624 + 625 + If you develop a new program, and you want it to be of the greatest 626 +possible use to the public, the best way to achieve this is to make it 627 +free software which everyone can redistribute and change under these terms. 628 + 629 + To do so, attach the following notices to the program. It is safest 630 +to attach them to the start of each source file to most effectively 631 +state the exclusion of warranty; and each file should have at least 632 +the "copyright" line and a pointer to where the full notice is found. 633 + 634 + <one line to give the program's name and a brief idea of what it does.> 635 + Copyright (C) <year> <name of author> 636 + 637 + This program is free software: you can redistribute it and/or modify 638 + it under the terms of the GNU General Public License as published by 639 + the Free Software Foundation, either version 3 of the License, or 640 + (at your option) any later version. 641 + 642 + This program is distributed in the hope that it will be useful, 643 + but WITHOUT ANY WARRANTY; without even the implied warranty of 644 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 + GNU General Public License for more details. 646 + 647 + You should have received a copy of the GNU General Public License 648 + along with this program. If not, see <http://www.gnu.org/licenses/>. 649 + 650 +Also add information on how to contact you by electronic and paper mail. 651 + 652 + If the program does terminal interaction, make it output a short 653 +notice like this when it starts in an interactive mode: 654 + 655 + <program> Copyright (C) <year> <name of author> 656 + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 + This is free software, and you are welcome to redistribute it 658 + under certain conditions; type `show c' for details. 659 + 660 +The hypothetical commands `show w' and `show c' should show the appropriate 661 +parts of the General Public License. Of course, your program's commands 662 +might be different; for a GUI interface, you would use an "about box". 663 + 664 + You should also get your employer (if you work as a programmer) or school, 665 +if any, to sign a "copyright disclaimer" for the program, if necessary. 666 +For more information on this, and how to apply and follow the GNU GPL, see 667 +<http://www.gnu.org/licenses/>. 668 + 669 + The GNU General Public License does not permit incorporating your program 670 +into proprietary programs. If your program is a subroutine library, you 671 +may consider it more useful to permit linking proprietary applications with 672 +the library. If this is what you want to do, use the GNU Lesser General 673 +Public License instead of this License. But first, please read 674 +<http://www.gnu.org/philosophy/why-not-lgpl.html>.
Changes to Classdef.h.
24 24 */ 25 25 26 26 #include "wx/wx.h" 27 27 #include "wx/aui/aui.h" 28 28 #include "wx/treectrl.h" 29 29 #include "wx/grid.h" 30 30 #include "wx/listctrl.h" 31 +#include "wx/textctrl.h" 31 32 #include "wx/propdlg.h" 32 33 #include "wx/generic/propdlg.h" 34 +#include "wx/timer.h" 33 35 34 36 #include <spatialite/sqlite3.h> 35 37 36 38 #define OMIT_GEOS 0 37 39 #define OMIT_PROJ 0 40 +#include <spatialite/gaiaaux.h> 41 +#include <spatialite/gaiaexif.h> 38 42 #include <spatialite/gaiageo.h> 43 +#include <spatialite.h> 44 + 45 +// 46 +// functions for QSORT / BSEARCH 47 +// 48 +int cmp_prenodes_code(const void *p1, const void *p2); 49 +int cmp_prenodes_id(const void *p1, const void *p2); 50 +int cmp_nodes2_code(const void *p1, const void *p2); 51 +int cmp_nodes2_id(const void *p1, const void *p2); 52 +int cmp_nodes1_code(const void *p1, const void *p2); 53 +int cmp_nodes1_id(const void *p1, const void *p2); 39 54 40 55 enum 41 56 { 42 57 // control IDs for main window and tree list control 43 - ID_Connect = 1, 44 - ID_CreateNew, 45 - ID_Disconnect, 46 - ID_Vacuum, 47 - ID_SqlScript, 48 - ID_LoadShp, 49 - ID_LoadTxt, 50 - ID_VirtualShp, 51 - ID_VirtualTxt, 52 - ID_Srids, 53 - ID_Charset, 54 - ID_Help, 55 - Tree_NewTable, 56 - Tree_NewView, 57 - Tree_NewIndex, 58 - Tree_NewTrigger, 59 - Tree_NewColumn, 60 - Tree_Show, 61 - Tree_Drop, 62 - Tree_Rename, 63 - Tree_Select, 64 - Tree_Refresh, 65 - Tree_SpatialIndex, 66 - Tree_MbrCache, 67 - Tree_ShowSql, 68 - Tree_Recover, 69 - Tree_CheckGeometry, 70 - Tree_SetSrid, 71 - Tree_DumpShp, 72 - Tree_DumpTxtTab, 73 - Tree_DumpCsv, 74 - Tree_DumpHtml, 75 - Tree_Edit, 76 - Grid_Clear, 77 - Grid_All, 78 - Grid_Column, 79 - Grid_Row, 80 - Grid_Copy, 81 - Grid_Blob, 82 - Grid_Delete, 83 - Grid_Insert, 84 - Grid_Abort, 85 - Grid_BlobIn, 86 - Grid_BlobOut, 87 - Grid_BlobNull, 88 - Image_Copy, 58 + ID_Connect = 1, 59 + ID_CreateNew, 60 + ID_Disconnect, 61 + ID_MemoryDbLoad, 62 + ID_MemoryDbNew, 63 + ID_MemoryDbClock, 64 + ID_MemoryDbSave, 65 + ID_Vacuum, 66 + ID_SqlScript, 67 + ID_LoadShp, 68 + ID_LoadTxt, 69 + ID_VirtualShp, 70 + ID_VirtualTxt, 71 + ID_Network, 72 + ID_Exif, 73 + ID_Srids, 74 + ID_Charset, 75 + ID_Help, 76 + Tree_NewTable, 77 + Tree_NewView, 78 + Tree_NewIndex, 79 + Tree_NewTrigger, 80 + Tree_NewColumn, 81 + Tree_Show, 82 + Tree_Drop, 83 + Tree_Rename, 84 + Tree_Select, 85 + Tree_Refresh, 86 + Tree_SpatialIndex, 87 + Tree_MbrCache, 88 + Tree_RebuildTriggers, 89 + Tree_ShowSql, 90 + Tree_Recover, 91 + Tree_CheckGeometry, 92 + Tree_SetSrid, 93 + Tree_DumpShp, 94 + Tree_DumpTxtTab, 95 + Tree_DumpCsv, 96 + Tree_DumpHtml, 97 + Tree_Edit, 98 + Grid_Clear, 99 + Grid_All, 100 + Grid_Column, 101 + Grid_Row, 102 + Grid_Copy, 103 + Grid_Blob, 104 + Grid_Delete, 105 + Grid_Insert, 106 + Grid_Abort, 107 + Grid_BlobIn, 108 + Grid_BlobOut, 109 + Grid_BlobNull, 110 + Image_Copy, 89 111 }; 90 112 91 113 enum 92 114 { 93 115 // control IDs for dialogs 94 - ID_SQL = 10000, 95 - ID_SQL_GO, 96 - ID_HISTORY_BACK, 97 - ID_HISTORY_FORWARD, 98 - ID_RS_FIRST, 99 - ID_RS_LAST, 100 - ID_RS_NEXT, 101 - ID_RS_PREVIOUS, 102 - ID_REFRESH, 103 - ID_RS_BLOCK, 104 - ID_PANE_HEXADECIMAL, 105 - ID_PANE_GEOMETRY, 106 - ID_PANE_IMAGE, 107 - ID_HEX, 108 - ID_GEOM_TABLE, 109 - ID_GEOM_GRAPH, 110 - ID_GEOM_BOX, 111 - ID_IMAGE_TITLE, 112 - ID_IMG_BOX, 113 - ID_IMAGE, 114 - ID_VIRTSHP_TABLE, 115 - ID_VIRTSHP_SRID, 116 - ID_VIRTSHP_CHARSET, 117 - ID_VIRTTXT_TABLE, 118 - ID_VIRTTXT_CHARSET, 119 - ID_VIRTTXT_TITLES, 120 - ID_VIRTTXT_SEPARATOR, 121 - ID_VIRTTXT_CHARSEPARATOR, 122 - ID_VIRTTXT_QUOTE, 123 - ID_VIRTTXT_POINT, 124 - ID_LDSHP_TABLE, 125 - ID_LDSHP_COLUMN, 126 - ID_LDSHP_SRID, 127 - ID_LDSHP_CHARSET, 128 - ID_LDTXT_TABLE, 129 - ID_LDTXT_CHARSET, 130 - ID_LDTXT_TITLES, 131 - ID_LDTXT_SEPARATOR, 132 - ID_LDTXT_CHARSEPARATOR, 133 - ID_LDTXT_QUOTE, 134 - ID_LDTXT_POINT, 135 - ID_DMPSHP_CHARSET, 136 - ID_DMPTXT_CHARSET, 137 - ID_DFLT_CHARSET, 138 - ID_DFLT_ASK, 139 - ID_SCRIPT_CHARSET, 140 - ID_RCVR_SRID, 141 - ID_RCVR_TYPE, 142 - ID_SRID_OLD, 143 - ID_SRID_SRID, 144 - ID_SEARCH, 116 + ID_SQL = 10000, 117 + ID_SQL_GO, 118 + ID_HISTORY_BACK, 119 + ID_HISTORY_FORWARD, 120 + ID_RS_FIRST, 121 + ID_RS_LAST, 122 + ID_RS_NEXT, 123 + ID_RS_PREVIOUS, 124 + ID_REFRESH, 125 + ID_RS_BLOCK, 126 + ID_PANE_HEXADECIMAL, 127 + ID_PANE_GEOMETRY, 128 + ID_PANE_IMAGE, 129 + ID_HEX, 130 + ID_GEOM_TABLE, 131 + ID_GEOM_GRAPH, 132 + ID_GEOM_BOX, 133 + ID_IMAGE_TITLE, 134 + ID_IMG_BOX, 135 + ID_IMAGE, 136 + ID_VIRTSHP_TABLE, 137 + ID_VIRTSHP_SRID, 138 + ID_VIRTSHP_CHARSET, 139 + ID_VIRTTXT_TABLE, 140 + ID_VIRTTXT_CHARSET, 141 + ID_VIRTTXT_TITLES, 142 + ID_VIRTTXT_SEPARATOR, 143 + ID_VIRTTXT_CHARSEPARATOR, 144 + ID_VIRTTXT_QUOTE, 145 + ID_VIRTTXT_POINT, 146 + ID_LDSHP_TABLE, 147 + ID_LDSHP_COLUMN, 148 + ID_LDSHP_SRID, 149 + ID_LDSHP_CHARSET, 150 + ID_LDTXT_TABLE, 151 + ID_LDTXT_CHARSET, 152 + ID_LDTXT_TITLES, 153 + ID_LDTXT_SEPARATOR, 154 + ID_LDTXT_CHARSEPARATOR, 155 + ID_LDTXT_QUOTE, 156 + ID_LDTXT_POINT, 157 + ID_DMPSHP_CHARSET, 158 + ID_DMPTXT_CHARSET, 159 + ID_NET_TABLE, 160 + ID_NET_FROM, 161 + ID_NET_TO, 162 + ID_NET_GEOM, 163 + ID_NET_LENGTH, 164 + ID_NET_COST, 165 + ID_NET_BIDIR, 166 + ID_NET_ONEWAY, 167 + ID_NET_FROM_TO, 168 + ID_NET_TO_FROM, 169 + ID_EXIF_PATH, 170 + ID_EXIF_FOLDER, 171 + ID_EXIF_SINGLE, 172 + ID_EXIF_METADATA, 173 + ID_EXIF_GPS_ONLY, 174 + ID_DFLT_CHARSET, 175 + ID_DFLT_ASK, 176 + ID_SCRIPT_CHARSET, 177 + ID_RCVR_SRID, 178 + ID_RCVR_TYPE, 179 + ID_SRID_OLD, 180 + ID_SRID_SRID, 181 + ID_SEARCH, 182 + ID_HELP_HTML, 183 + ID_AUTO_SAVE_PATH, 184 + ID_AUTO_SAVE_INTERVAL, 185 + ID_AUTO_SAVE_CHANGE_PATH, 145 186 }; 146 187 147 188 enum 148 189 { 149 190 // tree item data types 150 - MY_TABLE = 0, 151 - MY_VTABLE, 152 - MY_VIEW, 153 - MY_COLUMN, 154 - MY_GEOMETRY, 155 - MY_GEOMETRY_INDEX, 156 - MY_GEOMETRY_CACHED, 157 - MY_INDEX, 158 - MY_TRIGGER, 159 - MY_INT_VARIANT, 160 - MY_DBL_VARIANT, 161 - MY_TXT_VARIANT, 162 - MY_BLOB_VARIANT, 163 - MY_NULL_VARIANT, 191 + MY_TABLE = 0, 192 + MY_VTABLE, 193 + MY_VIEW, 194 + MY_COLUMN, 195 + MY_GEOMETRY, 196 + MY_GEOMETRY_INDEX, 197 + MY_GEOMETRY_CACHED, 198 + MY_INDEX, 199 + MY_TRIGGER, 200 + MY_INT_VARIANT, 201 + MY_DBL_VARIANT, 202 + MY_TXT_VARIANT, 203 + MY_BLOB_VARIANT, 204 + MY_NULL_VARIANT, 205 +}; 206 + 207 +enum 208 +{ 209 +// control IDs for timers 210 + ID_AUTO_SAVE_TIMER = 20000, 164 211 }; 165 212 166 213 class MyObject:public wxTreeItemData 167 214 { 168 215 // 169 216 // a class to store TreeItemData 170 217 // 171 - private: 172 - int Type; // the object type 173 - wxString Name; // the object name 174 - wxString Column; // the column name [optional] 175 - public: 176 - MyObject (int type, wxString & name); 177 - MyObject (int type, wxString & name, wxString & column); 178 - virtual ~ MyObject () { ; } 179 - int GetType () { return Type; } 180 - wxString & GetName () { return Name; } 181 - wxString & GetColumn () { return Column; } 218 +private: 219 + int Type; // the object type 220 + wxString Name; // the object name 221 + wxString Column; // the column name [optional] 222 +public: 223 + MyObject(int type, wxString & name); 224 + MyObject(int type, wxString & name, wxString & column); 225 + virtual ~ MyObject() 226 + {; 227 + } 228 + int GetType() 229 + { 230 + return Type; 231 + } 232 + wxString & GetName() 233 + { 234 + return Name; 235 + } 236 + wxString & GetColumn() 237 + { 238 + return Column; 239 + } 182 240 }; 183 241 184 242 class MyColumnInfo 185 243 { 186 244 // 187 245 // a class to store a DB column 188 246 // 189 - private: 190 - wxString Name; // the column name 191 - bool PrimaryKey; // Primary Key column 192 - bool Geometry; // Geometry column 193 - bool GeometryIndex; // Geometry column + SpatialIndex 194 - bool MbrCache; // Geometry column + MbrCache 195 - MyColumnInfo *Next; // pointer to next element into the linked list 196 - public: 197 - MyColumnInfo (wxString & name, bool pkey); 198 - ~MyColumnInfo () { ; } 199 - wxString & GetName () { return Name; } 200 - bool IsPrimaryKey () { return PrimaryKey; } 201 - void SetGeometry () { Geometry = true; } 202 - bool IsGeometry () { return Geometry; } 203 - void SetGeometryIndex () { GeometryIndex = true; } 204 - bool IsGeometryIndex () { return GeometryIndex; } 205 - void SetMbrCache () { MbrCache = true; } 206 - bool IsMbrCache () { return MbrCache; } 207 - void SetNext (MyColumnInfo * next) { Next = next; } 208 - MyColumnInfo *GetNext () { return Next; } 247 +private: 248 + wxString Name; // the column name 249 + bool PrimaryKey; // Primary Key column 250 + bool Geometry; // Geometry column 251 + bool GeometryIndex; // Geometry column + SpatialIndex 252 + bool MbrCache; // Geometry column + MbrCache 253 + MyColumnInfo *Next; // pointer to next element into the linked list 254 +public: 255 + MyColumnInfo(wxString & name, bool pkey); 256 + ~MyColumnInfo() 257 + {; 258 + } 259 + wxString & GetName() 260 + { 261 + return Name; 262 + } 263 + bool IsPrimaryKey() 264 + { 265 + return PrimaryKey; 266 + } 267 + void SetGeometry() 268 + { 269 + Geometry = true; 270 + } 271 + bool IsGeometry() 272 + { 273 + return Geometry; 274 + } 275 + void SetGeometryIndex() 276 + { 277 + GeometryIndex = true; 278 + } 279 + bool IsGeometryIndex() 280 + { 281 + return GeometryIndex; 282 + } 283 + void SetMbrCache() 284 + { 285 + MbrCache = true; 286 + } 287 + bool IsMbrCache() 288 + { 289 + return MbrCache; 290 + } 291 + void SetNext(MyColumnInfo * next) 292 + { 293 + Next = next; 294 + } 295 + MyColumnInfo *GetNext() 296 + { 297 + return Next; 298 + } 209 299 }; 210 300 211 301 class MyIndexInfo 212 302 { 213 303 // 214 304 // a class to store a DB index 215 305 // 216 - private: 217 - wxString Name; // the index name 218 - MyIndexInfo *Next; // pointer to next element into the linked list 219 - public: 220 - MyIndexInfo (wxString & name); 221 - ~MyIndexInfo () { ; } 222 - wxString & GetName () { return Name; } 223 - void SetNext (MyIndexInfo * next) { Next = next; } 224 - MyIndexInfo *GetNext () { return Next; } 306 +private: 307 + wxString Name; // the index name 308 + MyIndexInfo *Next; // pointer to next element into the linked list 309 +public: 310 + MyIndexInfo(wxString & name); 311 + MyIndexInfo() 312 + {; 313 + } 314 + wxString & GetName() 315 + { 316 + return Name; 317 + } 318 + void SetNext(MyIndexInfo * next) 319 + { 320 + Next = next; 321 + } 322 + MyIndexInfo *GetNext() 323 + { 324 + return Next; 325 + } 225 326 }; 226 327 227 328 class MyTriggerInfo 228 329 { 229 330 // 230 331 // a class to store a DB trigger 231 332 // 232 - private: 233 - wxString Name; // the trigger name 234 - MyTriggerInfo *Next; // pointer to next element into the linked list 235 - public: 236 - MyTriggerInfo (wxString & name); 237 - ~MyTriggerInfo () { ; } 238 - wxString & GetName () { return Name; } 239 - void SetNext (MyTriggerInfo * next) { Next = next; } 240 - MyTriggerInfo *GetNext () { return Next; } 333 +private: 334 + wxString Name; // the trigger name 335 + MyTriggerInfo *Next; // pointer to next element into the linked list 336 +public: 337 + MyTriggerInfo(wxString & name); 338 + ~MyTriggerInfo() 339 + {; 340 + } 341 + wxString & GetName() 342 + { 343 + return Name; 344 + } 345 + void SetNext(MyTriggerInfo * next) 346 + { 347 + Next = next; 348 + } 349 + MyTriggerInfo *GetNext() 350 + { 351 + return Next; 352 + } 241 353 }; 242 354 243 355 class MyTableInfo 244 356 { 245 357 // 246 358 // a class to store DB table columns 247 359 // 248 - private: 249 - MyColumnInfo * FirstColumn; // first element into the columns linked list 250 - MyColumnInfo *LastColumn; // last element into the columns linked list 251 - MyIndexInfo *FirstIndex; // first element into the indices linked list 252 - MyIndexInfo *LastIndex; // last element into the indices linked list 253 - MyTriggerInfo *FirstTrigger; // first element into the triggers linked list 254 - MyTriggerInfo *LastTrigger; // last element into the triggers linked list 255 - public: 256 - MyTableInfo () { FirstColumn = NULL; LastColumn = NULL; 257 - FirstIndex = NULL; LastIndex = NULL; FirstTrigger = NULL; 258 - LastTrigger = NULL; } 259 - ~MyTableInfo (); 260 - void AddColumn (wxString & name, bool pkey); 261 - void SetGeometry (wxString & name, bool index, bool cached); 262 - void AddIndex (wxString & name); 263 - void AddTrigger (wxString & name); 264 - MyColumnInfo *GetFirstColumn () { return FirstColumn; } 265 - MyIndexInfo *GetFirstIndex () { return FirstIndex; } 266 - MyTriggerInfo *GetFirstTrigger () { return FirstTrigger; } 360 +private: 361 + MyColumnInfo * FirstColumn; // first element into the columns linked list 362 + MyColumnInfo *LastColumn; // last element into the columns linked list 363 + MyIndexInfo *FirstIndex; // first element into the indices linked list 364 + MyIndexInfo *LastIndex; // last element into the indices linked list 365 + MyTriggerInfo *FirstTrigger; // first element into the triggers linked list 366 + MyTriggerInfo *LastTrigger; // last element into the triggers linked list 367 +public: 368 + MyTableInfo() 369 + { 370 + FirstColumn = NULL; 371 + LastColumn = NULL; 372 + FirstIndex = NULL; 373 + LastIndex = NULL; 374 + FirstTrigger = NULL; 375 + LastTrigger = NULL; 376 + } 377 + ~MyTableInfo(); 378 + void AddColumn(wxString & name, bool pkey); 379 + void SetGeometry(wxString & name, bool index, bool cached); 380 + void AddIndex(wxString & name); 381 + void AddTrigger(wxString & name); 382 + MyColumnInfo *GetFirstColumn() 383 + { 384 + return FirstColumn; 385 + } 386 + MyIndexInfo *GetFirstIndex() 387 + { 388 + return FirstIndex; 389 + } 390 + MyTriggerInfo *GetFirstTrigger() 391 + { 392 + return FirstTrigger; 393 + } 267 394 }; 268 395 269 396 class MyViewInfo 270 397 { 271 398 // 272 399 // a class to store DB view columns 273 400 // 274 - private: 275 - MyColumnInfo * First; // first element into the columns linked list 276 - MyColumnInfo *Last; // last element into the columns linked list 277 - public: 278 - MyViewInfo () { First = NULL; Last = NULL; } 279 - ~MyViewInfo (); 280 - void AddColumn (wxString & name); 281 - MyColumnInfo *GetFirst () { return First; } 401 +private: 402 + MyColumnInfo * First; // first element into the columns linked list 403 + MyColumnInfo *Last; // last element into the columns linked list 404 +public: 405 + MyViewInfo() 406 + { 407 + First = NULL; 408 + Last = NULL; 409 + } 410 + ~MyViewInfo(); 411 + void AddColumn(wxString & name); 412 + MyColumnInfo *GetFirst() 413 + { 414 + return First; 415 + } 282 416 }; 283 417 284 418 class MyVariant 285 419 { 286 420 // 287 421 // a class to store Variant-Type values 288 422 // 289 - private: 290 - int Type; // the Variant-Type 291 - int IntValue; // the Integer value 292 - double DblValue; // the Double value 293 - wxString TxtValue; // the Text value 294 - unsigned char *Blob; // the BLOB value 295 - int BlobSize; // the BLOB size 296 - public: 297 - MyVariant () { Type = MY_NULL_VARIANT; Blob = NULL; } 298 - ~MyVariant () { if (Blob) delete Blob; } 299 - void Clear () { if (Blob) delete Blob; Blob = NULL; 300 - Type = MY_NULL_VARIANT; } 301 - void Set (int value) { Type = MY_INT_VARIANT; 302 - IntValue = value; } 303 - void Set (double value) { Type = MY_DBL_VARIANT; 304 - DblValue = value; } 305 - void Set (const unsigned char *text); 306 - void Set (wxString & string) { Type = MY_TXT_VARIANT; 307 - TxtValue = string; } 308 - void Set (const void *blob, int size); 309 - void Copy (MyVariant * other); 310 - int GetType () { return Type; } 311 - int GetIntValue () { return IntValue; } 312 - double GetDblValue () { return DblValue; } 313 - wxString & GetTxtValue () { return TxtValue; } 314 - int GetBlobSize () { return BlobSize; } 315 - unsigned char *GetBlob () { return Blob; } 423 +private: 424 + int Type; // the Variant-Type 425 + sqlite3_int64 IntValue; // the Integer value 426 + double DblValue; // the Double value 427 + wxString TxtValue; // the Text value 428 + unsigned char *Blob; // the BLOB value 429 + int BlobSize; // the BLOB size 430 +public: 431 + MyVariant() 432 + { 433 + Type = MY_NULL_VARIANT; 434 + Blob = NULL; 435 + } 436 + ~MyVariant() 437 + { 438 + if (Blob) 439 + delete Blob; 440 + } 441 + void Clear() 442 + { 443 + if (Blob) 444 + delete Blob; 445 + Blob = NULL; 446 + Type = MY_NULL_VARIANT; 447 + } 448 + void Set(sqlite3_int64 value) 449 + { 450 + Type = MY_INT_VARIANT; 451 + IntValue = value; 452 + } 453 + void Set(double value) 454 + { 455 + Type = MY_DBL_VARIANT; 456 + DblValue = value; 457 + } 458 + void Set(const unsigned char *text); 459 + void Set(wxString & string) 460 + { 461 + Type = MY_TXT_VARIANT; 462 + TxtValue = string; 463 + } 464 + void Set(const void *blob, int size); 465 + void Copy(MyVariant * other); 466 + int GetType() 467 + { 468 + return Type; 469 + } 470 + sqlite3_int64 GetIntValue() 471 + { 472 + return IntValue; 473 + } 474 + double GetDblValue() 475 + { 476 + return DblValue; 477 + } 478 + wxString & GetTxtValue() 479 + { 480 + return TxtValue; 481 + } 482 + int GetBlobSize() 483 + { 484 + return BlobSize; 485 + } 486 + unsigned char *GetBlob() 487 + { 488 + return Blob; 489 + } 316 490 }; 317 491 318 492 class MyRowVariant 319 493 { 320 494 // 321 495 // a class to store a row composed of Variant-Type values 322 496 // 323 - private: 324 - int NumCols; // number of columns 325 - MyVariant *ColumnArray; // the column as an array 326 - bool Deleted; // switch to mark row deletion 327 - MyRowVariant *Next; // pointer to next element into the linked list 328 - public: 329 - MyRowVariant () { NumCols = 0; ColumnArray = NULL; 330 - Deleted = false; Next = NULL; } 331 - MyRowVariant (int cols) { NumCols = cols; 332 - ColumnArray = new MyVariant[cols]; Next = NULL; } 333 - ~MyRowVariant () { if (ColumnArray) delete[]ColumnArray; } 334 - void Create (int cols); 335 - int GetNumCols () { return NumCols; } 336 - void Set (int col, int value); 337 - void Set (int col, double value); 338 - void Set (int col, const unsigned char *text); 339 - void Set (int col, const void *blob, int size); 340 - MyVariant *GetColumn (int col); 341 - void SetDeleted () { Deleted = true; } 342 - bool IsDeleted () { return Deleted; } 343 - void SetNext (MyRowVariant * next) { Next = next; } 344 - MyRowVariant *GetNext () { return Next; } 497 +private: 498 + int NumCols; // number of columns 499 + MyVariant *ColumnArray; // the column as an array 500 + bool Deleted; // switch to mark row deletion 501 + MyRowVariant *Next; // pointer to next element into the linked list 502 +public: 503 + MyRowVariant() 504 + { 505 + NumCols = 0; 506 + ColumnArray = NULL; 507 + Deleted = false; 508 + Next = NULL; 509 + } 510 + MyRowVariant(int cols) 511 + { 512 + NumCols = cols; 513 + ColumnArray = new MyVariant[cols]; 514 + Next = NULL; 515 + } 516 + ~MyRowVariant() 517 + { 518 + if (ColumnArray) 519 + delete[]ColumnArray; 520 + } 521 + void Create(int cols); 522 + int GetNumCols() 523 + { 524 + return NumCols; 525 + } 526 + void Set(int col, sqlite3_int64 value); 527 + void Set(int col, double value); 528 + void Set(int col, const unsigned char *text); 529 + void Set(int col, const void *blob, int size); 530 + MyVariant *GetColumn(int col); 531 + void SetDeleted() 532 + { 533 + Deleted = true; 534 + } 535 + bool IsDeleted() 536 + { 537 + return Deleted; 538 + } 539 + void SetNext(MyRowVariant * next) 540 + { 541 + Next = next; 542 + } 543 + MyRowVariant *GetNext() 544 + { 545 + return Next; 546 + } 345 547 }; 346 548 347 549 class MyVariantList 348 550 { 349 551 // 350 552 // a class to store a whole result set 351 553 // 352 - private: 353 - int NumCols; // number of columns 354 - wxString *ColumnName; // the column names 355 - MyRowVariant *First; // first element into the linked list 356 - MyRowVariant *Last; // last element into the linked list 357 - public: 358 - MyVariantList (); 359 - ~MyVariantList (); 360 - MyRowVariant *Add (int columns); 361 - void SetColumnName (int col, const char *colName); 362 - MyRowVariant *GetFirst () { return First; } 363 - int GetRows (); 364 - int GetColumns () { return NumCols; } 365 - wxString & GetColumnName (int col); 554 +private: 555 + int NumCols; // number of columns 556 + wxString *ColumnName; // the column names 557 + MyRowVariant *First; // first element into the linked list 558 + MyRowVariant *Last; // last element into the linked list 559 +public: 560 + MyVariantList(); 561 + ~MyVariantList(); 562 + MyRowVariant *Add(int columns); 563 + void SetColumnName(int col, const char *colName); 564 + MyRowVariant *GetFirst() 565 + { 566 + return First; 567 + } 568 + int GetRows(); 569 + int GetColumns() 570 + { 571 + return NumCols; 572 + } 573 + wxString & GetColumnName(int col); 366 574 }; 367 575 368 576 class MyBlobs 369 577 { 370 578 // 371 579 // a class to store BLOBs 372 580 // 373 - private: 374 - int NumRows; // the number of rows 375 - int NumCols; // the number of columns 376 - MyRowVariant *Rows; // pointer to an array of rows 377 - public: 378 - MyBlobs (int rows, int cols); 379 - ~MyBlobs (); 380 - void SetBlob (int row, int col, MyVariant * blobVar); 381 - MyVariant *GetBlob (int row, int col); 581 +private: 582 + int NumRows; // the number of rows 583 + int NumCols; // the number of columns 584 + MyRowVariant *Rows; // pointer to an array of rows 585 +public: 586 + MyBlobs(int rows, int cols); 587 + ~MyBlobs(); 588 + void SetBlob(int row, int col, MyVariant * blobVar); 589 + MyVariant *GetBlob(int row, int col); 382 590 }; 383 591 384 592 class MyValues 385 593 { 386 594 // 387 595 // a class to store column values for editing 388 596 // 389 - private: 390 - int NumRows; // the number of rows 391 - int NumCols; // the number of columns 392 - MyRowVariant *Rows; // pointer to an array of rows 393 - public: 394 - MyValues (int rows, int cols); 395 - ~MyValues (); 396 - void SetValue (int row, int col, int value); 397 - void SetValue (int row, int col, double value); 398 - void SetValue (int row, int col, wxString & string); 399 - MyRowVariant *GetRow (int row); 400 - MyVariant *GetValue (int row, int col); 597 +private: 598 + int NumRows; // the number of rows 599 + int NumCols; // the number of columns 600 + MyRowVariant *Rows; // pointer to an array of rows 601 +public: 602 + MyValues(int rows, int cols); 603 + ~MyValues(); 604 + void SetValue(int row, int col, sqlite3_int64 value); 605 + void SetValue(int row, int col, double value); 606 + void SetValue(int row, int col, wxString & string); 607 + MyRowVariant *GetRow(int row); 608 + MyVariant *GetValue(int row, int col); 401 609 }; 402 610 403 611 class MySqlQuery 404 612 { 405 613 // 406 614 // a class to store an SQL query - history 407 615 // 408 - private: 409 - wxString Sql; 410 - MySqlQuery *Prev; 411 - MySqlQuery *Next; 412 - public: 413 - MySqlQuery (wxString & sql) { Sql = sql; Prev = NULL; 414 - Next = NULL; } 415 - ~MySqlQuery () { ; } 416 - wxString & GetSql () { return Sql; } 417 - void SetPrev (MySqlQuery * prev) { Prev = prev; } 418 - MySqlQuery *GetPrev () { return Prev; } 419 - void SetNext (MySqlQuery * next) { Next = next; } 420 - MySqlQuery *GetNext () { return Next; } 616 +private: 617 + wxString Sql; 618 + MySqlQuery *Prev; 619 + MySqlQuery *Next; 620 +public: 621 + MySqlQuery(wxString & sql) 622 + { 623 + Sql = sql; 624 + Prev = NULL; 625 + Next = NULL; 626 + } 627 + ~MySqlQuery() 628 + {; 629 + } 630 + wxString & GetSql() 631 + { 632 + return Sql; 633 + } 634 + void SetPrev(MySqlQuery * prev) 635 + { 636 + Prev = prev; 637 + } 638 + MySqlQuery *GetPrev() 639 + { 640 + return Prev; 641 + } 642 + void SetNext(MySqlQuery * next) 643 + { 644 + Next = next; 645 + } 646 + MySqlQuery *GetNext() 647 + { 648 + return Next; 649 + } 421 650 }; 422 651 423 652 class MySqlHistory 424 653 { 425 654 // 426 655 // a class supporting SQL queries history 427 656 // 428 - private: 429 - MySqlQuery * First; 430 - MySqlQuery *Last; 431 - MySqlQuery *Current; 432 - public: 433 - MySqlHistory () { First = NULL; Last = NULL; 434 - Current = NULL; } 435 - ~MySqlHistory (); 436 - void Add (wxString & sql); 437 - MySqlQuery *GetCurrent () { return Current; } 438 - MySqlQuery *GetNext (); 439 - MySqlQuery *GetPrev (); 440 - bool TestNext (); 441 - bool TestPrev (); 657 +private: 658 + MySqlQuery * First; 659 + MySqlQuery *Last; 660 + MySqlQuery *Current; 661 +public: 662 + MySqlHistory() 663 + { 664 + First = NULL; 665 + Last = NULL; 666 + Current = NULL; 667 + } 668 + ~MySqlHistory(); 669 + void Add(wxString & sql); 670 + MySqlQuery *GetCurrent() 671 + { 672 + return Current; 673 + } 674 + MySqlQuery *GetNext(); 675 + MySqlQuery *GetPrev(); 676 + bool TestNext(); 677 + bool TestPrev(); 442 678 }; 443 679 444 680 class MyApp:public wxApp 445 681 { 446 682 // 447 683 // the main APP 448 684 // 449 - virtual bool OnInit (); 685 + virtual bool OnInit(); 450 686 }; 451 687 452 688 class MyTableTree:public wxTreeCtrl 453 689 { 454 690 // 455 691 // a tree-control used for SQLite DB tables 456 692 // 457 - private: 458 - class MyFrame * MainFrame; 459 - wxTreeItemId Root; // the root node 460 - wxImageList *Images; // the images list 461 - wxTreeItemId CurrentItem; // the tree item holding the current context menu 462 - public: 463 - MyTableTree () { ; } 464 - MyTableTree (MyFrame * parent, wxWindowID id = wxID_ANY); 465 - virtual ~ MyTableTree () { ; } 466 - void SetPath (wxString & path) { SetItemText (Root, path); } 467 - void FlushAll () { DeleteChildren (Root); } 468 - void AddTable (wxString & tableName, bool virtualTable); 469 - void AddView (wxString & viewName); 470 - void ExpandRoot () { Expand (Root); } 471 - void ShowMenu (wxTreeItemId & item, wxPoint & pt); 472 - void OnSelChanged (wxTreeEvent & event); 473 - void OnRightClick (wxTreeEvent & event); 474 - void OnCmdNewTable (wxCommandEvent & event); 475 - void OnCmdNewView (wxCommandEvent & event); 476 - void OnCmdNewIndex (wxCommandEvent & event); 477 - void OnCmdNewTrigger (wxCommandEvent & event); 478 - void OnCmdNewColumn (wxCommandEvent & event); 479 - void OnCmdShow (wxCommandEvent & event); 480 - void OnCmdDrop (wxCommandEvent & event); 481 - void OnCmdRename (wxCommandEvent & event); 482 - void OnCmdSelect (wxCommandEvent & event); 483 - void OnCmdRefresh (wxCommandEvent & event); 484 - void OnCmdRecover (wxCommandEvent & event); 485 - void OnCmdShowSql (wxCommandEvent & event); 486 - void OnCmdSpatialIndex (wxCommandEvent & event); 487 - void OnCmdMbrCache (wxCommandEvent & event); 488 - void OnCmdCheckGeometry (wxCommandEvent & event); 489 - void OnCmdSetSrid (wxCommandEvent & event); 490 - void OnCmdDumpShp (wxCommandEvent & event); 491 - void OnCmdDumpTxtTab (wxCommandEvent & event); 492 - void OnCmdDumpCsv (wxCommandEvent & event); 493 - void OnCmdDumpHtml (wxCommandEvent & event); 494 - void OnCmdEdit (wxCommandEvent & event); 693 +private: 694 + class MyFrame * MainFrame; 695 + wxTreeItemId Root; // the root node 696 + wxImageList *Images; // the images list 697 + wxTreeItemId CurrentItem; // the tree item holding the current context menu 698 +public: 699 + MyTableTree() 700 + {; 701 + } 702 + MyTableTree(class MyFrame * parent, wxWindowID id = wxID_ANY); 703 + virtual ~ MyTableTree() 704 + {; 705 + } 706 + void SetPath(wxString & path) 707 + { 708 + SetItemText(Root, path); 709 + } 710 + void FlushAll() 711 + { 712 + DeleteChildren(Root); 713 + } 714 + void AddTable(wxString & tableName, bool virtualTable); 715 + void AddView(wxString & viewName); 716 + void ExpandRoot() 717 + { 718 + Expand(Root); 719 + } 720 + void ShowMenu(wxTreeItemId & item, wxPoint & pt); 721 + void OnSelChanged(wxTreeEvent & event); 722 + void OnRightClick(wxTreeEvent & event); 723 + void OnCmdNewTable(wxCommandEvent & event); 724 + void OnCmdNewView(wxCommandEvent & event); 725 + void OnCmdNewIndex(wxCommandEvent & event); 726 + void OnCmdNewTrigger(wxCommandEvent & event); 727 + void OnCmdNewColumn(wxCommandEvent & event); 728 + void OnCmdShow(wxCommandEvent & event); 729 + void OnCmdDrop(wxCommandEvent & event); 730 + void OnCmdRename(wxCommandEvent & event); 731 + void OnCmdSelect(wxCommandEvent & event); 732 + void OnCmdRefresh(wxCommandEvent & event); 733 + void OnCmdRecover(wxCommandEvent & event); 734 + void OnCmdShowSql(wxCommandEvent & event); 735 + void OnCmdSpatialIndex(wxCommandEvent & event); 736 + void OnCmdMbrCache(wxCommandEvent & event); 737 + void OnCmdRebuildTriggers(wxCommandEvent & event); 738 + void OnCmdCheckGeometry(wxCommandEvent & event); 739 + void OnCmdSetSrid(wxCommandEvent & event); 740 + void OnCmdDumpShp(wxCommandEvent & event); 741 + void OnCmdDumpTxtTab(wxCommandEvent & event); 742 + void OnCmdDumpCsv(wxCommandEvent & event); 743 + void OnCmdDumpHtml(wxCommandEvent & event); 744 + void OnCmdEdit(wxCommandEvent & event); 745 +}; 746 + 747 +class MyResultSetView:public wxPanel 748 +{ 749 +// 750 +// a panel to be used for SQL Queries 751 +// 752 +private: 753 + class MyFrame * MainFrame; 754 + wxBitmapButton *BtnRsFirst; 755 + wxBitmapButton *BtnRsLast; 756 + wxBitmapButton *BtnRsNext; 757 + wxBitmapButton *BtnRsPrevious; 758 + wxBitmapButton *BtnRefresh; 759 + wxStaticText *RsCurrentBlock; 760 + int RsBlock; 761 + int RsBeginRow; 762 + int RsEndRow; 763 + int RsMaxRow; 764 + int CurrentEvtRow; 765 + int CurrentEvtColumn; 766 + MyVariant *CurrentBlob; 767 + wxGrid *TableView; 768 + MyBlobs *TableBlobs; 769 + MyValues *TableValues; 770 + bool ReadOnly; 771 + sqlite3_int64 *RowIds; 772 + int PrimaryKeys[1024]; 773 + int BlobColumns[1024]; 774 + wxString TableName; 775 + bool InsertPending; 776 + MyRowVariant *InsertRow; 777 + wxString SqlErrorMsg; 778 +public: 779 + MyResultSetView() 780 + {; 781 + } 782 + MyResultSetView(MyFrame * parent, wxWindowID id = wxID_ANY); 783 + virtual ~ MyResultSetView(); 784 + void HideControls(); 785 + void ShowControls(); 786 + wxString & GetSqlErrorMsg() 787 + { 788 + return SqlErrorMsg; 789 + } 790 + bool IsPrimaryKey(int column); 791 + bool IsBlobColumn(int column); 792 + void EditTable(wxString & sql, int *primaryKeys, int *blobCols, 793 + wxString & tableName); 794 + void CreateGrid(int rows, int cols); 795 + bool ExecuteSql(wxString & sql, int from, bool read_only); 796 + void ResizeView(); 797 + void DoInsert(bool confirmed); 798 + void HexBlobValue(unsigned char *blob, int size, wxString & hex); 799 + void OnSize(wxSizeEvent & event); 800 + void OnRsFirst(wxCommandEvent & event); 801 + void OnRsLast(wxCommandEvent & event); 802 + void OnRsNext(wxCommandEvent & event); 803 + void OnRsPrevious(wxCommandEvent & event); 804 + void OnRefresh(wxCommandEvent & event); 805 + void OnCellSelected(wxGridEvent & event); 806 + void OnRightClick(wxGridEvent & event); 807 + void OnCellChanged(wxGridEvent & event); 808 + void OnCmdDelete(wxCommandEvent & event); 809 + void OnCmdInsert(wxCommandEvent & event); 810 + void OnCmdAbort(wxCommandEvent & event); 811 + void OnCmdClearSelection(wxCommandEvent & event); 812 + void OnCmdSelectAll(wxCommandEvent & event); 813 + void OnCmdSelectRow(wxCommandEvent & event); 814 + void OnCmdSelectColumn(wxCommandEvent & event); 815 + void OnCmdCopy(wxCommandEvent & event); 816 + void OnCmdBlob(wxCommandEvent & event); 817 + void OnCmdBlobIn(wxCommandEvent & event); 818 + void OnCmdBlobOut(wxCommandEvent & event); 819 + void OnCmdBlobNull(wxCommandEvent & event); 820 +}; 821 + 822 +class MySqlControl:public wxTextCtrl 823 +{ 824 +// 825 +// the SQL text control 826 +// 827 +private: 828 + class MyQueryView * Parent; 829 +public: 830 + MySqlControl(MyQueryView * parent, wxWindowID id, const wxString & value, 831 + const wxPoint & pos, const wxSize & size, long style); 832 + virtual ~ MySqlControl() 833 + {; 834 + } 835 + void OnSqlMousePosition(wxMouseEvent & event); 836 + void OnSqlArrowPosition(wxKeyEvent & event); 837 +}; 838 + 839 +class SqlTokenizer 840 +{ 841 +// 842 +// a class used for tokenizing SQL statements 843 +// 844 +private: 845 + wxString ** TokenList; 846 + int Block; 847 + int Max; 848 + int Index; 849 + void Expand(); 850 + void Insert(wxString * token); 851 + wxString CurrentToken; 852 +public: 853 + SqlTokenizer(wxString & sql); 854 + ~SqlTokenizer(); 855 + bool HasMoreTokens(); 856 + wxString & GetNextToken(); 495 857 }; 496 858 497 859 class MyQueryView:public wxPanel 498 860 { 499 861 // 500 862 // a panel to be used for SQL Queries 501 863 // 502 - private: 503 - class MyFrame * MainFrame; 504 - MySqlHistory History; 505 - wxTextCtrl *SqlCtrl; 506 - wxBitmapButton *BtnSqlGo; 507 - wxBitmapButton *BtnHistoryBack; 508 - wxBitmapButton *BtnHistoryForward; 509 - wxBitmapButton *BtnRsFirst; 510 - wxBitmapButton *BtnRsLast; 511 - wxBitmapButton *BtnRsNext; 512 - wxBitmapButton *BtnRsPrevious; 513 - wxBitmapButton *BtnRefresh; 514 - wxStaticText *RsCurrentBlock; 515 - int RsBlock; 516 - int RsBeginRow; 517 - int RsEndRow; 518 - int RsMaxRow; 519 - int CurrentEvtRow; 520 - int CurrentEvtColumn; 521 - MyVariant *CurrentBlob; 522 - wxString SqlErrorMsg; 523 - wxGrid *TableView; 524 - MyBlobs *TableBlobs; 525 - MyValues *TableValues; 526 - bool ReadOnly; 527 - int *RowIds; 528 - int PrimaryKeys[1024]; 529 - int BlobColumns[1024]; 530 - wxString TableName; 531 - bool InsertPending; 532 - MyRowVariant *InsertRow; 533 - public: 534 - MyQueryView () { ; } 535 - MyQueryView (MyFrame * parent, wxWindowID id = wxID_ANY); 536 - virtual ~ MyQueryView () { if (RowIds) delete[]RowIds; 537 - if (InsertRow) delete InsertRow; } 538 - void HideControls (); 539 - void HideRsControls (); 540 - void ShowSqlControls (); 541 - void ShowRsControls (); 542 - bool IsPrimaryKey (int column); 543 - bool IsBlobColumn (int column); 544 - void EditTable (wxString & sql, int *primaryKeys, int *blobCols, 545 - wxString & tableName); 546 - void SetSql (wxString & sql, bool execute); 547 - bool ExecuteSql (wxString & sql, int from); 548 - void CreateGrid (int rows, int cols); 549 - void ResizeTableView (); 550 - void SetHistoryStates (); 551 - void DoInsert (bool confirmed); 552 - void HexBlobValue (unsigned char *blob, int size, wxString & hex); 553 - void OnSize (wxSizeEvent & event); 554 - void OnSqlGo (wxCommandEvent & event); 555 - void OnHistoryBack (wxCommandEvent & event); 556 - void OnHistoryForward (wxCommandEvent & event); 557 - void OnRsFirst (wxCommandEvent & event); 558 - void OnRsLast (wxCommandEvent & event); 559 - void OnRsNext (wxCommandEvent & event); 560 - void OnRsPrevious (wxCommandEvent & event); 561 - void OnRefresh (wxCommandEvent & event); 562 - void OnCellSelected (wxGridEvent & event); 563 - void OnRightClick (wxGridEvent & event); 564 - void OnCellChanged (wxGridEvent & event); 565 - void OnCmdDelete (wxCommandEvent & event); 566 - void OnCmdInsert (wxCommandEvent & event); 567 - void OnCmdAbort (wxCommandEvent & event); 568 - void OnCmdClearSelection (wxCommandEvent & event); 569 - void OnCmdSelectAll (wxCommandEvent & event); 570 - void OnCmdSelectRow (wxCommandEvent & event); 571 - void OnCmdSelectColumn (wxCommandEvent & event); 572 - void OnCmdCopy (wxCommandEvent & event); 573 - void OnCmdBlob (wxCommandEvent & event); 574 - void OnCmdBlobIn (wxCommandEvent & event); 575 - void OnCmdBlobOut (wxCommandEvent & event); 576 - void OnCmdBlobNull (wxCommandEvent & event); 864 +private: 865 + class MyFrame * MainFrame; 866 + MySqlHistory History; 867 + MySqlControl *SqlCtrl; 868 + wxBitmapButton *BtnSqlGo; 869 + wxBitmapButton *BtnHistoryBack; 870 + wxBitmapButton *BtnHistoryForward; 871 + int BracketStart; 872 + int BracketEnd; 873 + bool IgnoreEvent; 874 +public: 875 + MyQueryView() 876 + {; 877 + } 878 + MyQueryView(MyFrame * parent, wxWindowID id = wxID_ANY); 879 + virtual ~ MyQueryView() 880 + {; 881 + } 882 + void HideControls(); 883 + void ShowControls(); 884 + bool IsSqliteExtra(wxString & str); 885 + bool IsSqlString(wxString & str); 886 + bool IsSqlNumber(wxString & str); 887 + bool IsSqlFunction(wxString & str, char next_c); 888 + bool IsSqlGeoFunction(wxString & str, char next_c); 889 + bool IsIgnoreEvent() 890 + { 891 + return IgnoreEvent; 892 + } 893 + void EventBrackets(); 894 + bool CheckBrackets(int pos, bool reverse_direction, int *on, int *off); 895 + void EvidBrackets(int on, int off); 896 + void DoSqlSyntaxColor(); 897 + wxTextCtrl *GetSqlCtrl() 898 + { 899 + return SqlCtrl; 900 + } 901 + void SetSql(wxString & sql, bool execute); 902 + void SetHistoryStates(); 903 + void OnSize(wxSizeEvent & event); 904 + void OnSqlGo(wxCommandEvent & event); 905 + void OnHistoryBack(wxCommandEvent & event); 906 + void OnHistoryForward(wxCommandEvent & event); 907 + void OnSqlSyntaxColor(wxCommandEvent & event); 908 + void AddToHistory(wxString & sql); 577 909 }; 578 910 579 911 class MyFrame:public wxFrame 580 912 { 581 913 // 582 914 // the main GUI frame 583 915 // 584 - private: 585 - unsigned char Jpeg1Signature[2]; 586 - unsigned char Jpeg2Signature[2]; 587 - unsigned char Jpeg3Signature[4]; 588 - unsigned char JfifSignature[4]; 589 - unsigned char ExifSignature[4]; 590 - unsigned char PngSignature[8]; 591 - unsigned char ZipSignature[4]; 592 - wxAuiManager Manager; // the GUI manager 593 - MyTableTree *TableTree; // the tables tree list 594 - MyQueryView *QueryView; // the QueryResult panel 595 - bool HelpPane; // is the HELP pane already opened ? 596 - sqlite3 *SqliteHandle; // handle for SQLite DB 597 - wxString SqlitePath; // path of SQLite DB 598 - wxString LastDirectory; // path of directory used 599 - int CharsetsLen; // # charsets defined 600 - wxString *Charsets; // table of charsets [code only] 601 - wxString *CharsetsNames; // table of charsets [whith description] 602 - wxString LocaleCharset; // locale charset 603 - wxString DefaultCharset; // default charset 604 - bool AskCharset; // switch to set default charset for every output 605 - wxBitmap *BtnCreateNew; // button icon for DB CREATE&CONNECT 606 - wxBitmap *BtnConnect; // button icon for DB CONNECT 607 - wxBitmap *BtnDisconnect; // button icon for DB DISCONNECT 608 - wxBitmap *BtnVacuum; // button icon for DB VACUUM 609 - wxBitmap *BtnSqlScript; // button icon for Execute SQL SCRIPT 610 - wxBitmap *BtnCharset; // button icon for Default CHARSET 611 - wxBitmap *BtnLoadShp; // button icon for LOAD SHP 612 - wxBitmap *BtnLoadTxt; // button icon for LOAD TXT/CSV 613 - wxBitmap *BtnVirtualShp; // button icon for VIRTUAL SHP 614 - wxBitmap *BtnVirtualTxt; // button icon for VIRTUAL TXT/CSV 615 - wxBitmap *BtnSrids; // button icon for SEARCH SRIDs 616 - wxBitmap *BtnHelp; // button icon for HELP 617 - wxBitmap *BtnAbout; // button icon for ABOUT 618 - wxBitmap *BtnExit; // button icon for EXIT 619 - public: 620 - enum 621 - { 622 - BLOB_NULL = 0, 623 - BLOB_HEX, 624 - BLOB_GEOMETRY, 625 - BLOB_JPEG, 626 - BLOB_JFIF, 627 - BLOB_EXIF, 628 - BLOB_PNG, 629 - BLOB_GIF, 630 - BLOB_PDF, 631 - BLOB_ZIP, 632 - }; 633 - MyFrame (const wxString & title, const wxPoint & pos, const wxSize & size, 634 - wxString & path); 635 - virtual ~ MyFrame (); 636 - 637 - void UpdateStatusBar (); 638 - bool IsConnected () { if (SqliteHandle) return true; 639 - else return false; 640 - } 641 - static void CleanSql (char *str); 642 - void CleanTxtTab (char *str); 643 - void CleanCsv (char *str); 644 - void CleanHtml (char *str); 645 - sqlite3 *GetSqlite () { return SqliteHandle; } 646 - void CloseHelpPane () { HelpPane = false; } 647 - void OpenHelpPane () { HelpPane = true; } 648 - 649 - bool OpenDB (); 650 - bool CreateDB (); 651 - void CloseDB (); 652 - void InitTableTree (); 653 - void ClearTableTree (); 654 - void GetTableColumns (wxString & tableName, MyTableInfo * list); 655 - void GetTableIndices (wxString & tableName, MyTableInfo * list); 656 - void GetTableTriggers (wxString & tableName, MyTableInfo * list); 657 - void GetViewColumns (wxString & viewName, MyViewInfo * list); 658 - void EditTable (wxString & sql, int *primaryKeys, int *blobCols, 659 - wxString & table) 660 - { QueryView->EditTable (sql, primaryKeys, blobCols, table); } 661 - void SetSql (wxString & sql, bool execute) 662 - { QueryView->SetSql (sql, execute); } 663 - int GuessBlobType (int blob_size, unsigned char *blob); 664 - bool ExecuteSql (const char *sql, int rowNo); 665 - void Rollback (); 666 - bool TableAlreadyExists (wxString & name); 667 - bool SridNotExists (int srid); 668 - bool CheckMetadata (); 669 - void CleanSqlString (char *sql); 670 - wxString *GetCharsets () { return Charsets; } 671 - wxString *GetCharsetsNames () { return CharsetsNames; } 672 - int GetCharsetsLen () { return CharsetsLen; } 673 - gaiaDbfFieldPtr GetDbfField (gaiaDbfListPtr list, char *name); 674 - void LoadShapefile (wxString & path, wxString & table, int srid, 675 - wxString & column, wxString & charset); 676 - void DumpShapefile (wxString & path, wxString & table, wxString & column, 677 - wxString & charset); 678 - void LoadText (wxString & path, wxString & table, wxString & charset, bool first_titles, char decimal_separator, 679 - char separator, char text_separator); 680 - void DumpTxtTab (wxString & path, wxString & table, wxString & charset); 681 - void DumpCsv (wxString & path, wxString & table, wxString & charset); 682 - void DumpHtml (wxString & path, wxString & table, wxString & charset); 683 - void GetHelp (wxString & html); 684 - wxString *GetColumnNames (wxString & table, int *columns); 685 - void SetLastDirectory (wxString & path) { LastDirectory = path; } 686 - wxString & GetLastDirectory () { return LastDirectory; } 687 - wxString & GetLocaleCharset () { return LocaleCharset; } 688 - wxString & GetDefaultCharset () { return DefaultCharset; } 689 - wxString & GetCharsetName (wxString & charset); 690 - int GetCharsetIndex (wxString & charset); 691 - bool IsSetAskCharset () { return AskCharset; } 692 - char * ReadSqlLine(FILE *fl, int *len, int *eof); 693 - 694 - void OnQuit (wxCommandEvent & event); 695 - void OnAbout (wxCommandEvent & event); 696 - void OnConnect (wxCommandEvent & event); 697 - void OnCreateNew (wxCommandEvent & event); 698 - void OnDisconnect (wxCommandEvent & event); 699 - void OnVacuum (wxCommandEvent & event); 700 - void OnSqlScript (wxCommandEvent & event); 701 - void OnCharset (wxCommandEvent & event); 702 - void OnLoadShp (wxCommandEvent & event); 703 - void OnLoadTxt (wxCommandEvent & event); 704 - void OnVirtualShp (wxCommandEvent & event); 705 - void OnVirtualTxt (wxCommandEvent & event); 706 - void OnSrids (wxCommandEvent & event); 707 - void OnHelp (wxCommandEvent & event); 708 - void OnMouseMove (wxMouseEvent & event); 916 +private: 917 + wxString AutoFDOmsg; 918 + bool SpatiaLiteMetadata; 919 + wxAuiManager Manager; // the GUI manager 920 + wxString ConfigLayout; // PERSISTENCY - the layout configuration 921 + int ConfigPaneX; // PERSISTENCY - the main pane screen origin X 922 + int ConfigPaneY; // PERSISTENCY - the main pane screen origin Y 923 + int ConfigPaneWidth; // PERSISTENCY - the main pane screen width 924 + int ConfigPaneHeight; // PERSISTENCY - the main pane screen height 925 + wxString ConfigDbPath; // PERSISTENCY - the last opend DB path 926 + wxString ConfigDir; //PERSISTENCY - the last used directory 927 + MyTableTree *TableTree; // the tables tree list 928 + MyQueryView *QueryView; // the QueryResult panel 929 + MyResultSetView *RsView; // the QueryResult panel 930 + bool HelpPane; // is the HELP pane already opened ? 931 + sqlite3 *SqliteHandle; // handle for SQLite DB 932 + wxString SqlitePath; // path of SQLite DB 933 + wxString ExternalSqlitePath; // path of external SQLite DB [LOAD/SAVE MEMORY database] 934 + bool MemoryDatabase; // TRUE if we are currently working on the MEMORY database 935 + wxString LastDirectory; // path of directory used 936 + int CharsetsLen; // # charsets defined 937 + wxString *Charsets; // table of charsets [code only] 938 + wxString *CharsetsNames; // table of charsets [with description] 939 + wxString LocaleCharset; // locale charset 940 + wxString DefaultCharset; // default charset 941 + bool AskCharset; // switch to set default charset for every output 942 + int TablesLen; // # tables defined 943 + wxString *TableNames; // array of tables 944 + wxBitmap *BtnCreateNew; // button icon for DB CREATE&CONNECT 945 + wxBitmap *BtnConnect; // button icon for DB CONNECT 946 + wxBitmap *BtnDisconnect; // button icon for DB DISCONNECT 947 + wxBitmap *BtnMemDbLoad; // button icon for MEMORY DB LOAD 948 + wxBitmap *BtnMemDbNew; // button icon for MEMORY DB NEW 949 + wxBitmap *BtnMemDbClock; // button icon for MEMORY DB CLOCK 950 + wxBitmap *BtnMemDbSave; // button icon for MEMORY DB SAVE 951 + wxBitmap *BtnVacuum; // button icon for DB VACUUM 952 + wxBitmap *BtnSqlScript; // button icon for Execute SQL SCRIPT 953 + wxBitmap *BtnCharset; // button icon for Default CHARSET 954 + wxBitmap *BtnLoadShp; // button icon for LOAD SHP 955 + wxBitmap *BtnLoadTxt; // button icon for LOAD TXT/CSV 956 + wxBitmap *BtnVirtualShp; // button icon for VIRTUAL SHP 957 + wxBitmap *BtnVirtualTxt; // button icon for VIRTUAL TXT/CSV 958 + wxBitmap *BtnNetwork; // button icon for BUILD NETWORK 959 + wxBitmap *BtnExif; // button icon for EXIF LOAD 960 + wxBitmap *BtnSrids; // button icon for SEARCH SRIDs 961 + wxBitmap *BtnHelp; // button icon for HELP 962 + wxBitmap *BtnAbout; // button icon for ABOUT 963 + wxBitmap *BtnExit; // button icon for EXIT 964 +// AutoSave timer 965 + int AutoSaveInterval; 966 + int LastTotalChanges; 967 + wxTimer *TimerAutoSave; 968 +public: 969 + MyFrame(const wxString & title, const wxPoint & pos, const wxSize & size, 970 + wxString & path); 971 + virtual ~ MyFrame(); 972 + 973 + void UpdateStatusBar(); 974 + bool IsConnected() 975 + { 976 + if (SqliteHandle) 977 + return true; 978 + else 979 + return false; 980 + } 981 + static void CleanSql(char *str); 982 + void CleanTxtTab(char *str); 983 + void CleanCsv(char *str); 984 + void CleanHtml(char *str); 985 + wxString & GetExternalSqlitePath() 986 + { 987 + return ExternalSqlitePath; 988 + } 989 + void SetExternalSqlitePath(wxString & path) 990 + { 991 + ExternalSqlitePath = path; 992 + } 993 + sqlite3 *GetSqlite() 994 + { 995 + return SqliteHandle; 996 + } 997 + void CloseHelpPane() 998 + { 999 + HelpPane = false; 1000 + } 1001 + void OpenHelpPane() 1002 + { 1003 + HelpPane = true; 1004 + } 1005 + 1006 + bool OpenDB(); 1007 + bool CreateDB(); 1008 + void CloseDB(); 1009 + bool CreateSpatialMetaData(); 1010 + void AutoFDOStart(); 1011 + void AutoFDOStop(); 1012 + void InitTableTree(); 1013 + void ClearTableTree(); 1014 + void GetTableColumns(wxString & tableName, MyTableInfo * list); 1015 + void GetTableIndices(wxString & tableName, MyTableInfo * list); 1016 + void GetTableTriggers(wxString & tableName, MyTableInfo * list); 1017 + void GetViewColumns(wxString & viewName, MyViewInfo * list); 1018 + void EditTable(wxString & sql, int *primaryKeys, int *blobCols, 1019 + wxString & table) 1020 + { 1021 + RsView->EditTable(sql, primaryKeys, blobCols, table); 1022 + } 1023 + void SetSql(wxString & sql, bool execute) 1024 + { 1025 + QueryView->SetSql(sql, execute); 1026 + } 1027 + bool ExecuteSql(const char *sql, int rowNo); 1028 + void Rollback(); 1029 + bool TableAlreadyExists(wxString & name); 1030 + bool SridNotExists(int srid); 1031 + bool CheckMetadata(); 1032 + void CleanSqlString(char *sql); 1033 + void SaveConfig(); 1034 + void LoadConfig(); 1035 + wxString *GetCharsets() 1036 + { 1037 + return Charsets; 1038 + } 1039 + wxString *GetCharsetsNames() 1040 + { 1041 + return CharsetsNames; 1042 + } 1043 + int GetCharsetsLen() 1044 + { 1045 + return CharsetsLen; 1046 + } 1047 + gaiaDbfFieldPtr GetDbfField(gaiaDbfListPtr list, char *name); 1048 + void LoadShapefile(wxString & path, wxString & table, int srid, 1049 + wxString & column, wxString & charset); 1050 + void DumpShapefile(wxString & path, wxString & table, wxString & column, 1051 + wxString & charset); 1052 + void LoadText(wxString & path, wxString & table, wxString & charset, 1053 + bool first_titles, char decimal_separator, char separator, 1054 + char text_separator); 1055 + void DumpTxtTab(wxString & path, wxString & table, wxString & charset); 1056 + void DumpCsv(wxString & path, wxString & table, wxString & charset); 1057 + void DumpHtml(wxString & path, wxString & table, wxString & charset); 1058 + void GetHelp(wxString & html); 1059 + wxString *GetColumnNames(wxString & table, int *columns); 1060 + void SetLastDirectory(wxString & path) 1061 + { 1062 + LastDirectory = path; 1063 + } 1064 + wxString & GetLastDirectory() 1065 + { 1066 + return LastDirectory; 1067 + } 1068 + wxString & GetLocaleCharset() 1069 + { 1070 + return LocaleCharset; 1071 + } 1072 + wxString & GetDefaultCharset() 1073 + { 1074 + return DefaultCharset; 1075 + } 1076 + wxString & GetCharsetName(wxString & charset); 1077 + int GetCharsetIndex(wxString & charset); 1078 + bool IsSetAskCharset() 1079 + { 1080 + return AskCharset; 1081 + } 1082 + char *ReadSqlLine(FILE * fl, int *len, int *eof); 1083 + MyQueryView *GetQueryView() 1084 + { 1085 + return QueryView; 1086 + } 1087 + MyResultSetView *GetRsView() 1088 + { 1089 + return RsView; 1090 + } 1091 + wxString *GetTables(int *cnt); 1092 + void BuildNetwork(wxString & table, wxString & from, wxString & to, 1093 + wxString & geometry, bool cost_length, wxString & cost, 1094 + bool bidirectional, bool one_way, 1095 + wxString & one_way_from_to, wxString & one_way_to_from); 1096 + bool CreateNetwork(class Network * net, wxString & table, wxString & from, 1097 + wxString & to, wxString & geometry); 1098 + void ImportExifPhotos(wxString & path, bool folder, bool metadata, 1099 + bool gps_only); 1100 + void OutputNetNode(unsigned char *auxbuf, int *size, int ind, bool node_code, 1101 + int max_node_length, class NetNode * pN, int endian_arch); 1102 + bool CheckExifTables(); 1103 + int ExifLoadDir(wxString & path, bool gps_only, bool metadata); 1104 + int ExifLoadFile(wxString & path, bool gps_only, bool metadata); 1105 + bool UpdateExifTables(unsigned char *blob, int sz, 1106 + gaiaExifTagListPtr tag_list, bool metadata, 1107 + wxString & path); 1108 + bool IsExifGps(gaiaExifTagListPtr tag_list); 1109 + void GetMake(gaiaExifTagListPtr tag_list, wxString & str, bool * ok); 1110 + void GetModel(gaiaExifTagListPtr tag_list, wxString & str, bool * ok); 1111 + void GetGpsTimestamp(gaiaExifTagListPtr tag_list, wxString & str, bool * ok); 1112 + void GetDate(gaiaExifTagListPtr tag_list, wxString & str, bool * ok); 1113 + double GetGpsDirection(gaiaExifTagListPtr tag_list, bool * ok); 1114 + void GetGpsSatellites(gaiaExifTagListPtr tag_list, wxString & str, bool * ok); 1115 + void GetGpsCoords(gaiaExifTagListPtr tag_list, double *longitude, 1116 + double *latitude, bool * ok); 1117 + sqlite3_int64 GetPixelX(gaiaExifTagListPtr tag_list, bool * ok); 1118 + sqlite3_int64 GetPixelY(gaiaExifTagListPtr tag_list, bool * ok); 1119 + 1120 + bool MemoryDbSave(); 1121 + void LastDitchMemoryDbSave(); 1122 + 1123 + void OnQuit(wxCommandEvent & event); 1124 + void OnAbout(wxCommandEvent & event); 1125 + void OnConnect(wxCommandEvent & event); 1126 + void OnCreateNew(wxCommandEvent & event); 1127 + void OnDisconnect(wxCommandEvent & event); 1128 + void OnMemoryDbLoad(wxCommandEvent & event); 1129 + void OnMemoryDbNew(wxCommandEvent & event); 1130 + void OnMemoryDbClock(wxCommandEvent & event); 1131 + void OnMemoryDbSave(wxCommandEvent & event); 1132 + void OnVacuum(wxCommandEvent & event); 1133 + void OnSqlScript(wxCommandEvent & event); 1134 + void OnCharset(wxCommandEvent & event); 1135 + void OnLoadShp(wxCommandEvent & event); 1136 + void OnLoadTxt(wxCommandEvent & event); 1137 + void OnVirtualShp(wxCommandEvent & event); 1138 + void OnVirtualTxt(wxCommandEvent & event); 1139 + void OnNetwork(wxCommandEvent & event); 1140 + void OnImportExifPhotos(wxCommandEvent & event); 1141 + void OnSrids(wxCommandEvent & event); 1142 + void OnHelp(wxCommandEvent & event); 1143 + void OnMouseMove(wxMouseEvent & event); 1144 + void OnTimerAutoSave(wxTimerEvent & event); 709 1145 }; 710 1146 711 1147 class HelpDialog:public wxDialog 712 1148 { 713 1149 // 714 1150 // the help dialog 715 1151 // 716 - private: 717 - MyFrame * MainFrame; 718 - public: 719 - HelpDialog () { MainFrame = NULL; } 720 - HelpDialog (MyFrame * parent) { Create (parent); } 721 - bool Create (MyFrame * parent); 722 - virtual ~ HelpDialog () { ; } 723 - void CreateControls (); 724 - void OnClose (wxCloseEvent & event); 1152 +private: 1153 + MyFrame * MainFrame; 1154 +public: 1155 + HelpDialog() 1156 + { 1157 + MainFrame = NULL; 1158 + } 1159 + HelpDialog(MyFrame * parent) 1160 + { 1161 + Create(parent); 1162 + } 1163 + bool Create(MyFrame * parent); 1164 + virtual ~ HelpDialog() 1165 + {; 1166 + } 1167 + void CreateControls(); 1168 + void OnClose(wxCloseEvent & event); 1169 + void OnSize(wxSizeEvent & event); 725 1170 }; 726 1171 727 1172 class SearchSridDialog:public wxDialog 728 1173 { 729 1174 // 730 1175 // a dialog preparing a Search SRID by name 731 1176 // 732 - private: 733 - MyFrame * MainFrame; 734 - wxString String; // required search string 735 - public: 736 - SearchSridDialog () { ; } 737 - SearchSridDialog (MyFrame * parent); 738 - bool Create (MyFrame * parent); 739 - virtual ~ SearchSridDialog () { ; } 740 - void CreateControls (); 741 - wxString & GetString () { return String; } 742 - void OnOk (wxCommandEvent & event); 1177 +private: 1178 + MyFrame * MainFrame; 1179 + wxString String; // required search string 1180 +public: 1181 + SearchSridDialog() 1182 + {; 1183 + } 1184 + SearchSridDialog(MyFrame * parent); 1185 + bool Create(MyFrame * parent); 1186 + virtual ~ SearchSridDialog() 1187 + {; 1188 + } 1189 + void CreateControls(); 1190 + wxString & GetString() 1191 + { 1192 + return String; 1193 + } 1194 + void OnOk(wxCommandEvent & event); 743 1195 }; 744 1196 745 1197 class SetSridDialog:public wxDialog 746 1198 { 747 1199 // 748 1200 // a dialog preparing a SET SRID 749 1201 // 750 - private: 751 - MyFrame * MainFrame; 752 - wxString Table; // the table's name 753 - wxString Column; // the column's name to be recovered 754 - int OldSrid; // SRID to substitute 755 - int Srid; // required SRID 756 - public: 757 - SetSridDialog () { ; } 758 - SetSridDialog (MyFrame * parent, wxString & table, wxString & column); 759 - bool Create (MyFrame * parent, wxString & table, wxString & column); 760 - virtual ~ SetSridDialog () { ; } 761 - void CreateControls (); 762 - int GetOldSrid () { return OldSrid; } 763 - int GetSrid () { return Srid; } 764 - void OnOk (wxCommandEvent & event); 1202 +private: 1203 + MyFrame * MainFrame; 1204 + wxString Table; // the table's name 1205 + wxString Column; // the column's name to be recovered 1206 + int OldSrid; // SRID to substitute 1207 + int Srid; // required SRID 1208 +public: 1209 + SetSridDialog() 1210 + {; 1211 + } 1212 + SetSridDialog(MyFrame * parent, wxString & table, wxString & column); 1213 + bool Create(MyFrame * parent, wxString & table, wxString & column); 1214 + virtual ~ SetSridDialog() 1215 + {; 1216 + } 1217 + void CreateControls(); 1218 + int GetOldSrid() 1219 + { 1220 + return OldSrid; 1221 + } 1222 + int GetSrid() 1223 + { 1224 + return Srid; 1225 + } 1226 + void OnOk(wxCommandEvent & event); 765 1227 }; 766 1228 767 1229 class RecoverDialog:public wxDialog 768 1230 { 769 1231 // 770 1232 // a dialog preparing a RECOVER GEOMETRY 771 1233 // 772 - private: 773 - MyFrame * MainFrame; 774 - wxString Table; // the table's name 775 - wxString Column; // the column's name to be recovered 776 - int Srid; // required SRID 777 - wxString Type; // required Geometry Type 778 - public: 779 - RecoverDialog () { ; } 780 - RecoverDialog (MyFrame * parent, wxString & table, wxString & column); 781 - bool Create (MyFrame * parent, wxString & table, wxString & column); 782 - virtual ~ RecoverDialog () { ; } 783 - void CreateControls (); 784 - wxString & GetType () { return Type; } 785 - int GetSrid () { return Srid; } 786 - void OnOk (wxCommandEvent & event); 1234 +private: 1235 + MyFrame * MainFrame; 1236 + wxString Table; // the table's name 1237 + wxString Column; // the column's name to be recovered 1238 + int Srid; // required SRID 1239 + wxString Type; // required Geometry Type 1240 +public: 1241 + RecoverDialog() 1242 + {; 1243 + } 1244 + RecoverDialog(MyFrame * parent, wxString & table, wxString & column); 1245 + bool Create(MyFrame * parent, wxString & table, wxString & column); 1246 + virtual ~ RecoverDialog() 1247 + {; 1248 + } 1249 + void CreateControls(); 1250 + wxString & GetType() 1251 + { 1252 + return Type; 1253 + } 1254 + int GetSrid() 1255 + { 1256 + return Srid; 1257 + } 1258 + void OnOk(wxCommandEvent & event); 787 1259 }; 788 1260 789 1261 class VirtualShpDialog:public wxDialog 790 1262 { 791 1263 // 792 1264 // a dialog preparing a CREATE VIRTUAL SHAPE 793 1265 // 794 - private: 795 - MyFrame * MainFrame; 796 - wxString Path; // the SHP base path 797 - wxString Table; // the table name 798 - wxString Default; // the default charset 799 - wxString Charset; // the SHP charset 800 - int Srid; // the SRID 801 - public: 802 - VirtualShpDialog () { ; } 803 - VirtualShpDialog (MyFrame * parent, wxString & path, wxString & table, wxString & defCs); 804 - bool Create (MyFrame * parent, wxString & path, wxString & table, wxString & defCs); 805 - virtual ~ VirtualShpDialog () { ; } 806 - void CreateControls (); 807 - wxString & GetTable() { return Table; } 808 - wxString & GetCharset () { return Charset; } 809 - int GetSrid () { return Srid; } 810 - void OnOk (wxCommandEvent & event); 1266 +private: 1267 + MyFrame * MainFrame; 1268 + wxString Path; // the SHP base path 1269 + wxString Table; // the table name 1270 + wxString Default; // the default charset 1271 + wxString Charset; // the SHP charset 1272 + int Srid; // the SRID 1273 +public: 1274 + VirtualShpDialog() 1275 + {; 1276 + } 1277 + VirtualShpDialog(MyFrame * parent, wxString & path, wxString & table, 1278 + wxString & defCs); 1279 + bool Create(MyFrame * parent, wxString & path, wxString & table, 1280 + wxString & defCs); 1281 + virtual ~ VirtualShpDialog() 1282 + {; 1283 + } 1284 + void CreateControls(); 1285 + wxString & GetTable() 1286 + { 1287 + return Table; 1288 + } 1289 + wxString & GetCharset() 1290 + { 1291 + return Charset; 1292 + } 1293 + int GetSrid() 1294 + { 1295 + return Srid; 1296 + } 1297 + void OnOk(wxCommandEvent & event); 811 1298 }; 812 1299 813 1300 class VirtualTxtDialog:public wxDialog 814 1301 { 815 1302 // 816 1303 // a dialog preparing a CREATE VIRTUAL TEXT 817 1304 // 818 - private: 819 - MyFrame * MainFrame; 820 - wxString Path; // the CSV/TXT base path 821 - wxString Table; // the table name 822 - wxString Default; // the default charset 823 - wxString Charset; // the CSV/TXT charset 824 - bool FirstLineTitles; // TRUE if first line stores column titles 825 - char Separator; // the character to be used as field separator 826 - char TextSeparator; // the character to be used as text separator 827 - bool DecimalPointIsComma; // TRUE if decimal separator is COMMA 828 - public: 829 - VirtualTxtDialog () { ; } 830 - VirtualTxtDialog (MyFrame * parent, wxString & path, wxString & table, wxString & defCs); 831 - bool Create (MyFrame * parent, wxString & path, wxString & table, wxString & defCs); 832 - virtual ~ VirtualTxtDialog () { ; } 833 - void CreateControls (); 834 - wxString & GetTable() { return Table; } 835 - wxString & GetCharset () { return Charset; } 836 - bool IsFirstLineTitles() { return FirstLineTitles; } 837 - char GetSeparator() { return Separator; } 838 - char GetTextSeparator() { return TextSeparator; } 839 - bool IsDecimalPointComma() { return DecimalPointIsComma; } 840 - void OnSeparator (wxCommandEvent & event); 841 - void OnDecimalSeparator (wxCommandEvent & event); 842 - void OnQuote (wxCommandEvent & event); 843 - void OnOk (wxCommandEvent & event); 1305 +private: 1306 + MyFrame * MainFrame; 1307 + wxString Path; // the CSV/TXT base path 1308 + wxString Table; // the table name 1309 + wxString Default; // the default charset 1310 + wxString Charset; // the CSV/TXT charset 1311 + bool FirstLineTitles; // TRUE if first line stores column titles 1312 + char Separator; // the character to be used as field separator 1313 + char TextSeparator; // the character to be used as text separator 1314 + bool DecimalPointIsComma; // TRUE if decimal separator is COMMA 1315 +public: 1316 + VirtualTxtDialog() 1317 + {; 1318 + } 1319 + VirtualTxtDialog(MyFrame * parent, wxString & path, wxString & table, 1320 + wxString & defCs); 1321 + bool Create(MyFrame * parent, wxString & path, wxString & table, 1322 + wxString & defCs); 1323 + virtual ~ VirtualTxtDialog() 1324 + {; 1325 + } 1326 + void CreateControls(); 1327 + wxString & GetTable() 1328 + { 1329 + return Table; 1330 + } 1331 + wxString & GetCharset() 1332 + { 1333 + return Charset; 1334 + } 1335 + bool IsFirstLineTitles() 1336 + { 1337 + return FirstLineTitles; 1338 + } 1339 + char GetSeparator() 1340 + { 1341 + return Separator; 1342 + } 1343 + char GetTextSeparator() 1344 + { 1345 + return TextSeparator; 1346 + } 1347 + bool IsDecimalPointComma() 1348 + { 1349 + return DecimalPointIsComma; 1350 + } 1351 + void OnSeparator(wxCommandEvent & event); 1352 + void OnDecimalSeparator(wxCommandEvent & event); 1353 + void OnQuote(wxCommandEvent & event); 1354 + void OnOk(wxCommandEvent & event); 844 1355 }; 845 1356 846 1357 class LoadShpDialog:public wxDialog 847 1358 { 848 1359 // 849 1360 // a dialog preparing a LOAD SHAPE 850 1361 // 851 - private: 852 - MyFrame * MainFrame; 853 - wxString Path; // the SHP base path 854 - wxString Table; // the table's name to be created 855 - wxString Column; // the column's name for Geometry 856 - wxString Default; // the default charset 857 - wxString Charset; // the SHP charset 858 - int Srid; // the SRID 859 - public: 860 - LoadShpDialog () { ; } 861 - LoadShpDialog (MyFrame * parent, wxString & path, wxString & table, 862 - int srid, wxString & column, wxString & defCs); 863 - bool Create (MyFrame * parent, wxString & path, wxString & table, int srid, 864 - wxString & column, wxString & defCs); 865 - virtual ~ LoadShpDialog () { ; } 866 - void CreateControls (); 867 - wxString & GetTable () { return Table; } 868 - wxString & GetColumn () { return Column; } 869 - wxString & GetCharset () { return Charset; } 870 - int GetSrid () { return Srid; } 871 - void OnOk (wxCommandEvent & event); 1362 +private: 1363 + MyFrame * MainFrame; 1364 + wxString Path; // the SHP base path 1365 + wxString Table; // the table's name to be created 1366 + wxString Column; // the column's name for Geometry 1367 + wxString Default; // the default charset 1368 + wxString Charset; // the SHP charset 1369 + int Srid; // the SRID 1370 +public: 1371 + LoadShpDialog() 1372 + {; 1373 + } 1374 + LoadShpDialog(MyFrame * parent, wxString & path, wxString & table, int srid, 1375 + wxString & column, wxString & defCs); 1376 + bool Create(MyFrame * parent, wxString & path, wxString & table, int srid, 1377 + wxString & column, wxString & defCs); 1378 + virtual ~ LoadShpDialog() 1379 + {; 1380 + } 1381 + void CreateControls(); 1382 + wxString & GetTable() 1383 + { 1384 + return Table; 1385 + } 1386 + wxString & GetColumn() 1387 + { 1388 + return Column; 1389 + } 1390 + wxString & GetCharset() 1391 + { 1392 + return Charset; 1393 + } 1394 + int GetSrid() 1395 + { 1396 + return Srid; 1397 + } 1398 + void OnOk(wxCommandEvent & event); 872 1399 }; 873 1400 874 1401 class DumpShpDialog:public wxDialog 875 1402 { 876 1403 // 877 1404 // a dialog preparing a DUMP SHAPE 878 1405 // 879 - private: 880 - MyFrame * MainFrame; 881 - wxString Path; // the SHP base path 882 - wxString Table; // the table's name to be created 883 - wxString Column; // the column's name for Geometry 884 - wxString Default; // the default charset 885 - wxString Charset; // the SHP charset 886 - public: 887 - DumpShpDialog () { ; } 888 - DumpShpDialog (MyFrame * parent, wxString & path, wxString & table, 889 - wxString & column, wxString & defCs); 890 - bool Create (MyFrame * parent, wxString & path, wxString & table, 891 - wxString & column, wxString & defCs); 892 - virtual ~ DumpShpDialog () { ; } 893 - void CreateControls (); 894 - wxString & GetCharset () { return Charset; } 895 - void OnOk (wxCommandEvent & event); 1406 +private: 1407 + MyFrame * MainFrame; 1408 + wxString Path; // the SHP base path 1409 + wxString Table; // the table's name to be created 1410 + wxString Column; // the column's name for Geometry 1411 + wxString Default; // the default charset 1412 + wxString Charset; // the SHP charset 1413 +public: 1414 + DumpShpDialog() 1415 + {; 1416 + } 1417 + DumpShpDialog(MyFrame * parent, wxString & path, wxString & table, 1418 + wxString & column, wxString & defCs); 1419 + bool Create(MyFrame * parent, wxString & path, wxString & table, 1420 + wxString & column, wxString & defCs); 1421 + virtual ~ DumpShpDialog() 1422 + {; 1423 + } 1424 + void CreateControls(); 1425 + wxString & GetCharset() 1426 + { 1427 + return Charset; 1428 + } 1429 + void OnOk(wxCommandEvent & event); 896 1430 }; 897 1431 898 1432 class LoadTxtDialog:public wxDialog 899 1433 { 900 1434 // 901 1435 // a dialog preparing a LOAD TXT/CSV 902 1436 // 903 - private: 904 - MyFrame * MainFrame; 905 - wxString Path; // the CSV/TXT base path 906 - wxString Table; // the table name 907 - wxString Default; // the default charset 908 - wxString Charset; // the CSV/TXT charset 909 - bool FirstLineTitles; // TRUE if first line stores column titles 910 - char Separator; // the character to be used as field separator 911 - char TextSeparator; // the character to be used as text separator 912 - bool DecimalPointIsComma; // TRUE if decimal separator is COMMA 913 - public: 914 - LoadTxtDialog () { ; } 915 - LoadTxtDialog (MyFrame * parent, wxString & path, wxString & table, wxString & defCs); 916 - bool Create (MyFrame * parent, wxString & path, wxString & table, wxString & defCs); 917 - virtual ~ LoadTxtDialog () { ; } 918 - void CreateControls (); 919 - wxString & GetTable() { return Table; } 920 - wxString & GetCharset () { return Charset; } 921 - bool IsFirstLineTitles() { return FirstLineTitles; } 922 - char GetSeparator() { return Separator; } 923 - char GetTextSeparator() { return TextSeparator; } 924 - bool IsDecimalPointComma() { return DecimalPointIsComma; } 925 - void OnSeparator (wxCommandEvent & event); 926 - void OnDecimalSeparator (wxCommandEvent & event); 927 - void OnQuote (wxCommandEvent & event); 928 - void OnOk (wxCommandEvent & event); 1437 +private: 1438 + MyFrame * MainFrame; 1439 + wxString Path; // the CSV/TXT base path 1440 + wxString Table; // the table name 1441 + wxString Default; // the default charset 1442 + wxString Charset; // the CSV/TXT charset 1443 + bool FirstLineTitles; // TRUE if first line stores column titles 1444 + char Separator; // the character to be used as field separator 1445 + char TextSeparator; // the character to be used as text separator 1446 + bool DecimalPointIsComma; // TRUE if decimal separator is COMMA 1447 +public: 1448 + LoadTxtDialog() 1449 + {; 1450 + } 1451 + LoadTxtDialog(MyFrame * parent, wxString & path, wxString & table, 1452 + wxString & defCs); 1453 + bool Create(MyFrame * parent, wxString & path, wxString & table, 1454 + wxString & defCs); 1455 + virtual ~ LoadTxtDialog() 1456 + {; 1457 + } 1458 + void CreateControls(); 1459 + wxString & GetTable() 1460 + { 1461 + return Table; 1462 + } 1463 + wxString & GetCharset() 1464 + { 1465 + return Charset; 1466 + } 1467 + bool IsFirstLineTitles() 1468 + { 1469 + return FirstLineTitles; 1470 + } 1471 + char GetSeparator() 1472 + { 1473 + return Separator; 1474 + } 1475 + char GetTextSeparator() 1476 + { 1477 + return TextSeparator; 1478 + } 1479 + bool IsDecimalPointComma() 1480 + { 1481 + return DecimalPointIsComma; 1482 + } 1483 + void OnSeparator(wxCommandEvent & event); 1484 + void OnDecimalSeparator(wxCommandEvent & event); 1485 + void OnQuote(wxCommandEvent & event); 1486 + void OnOk(wxCommandEvent & event); 929 1487 }; 930 1488 931 1489 class DumpTxtDialog:public wxDialog 932 1490 { 933 1491 // 934 1492 // a dialog preparing a DUMP generic text 935 1493 // 936 - private: 937 - MyFrame * MainFrame; 938 - wxString Path; // the SHP base path 939 - wxString Default; // the default charset 940 - wxString Charset; // the target charset 941 - public: 942 - DumpTxtDialog () { ; } 943 - DumpTxtDialog (MyFrame * parent, wxString & path, wxString & target, 944 - wxString & defCs); 945 - bool Create (MyFrame * parent, wxString & path, wxString & target, 946 - wxString & defCs); 947 - virtual ~ DumpTxtDialog () { ; } 948 - void CreateControls (); 949 - wxString & GetCharset () { return Charset; } 950 - void OnOk (wxCommandEvent & event); 1494 +private: 1495 + MyFrame * MainFrame; 1496 + wxString Path; // the SHP base path 1497 + wxString Default; // the default charset 1498 + wxString Charset; // the target charset 1499 +public: 1500 + DumpTxtDialog() 1501 + {; 1502 + } 1503 + DumpTxtDialog(MyFrame * parent, wxString & path, wxString & target, 1504 + wxString & defCs); 1505 + bool Create(MyFrame * parent, wxString & path, wxString & target, 1506 + wxString & defCs); 1507 + virtual ~ DumpTxtDialog() 1508 + {; 1509 + } 1510 + void CreateControls(); 1511 + wxString & GetCharset() 1512 + { 1513 + return Charset; 1514 + } 1515 + void OnOk(wxCommandEvent & event); 1516 +}; 1517 + 1518 +class NetworkDialog:public wxDialog 1519 +{ 1520 +// 1521 +// a dialog preparing a BUILD NETWORK 1522 +// 1523 +private: 1524 + MyFrame * MainFrame; 1525 + wxString TableName; // the table name 1526 + wxString FromColumn; // the NodeFrom column name 1527 + wxString ToColumn; // the NodeTo column name 1528 + wxString GeomColumn; // the Geometry column name 1529 + bool GeomLength; // Cost is Geometry Length 1530 + wxString CostColumn; // the Cost column name 1531 + bool Bidirectional; // Bidirectional arcs 1532 + bool OneWays; // OneWays columns supported 1533 + wxString OneWayToFrom; // the OneWay To-From column 1534 + wxString OneWayFromTo; // the OneWay From-To column 1535 +public: 1536 + NetworkDialog() 1537 + {; 1538 + } 1539 + NetworkDialog(MyFrame * parent); 1540 + bool Create(MyFrame * parent); 1541 + virtual ~ NetworkDialog() 1542 + {; 1543 + } 1544 + void CreateControls(); 1545 + wxString & GetTableName() 1546 + { 1547 + return TableName; 1548 + } 1549 + wxString & GetFromColumn() 1550 + { 1551 + return FromColumn; 1552 + } 1553 + wxString & GetToColumn() 1554 + { 1555 + return ToColumn; 1556 + } 1557 + wxString & GetGeomColumn() 1558 + { 1559 + return GeomColumn; 1560 + } 1561 + bool IsGeomLength() 1562 + { 1563 + return GeomLength; 1564 + } 1565 + wxString & GetCostColumn() 1566 + { 1567 + return CostColumn; 1568 + } 1569 + bool IsBidirectional() 1570 + { 1571 + return Bidirectional; 1572 + } 1573 + bool IsOneWays() 1574 + { 1575 + return OneWays; 1576 + } 1577 + wxString & GetOneWayFromTo() 1578 + { 1579 + return OneWayFromTo; 1580 + } 1581 + wxString & GetOneWayToFrom() 1582 + { 1583 + return OneWayToFrom; 1584 + } 1585 + void OnTable(wxCommandEvent & event); 1586 + void OnDirection(wxCommandEvent & event); 1587 + void OnCost(wxCommandEvent & event); 1588 + void OnOneWay(wxCommandEvent & event); 1589 + void OnOk(wxCommandEvent & event); 1590 +}; 1591 + 1592 +class ExifDialog:public wxDialog 1593 +{ 1594 +// 1595 +// a dialog preparing an IMPORT EXIF PHOTOS 1596 +// 1597 +private: 1598 + MyFrame * MainFrame; 1599 + wxString ImgPath; // the file name 1600 + wxString DirPath; // the folder path 1601 + bool Folder; // import a whole folder 1602 + bool Metadata; // feed Metadata tables 1603 + bool GpsOnly; // import only if GpsExif present 1604 +public: 1605 + ExifDialog() 1606 + {; 1607 + } 1608 + ExifDialog(MyFrame * parent, wxString & dir_path, wxString & img_path); 1609 + bool Create(MyFrame * parent, wxString & dir_path, wxString & img_path); 1610 + virtual ~ ExifDialog() 1611 + {; 1612 + } 1613 + void CreateControls(); 1614 + wxString & GetImgPath() 1615 + { 1616 + return ImgPath; 1617 + } 1618 + wxString & GetDirPath() 1619 + { 1620 + return DirPath; 1621 + } 1622 + bool IsFolder() 1623 + { 1624 + return Folder; 1625 + } 1626 + bool IsMetadata() 1627 + { 1628 + return Metadata; 1629 + } 1630 + bool IsGpsOnly() 1631 + { 1632 + return GpsOnly; 1633 + } 1634 + void OnFolder(wxCommandEvent & event); 1635 + void OnMetadata(wxCommandEvent & event); 1636 + void OnGpsOnly(wxCommandEvent & event); 1637 + void OnOk(wxCommandEvent & event); 951 1638 }; 952 1639 953 1640 class SqlScriptDialog:public wxDialog 954 1641 { 955 1642 // 956 1643 // a dialog preparing an SQL SCRIPT execute 957 1644 // 958 - private: 959 - MyFrame * MainFrame; 960 - wxString Path; // the SHP base path 961 - wxString Default; // the default charset 962 - wxString Charset; // the target charset 963 - public: 964 - SqlScriptDialog () { ; } 965 - SqlScriptDialog (MyFrame * parent, wxString & path, wxString & defCs); 966 - bool Create (MyFrame * parent, wxString & path, wxString & defCs); 967 - virtual ~ SqlScriptDialog () { ; } 968 - void CreateControls (); 969 - wxString & GetCharset () { return Charset; } 970 - void OnOk (wxCommandEvent & event); 1645 +private: 1646 + MyFrame * MainFrame; 1647 + wxString Path; // the SHP base path 1648 + wxString Default; // the default charset 1649 + wxString Charset; // the target charset 1650 +public: 1651 + SqlScriptDialog() 1652 + {; 1653 + } 1654 + SqlScriptDialog(MyFrame * parent, wxString & path, wxString & defCs); 1655 + bool Create(MyFrame * parent, wxString & path, wxString & defCs); 1656 + virtual ~ SqlScriptDialog() 1657 + {; 1658 + } 1659 + void CreateControls(); 1660 + wxString & GetCharset() 1661 + { 1662 + return Charset; 1663 + } 1664 + void OnOk(wxCommandEvent & event); 971 1665 }; 972 1666 973 1667 class DefaultCharsetDialog:public wxDialog 974 1668 { 975 1669 // 976 1670 // a dialog for selecting DEFAULT CHARSET 977 1671 // 978 - private: 979 - MyFrame * MainFrame; 980 - wxString Charset; // the default charset 981 - bool AskCharset; // true / false 982 - public: 983 - DefaultCharsetDialog () { ; } 984 - DefaultCharsetDialog (MyFrame * parent, wxString & charset, bool ask); 985 - bool Create (MyFrame * parent, wxString & charset, bool ask); 986 - virtual ~ DefaultCharsetDialog () { ; } 987 - void CreateControls (); 988 - wxString & GetCharset () { return Charset; } 989 - bool IsSetAskCharset () { return AskCharset; } 990 - void OnOk (wxCommandEvent & event); 1672 +private: 1673 + MyFrame * MainFrame; 1674 + wxString Charset; // the default charset 1675 + bool AskCharset; // true / false 1676 +public: 1677 + DefaultCharsetDialog() 1678 + {; 1679 + } 1680 + DefaultCharsetDialog(MyFrame * parent, wxString & charset, bool ask); 1681 + bool Create(MyFrame * parent, wxString & charset, bool ask); 1682 + virtual ~ DefaultCharsetDialog() 1683 + {; 1684 + } 1685 + void CreateControls(); 1686 + wxString & GetCharset() 1687 + { 1688 + return Charset; 1689 + } 1690 + bool IsSetAskCharset() 1691 + { 1692 + return AskCharset; 1693 + } 1694 + void OnOk(wxCommandEvent & event); 991 1695 }; 992 - 993 1696 994 1697 class BlobExplorerDialog:public wxPropertySheetDialog 995 1698 { 996 1699 // 997 1700 // a dialog to explore a BLOB value 998 1701 // 999 - private: 1000 - MyFrame * MainFrame; 1001 - int BlobSize; // the BLOB size 1002 - unsigned char *Blob; // the BLOB value 1003 - int BlobType; // the BLOB type 1004 - gaiaGeomCollPtr Geometry; // the geometry [optional] 1005 - wxImage *Image; // the image [optional] 1006 - wxBitmap GeomPreview; // the geometry preview 1007 - public: 1008 - BlobExplorerDialog () 1009 - {; 1010 - } 1011 - BlobExplorerDialog (MyFrame * parent, int blob_size, unsigned char *blob); 1012 - bool Create (MyFrame * parent, int blob_size, unsigned char *blob); 1013 - virtual ~ BlobExplorerDialog () { if (Geometry) gaiaFreeGeomColl (Geometry); 1014 - if (Image) delete Image; } 1015 - void DrawGeometry (int horz, int vert); 1016 - wxPanel *CreateHexadecimalPage (wxWindow * book); 1017 - wxPanel *CreateGeometryPage (wxWindow * book); 1018 - wxPanel *CreateImagePage (wxWindow * book); 1019 - void UpdateHexadecimalPage (); 1020 - void UpdateGeometryPage (); 1021 - void UpdateImagePage (); 1022 - gaiaGeomCollPtr GetGeometry () { return Geometry; } 1023 - wxImage *GetImage () { return Image; } 1024 - int GetBlobType () { return BlobType; } 1025 - void OnOk (wxCommandEvent & event); 1026 - void OnPageChanged (wxNotebookEvent & event); 1702 +private: 1703 + MyFrame * MainFrame; 1704 + int BlobSize; // the BLOB size 1705 + unsigned char *Blob; // the BLOB value 1706 + int BlobType; // the BLOB type 1707 + gaiaGeomCollPtr Geometry; // the geometry [optional] 1708 + wxImage *Image; // the image [optional] 1709 + wxBitmap GeomPreview; // the geometry preview 1710 +public: 1711 + BlobExplorerDialog() 1712 + {; 1713 + } 1714 + BlobExplorerDialog(MyFrame * parent, int blob_size, unsigned char *blob); 1715 + bool Create(MyFrame * parent, int blob_size, unsigned char *blob); 1716 + virtual ~ BlobExplorerDialog() 1717 + { 1718 + if (Geometry) 1719 + gaiaFreeGeomColl(Geometry); 1720 + if (Image) 1721 + delete Image; 1722 + } 1723 + void DrawGeometry(int horz, int vert); 1724 + wxPanel *CreateHexadecimalPage(wxWindow * book); 1725 + wxPanel *CreateGeometryPage(wxWindow * book); 1726 + wxPanel *CreateImagePage(wxWindow * book); 1727 + void UpdateHexadecimalPage(); 1728 + void UpdateGeometryPage(); 1729 + void UpdateImagePage(); 1730 + gaiaGeomCollPtr GetGeometry() 1731 + { 1732 + return Geometry; 1733 + } 1734 + wxImage *GetImage() 1735 + { 1736 + return Image; 1737 + } 1738 + int GetBlobType() 1739 + { 1740 + return BlobType; 1741 + } 1742 + void OnOk(wxCommandEvent & event); 1743 + void OnPageChanged(wxNotebookEvent & event); 1027 1744 }; 1028 1745 1029 1746 class GraphicsGeometry:public wxStaticBitmap 1030 1747 { 1031 1748 // 1032 1749 // a window to show some Geometry in a graphical fashion 1033 1750 // 1034 - private: 1035 - BlobExplorerDialog * Parent; 1036 - public: 1037 - GraphicsGeometry (BlobExplorerDialog * parent, wxWindow * panel, 1038 - wxWindowID id, const wxBitmap & bmp, wxSize const &size); 1039 - virtual ~ GraphicsGeometry () { ; } 1751 +private: 1752 + BlobExplorerDialog * Parent; 1753 +public: 1754 + GraphicsGeometry(BlobExplorerDialog * parent, wxWindow * panel, wxWindowID id, 1755 + const wxBitmap & bmp, wxSize const &size); 1756 + virtual ~ GraphicsGeometry() 1757 + {; 1758 + } 1040 1759 }; 1041 1760 1042 1761 class ImageShow:public wxStaticBitmap 1043 1762 { 1044 1763 // 1045 1764 // a window to show some Image [Jpeg-Png-Gif] 1046 1765 // 1047 - private: 1048 - BlobExplorerDialog * Parent; 1049 - public: 1050 - ImageShow (BlobExplorerDialog * parent, wxWindow * panel, wxWindowID id, 1051 - const wxBitmap & bmp, const wxSize & size); 1052 - virtual ~ ImageShow () { ; } 1053 - void OnRightClick (wxMouseEvent & event); 1054 - void OnCmdCopy (wxCommandEvent & event); 1766 +private: 1767 + BlobExplorerDialog * Parent; 1768 +public: 1769 + ImageShow(BlobExplorerDialog * parent, wxWindow * panel, wxWindowID id, 1770 + const wxBitmap & bmp, const wxSize & size); 1771 + virtual ~ ImageShow() 1772 + {; 1773 + } 1774 + void OnRightClick(wxMouseEvent & event); 1775 + void OnCmdCopy(wxCommandEvent & event); 1055 1776 }; 1056 1777 1057 1778 class MyHexList:public wxListCtrl 1058 1779 { 1059 1780 // 1060 1781 // a class for Hexdecimal dumps 1061 1782 // 1062 - private: 1063 - BlobExplorerDialog * Parent; 1064 - int BlobSize; // the BLOB size 1065 - unsigned char *Blob; // the BLOB value 1066 - public: 1067 - MyHexList (BlobExplorerDialog * parent, unsigned char *blob, 1068 - int blob_size, wxWindow * panel, wxWindowID id, 1069 - const wxPoint & pos = wxDefaultPosition, const wxSize & size = 1070 - wxDefaultSize, long style = 0); 1071 - virtual ~ MyHexList (); 1072 - virtual wxString OnGetItemText (long item, long column) const; 1783 +private: 1784 + BlobExplorerDialog * Parent; 1785 + int BlobSize; // the BLOB size 1786 + unsigned char *Blob; // the BLOB value 1787 +public: 1788 + MyHexList(BlobExplorerDialog * parent, unsigned char *blob, 1789 + int blob_size, wxWindow * panel, wxWindowID id, 1790 + const wxPoint & pos = wxDefaultPosition, const wxSize & size = 1791 + wxDefaultSize, long style = 0); 1792 + virtual ~ MyHexList(); 1793 + virtual wxString OnGetItemText(long item, long column) const; 1794 +}; 1795 + 1796 +class NetNodePre 1797 +{ 1798 +// 1799 +// a class to store a temporary node for Network 1800 +// 1801 +private: 1802 + int Id; 1803 + wxString Code; 1804 + NetNodePre *Next; 1805 +public: 1806 + NetNodePre(int id); 1807 + NetNodePre(const char *code); 1808 + ~NetNodePre() 1809 + {; 1810 + } 1811 + int GetId() 1812 + { 1813 + return Id; 1814 + } 1815 + wxString & GetCode() 1816 + { 1817 + return Code; 1818 + } 1819 + void SetNext(NetNodePre * next) 1820 + { 1821 + Next = next; 1822 + } 1823 + NetNodePre *GetNext() 1824 + { 1825 + return Next; 1826 + } 1827 +}; 1828 + 1829 +class NetNode 1830 +{ 1831 +// 1832 +// a class to store a final node for Network 1833 +// 1834 +private: 1835 + int InternalIndex; 1836 + int Id; 1837 + wxString Code; 1838 + double X; 1839 + double Y; 1840 + class NetArcRef *First; 1841 + class NetArcRef *Last; 1842 + NetNode *Next; 1843 +public: 1844 + NetNode(int id); 1845 + NetNode(wxString & code); 1846 + ~NetNode(); 1847 + int GetInternalIndex() 1848 + { 1849 + return InternalIndex; 1850 + } 1851 + void SetInternalIndex(int idx) 1852 + { 1853 + InternalIndex = idx; 1854 + } 1855 + int GetId() 1856 + { 1857 + return Id; 1858 + } 1859 + wxString & GetCode() 1860 + { 1861 + return Code; 1862 + } 1863 + double GetX() 1864 + { 1865 + return X; 1866 + } 1867 + void SetX(double x) 1868 + { 1869 + X = x; 1870 + } 1871 + double GetY() 1872 + { 1873 + return Y; 1874 + } 1875 + void SetY(double y) 1876 + { 1877 + Y = y; 1878 + } 1879 + void AddOutcoming(class NetArc * pA); 1880 + NetArcRef *GetFirst() 1881 + { 1882 + return First; 1883 + } 1884 + NetArc **PrepareOutcomings(int *count); 1885 + void SetNext(NetNode * next) 1886 + { 1887 + Next = next; 1888 + } 1889 + NetNode *GetNext() 1890 + { 1891 + return Next; 1892 + } 1893 +}; 1894 + 1895 +class NetArc 1896 +{ 1897 +// 1898 +// a class to store an arc for Network 1899 +// 1900 +private: 1901 + int RowId; 1902 + NetNode *From; 1903 + NetNode *To; 1904 + double Cost; 1905 + NetArc *Next; 1906 +public: 1907 + NetArc(int rowid, NetNode * from, NetNode * to, double cost); 1908 + ~NetArc() 1909 + {; 1910 + } 1911 + int GetRowId() 1912 + { 1913 + return RowId; 1914 + } 1915 + NetNode *GetFrom() 1916 + { 1917 + return From; 1918 + } 1919 + NetNode *GetTo() 1920 + { 1921 + return To; 1922 + } 1923 + double GetCost() 1924 + { 1925 + return Cost; 1926 + } 1927 + void SetNext(NetArc * next) 1928 + { 1929 + Next = next; 1930 + } 1931 + NetArc *GetNext() 1932 + { 1933 + return Next; 1934 + } 1935 +}; 1936 + 1937 +class NetArcRef 1938 +{ 1939 +// 1940 +// a class to store a reference to an arc for Network 1941 +// 1942 +private: 1943 + NetArc * Reference; 1944 + NetArcRef *Next; 1945 +public: 1946 + NetArcRef(NetArc * arc) 1947 + { 1948 + Reference = arc; 1949 + Next = NULL; 1950 + } 1951 + ~NetArcRef() 1952 + {; 1953 + } 1954 + NetArc *GetReference() 1955 + { 1956 + return Reference; 1957 + } 1958 + void SetNext(NetArcRef * next) 1959 + { 1960 + Next = next; 1961 + } 1962 + NetArcRef *GetNext() 1963 + { 1964 + return Next; 1965 + } 1966 +}; 1967 + 1968 +class Network 1969 +{ 1970 +// 1971 +// a class representing a Network 1972 +// 1973 +private: 1974 + NetNodePre * FirstPre; 1975 + NetNodePre *LastPre; 1976 + int NumPreNodes; 1977 + NetNodePre **SortedPreNodes; 1978 + NetArc *FirstArc; 1979 + NetArc *LastArc; 1980 + NetNode *FirstNode; 1981 + NetNode *LastNode; 1982 + int NumNodes; 1983 + NetNode **SortedNodes; 1984 + bool Error; 1985 + bool NodeCode; 1986 + int MaxCodeLength; 1987 +public: 1988 + Network(); 1989 + ~Network(); 1990 + void CleanPreNodes(); 1991 + void InsertNode(int id); 1992 + void InsertNode(const char *code); 1993 + void AddNode(int id); 1994 + void AddNode(wxString & code); 1995 + NetNode *ProcessNode(int id, double x, double y, NetNode ** pOther); 1996 + NetNode *ProcessNode(wxString & code, double x, double y, NetNode ** pOther); 1997 + void Sort(); 1998 + NetNode *Find(int id); 1999 + NetNode *Find(wxString & code); 2000 + NetNode *GetSortedNode(int x); 2001 + void AddArc(int rowid, int id_from, int id_to, double node_from_x, 2002 + double node_from_y, double node_to_x, double node_to_y, 2003 + double cost); 2004 + void AddArc(int rowid, const char *code_from, const char *code_to, 2005 + double node_from_x, double node_from_y, double node_to_x, 2006 + double node_to_y, double cost); 2007 + void InitNodes(); 2008 + void SetError() 2009 + { 2010 + Error = true; 2011 + } 2012 + bool IsError() 2013 + { 2014 + return Error; 2015 + } 2016 + void SetNodeCode(bool mode) 2017 + { 2018 + NodeCode = mode; 2019 + } 2020 + bool IsNodeCode() 2021 + { 2022 + return NodeCode; 2023 + } 2024 + int GetNumNodes() 2025 + { 2026 + return NumNodes; 2027 + } 2028 + int GetMaxCodeLength() 2029 + { 2030 + return MaxCodeLength; 2031 + } 2032 +}; 2033 + 2034 +class AutoFDOTable 2035 +{ 2036 +private: 2037 + char *Name; 2038 + AutoFDOTable *Next; 2039 +public: 2040 + AutoFDOTable(const char *name, const int len) 2041 + { 2042 + Name = new char[len]; 2043 + strcpy(Name, name); 2044 + Next = NULL; 2045 + } 2046 + ~AutoFDOTable() 2047 + { 2048 + if (Name) 2049 + delete[]Name; 2050 + } 2051 + char *GetName() 2052 + { 2053 + return Name; 2054 + } 2055 + void SetNext(AutoFDOTable * next) 2056 + { 2057 + Next = next; 2058 + } 2059 + AutoFDOTable *GetNext() 2060 + { 2061 + return Next; 2062 + } 2063 +}; 2064 + 2065 +class AutoFDOTables 2066 +{ 2067 +private: 2068 + AutoFDOTable * First; 2069 + AutoFDOTable *Last; 2070 +public: 2071 + AutoFDOTables() 2072 + { 2073 + First = NULL; 2074 + Last = NULL; 2075 + } 2076 + ~AutoFDOTables(); 2077 + void Add(const char *name, const int len); 2078 + AutoFDOTable *GetFirst() 2079 + { 2080 + return First; 2081 + } 2082 +}; 2083 + 2084 +class AutoSaveDialog:public wxDialog 2085 +{ 2086 +// 2087 +// a dialog to manage AutoSave 2088 +// 2089 +private: 2090 + MyFrame * MainFrame; 2091 + wxString Path; // the path to save 2092 + int Seconds; // interval 2093 + wxRadioBox *IntervalCtrl; 2094 + wxTextCtrl *PathCtrl; 2095 +public: 2096 + AutoSaveDialog() 2097 + {; 2098 + } 2099 + AutoSaveDialog(MyFrame * parent, wxString & path, int secs); 2100 + bool Create(MyFrame * parent, wxString & path, int secs); 2101 + virtual ~ AutoSaveDialog() 2102 + {; 2103 + } 2104 + void CreateControls(); 2105 + int GetSeconds() 2106 + { 2107 + return Seconds; 2108 + } 2109 + void OnOk(wxCommandEvent & event); 2110 + wxString & GetPath() 2111 + { 2112 + return Path; 2113 + } 2114 + void OnIntervalChanged(wxCommandEvent & event); 2115 + void OnChangePath(wxCommandEvent & event); 1073 2116 };
Changes to Dialogs.cpp.
1 1 /* 2 2 / Dialogs.cpp 3 3 / various dialog classes 4 4 / 5 -/ version 1.1, 2008 September 13 5 +/ version 1.2, 2008 October 9 6 6 / 7 7 / Author: Sandro Furieri a-furieri@lqt.it 8 8 / 9 9 / Copyright (C) 2008 Alessandro Furieri 10 10 / 11 11 / This program is free software: you can redistribute it and/or modify 12 12 / it under the terms of the GNU General Public License as published by ................................................................................ 25 25 26 26 #include "Classdef.h" 27 27 28 28 #include "wx/spinctrl.h" 29 29 #include "wx/listctrl.h" 30 30 #include "wx/html/htmlwin.h" 31 31 32 -bool 33 -VirtualShpDialog::Create (MyFrame * parent, wxString & path, wxString & table, 34 - wxString & defCs) 35 -{ 36 -// 37 -// creating the dialog 38 -// 39 - MainFrame = parent; 40 - Path = path; 41 - Table = table; 42 - Default = defCs; 43 - if (wxDialog::Create (parent, wxID_ANY, wxT ("Creating Virtual Shapefile")) 44 - == false) 45 - return false; 46 -// populates individual controls 47 - CreateControls (); 48 -// sets dialog sizer 49 - GetSizer ()->Fit (this); 50 - GetSizer ()->SetSizeHints (this); 51 -// centers the dialog window 52 - Centre (); 53 - return true; 54 -} 55 - 56 -void 57 -VirtualShpDialog::CreateControls () 58 -{ 59 -// 60 -// creating individual control and setting initial values 61 -// 62 - wxBoxSizer *topSizer = new wxBoxSizer (wxVERTICAL); 63 - this->SetSizer (topSizer); 64 - wxBoxSizer *boxSizer = new wxBoxSizer (wxVERTICAL); 65 - topSizer->Add (boxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 32 +bool VirtualShpDialog::Create(MyFrame * parent, wxString & path, 33 + wxString & table, wxString & defCs) 34 +{ 35 +// 36 +// creating the dialog 37 +// 38 + MainFrame = parent; 39 + Path = path; 40 + Table = table; 41 + Default = defCs; 42 + if (wxDialog::Create(parent, wxID_ANY, wxT("Creating Virtual Shapefile")) == 43 + false) 44 + return false; 45 +// populates individual controls 46 + CreateControls(); 47 +// sets dialog sizer 48 + GetSizer()->Fit(this); 49 + GetSizer()->SetSizeHints(this); 50 +// centers the dialog window 51 + Centre(); 52 + return true; 53 +} 54 + 55 +void VirtualShpDialog::CreateControls() 56 +{ 57 +// 58 +// creating individual control and setting initial values 59 +// 60 + wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL); 61 + this->SetSizer(topSizer); 62 + wxBoxSizer *boxSizer = new wxBoxSizer(wxVERTICAL); 63 + topSizer->Add(boxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 66 64 // first row: the Shapefile path 67 - wxBoxSizer *pathSizer = new wxBoxSizer (wxHORIZONTAL); 68 - boxSizer->Add (pathSizer, 0, wxALIGN_RIGHT | wxALL, 0); 69 - wxStaticText *pathLabel = 70 - new wxStaticText (this, wxID_STATIC, wxT ("&Path:")); 71 - pathSizer->Add (pathLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 72 - wxTextCtrl *pathValue = new wxTextCtrl (this, wxID_STATIC, 73 - Path, wxDefaultPosition, 74 - wxSize (350, 22), wxTE_READONLY); 75 - pathSizer->Add (pathValue, 0, wxALIGN_RIGHT | wxALL, 5); 65 + wxBoxSizer *pathSizer = new wxBoxSizer(wxHORIZONTAL); 66 + boxSizer->Add(pathSizer, 0, wxALIGN_RIGHT | wxALL, 0); 67 + wxStaticText *pathLabel = new wxStaticText(this, wxID_STATIC, wxT("&Path:")); 68 + pathSizer->Add(pathLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 69 + wxTextCtrl *pathValue = new wxTextCtrl(this, wxID_STATIC, 70 + Path, wxDefaultPosition, 71 + wxSize(350, 22), wxTE_READONLY); 72 + pathSizer->Add(pathValue, 0, wxALIGN_RIGHT | wxALL, 5); 76 73 // second row: TABLE name 77 - wxBoxSizer *tableSizer = new wxBoxSizer (wxHORIZONTAL); 78 - boxSizer->Add (tableSizer, 0, wxALIGN_RIGHT | wxALL, 0); 79 - wxStaticText *tableLabel = 80 - new wxStaticText (this, wxID_STATIC, wxT ("&Table name:")); 81 - tableSizer->Add (tableLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 82 - wxTextCtrl *tableCtrl = new wxTextCtrl (this, ID_VIRTSHP_TABLE, Table, 83 - wxDefaultPosition, wxSize (350, 84 - 22)); 85 - tableSizer->Add (tableCtrl, 0, wxALIGN_RIGHT | wxALL, 5); 74 + wxBoxSizer *tableSizer = new wxBoxSizer(wxHORIZONTAL); 75 + boxSizer->Add(tableSizer, 0, wxALIGN_RIGHT | wxALL, 0); 76 + wxStaticText *tableLabel = 77 + new wxStaticText(this, wxID_STATIC, wxT("&Table name:")); 78 + tableSizer->Add(tableLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 79 + wxTextCtrl *tableCtrl = new wxTextCtrl(this, ID_VIRTSHP_TABLE, Table, 80 + wxDefaultPosition, wxSize(350, 81 + 22)); 82 + tableSizer->Add(tableCtrl, 0, wxALIGN_RIGHT | wxALL, 5); 86 83 // second row: SRID 87 - wxBoxSizer *sridSizer = new wxBoxSizer (wxHORIZONTAL); 88 - boxSizer->Add (sridSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 89 - wxStaticText *sridLabel = 90 - new wxStaticText (this, wxID_STATIC, wxT ("&SRID:")); 91 - sridSizer->Add (sridLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 92 - wxSpinCtrl *sridCtrl = new wxSpinCtrl (this, ID_VIRTSHP_SRID, wxEmptyString, 93 - wxDefaultPosition, wxSize (80, 20), 94 - wxSP_ARROW_KEYS, 95 - -1, 40000, -1); 96 - sridSizer->Add (sridCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 84 + wxBoxSizer *sridSizer = new wxBoxSizer(wxHORIZONTAL); 85 + boxSizer->Add(sridSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 86 + wxStaticText *sridLabel = new wxStaticText(this, wxID_STATIC, wxT("&SRID:")); 87 + sridSizer->Add(sridLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 88 + wxSpinCtrl *sridCtrl = new wxSpinCtrl(this, ID_VIRTSHP_SRID, wxEmptyString, 89 + wxDefaultPosition, wxSize(80, 20), 90 + wxSP_ARROW_KEYS, 91 + -1, 40000, -1); 92 + sridSizer->Add(sridCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 97 93 // third row: CHARSET 98 - wxStaticBox *charsetBox = new wxStaticBox (this, wxID_STATIC, 99 - wxT ("Charset Encoding"), 100 - wxDefaultPosition, 101 - wxDefaultSize); 102 - wxBoxSizer *charsetSizer = new wxStaticBoxSizer (charsetBox, wxHORIZONTAL); 103 - sridSizer->Add (charsetSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 104 - wxListBox *charsetCtrl = new wxListBox (this, ID_VIRTSHP_CHARSET, 105 - wxDefaultPosition, wxDefaultSize, 106 - MainFrame->GetCharsetsLen (), 107 - MainFrame->GetCharsetsNames (), 108 - wxLB_SINGLE); 109 - charsetCtrl->SetFont (wxFont 110 - (8, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, 111 - wxFONTWEIGHT_NORMAL)); 112 - int idSel = MainFrame->GetCharsetIndex (Default); 113 - if (idSel != wxNOT_FOUND) 114 - charsetCtrl->SetSelection (idSel); 115 - charsetSizer->Add (charsetCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0); 116 -// OK - CANCEL buttons 117 - wxBoxSizer *okCancelBox = new wxBoxSizer (wxHORIZONTAL); 118 - boxSizer->Add (okCancelBox, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 119 - wxButton *ok = new wxButton (this, wxID_OK, wxT ("&OK")); 120 - okCancelBox->Add (ok, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 121 - wxButton *cancel = new wxButton (this, wxID_CANCEL, wxT ("&Cancel")); 122 - okCancelBox->Add (cancel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 123 -// appends event handler for OK button 124 - Connect (wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, 125 - (wxObjectEventFunction) & VirtualShpDialog::OnOk); 126 -} 127 - 128 -void 129 -VirtualShpDialog::OnOk (wxCommandEvent & event) 130 -{ 131 -// 132 -// all done: 133 -// 134 - wxTextCtrl *tableCtrl = (wxTextCtrl *) FindWindow (ID_VIRTSHP_TABLE); 135 - Table = tableCtrl->GetValue (); 136 - if (Table.Len () < 1) 137 - { 138 - wxMessageBox (wxT ("You must specify the TABLE NAME !!!"), 139 - wxT ("spatialite-gui"), wxOK | wxICON_WARNING, this); 140 - return; 141 - } 142 - if (MainFrame->TableAlreadyExists (Table) == true) 143 - { 144 - wxMessageBox (wxT ("a table name '") + Table + 145 - wxT ("' already exists"), wxT ("spatialite-gui"), 146 - wxOK | wxICON_WARNING, this); 147 - return; 148 - } 149 - if (gaiaIllegalSqlName (Table.ToUTF8 ()) == 1 150 - || gaiaIsReservedSqlName (Table.ToUTF8 ()) == 1 151 - || gaiaIsReservedSqliteName (Table.ToUTF8 ()) == 1) 152 - { 153 - wxMessageBox (wxT ("'") + Table + 154 - wxT 155 - ("' is an invalid TABLE NAME\n\nillegal name or reserved keyword"), 156 - wxT ("spatialite-gui"), wxOK | wxICON_WARNING, this); 157 - return; 158 - } 159 - wxSpinCtrl *sridCtrl = (wxSpinCtrl *) FindWindow (ID_VIRTSHP_SRID); 160 - Srid = sridCtrl->GetValue (); 161 - if (Srid == -1) 162 - ; 163 - else if (MainFrame->SridNotExists (Srid) == true) 164 - { 165 - wxMessageBox (wxT ("invalid SRID value"), 166 - wxT ("spatialite-gui"), wxOK | wxICON_WARNING, this); 167 - return; 168 - } 169 - wxListBox *charsetCtrl = (wxListBox *) FindWindow (ID_VIRTSHP_CHARSET); 170 - int idSel = charsetCtrl->GetSelection (); 171 - if (idSel == wxNOT_FOUND) 172 - { 173 - wxMessageBox (wxT 174 - ("you must select some Charset Encoding from the list"), 175 - wxT ("spatialite-gui"), wxOK | wxICON_WARNING, this); 176 - return; 177 - } 178 - wxString *charsets = MainFrame->GetCharsets (); 179 - Charset = *(charsets + idSel); 180 - wxDialog::EndModal (wxID_OK); 181 -} 182 - 183 -bool 184 -VirtualTxtDialog::Create (MyFrame * parent, wxString & path, wxString & table, 185 - wxString & defCs) 186 -{ 187 -// 188 -// creating the dialog 189 -// 190 - MainFrame = parent; 191 - Path = path; 192 - Table = table; 193 - Default = defCs; 194 - if (wxDialog::Create (parent, wxID_ANY, wxT ("Creating Virtual CSV/TXT")) 195 - == false) 196 - return false; 197 -// populates individual controls 198 - CreateControls (); 199 -// sets dialog sizer 200 - GetSizer ()->Fit (this); 201 - GetSizer ()->SetSizeHints (this); 202 -// centers the dialog window 203 - Centre (); 204 - return true; 205 -} 206 - 207 -void 208 -VirtualTxtDialog::CreateControls () 209 -{ 210 -// 211 -// creating individual control and setting initial values 212 -// 213 - FirstLineTitles = true; 214 - Separator = '\t'; 215 - TextSeparator = '"'; 216 - DecimalPointIsComma = false; 217 - wxBoxSizer *topSizer = new wxBoxSizer (wxVERTICAL); 218 - this->SetSizer (topSizer); 219 - wxBoxSizer *boxSizer = new wxBoxSizer (wxVERTICAL); 220 - topSizer->Add (boxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 94 + wxStaticBox *charsetBox = new wxStaticBox(this, wxID_STATIC, 95 + wxT("Charset Encoding"), 96 + wxDefaultPosition, 97 + wxDefaultSize); 98 + wxBoxSizer *charsetSizer = new wxStaticBoxSizer(charsetBox, wxHORIZONTAL); 99 + sridSizer->Add(charsetSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 100 + wxListBox *charsetCtrl = new wxListBox(this, ID_VIRTSHP_CHARSET, 101 + wxDefaultPosition, wxDefaultSize, 102 + MainFrame->GetCharsetsLen(), 103 + MainFrame->GetCharsetsNames(), 104 + wxLB_SINGLE); 105 + charsetCtrl-> 106 + SetFont(wxFont 107 + (8, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL)); 108 + int idSel = MainFrame->GetCharsetIndex(Default); 109 + if (idSel != wxNOT_FOUND) 110 + charsetCtrl->SetSelection(idSel); 111 + charsetSizer->Add(charsetCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0); 112 +// OK - CANCEL buttons 113 + wxBoxSizer *okCancelBox = new wxBoxSizer(wxHORIZONTAL); 114 + boxSizer->Add(okCancelBox, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 115 + wxButton *ok = new wxButton(this, wxID_OK, wxT("&OK")); 116 + okCancelBox->Add(ok, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 117 + wxButton *cancel = new wxButton(this, wxID_CANCEL, wxT("&Cancel")); 118 + okCancelBox->Add(cancel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 119 +// appends event handler for OK button 120 + Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, 121 + (wxObjectEventFunction) & VirtualShpDialog::OnOk); 122 +} 123 + 124 +void VirtualShpDialog::OnOk(wxCommandEvent & event) 125 +{ 126 +// 127 +// all done: 128 +// 129 + wxTextCtrl *tableCtrl = (wxTextCtrl *) FindWindow(ID_VIRTSHP_TABLE); 130 + Table = tableCtrl->GetValue(); 131 + if (Table.Len() < 1) 132 + { 133 + wxMessageBox(wxT("You must specify the TABLE NAME !!!"), 134 + wxT("spatialite-gui"), wxOK | wxICON_WARNING, this); 135 + return; 136 + } 137 + if (MainFrame->TableAlreadyExists(Table) == true) 138 + { 139 + wxMessageBox(wxT("a table name '") + Table + wxT("' already exists"), 140 + wxT("spatialite-gui"), wxOK | wxICON_WARNING, this); 141 + return; 142 + } 143 + wxSpinCtrl *sridCtrl = (wxSpinCtrl *) FindWindow(ID_VIRTSHP_SRID); 144 + Srid = sridCtrl->GetValue(); 145 + if (Srid == -1) 146 + ; 147 + else if (MainFrame->SridNotExists(Srid) == true) 148 + { 149 + wxMessageBox(wxT("invalid SRID value"), wxT("spatialite-gui"), 150 + wxOK | wxICON_WARNING, this); 151 + return; 152 + } 153 + wxListBox *charsetCtrl = (wxListBox *) FindWindow(ID_VIRTSHP_CHARSET); 154 + int idSel = charsetCtrl->GetSelection(); 155 + if (idSel == wxNOT_FOUND) 156 + { 157 + wxMessageBox(wxT("you must select some Charset Encoding from the list"), 158 + wxT("spatialite-gui"), wxOK | wxICON_WARNING, this); 159 + return; 160 + } 161 + wxString *charsets = MainFrame->GetCharsets(); 162 + Charset = *(charsets + idSel); 163 + wxDialog::EndModal(wxID_OK); 164 +} 165 + 166 +bool VirtualTxtDialog::Create(MyFrame * parent, wxString & path, 167 + wxString & table, wxString & defCs) 168 +{ 169 +// 170 +// creating the dialog 171 +// 172 + MainFrame = parent; 173 + Path = path; 174 + Table = table; 175 + Default = defCs; 176 + if (wxDialog::Create(parent, wxID_ANY, wxT("Creating Virtual CSV/TXT")) == 177 + false) 178 + return false; 179 +// populates individual controls 180 + CreateControls(); 181 +// sets dialog sizer 182 + GetSizer()->Fit(this); 183 + GetSizer()->SetSizeHints(this); 184 +// centers the dialog window 185 + Centre(); 186 + return true; 187 +} 188 + 189 +void VirtualTxtDialog::CreateControls() 190 +{ 191 +// 192 +// creating individual control and setting initial values 193 +// 194 + FirstLineTitles = true; 195 + Separator = '\t'; 196 + TextSeparator = '"'; 197 + DecimalPointIsComma = false; 198 + wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL); 199 + this->SetSizer(topSizer); 200 + wxBoxSizer *boxSizer = new wxBoxSizer(wxVERTICAL); 201 + topSizer->Add(boxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 221 202 // first row: the CSV/TXT path 222 - wxBoxSizer *pathSizer = new wxBoxSizer (wxHORIZONTAL); 223 - boxSizer->Add (pathSizer, 0, wxALIGN_RIGHT | wxALL, 0); 224 - wxStaticText *pathLabel = 225 - new wxStaticText (this, wxID_STATIC, wxT ("&Path:")); 226 - pathSizer->Add (pathLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 227 - wxTextCtrl *pathValue = new wxTextCtrl (this, wxID_STATIC, 228 - Path, wxDefaultPosition, 229 - wxSize (350, 22), wxTE_READONLY); 230 - pathSizer->Add (pathValue, 0, wxALIGN_RIGHT | wxALL, 5); 203 + wxBoxSizer *pathSizer = new wxBoxSizer(wxHORIZONTAL); 204 + boxSizer->Add(pathSizer, 0, wxALIGN_RIGHT | wxALL, 0); 205 + wxStaticText *pathLabel = new wxStaticText(this, wxID_STATIC, wxT("&Path:")); 206 + pathSizer->Add(pathLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 207 + wxTextCtrl *pathValue = new wxTextCtrl(this, wxID_STATIC, 208 + Path, wxDefaultPosition, 209 + wxSize(350, 22), wxTE_READONLY); 210 + pathSizer->Add(pathValue, 0, wxALIGN_RIGHT | wxALL, 5); 231 211 // second row: TABLE name 232 - wxBoxSizer *tableSizer = new wxBoxSizer (wxHORIZONTAL); 233 - boxSizer->Add (tableSizer, 0, wxALIGN_RIGHT | wxALL, 0); 234 - wxStaticText *tableLabel = 235 - new wxStaticText (this, wxID_STATIC, wxT ("&Table name:")); 236 - tableSizer->Add (tableLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 237 - wxTextCtrl *tableCtrl = new wxTextCtrl (this, ID_VIRTTXT_TABLE, Table, 238 - wxDefaultPosition, wxSize (350, 239 - 22)); 240 - tableSizer->Add (tableCtrl, 0, wxALIGN_RIGHT | wxALL, 5); 212 + wxBoxSizer *tableSizer = new wxBoxSizer(wxHORIZONTAL); 213 + boxSizer->Add(tableSizer, 0, wxALIGN_RIGHT | wxALL, 0); 214 + wxStaticText *tableLabel = 215 + new wxStaticText(this, wxID_STATIC, wxT("&Table name:")); 216 + tableSizer->Add(tableLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 217 + wxTextCtrl *tableCtrl = new wxTextCtrl(this, ID_VIRTTXT_TABLE, Table, 218 + wxDefaultPosition, wxSize(350, 219 + 22)); 220 + tableSizer->Add(tableCtrl, 0, wxALIGN_RIGHT | wxALL, 5); 241 221 // second row: OPTIONS 242 - wxBoxSizer *optSizer = new wxBoxSizer (wxHORIZONTAL); 243 - boxSizer->Add (optSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 244 - wxBoxSizer *modeSizer = new wxBoxSizer (wxVERTICAL); 245 - optSizer->Add (modeSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0); 246 - wxBoxSizer *mode1Sizer = new wxBoxSizer (wxHORIZONTAL); 247 - modeSizer->Add (mode1Sizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 248 - wxCheckBox *titleCtrl = new wxCheckBox (this, ID_VIRTTXT_TITLES, 249 - wxT 250 - ("First line contains column names"), 251 - wxDefaultPosition, wxDefaultSize); 252 - titleCtrl->SetValue (true); 253 - mode1Sizer->Add (titleCtrl, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 254 - wxStaticBox *sepBox = new wxStaticBox (this, wxID_STATIC, 255 - wxT ("Separators"), 256 - wxDefaultPosition, wxDefaultSize); 257 - wxBoxSizer *sepSizer = new wxStaticBoxSizer (sepBox, wxVERTICAL); 258 - modeSizer->Add (sepSizer, 0, wxALIGN_LEFT | wxALL, 0); 259 - wxBoxSizer *mode2Sizer = new wxBoxSizer (wxHORIZONTAL); 260 - sepSizer->Add (mode2Sizer, 0, wxALIGN_LEFT | wxALL, 0); 261 - wxString quotes[2]; 262 - quotes[0] = wxT ("&Double \""); 263 - quotes[1] = wxT ("&Single '"); 264 - wxRadioBox *textSeparatorBox = new wxRadioBox (this, ID_VIRTTXT_QUOTE, 265 - wxT 266 - ("&Text separator: quotes"), 267 - wxDefaultPosition, 268 - wxDefaultSize, 2, 269 - quotes, 2, 270 - wxRA_SPECIFY_COLS); 271 - mode2Sizer->Add (textSeparatorBox, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 272 - wxBoxSizer *mode3Sizer = new wxBoxSizer (wxHORIZONTAL); 273 - sepSizer->Add (mode3Sizer, 0, wxALIGN_LEFT | wxALL, 0); 274 - wxString separators[6]; 275 - separators[0] = wxT ("&Tab"); 276 - separators[1] = wxT ("&Space"); 277 - separators[2] = wxT ("Co&mma ,"); 278 - separators[3] = wxT ("&Colon :"); 279 - separators[4] = wxT ("S&emicolon ;"); 280 - separators[5] = wxT ("&Other"); 281 - wxRadioBox *separatorBox = new wxRadioBox (this, ID_VIRTTXT_SEPARATOR, 282 - wxT ("&Column separator"), 283 - wxDefaultPosition, wxDefaultSize, 284 - 6, 285 - separators, 2, 286 - wxRA_SPECIFY_COLS); 287 - mode3Sizer->Add (separatorBox, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 288 - wxBoxSizer *mode4Sizer = new wxBoxSizer (wxHORIZONTAL); 289 - sepSizer->Add (mode4Sizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 290 - wxStaticText *charSeparatorLabel = new wxStaticText (this, wxID_STATIC, 291 - wxT 292 - ("&Custom separator:"), 293 - wxDefaultPosition, 294 - wxDefaultSize, 0); 295 - mode4Sizer->Add (charSeparatorLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 296 - wxTextCtrl *dummy = 297 - new wxTextCtrl (this, ID_VIRTTXT_CHARSEPARATOR, wxT ("Dummy Text pq"), 298 - wxDefaultPosition, 299 - wxDefaultSize, 0); 300 - wxSize sz = dummy->GetSize (); 301 - delete dummy; 302 - sz.SetWidth (40); 303 - wxTextCtrl *charSeparatorCtrl = 304 - new wxTextCtrl (this, ID_VIRTTXT_CHARSEPARATOR, wxT ("TAB"), 305 - wxDefaultPosition, sz, 0); 306 - charSeparatorCtrl->SetMaxLength (1); 307 - charSeparatorCtrl->Enable (false); 308 - mode4Sizer->Add (charSeparatorCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 309 - wxBoxSizer *mode5Sizer = new wxBoxSizer (wxHORIZONTAL); 310 - sepSizer->Add (mode5Sizer, 0, wxALIGN_LEFT | wxALL, 0); 311 - wxString points[2]; 312 - points[0] = wxT ("&Point ."); 313 - points[1] = wxT ("&Comma ,"); 314 - wxRadioBox *decimalSeparatorBox = new wxRadioBox (this, ID_VIRTTXT_POINT, 315 - wxT 316 - ("&Decimal separator"), 317 - wxDefaultPosition, 318 - wxDefaultSize, 2, 319 - points, 2, 320 - wxRA_SPECIFY_COLS); 321 - mode5Sizer->Add (decimalSeparatorBox, 0, wxALIGN_CENTER_VERTICAL | wxALL, 322 - 5); 222 + wxBoxSizer *optSizer = new wxBoxSizer(wxHORIZONTAL); 223 + boxSizer->Add(optSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 224 + wxBoxSizer *modeSizer = new wxBoxSizer(wxVERTICAL); 225 + optSizer->Add(modeSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0); 226 + wxBoxSizer *mode1Sizer = new wxBoxSizer(wxHORIZONTAL); 227 + modeSizer->Add(mode1Sizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 228 + wxCheckBox *titleCtrl = new wxCheckBox(this, ID_VIRTTXT_TITLES, 229 + wxT 230 + ("First line contains column names"), 231 + wxDefaultPosition, wxDefaultSize); 232 + titleCtrl->SetValue(true); 233 + mode1Sizer->Add(titleCtrl, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 234 + wxStaticBox *sepBox = new wxStaticBox(this, wxID_STATIC, 235 + wxT("Separators"), 236 + wxDefaultPosition, wxDefaultSize); 237 + wxBoxSizer *sepSizer = new wxStaticBoxSizer(sepBox, wxVERTICAL); 238 + modeSizer->Add(sepSizer, 0, wxALIGN_LEFT | wxALL, 0); 239 + wxBoxSizer *mode2Sizer = new wxBoxSizer(wxHORIZONTAL); 240 + sepSizer->Add(mode2Sizer, 0, wxALIGN_LEFT | wxALL, 0); 241 + wxString quotes[2]; 242 + quotes[0] = wxT("&Double \""); 243 + quotes[1] = wxT("&Single '"); 244 + wxRadioBox *textSeparatorBox = new wxRadioBox(this, ID_VIRTTXT_QUOTE, 245 + wxT("&Text separator: quotes"), 246 + wxDefaultPosition, 247 + wxDefaultSize, 2, 248 + quotes, 2, 249 + wxRA_SPECIFY_COLS); 250 + mode2Sizer->Add(textSeparatorBox, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 251 + wxBoxSizer *mode3Sizer = new wxBoxSizer(wxHORIZONTAL); 252 + sepSizer->Add(mode3Sizer, 0, wxALIGN_LEFT | wxALL, 0); 253 + wxString separators[6]; 254 + separators[0] = wxT("&Tab"); 255 + separators[1] = wxT("&Space"); 256 + separators[2] = wxT("Co&mma ,"); 257 + separators[3] = wxT("&Colon :"); 258 + separators[4] = wxT("S&emicolon ;"); 259 + separators[5] = wxT("&Other"); 260 + wxRadioBox *separatorBox = new wxRadioBox(this, ID_VIRTTXT_SEPARATOR, 261 + wxT("&Column separator"), 262 + wxDefaultPosition, wxDefaultSize, 263 + 6, 264 + separators, 2, 265 + wxRA_SPECIFY_COLS); 266 + mode3Sizer->Add(separatorBox, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 267 + wxBoxSizer *mode4Sizer = new wxBoxSizer(wxHORIZONTAL); 268 + sepSizer->Add(mode4Sizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 269 + wxStaticText *charSeparatorLabel = new wxStaticText(this, wxID_STATIC, 270 + wxT("&Custom separator:"), 271 + wxDefaultPosition, 272 + wxDefaultSize, 0); 273 + mode4Sizer->Add(charSeparatorLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 274 + wxTextCtrl *dummy = 275 + new wxTextCtrl(this, ID_VIRTTXT_CHARSEPARATOR, wxT("Dummy Text pq"), 276 + wxDefaultPosition, 277 + wxDefaultSize, 0); 278 + wxSize sz = dummy->GetSize(); 279 + delete dummy; 280 + sz.SetWidth(40); 281 + wxTextCtrl *charSeparatorCtrl = 282 + new wxTextCtrl(this, ID_VIRTTXT_CHARSEPARATOR, wxT("TAB"), 283 + wxDefaultPosition, sz, 0); 284 + charSeparatorCtrl->SetMaxLength(1); 285 + charSeparatorCtrl->Enable(false); 286 + mode4Sizer->Add(charSeparatorCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 287 + wxBoxSizer *mode5Sizer = new wxBoxSizer(wxHORIZONTAL); 288 + sepSizer->Add(mode5Sizer, 0, wxALIGN_LEFT | wxALL, 0); 289 + wxString points[2]; 290 + points[0] = wxT("&Point ."); 291 + points[1] = wxT("&Comma ,"); 292 + wxRadioBox *decimalSeparatorBox = new wxRadioBox(this, ID_VIRTTXT_POINT, 293 + wxT("&Decimal separator"), 294 + wxDefaultPosition, 295 + wxDefaultSize, 2, 296 + points, 2, 297 + wxRA_SPECIFY_COLS); 298 + mode5Sizer->Add(decimalSeparatorBox, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 323 299 // third row: CHARSET 324 - wxStaticBox *charsetBox = new wxStaticBox (this, wxID_STATIC, 325 - wxT ("Charset Encoding"), 326 - wxDefaultPosition, 327 - wxDefaultSize); 328 - wxBoxSizer *charsetSizer = new wxStaticBoxSizer (charsetBox, wxHORIZONTAL); 329 - optSizer->Add (charsetSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 330 - wxListBox *charsetCtrl = new wxListBox (this, ID_VIRTTXT_CHARSET, 331 - wxDefaultPosition, wxDefaultSize, 332 - MainFrame->GetCharsetsLen (), 333 - MainFrame->GetCharsetsNames (), 334 - wxLB_SINGLE); 335 - charsetCtrl->SetFont (wxFont 336 - (8, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, 337 - wxFONTWEIGHT_NORMAL)); 338 - int idSel = MainFrame->GetCharsetIndex (Default); 339 - if (idSel != wxNOT_FOUND) 340 - charsetCtrl->SetSelection (idSel); 341 - charsetSizer->Add (charsetCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0); 342 -// OK - CANCEL buttons 343 - wxBoxSizer *okCancelBox = new wxBoxSizer (wxHORIZONTAL); 344 - boxSizer->Add (okCancelBox, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 345 - wxButton *ok = new wxButton (this, wxID_OK, wxT ("&OK")); 346 - okCancelBox->Add (ok, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 347 - wxButton *cancel = new wxButton (this, wxID_CANCEL, wxT ("&Cancel")); 348 - okCancelBox->Add (cancel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 349 -// appends event handler for OK button 350 - Connect (wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, 351 - (wxObjectEventFunction) & VirtualTxtDialog::OnOk); 300 + wxStaticBox *charsetBox = new wxStaticBox(this, wxID_STATIC, 301 + wxT("Charset Encoding"), 302 + wxDefaultPosition, 303 + wxDefaultSize); 304 + wxBoxSizer *charsetSizer = new wxStaticBoxSizer(charsetBox, wxHORIZONTAL); 305 + optSizer->Add(charsetSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 306 + wxListBox *charsetCtrl = new wxListBox(this, ID_VIRTTXT_CHARSET, 307 + wxDefaultPosition, wxDefaultSize, 308 + MainFrame->GetCharsetsLen(), 309 + MainFrame->GetCharsetsNames(), 310 + wxLB_SINGLE); 311 + charsetCtrl-> 312 + SetFont(wxFont 313 + (8, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL)); 314 + int idSel = MainFrame->GetCharsetIndex(Default); 315 + if (idSel != wxNOT_FOUND) 316 + charsetCtrl->SetSelection(idSel); 317 + charsetSizer->Add(charsetCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0); 318 +// OK - CANCEL buttons 319 + wxBoxSizer *okCancelBox = new wxBoxSizer(wxHORIZONTAL); 320 + boxSizer->Add(okCancelBox, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 321 + wxButton *ok = new wxButton(this, wxID_OK, wxT("&OK")); 322 + okCancelBox->Add(ok, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 323 + wxButton *cancel = new wxButton(this, wxID_CANCEL, wxT("&Cancel")); 324 + okCancelBox->Add(cancel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 325 +// appends event handler for OK button 326 + Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, 327 + (wxObjectEventFunction) & VirtualTxtDialog::OnOk); 352 328 // appends event handler for radioboxes 353 - Connect (ID_VIRTTXT_QUOTE, wxEVT_COMMAND_RADIOBOX_SELECTED, 354 - (wxObjectEventFunction) & VirtualTxtDialog::OnQuote); 355 - Connect (ID_VIRTTXT_SEPARATOR, wxEVT_COMMAND_RADIOBOX_SELECTED, 356 - (wxObjectEventFunction) & VirtualTxtDialog::OnSeparator); 357 - Connect (ID_VIRTTXT_POINT, wxEVT_COMMAND_RADIOBOX_SELECTED, 358 - (wxObjectEventFunction) & VirtualTxtDialog::OnDecimalSeparator); 329 + Connect(ID_VIRTTXT_QUOTE, wxEVT_COMMAND_RADIOBOX_SELECTED, 330 + (wxObjectEventFunction) & VirtualTxtDialog::OnQuote); 331 + Connect(ID_VIRTTXT_SEPARATOR, wxEVT_COMMAND_RADIOBOX_SELECTED, 332 + (wxObjectEventFunction) & VirtualTxtDialog::OnSeparator); 333 + Connect(ID_VIRTTXT_POINT, wxEVT_COMMAND_RADIOBOX_SELECTED, 334 + (wxObjectEventFunction) & VirtualTxtDialog::OnDecimalSeparator); 359 335 } 360 336 361 -void 362 -VirtualTxtDialog::OnDecimalSeparator (wxCommandEvent & event) 337 +void VirtualTxtDialog::OnDecimalSeparator(wxCommandEvent & event) 363 338 { 364 339 // 365 340 // POINT selection changed 366 341 // 367 - wxRadioBox *decimalSeparatorCtrl = 368 - (wxRadioBox *) FindWindow (ID_VIRTTXT_POINT); 369 - switch (decimalSeparatorCtrl->GetSelection ()) 370 - { 342 + wxRadioBox *decimalSeparatorCtrl = 343 + (wxRadioBox *) FindWindow(ID_VIRTTXT_POINT); 344 + switch (decimalSeparatorCtrl->GetSelection()) 345 + { 371 346 case 0: 372 - DecimalPointIsComma = false; 373 - break; 347 + DecimalPointIsComma = false; 348 + break; 374 349 case 1: 375 - DecimalPointIsComma = true; 376 - break; 377 - }; 350 + DecimalPointIsComma = true; 351 + break; 352 + }; 378 353 } 379 354 380 -void 381 -VirtualTxtDialog::OnQuote (wxCommandEvent & event) 355 +void VirtualTxtDialog::OnQuote(wxCommandEvent & event) 382 356 { 383 357 // 384 358 // QUOTE selection changed 385 359 // 386 - wxRadioBox *separatorCtrl = (wxRadioBox *) FindWindow (ID_VIRTTXT_QUOTE); 387 - switch (separatorCtrl->GetSelection ()) 388 - { 360 + wxRadioBox *separatorCtrl = (wxRadioBox *) FindWindow(ID_VIRTTXT_QUOTE); 361 + switch (separatorCtrl->GetSelection()) 362 + { 389 363 case 0: 390 - TextSeparator = '"'; 391 - break; 364 + TextSeparator = '"'; 365 + break; 392 366 case 1: 393 - TextSeparator = '\''; 394 - break; 395 - }; 367 + TextSeparator = '\''; 368 + break; 369 + }; 396 370 } 397 371 398 -void 399 -VirtualTxtDialog::OnSeparator (wxCommandEvent & event) 372 +void VirtualTxtDialog::OnSeparator(wxCommandEvent & event) 400 373 { 401 374 // 402 375 // SEPARATOR selection changed 403 376 // 404 - wxTextCtrl *charSeparatorCtrl = 405 - (wxTextCtrl *) FindWindow (ID_VIRTTXT_CHARSEPARATOR); 406 - wxRadioBox *separatorCtrl = 407 - (wxRadioBox *) FindWindow (ID_VIRTTXT_SEPARATOR); 408 - switch (separatorCtrl->GetSelection ()) 409 - { 377 + wxTextCtrl *charSeparatorCtrl = 378 + (wxTextCtrl *) FindWindow(ID_VIRTTXT_CHARSEPARATOR); 379 + wxRadioBox *separatorCtrl = (wxRadioBox *) FindWindow(ID_VIRTTXT_SEPARATOR); 380 + switch (separatorCtrl->GetSelection()) 381 + { 410 382 case 0: 411 - Separator = '\t'; 412 - charSeparatorCtrl->SetValue (wxT ("TAB")); 413 - break; 383 + Separator = '\t'; 384 + charSeparatorCtrl->SetValue(wxT("TAB")); 385 + break; 414 386 case 1: 415 - Separator = ' '; 416 - charSeparatorCtrl->SetValue (wxT ("SP")); 417 - break; 387 + Separator = ' '; 388 + charSeparatorCtrl->SetValue(wxT("SP")); 389 + break; 418 390 case 2: 419 - Separator = ','; 420 - charSeparatorCtrl->SetValue (wxT (",")); 421 - break; 391 + Separator = ','; 392 + charSeparatorCtrl->SetValue(wxT(",")); 393 + break; 422 394 case 3: 423 - Separator = ':'; 424 - charSeparatorCtrl->SetValue (wxT (":")); 425 - break; 395 + Separator = ':'; 396 + charSeparatorCtrl->SetValue(wxT(":")); 397 + break; 426 398 case 4: 427 - Separator = ';'; 428 - charSeparatorCtrl->SetValue (wxT (";")); 429 - break; 399 + Separator = ';'; 400 + charSeparatorCtrl->SetValue(wxT(";")); 401 + break; 430 402 case 5: 431 - Separator = '|'; 432 - charSeparatorCtrl->SetValue (wxT ("|")); 433 - break; 434 - }; 435 - if (separatorCtrl->GetSelection () == 5) 436 - charSeparatorCtrl->Enable (true); 437 - else 438 - charSeparatorCtrl->Enable (false); 439 -} 440 - 441 -void 442 -VirtualTxtDialog::OnOk (wxCommandEvent & event) 443 -{ 444 -// 445 -// all done: 446 -// 447 - wxTextCtrl *tableCtrl = (wxTextCtrl *) FindWindow (ID_VIRTTXT_TABLE); 448 - Table = tableCtrl->GetValue (); 449 - if (Table.Len () < 1) 450 - { 451 - wxMessageBox (wxT ("You must specify the TABLE NAME !!!"), 452 - wxT ("spatialite-gui"), wxOK | wxICON_WARNING, this); 453 - return; 454 - } 455 - if (MainFrame->TableAlreadyExists (Table) == true) 456 - { 457 - wxMessageBox (wxT ("a table name '") + Table + 458 - wxT ("' already exists"), wxT ("spatialite-gui"), 459 - wxOK | wxICON_WARNING, this); 460 - return; 461 - } 462 - if (gaiaIllegalSqlName (Table.ToUTF8 ()) == 1 463 - || gaiaIsReservedSqlName (Table.ToUTF8 ()) == 1 464 - || gaiaIsReservedSqliteName (Table.ToUTF8 ()) == 1) 465 - { 466 - wxMessageBox (wxT ("'") + Table + 467 - wxT 468 - ("' is an invalid TABLE NAME\n\nillegal name or reserved keyword"), 469 - wxT ("spatialite-gui"), wxOK | wxICON_WARNING, this); 470 - return; 471 - } 472 - wxListBox *charsetCtrl = (wxListBox *) FindWindow (ID_VIRTTXT_CHARSET); 473 - int idSel = charsetCtrl->GetSelection (); 474 - if (idSel == wxNOT_FOUND) 475 - { 476 - wxMessageBox (wxT 477 - ("you must select some Charset Encoding from the list"), 478 - wxT ("spatialite-gui"), wxOK | wxICON_WARNING, this); 479 - return; 480 - } 481 - wxString *charsets = MainFrame->GetCharsets (); 482 - Charset = *(charsets + idSel); 483 - wxRadioBox *separatorCtrl = 484 - (wxRadioBox *) FindWindow (ID_VIRTTXT_SEPARATOR); 485 - if (separatorCtrl->GetSelection () == 5) 486 - { 487 - wxTextCtrl *charSeparatorCtrl = 488 - (wxTextCtrl *) FindWindow (ID_VIRTTXT_CHARSEPARATOR); 489 - wxString separator = charSeparatorCtrl->GetValue (); 490 - if (separator.Len () != 1) 491 - { 492 - wxMessageBox (wxT 493 - ("you must specificy a single char as Custom Column Separator"), 494 - wxT ("spatialite-gui"), wxOK | wxICON_WARNING, 495 - this); 496 - return; 497 - } 498 - char dummy[64]; 499 - strcpy (dummy, separator.ToUTF8 ()); 500 - Separator = *dummy; 501 - } 502 - wxDialog::EndModal (wxID_OK); 503 -} 504 - 505 -bool 506 -LoadTxtDialog::Create (MyFrame * parent, wxString & path, wxString & table, 507 - wxString & defCs) 508 -{ 509 -// 510 -// creating the dialog 511 -// 512 - MainFrame = parent; 513 - Path = path; 514 - Table = table; 515 - Default = defCs; 516 - if (wxDialog::Create (parent, wxID_ANY, wxT ("Load CSV/TXT")) == false) 517 - return false; 518 -// populates individual controls 519 - CreateControls (); 520 -// sets dialog sizer 521 - GetSizer ()->Fit (this); 522 - GetSizer ()->SetSizeHints (this); 523 -// centers the dialog window 524 - Centre (); 525 - return true; 526 -} 527 - 528 -void 529 -LoadTxtDialog::CreateControls () 530 -{ 531 -// 532 -// creating individual control and setting initial values 533 -// 534 - FirstLineTitles = true; 535 - Separator = '\t'; 536 - TextSeparator = '"'; 537 - DecimalPointIsComma = false; 538 - wxBoxSizer *topSizer = new wxBoxSizer (wxVERTICAL); 539 - this->SetSizer (topSizer); 540 - wxBoxSizer *boxSizer = new wxBoxSizer (wxVERTICAL); 541 - topSizer->Add (boxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 403 + Separator = '|'; 404 + charSeparatorCtrl->SetValue(wxT("|")); 405 + break; 406 + }; 407 + if (separatorCtrl->GetSelection() == 5) 408 + charSeparatorCtrl->Enable(true); 409 + else 410 + charSeparatorCtrl->Enable(false); 411 +} 412 + 413 +void VirtualTxtDialog::OnOk(wxCommandEvent & event) 414 +{ 415 +// 416 +// all done: 417 +// 418 + wxTextCtrl *tableCtrl = (wxTextCtrl *) FindWindow(ID_VIRTTXT_TABLE); 419 + Table = tableCtrl->GetValue(); 420 + if (Table.Len() < 1) 421 + { 422 + wxMessageBox(wxT("You must specify the TABLE NAME !!!"), 423 + wxT("spatialite-gui"), wxOK | wxICON_WARNING, this); 424 + return; 425 + } 426 + if (MainFrame->TableAlreadyExists(Table) == true) 427 + { 428 + wxMessageBox(wxT("a table name '") + Table + wxT("' already exists"), 429 + wxT("spatialite-gui"), wxOK | wxICON_WARNING, this); 430 + return; 431 + } 432 + wxListBox *charsetCtrl = (wxListBox *) FindWindow(ID_VIRTTXT_CHARSET); 433 + int idSel = charsetCtrl->GetSelection(); 434 + if (idSel == wxNOT_FOUND) 435 + { 436 + wxMessageBox(wxT("you must select some Charset Encoding from the list"), 437 + wxT("spatialite-gui"), wxOK | wxICON_WARNING, this); 438 + return; 439 + } 440 + wxString *charsets = MainFrame->GetCharsets(); 441 + Charset = *(charsets + idSel); 442 + wxRadioBox *separatorCtrl = (wxRadioBox *) FindWindow(ID_VIRTTXT_SEPARATOR); 443 + if (separatorCtrl->GetSelection() == 5) 444 + { 445 + wxTextCtrl *charSeparatorCtrl = 446 + (wxTextCtrl *) FindWindow(ID_VIRTTXT_CHARSEPARATOR); 447 + wxString separator = charSeparatorCtrl->GetValue(); 448 + if (separator.Len() != 1) 449 + { 450 + wxMessageBox(wxT 451 + ("you must specificy a single char as Custom Column Separator"), 452 + wxT("spatialite-gui"), wxOK | wxICON_WARNING, this); 453 + return; 454 + } 455 + char dummy[64]; 456 + strcpy(dummy, separator.ToUTF8()); 457 + Separator = *dummy; 458 + } 459 + wxDialog::EndModal(wxID_OK); 460 +} 461 + 462 +bool LoadTxtDialog::Create(MyFrame * parent, wxString & path, wxString & table, 463 + wxString & defCs) 464 +{ 465 +// 466 +// creating the dialog 467 +// 468 + MainFrame = parent; 469 + Path = path; 470 + Table = table; 471 + Default = defCs; 472 + if (wxDialog::Create(parent, wxID_ANY, wxT("Load CSV/TXT")) == false) 473 + return false; 474 +// populates individual controls 475 + CreateControls(); 476 +// sets dialog sizer 477 + GetSizer()->Fit(this); 478 + GetSizer()->SetSizeHints(this); 479 +// centers the dialog window 480 + Centre(); 481 + return true; 482 +} 483 + 484 +void LoadTxtDialog::CreateControls() 485 +{ 486 +// 487 +// creating individual control and setting initial values 488 +// 489 + FirstLineTitles = true; 490 + Separator = '\t'; 491 + TextSeparator = '"'; 492 + DecimalPointIsComma = false; 493 + wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL); 494 + this->SetSizer(topSizer); 495 + wxBoxSizer *boxSizer = new wxBoxSizer(wxVERTICAL); 496 + topSizer->Add(boxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 542 497 // first row: the CSV/TXT path 543 - wxBoxSizer *pathSizer = new wxBoxSizer (wxHORIZONTAL); 544 - boxSizer->Add (pathSizer, 0, wxALIGN_RIGHT | wxALL, 0); 545 - wxStaticText *pathLabel = 546 - new wxStaticText (this, wxID_STATIC, wxT ("&Path:")); 547 - pathSizer->Add (pathLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 548 - wxTextCtrl *pathValue = new wxTextCtrl (this, wxID_STATIC, 549 - Path, wxDefaultPosition, 550 - wxSize (350, 22), wxTE_READONLY); 551 - pathSizer->Add (pathValue, 0, wxALIGN_RIGHT | wxALL, 5); 498 + wxBoxSizer *pathSizer = new wxBoxSizer(wxHORIZONTAL); 499 + boxSizer->Add(pathSizer, 0, wxALIGN_RIGHT | wxALL, 0); 500 + wxStaticText *pathLabel = new wxStaticText(this, wxID_STATIC, wxT("&Path:")); 501 + pathSizer->Add(pathLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 502 + wxTextCtrl *pathValue = new wxTextCtrl(this, wxID_STATIC, 503 + Path, wxDefaultPosition, 504 + wxSize(350, 22), wxTE_READONLY); 505 + pathSizer->Add(pathValue, 0, wxALIGN_RIGHT | wxALL, 5); 552 506 // second row: TABLE name 553 - wxBoxSizer *tableSizer = new wxBoxSizer (wxHORIZONTAL); 554 - boxSizer->Add (tableSizer, 0, wxALIGN_RIGHT | wxALL, 0); 555 - wxStaticText *tableLabel = 556 - new wxStaticText (this, wxID_STATIC, wxT ("&Table name:")); 557 - tableSizer->Add (tableLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 558 - wxTextCtrl *tableCtrl = new wxTextCtrl (this, ID_LDTXT_TABLE, Table, 559 - wxDefaultPosition, wxSize (350, 560 - 22)); 561 - tableSizer->Add (tableCtrl, 0, wxALIGN_RIGHT | wxALL, 5); 507 + wxBoxSizer *tableSizer = new wxBoxSizer(wxHORIZONTAL); 508 + boxSizer->Add(tableSizer, 0, wxALIGN_RIGHT | wxALL, 0); 509 + wxStaticText *tableLabel = 510 + new wxStaticText(this, wxID_STATIC, wxT("&Table name:")); 511 + tableSizer->Add(tableLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 512 + wxTextCtrl *tableCtrl = new wxTextCtrl(this, ID_LDTXT_TABLE, Table, 513 + wxDefaultPosition, wxSize(350, 514 + 22)); 515 + tableSizer->Add(tableCtrl, 0, wxALIGN_RIGHT | wxALL, 5); 562 516 // second row: OPTIONS 563 - wxBoxSizer *optSizer = new wxBoxSizer (wxHORIZONTAL); 564 - boxSizer->Add (optSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 565 - wxBoxSizer *modeSizer = new wxBoxSizer (wxVERTICAL); 566 - optSizer->Add (modeSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0); 567 - wxBoxSizer *mode1Sizer = new wxBoxSizer (wxHORIZONTAL); 568 - modeSizer->Add (mode1Sizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 569 - wxCheckBox *titleCtrl = new wxCheckBox (this, ID_LDTXT_TITLES, 570 - wxT 571 - ("First line contains column names"), 572 - wxDefaultPosition, wxDefaultSize); 573 - titleCtrl->SetValue (true); 574 - mode1Sizer->Add (titleCtrl, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 575 - wxStaticBox *sepBox = new wxStaticBox (this, wxID_STATIC, 576 - wxT ("Separators"), 577 - wxDefaultPosition, wxDefaultSize); 578 - wxBoxSizer *sepSizer = new wxStaticBoxSizer (sepBox, wxVERTICAL); 579 - modeSizer->Add (sepSizer, 0, wxALIGN_LEFT | wxALL, 0); 580 - wxBoxSizer *mode2Sizer = new wxBoxSizer (wxHORIZONTAL); 581 - sepSizer->Add (mode2Sizer, 0, wxALIGN_LEFT | wxALL, 0); 582 - wxString quotes[2]; 583 - quotes[0] = wxT ("&Double \""); 584 - quotes[1] = wxT ("&Single '"); 585 - wxRadioBox *textSeparatorBox = new wxRadioBox (this, ID_LDTXT_QUOTE, 586 - wxT 587 - ("&Text separator: quotes"), 588 - wxDefaultPosition, 589 - wxDefaultSize, 2, 590 - quotes, 2, 591 - wxRA_SPECIFY_COLS); 592 - mode2Sizer->Add (textSeparatorBox, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 593 - wxBoxSizer *mode3Sizer = new wxBoxSizer (wxHORIZONTAL); 594 - sepSizer->Add (mode3Sizer, 0, wxALIGN_LEFT | wxALL, 0); 595 - wxString separators[6]; 596 - separators[0] = wxT ("&Tab"); 597 - separators[1] = wxT ("&Space"); 598 - separators[2] = wxT ("Co&mma ,"); 599 - separators[3] = wxT ("&Colon :"); 600 - separators[4] = wxT ("S&emicolon ;"); 601 - separators[5] = wxT ("&Other"); 602 - wxRadioBox *separatorBox = new wxRadioBox (this, ID_LDTXT_SEPARATOR, 603 - wxT ("&Column separator"), 604 - wxDefaultPosition, wxDefaultSize, 605 - 6, 606 - separators, 2, 607 - wxRA_SPECIFY_COLS); 608 - mode3Sizer->Add (separatorBox, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 609 - wxBoxSizer *mode4Sizer = new wxBoxSizer (wxHORIZONTAL); 610 - sepSizer->Add (mode4Sizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 611 - wxStaticText *charSeparatorLabel = new wxStaticText (this, wxID_STATIC, 612 - wxT 613 - ("&Custom separator:"), 614 - wxDefaultPosition, 615 - wxDefaultSize, 0); 616 - mode4Sizer->Add (charSeparatorLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 617 - wxTextCtrl *dummy = 618 - new wxTextCtrl (this, ID_LDTXT_CHARSEPARATOR, wxT ("Dummy Text pq"), 619 - wxDefaultPosition, 620 - wxDefaultSize, 0); 621 - wxSize sz = dummy->GetSize (); 622 - delete dummy; 623 - sz.SetWidth (40); 624 - wxTextCtrl *charSeparatorCtrl = 625 - new wxTextCtrl (this, ID_LDTXT_CHARSEPARATOR, wxT ("TAB"), 626 - wxDefaultPosition, sz, 0); 627 - charSeparatorCtrl->SetMaxLength (1); 628 - charSeparatorCtrl->Enable (false); 629 - mode4Sizer->Add (charSeparatorCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 630 - wxBoxSizer *mode5Sizer = new wxBoxSizer (wxHORIZONTAL); 631 - sepSizer->Add (mode5Sizer, 0, wxALIGN_LEFT | wxALL, 0); 632 - wxString points[2]; 633 - points[0] = wxT ("&Point ."); 634 - points[1] = wxT ("&Comma ,"); 635 - wxRadioBox *decimalSeparatorBox = new wxRadioBox (this, ID_LDTXT_POINT, 636 - wxT 637 - ("&Decimal separator"), 638 - wxDefaultPosition, 639 - wxDefaultSize, 2, 640 - points, 2, 641 - wxRA_SPECIFY_COLS); 642 - mode5Sizer->Add (decimalSeparatorBox, 0, wxALIGN_CENTER_VERTICAL | wxALL, 643 - 5); 517 + wxBoxSizer *optSizer = new wxBoxSizer(wxHORIZONTAL); 518 + boxSizer->Add(optSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 519 + wxBoxSizer *modeSizer = new wxBoxSizer(wxVERTICAL); 520 + optSizer->Add(modeSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0); 521 + wxBoxSizer *mode1Sizer = new wxBoxSizer(wxHORIZONTAL); 522 + modeSizer->Add(mode1Sizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 523 + wxCheckBox *titleCtrl = new wxCheckBox(this, ID_LDTXT_TITLES, 524 + wxT 525 + ("First line contains column names"), 526 + wxDefaultPosition, wxDefaultSize); 527 + titleCtrl->SetValue(true); 528 + mode1Sizer->Add(titleCtrl, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 529 + wxStaticBox *sepBox = new wxStaticBox(this, wxID_STATIC, 530 + wxT("Separators"), 531 + wxDefaultPosition, wxDefaultSize); 532 + wxBoxSizer *sepSizer = new wxStaticBoxSizer(sepBox, wxVERTICAL); 533 + modeSizer->Add(sepSizer, 0, wxALIGN_LEFT | wxALL, 0); 534 + wxBoxSizer *mode2Sizer = new wxBoxSizer(wxHORIZONTAL); 535 + sepSizer->Add(mode2Sizer, 0, wxALIGN_LEFT | wxALL, 0); 536 + wxString quotes[2]; 537 + quotes[0] = wxT("&Double \""); 538 + quotes[1] = wxT("&Single '"); 539 + wxRadioBox *textSeparatorBox = new wxRadioBox(this, ID_LDTXT_QUOTE, 540 + wxT("&Text separator: quotes"), 541 + wxDefaultPosition, 542 + wxDefaultSize, 2, 543 + quotes, 2, 544 + wxRA_SPECIFY_COLS); 545 + mode2Sizer->Add(textSeparatorBox, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 546 + wxBoxSizer *mode3Sizer = new wxBoxSizer(wxHORIZONTAL); 547 + sepSizer->Add(mode3Sizer, 0, wxALIGN_LEFT | wxALL, 0); 548 + wxString separators[6]; 549 + separators[0] = wxT("&Tab"); 550 + separators[1] = wxT("&Space"); 551 + separators[2] = wxT("Co&mma ,"); 552 + separators[3] = wxT("&Colon :"); 553 + separators[4] = wxT("S&emicolon ;"); 554 + separators[5] = wxT("&Other"); 555 + wxRadioBox *separatorBox = new wxRadioBox(this, ID_LDTXT_SEPARATOR, 556 + wxT("&Column separator"), 557 + wxDefaultPosition, wxDefaultSize, 558 + 6, 559 + separators, 2, 560 + wxRA_SPECIFY_COLS); 561 + mode3Sizer->Add(separatorBox, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 562 + wxBoxSizer *mode4Sizer = new wxBoxSizer(wxHORIZONTAL); 563 + sepSizer->Add(mode4Sizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 564 + wxStaticText *charSeparatorLabel = new wxStaticText(this, wxID_STATIC, 565 + wxT("&Custom separator:"), 566 + wxDefaultPosition, 567 + wxDefaultSize, 0); 568 + mode4Sizer->Add(charSeparatorLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 569 + wxTextCtrl *dummy = 570 + new wxTextCtrl(this, ID_LDTXT_CHARSEPARATOR, wxT("Dummy Text pq"), 571 + wxDefaultPosition, 572 + wxDefaultSize, 0); 573 + wxSize sz = dummy->GetSize(); 574 + delete dummy; 575 + sz.SetWidth(40); 576 + wxTextCtrl *charSeparatorCtrl = 577 + new wxTextCtrl(this, ID_LDTXT_CHARSEPARATOR, wxT("TAB"), 578 + wxDefaultPosition, sz, 0); 579 + charSeparatorCtrl->SetMaxLength(1); 580 + charSeparatorCtrl->Enable(false); 581 + mode4Sizer->Add(charSeparatorCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 582 + wxBoxSizer *mode5Sizer = new wxBoxSizer(wxHORIZONTAL); 583 + sepSizer->Add(mode5Sizer, 0, wxALIGN_LEFT | wxALL, 0); 584 + wxString points[2]; 585 + points[0] = wxT("&Point ."); 586 + points[1] = wxT("&Comma ,"); 587 + wxRadioBox *decimalSeparatorBox = new wxRadioBox(this, ID_LDTXT_POINT, 588 + wxT("&Decimal separator"), 589 + wxDefaultPosition, 590 + wxDefaultSize, 2, 591 + points, 2, 592 + wxRA_SPECIFY_COLS); 593 + mode5Sizer->Add(decimalSeparatorBox, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 644 594 // third row: CHARSET 645 - wxStaticBox *charsetBox = new wxStaticBox (this, wxID_STATIC, 646 - wxT ("Charset Encoding"), 647 - wxDefaultPosition, 648 - wxDefaultSize); 649 - wxBoxSizer *charsetSizer = new wxStaticBoxSizer (charsetBox, wxHORIZONTAL); 650 - optSizer->Add (charsetSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 651 - wxListBox *charsetCtrl = new wxListBox (this, ID_LDTXT_CHARSET, 652 - wxDefaultPosition, wxDefaultSize, 653 - MainFrame->GetCharsetsLen (), 654 - MainFrame->GetCharsetsNames (), 655 - wxLB_SINGLE); 656 - charsetCtrl->SetFont (wxFont 657 - (8, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, 658 - wxFONTWEIGHT_NORMAL)); 659 - int idSel = MainFrame->GetCharsetIndex (Default); 660 - if (idSel != wxNOT_FOUND) 661 - charsetCtrl->SetSelection (idSel); 662 - charsetSizer->Add (charsetCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0); 595 + wxStaticBox *charsetBox = new wxStaticBox(this, wxID_STATIC, 596 + wxT("Charset Encoding"), 597 + wxDefaultPosition, 598 + wxDefaultSize); 599 + wxBoxSizer *charsetSizer = new wxStaticBoxSizer(charsetBox, wxHORIZONTAL); 600 + optSizer->Add(charsetSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 601 + wxListBox *charsetCtrl = new wxListBox(this, ID_LDTXT_CHARSET, 602 + wxDefaultPosition, wxDefaultSize, 603 + MainFrame->GetCharsetsLen(), 604 + MainFrame->GetCharsetsNames(), 605 + wxLB_SINGLE); 606 + charsetCtrl-> 607 + SetFont(wxFont 608 + (8, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL)); 609 + int idSel = MainFrame->GetCharsetIndex(Default); 610 + if (idSel != wxNOT_FOUND) 611 + charsetCtrl->SetSelection(idSel); 612 + charsetSizer->Add(charsetCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0); 663 613 // OK - CANCEL buttons 664 - wxBoxSizer *okCancelBox = new wxBoxSizer (wxHORIZONTAL); 665 - boxSizer->Add (okCancelBox, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 666 - wxButton *ok = new wxButton (this, wxID_OK, wxT ("&OK")); 667 - okCancelBox->Add (ok, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 668 - wxButton *cancel = new wxButton (this, wxID_CANCEL, wxT ("&Cancel")); 669 - okCancelBox->Add (cancel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 614 + wxBoxSizer *okCancelBox = new wxBoxSizer(wxHORIZONTAL); 615 + boxSizer->Add(okCancelBox, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 616 + wxButton *ok = new wxButton(this, wxID_OK, wxT("&OK")); 617 + okCancelBox->Add(ok, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 618 + wxButton *cancel = new wxButton(this, wxID_CANCEL, wxT("&Cancel")); 619 + okCancelBox->Add(cancel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 670 620 // appends event handler for OK button 671 - Connect (wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, 672 - (wxObjectEventFunction) & LoadTxtDialog::OnOk); 621 + Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, 622 + (wxObjectEventFunction) & LoadTxtDialog::OnOk); 673 623 // appends event handler for radioboxes 674 - Connect (ID_LDTXT_QUOTE, wxEVT_COMMAND_RADIOBOX_SELECTED, 675 - (wxObjectEventFunction) & LoadTxtDialog::OnQuote); 676 - Connect (ID_LDTXT_SEPARATOR, wxEVT_COMMAND_RADIOBOX_SELECTED, 677 - (wxObjectEventFunction) & LoadTxtDialog::OnSeparator); 678 - Connect (ID_LDTXT_POINT, wxEVT_COMMAND_RADIOBOX_SELECTED, 679 - (wxObjectEventFunction) & LoadTxtDialog::OnDecimalSeparator); 624 + Connect(ID_LDTXT_QUOTE, wxEVT_COMMAND_RADIOBOX_SELECTED, 625 + (wxObjectEventFunction) & LoadTxtDialog::OnQuote); 626 + Connect(ID_LDTXT_SEPARATOR, wxEVT_COMMAND_RADIOBOX_SELECTED, 627 + (wxObjectEventFunction) & LoadTxtDialog::OnSeparator); 628 + Connect(ID_LDTXT_POINT, wxEVT_COMMAND_RADIOBOX_SELECTED, 629 + (wxObjectEventFunction) & LoadTxtDialog::OnDecimalSeparator); 680 630 } 681 631 682 -void 683 -LoadTxtDialog::OnDecimalSeparator (wxCommandEvent & event) 632 +void LoadTxtDialog::OnDecimalSeparator(wxCommandEvent & event) 684 633 { 685 634 // 686 635 // POINT selection changed 687 636 // 688 - wxRadioBox *decimalSeparatorCtrl = 689 - (wxRadioBox *) FindWindow (ID_LDTXT_POINT); 690 - switch (decimalSeparatorCtrl->GetSelection ()) 691 - { 637 + wxRadioBox *decimalSeparatorCtrl = (wxRadioBox *) FindWindow(ID_LDTXT_POINT); 638 + switch (decimalSeparatorCtrl->GetSelection()) 639 + { 692 640 case 0: 693 - DecimalPointIsComma = false; 694 - break; 641 + DecimalPointIsComma = false; 642 + break; 695 643 case 1: 696 - DecimalPointIsComma = true; 697 - break; 698 - }; 644 + DecimalPointIsComma = true; 645 + break; 646 + }; 699 647 } 700 648 701 -void 702 -LoadTxtDialog::OnQuote (wxCommandEvent & event) 649 +void LoadTxtDialog::OnQuote(wxCommandEvent & event) 703 650 { 704 651 // 705 652 // QUOTE selection changed 706 653 // 707 - wxRadioBox *separatorCtrl = (wxRadioBox *) FindWindow (ID_LDTXT_QUOTE); 708 - switch (separatorCtrl->GetSelection ()) 709 - { 654 + wxRadioBox *separatorCtrl = (wxRadioBox *) FindWindow(ID_LDTXT_QUOTE); 655 + switch (separatorCtrl->GetSelection()) 656 + { 710 657 case 0: 711 - TextSeparator = '"'; 712 - break; 658 + TextSeparator = '"'; 659 + break; 713 660 case 1: 714 - TextSeparator = '\''; 715 - break; 716 - }; 661 + TextSeparator = '\''; 662 + break; 663 + }; 717 664 } 718 665 719 -void 720 -LoadTxtDialog::OnSeparator (wxCommandEvent & event) 666 +void LoadTxtDialog::OnSeparator(wxCommandEvent & event) 721 667 { 722 668 // 723 669 // SEPARATOR selection changed 724 670 // 725 - wxTextCtrl *charSeparatorCtrl = 726 - (wxTextCtrl *) FindWindow (ID_LDTXT_CHARSEPARATOR); 727 - wxRadioBox *separatorCtrl = (wxRadioBox *) FindWindow (ID_LDTXT_SEPARATOR); 728 - switch (separatorCtrl->GetSelection ()) 729 - { 671 + wxTextCtrl *charSeparatorCtrl = 672 + (wxTextCtrl *) FindWindow(ID_LDTXT_CHARSEPARATOR); 673 + wxRadioBox *separatorCtrl = (wxRadioBox *) FindWindow(ID_LDTXT_SEPARATOR); 674 + switch (separatorCtrl->GetSelection()) 675 + { 730 676 case 0: 731 - Separator = '\t'; 732 - charSeparatorCtrl->SetValue (wxT ("TAB")); 733 - break; 677 + Separator = '\t'; 678 + charSeparatorCtrl->SetValue(wxT("TAB")); 679 + break; 734 680 case 1: 735 - Separator = ' '; 736 - charSeparatorCtrl->SetValue (wxT ("SP")); 737 - break; 681 + Separator = ' '; 682 + charSeparatorCtrl->SetValue(wxT("SP")); 683 + break; 738 684 case 2: 739 - Separator = ','; 740 - charSeparatorCtrl->SetValue (wxT (",")); 741 - break; 685 + Separator = ','; 686 + charSeparatorCtrl->SetValue(wxT(",")); 687 + break; 742 688 case 3: 743 - Separator = ':'; 744 - charSeparatorCtrl->SetValue (wxT (":")); 745 - break; 689 + Separator = ':'; 690 + charSeparatorCtrl->SetValue(wxT(":")); 691 + break; 746 692 case 4: 747 - Separator = ';'; 748 - charSeparatorCtrl->SetValue (wxT (";")); 749 - break; 693 + Separator = ';'; 694 + charSeparatorCtrl->SetValue(wxT(";")); 695 + break; 750 696 case 5: 751 - Separator = '|'; 752 - charSeparatorCtrl->SetValue (wxT ("|")); 753 - break; 754 - }; 755 - if (separatorCtrl->GetSelection () == 5) 756 - charSeparatorCtrl->Enable (true); 757 - else 758 - charSeparatorCtrl->Enable (false); 759 -} 760 - 761 -void 762 -LoadTxtDialog::OnOk (wxCommandEvent & event) 697 + Separator = '|'; 698 + charSeparatorCtrl->SetValue(wxT("|")); 699 + break; 700 + }; 701 + if (separatorCtrl->GetSelection() == 5) 702 + charSeparatorCtrl->Enable(true); 703 + else 704 + charSeparatorCtrl->Enable(false); 705 +} 706 + 707 +void LoadTxtDialog::OnOk(wxCommandEvent & event) 708 +{ 709 +// 710 +// all done: 711 +// 712 + wxTextCtrl *tableCtrl = (wxTextCtrl *) FindWindow(ID_LDTXT_TABLE); 713 + Table = tableCtrl->GetValue(); 714 + if (Table.Len() < 1) 715 + { 716 + wxMessageBox(wxT("You must specify the TABLE NAME !!!"), 717 + wxT("spatialite-gui"), wxOK | wxICON_WARNING, this); 718 + return; 719 + } 720 + if (MainFrame->TableAlreadyExists(Table) == true) 721 + { 722 + wxMessageBox(wxT("a table name '") + Table + wxT("' already exists"), 723 + wxT("spatialite-gui"), wxOK | wxICON_WARNING, this); 724 + return; 725 + } 726 + wxListBox *charsetCtrl = (wxListBox *) FindWindow(ID_LDTXT_CHARSET); 727 + int idSel = charsetCtrl->GetSelection(); 728 + if (idSel == wxNOT_FOUND) 729 + { 730 + wxMessageBox(wxT("you must select some Charset Encoding from the list"), 731 + wxT("spatialite-gui"), wxOK | wxICON_WARNING, this); 732 + return; 733 + } 734 + wxString *charsets = MainFrame->GetCharsets(); 735 + Charset = *(charsets + idSel); 736 + wxRadioBox *separatorCtrl = (wxRadioBox *) FindWindow(ID_LDTXT_SEPARATOR); 737 + if (separatorCtrl->GetSelection() == 5) 738 + { 739 + wxTextCtrl *charSeparatorCtrl = 740 + (wxTextCtrl *) FindWindow(ID_LDTXT_CHARSEPARATOR); 741 + wxString separator = charSeparatorCtrl->GetValue(); 742 + if (separator.Len() != 1) 743 + { 744 + wxMessageBox(wxT 745 + ("you must specificy a single char as Custom Column Separator"), 746 + wxT("spatialite-gui"), wxOK | wxICON_WARNING, this); 747 + return; 748 + } 749 + char dummy[64]; 750 + strcpy(dummy, separator.ToUTF8()); 751 + Separator = *dummy; 752 + } 753 + wxDialog::EndModal(wxID_OK); 754 +} 755 + 756 +bool LoadShpDialog::Create(MyFrame * parent, wxString & path, wxString & table, 757 + int srid, wxString & column, wxString & defCs) 758 +{ 759 +// 760 +// creating the dialog 761 +// 762 + MainFrame = parent; 763 + Path = path; 764 + Table = table; 765 + Srid = srid; 766 + Column = column; 767 + Default = defCs; 768 + if (wxDialog::Create(parent, wxID_ANY, wxT("Load Shapefile")) == false) 769 + return false; 770 +// populates individual controls 771 + CreateControls(); 772 +// sets dialog sizer 773 + GetSizer()->Fit(this); 774 + GetSizer()->SetSizeHints(this); 775 +// centers the dialog window 776 + Centre(); 777 + return true; 778 +} 779 + 780 +void LoadShpDialog::CreateControls() 781 +{ 782 +// 783 +// creating individual control and setting initial values 784 +// 785 + wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL); 786 + this->SetSizer(topSizer); 787 + wxBoxSizer *boxSizer = new wxBoxSizer(wxVERTICAL); 788 + topSizer->Add(boxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 789 +// first row: the Shapefile path 790 + wxBoxSizer *pathSizer = new wxBoxSizer(wxHORIZONTAL); 791 + boxSizer->Add(pathSizer, 0, wxALIGN_RIGHT | wxALL, 0); 792 + wxStaticText *pathLabel = new wxStaticText(this, wxID_STATIC, wxT("&Path:")); 793 + pathSizer->Add(pathLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 794 + wxTextCtrl *pathValue = new wxTextCtrl(this, wxID_STATIC, 795 + Path, wxDefaultPosition, 796 + wxSize(350, 22), wxTE_READONLY); 797 + pathSizer->Add(pathValue, 0, wxALIGN_RIGHT | wxALL, 5); 798 +// second row: TABLE name 799 + wxBoxSizer *tableSizer = new wxBoxSizer(wxHORIZONTAL); 800 + boxSizer->Add(tableSizer, 0, wxALIGN_RIGHT | wxALL, 0); 801 + wxStaticText *tableLabel = 802 + new wxStaticText(this, wxID_STATIC, wxT("&Table name:")); 803 + tableSizer->Add(tableLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 804 + wxTextCtrl *tableCtrl = new wxTextCtrl(this, ID_LDSHP_TABLE, Table, 805 + wxDefaultPosition, wxSize(350, 806 + 22)); 807 + tableSizer->Add(tableCtrl, 0, wxALIGN_RIGHT | wxALL, 5); 808 +// third row: GEOMETRY COLUMN name 809 + wxBoxSizer *colSizer = new wxBoxSizer(wxHORIZONTAL); 810 + boxSizer->Add(colSizer, 0, wxALIGN_RIGHT | wxALL, 0); 811 + wxStaticText *colLabel = 812 + new wxStaticText(this, wxID_STATIC, wxT("&GeomColumn name:")); 813 + colSizer->Add(colLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 814 + wxTextCtrl *colCtrl = new wxTextCtrl(this, ID_LDSHP_COLUMN, Column, 815 + wxDefaultPosition, wxSize(350, 22)); 816 + colSizer->Add(colCtrl, 0, wxALIGN_RIGHT | wxALL, 5); 817 +// fourth row: SRID 818 + wxBoxSizer *sridSizer = new wxBoxSizer(wxHORIZONTAL); 819 + boxSizer->Add(sridSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 820 + wxStaticText *sridLabel = new wxStaticText(this, wxID_STATIC, wxT("&SRID:")); 821 + sridSizer->Add(sridLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 822 + wxSpinCtrl *sridCtrl = new wxSpinCtrl(this, ID_LDSHP_SRID, wxEmptyString, 823 + wxDefaultPosition, wxSize(80, 20), 824 + wxSP_ARROW_KEYS, 825 + -1, 40000, Srid); 826 + sridSizer->Add(sridCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 827 +// fifth row: CHARSET 828 + wxStaticBox *charsetBox = new wxStaticBox(this, wxID_STATIC, 829 + wxT("Charset Encoding"), 830 + wxDefaultPosition, 831 + wxDefaultSize); 832 + wxBoxSizer *charsetSizer = new wxStaticBoxSizer(charsetBox, wxHORIZONTAL); 833 + sridSizer->Add(charsetSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 834 + wxListBox *charsetCtrl = new wxListBox(this, ID_LDSHP_CHARSET, 835 + wxDefaultPosition, wxDefaultSize, 836 + MainFrame->GetCharsetsLen(), 837 + MainFrame->GetCharsetsNames(), 838 + wxLB_SINGLE); 839 + charsetCtrl-> 840 + SetFont(wxFont 841 + (8, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL)); 842 + int idSel = MainFrame->GetCharsetIndex(Default); 843 + if (idSel != wxNOT_FOUND) 844 + charsetCtrl->SetSelection(idSel); 845 + charsetSizer->Add(charsetCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0); 846 +// OK - CANCEL buttons 847 + wxBoxSizer *okCancelBox = new wxBoxSizer(wxHORIZONTAL); 848 + boxSizer->Add(okCancelBox, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 849 + wxButton *ok = new wxButton(this, wxID_OK, wxT("&OK")); 850 + okCancelBox->Add(ok, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 851 + wxButton *cancel = new wxButton(this, wxID_CANCEL, wxT("&Cancel")); 852 + okCancelBox->Add(cancel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 853 +// appends event handler for OK button 854 + Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, 855 + (wxObjectEventFunction) & LoadShpDialog::OnOk); 856 +} 857 + 858 +void LoadShpDialog::OnOk(wxCommandEvent & event) 859 +{ 860 +// 861 +// all done: 862 +// 863 + wxTextCtrl *tableCtrl = (wxTextCtrl *) FindWindow(ID_LDSHP_TABLE); 864 + Table = tableCtrl->GetValue(); 865 + if (Table.Len() < 1) 866 + { 867 + wxMessageBox(wxT("You must specify the TABLE NAME !!!"), 868 + wxT("spatialite-gui"), wxOK | wxICON_WARNING, this); 869 + return; 870 + } 871 + if (MainFrame->TableAlreadyExists(Table) == true) 872 + { 873 + wxMessageBox(wxT("a table name '") + Table + wxT("' already exists"), 874 + wxT("spatialite-gui"), wxOK | wxICON_WARNING, this); 875 + return; 876 + } 877 + wxTextCtrl *columnCtrl = (wxTextCtrl *) FindWindow(ID_LDSHP_COLUMN); 878 + Column = columnCtrl->GetValue(); 879 + if (Column.Len() < 1) 880 + { 881 + wxMessageBox(wxT("You must specify the GEOMETRY COLUMN NAME !!!"), 882 + wxT("spatialite-gui"), wxOK | wxICON_WARNING, this); 883 + return; 884 + } 885 + wxSpinCtrl *sridCtrl = (wxSpinCtrl *) FindWindow(ID_LDSHP_SRID); 886 + Srid = sridCtrl->GetValue(); 887 + if (MainFrame->SridNotExists(Srid) == true) 888 + { 889 + wxMessageBox(wxT("invalid SRID value"), wxT("spatialite-gui"), 890 + wxOK | wxICON_WARNING, this); 891 + return; 892 + } 893 + wxListBox *charsetCtrl = (wxListBox *) FindWindow(ID_LDSHP_CHARSET); 894 + int idSel = charsetCtrl->GetSelection(); 895 + if (idSel == wxNOT_FOUND) 896 + { 897 + wxMessageBox(wxT("you must select some Charset Encoding from the list"), 898 + wxT("spatialite-gui"), wxOK | wxICON_WARNING, this); 899 + return; 900 + } 901 + wxString *charsets = MainFrame->GetCharsets(); 902 + Charset = *(charsets + idSel); 903 + wxDialog::EndModal(wxID_OK); 904 +} 905 + 906 +bool DumpShpDialog::Create(MyFrame * parent, wxString & path, wxString & table, 907 + wxString & column, wxString & defCs) 908 +{ 909 +// 910 +// creating the dialog 911 +// 912 + MainFrame = parent; 913 + Path = path; 914 + Table = table; 915 + Column = column; 916 + Default = defCs; 917 + if (wxDialog::Create(parent, wxID_ANY, wxT("Dump Shapefile")) == false) 918 + return false; 919 +// populates individual controls 920 + CreateControls(); 921 +// sets dialog sizer 922 + GetSizer()->Fit(this); 923 + GetSizer()->SetSizeHints(this); 924 +// centers the dialog window 925 + Centre(); 926 + return true; 927 +} 928 + 929 +void DumpShpDialog::CreateControls() 930 +{ 931 +// 932 +// creating individual control and setting initial values 933 +// 934 + wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL); 935 + this->SetSizer(topSizer); 936 + wxBoxSizer *boxSizer = new wxBoxSizer(wxVERTICAL); 937 + topSizer->Add(boxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 938 +// first row: the Shapefile path 939 + wxBoxSizer *pathSizer = new wxBoxSizer(wxHORIZONTAL); 940 + boxSizer->Add(pathSizer, 0, wxALIGN_RIGHT | wxALL, 0); 941 + wxStaticText *pathLabel = new wxStaticText(this, wxID_STATIC, wxT("&Path:")); 942 + pathSizer->Add(pathLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 943 + wxTextCtrl *pathValue = new wxTextCtrl(this, wxID_STATIC, 944 + Path, wxDefaultPosition, 945 + wxSize(350, 22), wxTE_READONLY); 946 + pathSizer->Add(pathValue, 0, wxALIGN_RIGHT | wxALL, 5); 947 +// second row: TABLE name 948 + wxBoxSizer *tableSizer = new wxBoxSizer(wxHORIZONTAL); 949 + boxSizer->Add(tableSizer, 0, wxALIGN_RIGHT | wxALL, 0); 950 + wxStaticText *tableLabel = 951 + new wxStaticText(this, wxID_STATIC, wxT("&Table name:")); 952 + tableSizer->Add(tableLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 953 + wxTextCtrl *tableCtrl = new wxTextCtrl(this, wxID_STATIC, Table, 954 + wxDefaultPosition, wxSize(350, 955 + 22)); 956 + tableCtrl->Enable(false); 957 + tableSizer->Add(tableCtrl, 0, wxALIGN_RIGHT | wxALL, 5); 958 +// third row: GEOMETRY COLUMN name 959 + wxBoxSizer *colSizer = new wxBoxSizer(wxHORIZONTAL); 960 + boxSizer->Add(colSizer, 0, wxALIGN_RIGHT | wxALL, 0); 961 + wxStaticText *colLabel = 962 + new wxStaticText(this, wxID_STATIC, wxT("&GeomColumn name:")); 963 + colSizer->Add(colLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 964 + wxTextCtrl *colCtrl = new wxTextCtrl(this, wxID_STATIC, Column, 965 + wxDefaultPosition, wxSize(350, 22)); 966 + colCtrl->Enable(false); 967 + colSizer->Add(colCtrl, 0, wxALIGN_RIGHT | wxALL, 5); 968 +// fourth row: CHARSET 969 + wxBoxSizer *csSizer = new wxBoxSizer(wxHORIZONTAL); 970 + boxSizer->Add(csSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 971 + wxStaticBox *charsetBox = new wxStaticBox(this, wxID_STATIC, 972 + wxT("Charset Encoding"), 973 + wxDefaultPosition, 974 + wxDefaultSize); 975 + wxBoxSizer *charsetSizer = new wxStaticBoxSizer(charsetBox, wxHORIZONTAL); 976 + csSizer->Add(charsetSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 977 + wxListBox *charsetCtrl = new wxListBox(this, ID_DMPSHP_CHARSET, 978 + wxDefaultPosition, wxDefaultSize, 979 + MainFrame->GetCharsetsLen(), 980 + MainFrame->GetCharsetsNames(), 981 + wxLB_SINGLE); 982 + charsetCtrl-> 983 + SetFont(wxFont 984 + (8, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL)); 985 + int idSel = MainFrame->GetCharsetIndex(Default); 986 + if (idSel != wxNOT_FOUND) 987 + charsetCtrl->SetSelection(idSel); 988 + charsetSizer->Add(charsetCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0); 989 +// OK - CANCEL buttons 990 + wxBoxSizer *okCancelBox = new wxBoxSizer(wxHORIZONTAL); 991 + boxSizer->Add(okCancelBox, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 992 + wxButton *ok = new wxButton(this, wxID_OK, wxT("&OK")); 993 + okCancelBox->Add(ok, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 994 + wxButton *cancel = new wxButton(this, wxID_CANCEL, wxT("&Cancel")); 995 + okCancelBox->Add(cancel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 996 +// appends event handler for OK button 997 + Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, 998 + (wxObjectEventFunction) & DumpShpDialog::OnOk); 999 +} 1000 + 1001 +void DumpShpDialog::OnOk(wxCommandEvent & event) 1002 +{ 1003 +// 1004 +// all done: 1005 +// 1006 + wxListBox *charsetCtrl = (wxListBox *) FindWindow(ID_DMPSHP_CHARSET); 1007 + int idSel = charsetCtrl->GetSelection(); 1008 + if (idSel == wxNOT_FOUND) 1009 + { 1010 + wxMessageBox(wxT("you must select some Charset Encoding from the list"), 1011 + wxT("spatialite-gui"), wxOK | wxICON_WARNING, this); 1012 + return; 1013 + } 1014 + wxString *charsets = MainFrame->GetCharsets(); 1015 + Charset = *(charsets + idSel); 1016 + wxDialog::EndModal(wxID_OK); 1017 +} 1018 + 1019 +bool DumpTxtDialog::Create(MyFrame * parent, wxString & path, wxString & target, 1020 + wxString & defCs) 1021 +{ 1022 +// 1023 +// creating the dialog 1024 +// 1025 + MainFrame = parent; 1026 + Path = path; 1027 + Default = defCs; 1028 + if (wxDialog::Create(parent, wxID_ANY, wxT("Dump ") + target) == false) 1029 + return false; 1030 +// populates individual controls 1031 + CreateControls(); 1032 +// sets dialog sizer 1033 + GetSizer()->Fit(this); 1034 + GetSizer()->SetSizeHints(this); 1035 +// centers the dialog window 1036 + Centre(); 1037 + return true; 1038 +} 1039 + 1040 +void DumpTxtDialog::CreateControls() 1041 +{ 1042 +// 1043 +// creating individual control and setting initial values 1044 +// 1045 + wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL); 1046 + this->SetSizer(topSizer); 1047 + wxBoxSizer *boxSizer = new wxBoxSizer(wxVERTICAL); 1048 + topSizer->Add(boxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 1049 +// first row: the Shapefile path 1050 + wxBoxSizer *pathSizer = new wxBoxSizer(wxHORIZONTAL); 1051 + boxSizer->Add(pathSizer, 0, wxALIGN_RIGHT | wxALL, 0); 1052 + wxStaticText *pathLabel = new wxStaticText(this, wxID_STATIC, wxT("&Path:")); 1053 + pathSizer->Add(pathLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1054 + wxTextCtrl *pathValue = new wxTextCtrl(this, wxID_STATIC, 1055 + Path, wxDefaultPosition, 1056 + wxSize(350, 22), wxTE_READONLY); 1057 + pathSizer->Add(pathValue, 0, wxALIGN_RIGHT | wxALL, 5); 1058 +// second row: CHARSET 1059 + wxBoxSizer *csSizer = new wxBoxSizer(wxHORIZONTAL); 1060 + boxSizer->Add(csSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 1061 + wxStaticBox *charsetBox = new wxStaticBox(this, wxID_STATIC, 1062 + wxT("Charset Encoding"), 1063 + wxDefaultPosition, 1064 + wxDefaultSize); 1065 + wxBoxSizer *charsetSizer = new wxStaticBoxSizer(charsetBox, wxHORIZONTAL); 1066 + csSizer->Add(charsetSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 1067 + wxListBox *charsetCtrl = new wxListBox(this, ID_DMPTXT_CHARSET, 1068 + wxDefaultPosition, wxDefaultSize, 1069 + MainFrame->GetCharsetsLen(), 1070 + MainFrame->GetCharsetsNames(), 1071 + wxLB_SINGLE); 1072 + charsetCtrl-> 1073 + SetFont(wxFont 1074 + (8, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL)); 1075 + int idSel = MainFrame->GetCharsetIndex(Default); 1076 + if (idSel != wxNOT_FOUND) 1077 + charsetCtrl->SetSelection(idSel); 1078 + charsetSizer->Add(charsetCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0); 1079 +// OK - CANCEL buttons 1080 + wxBoxSizer *okCancelBox = new wxBoxSizer(wxHORIZONTAL); 1081 + boxSizer->Add(okCancelBox, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 1082 + wxButton *ok = new wxButton(this, wxID_OK, wxT("&OK")); 1083 + okCancelBox->Add(ok, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1084 + wxButton *cancel = new wxButton(this, wxID_CANCEL, wxT("&Cancel")); 1085 + okCancelBox->Add(cancel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1086 +// appends event handler for OK button 1087 + Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, 1088 + (wxObjectEventFunction) & DumpTxtDialog::OnOk); 1089 +} 1090 + 1091 +void DumpTxtDialog::OnOk(wxCommandEvent & event) 1092 +{ 1093 +// 1094 +// all done: 1095 +// 1096 + wxListBox *charsetCtrl = (wxListBox *) FindWindow(ID_DMPTXT_CHARSET); 1097 + int idSel = charsetCtrl->GetSelection(); 1098 + if (idSel == wxNOT_FOUND) 1099 + { 1100 + wxMessageBox(wxT("you must select some Charset Encoding from the list"), 1101 + wxT("spatialite-gui"), wxOK | wxICON_WARNING, this); 1102 + return; 1103 + } 1104 + wxString *charsets = MainFrame->GetCharsets(); 1105 + Charset = *(charsets + idSel); 1106 + wxDialog::EndModal(wxID_OK); 1107 +} 1108 + 1109 +bool SqlScriptDialog::Create(MyFrame * parent, wxString & path, 1110 + wxString & defCs) 1111 +{ 1112 +// 1113 +// creating the dialog 1114 +// 1115 + MainFrame = parent; 1116 + Path = path; 1117 + Default = defCs; 1118 + if (wxDialog::Create(parent, wxID_ANY, wxT("SQL script execute")) == false) 1119 + return false; 1120 +// populates individual controls 1121 + CreateControls(); 1122 +// sets dialog sizer 1123 + GetSizer()->Fit(this); 1124 + GetSizer()->SetSizeHints(this); 1125 +// centers the dialog window 1126 + Centre(); 1127 + return true; 1128 +} 1129 + 1130 +void SqlScriptDialog::CreateControls() 1131 +{ 1132 +// 1133 +// creating individual control and setting initial values 1134 +// 1135 + wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL); 1136 + this->SetSizer(topSizer); 1137 + wxBoxSizer *boxSizer = new wxBoxSizer(wxVERTICAL); 1138 + topSizer->Add(boxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 1139 +// first row: the SQL script path 1140 + wxBoxSizer *pathSizer = new wxBoxSizer(wxHORIZONTAL); 1141 + boxSizer->Add(pathSizer, 0, wxALIGN_RIGHT | wxALL, 0); 1142 + wxStaticText *pathLabel = new wxStaticText(this, wxID_STATIC, wxT("&Path:")); 1143 + pathSizer->Add(pathLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1144 + wxTextCtrl *pathValue = new wxTextCtrl(this, wxID_STATIC, 1145 + Path, wxDefaultPosition, 1146 + wxSize(350, 22), wxTE_READONLY); 1147 + pathSizer->Add(pathValue, 0, wxALIGN_RIGHT | wxALL, 5); 1148 +// second row: CHARSET 1149 + wxBoxSizer *csSizer = new wxBoxSizer(wxHORIZONTAL); 1150 + boxSizer->Add(csSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 1151 + wxStaticBox *charsetBox = new wxStaticBox(this, wxID_STATIC, 1152 + wxT("Charset Encoding"), 1153 + wxDefaultPosition, 1154 + wxDefaultSize); 1155 + wxBoxSizer *charsetSizer = new wxStaticBoxSizer(charsetBox, wxHORIZONTAL); 1156 + csSizer->Add(charsetSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 1157 + wxListBox *charsetCtrl = new wxListBox(this, ID_SCRIPT_CHARSET, 1158 + wxDefaultPosition, wxDefaultSize, 1159 + MainFrame->GetCharsetsLen(), 1160 + MainFrame->GetCharsetsNames(), 1161 + wxLB_SINGLE); 1162 + charsetCtrl-> 1163 + SetFont(wxFont 1164 + (8, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL)); 1165 + int idSel = MainFrame->GetCharsetIndex(Default); 1166 + if (idSel != wxNOT_FOUND) 1167 + charsetCtrl->SetSelection(idSel); 1168 + charsetSizer->Add(charsetCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0); 1169 +// OK - CANCEL buttons 1170 + wxBoxSizer *okCancelBox = new wxBoxSizer(wxHORIZONTAL); 1171 + boxSizer->Add(okCancelBox, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 1172 + wxButton *ok = new wxButton(this, wxID_OK, wxT("&OK")); 1173 + okCancelBox->Add(ok, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1174 + wxButton *cancel = new wxButton(this, wxID_CANCEL, wxT("&Cancel")); 1175 + okCancelBox->Add(cancel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1176 +// appends event handler for OK button 1177 + Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, 1178 + (wxObjectEventFunction) & SqlScriptDialog::OnOk); 1179 +} 1180 + 1181 +void SqlScriptDialog::OnOk(wxCommandEvent & event) 1182 +{ 1183 +// 1184 +// all done: 1185 +// 1186 + wxListBox *charsetCtrl = (wxListBox *) FindWindow(ID_SCRIPT_CHARSET); 1187 + int idSel = charsetCtrl->GetSelection(); 1188 + if (idSel == wxNOT_FOUND) 1189 + { 1190 + wxMessageBox(wxT("you must select some Charset Encoding from the list"), 1191 + wxT("spatialite-gui"), wxOK | wxICON_WARNING, this); 1192 + return; 1193 + } 1194 + wxString *charsets = MainFrame->GetCharsets(); 1195 + Charset = *(charsets + idSel); 1196 + wxDialog::EndModal(wxID_OK); 1197 +} 1198 + 1199 +bool DefaultCharsetDialog::Create(MyFrame * parent, wxString & charset, 1200 + bool ask) 1201 +{ 1202 +// 1203 +// creating the dialog 1204 +// 1205 + MainFrame = parent; 1206 + Charset = charset; 1207 + AskCharset = ask; 1208 + if (wxDialog::Create(parent, wxID_ANY, wxT("Charset settings")) == false) 1209 + return false; 1210 +// populates individual controls 1211 + CreateControls(); 1212 +// sets dialog sizer 1213 + GetSizer()->Fit(this); 1214 + GetSizer()->SetSizeHints(this); 1215 +// centers the dialog window 1216 + Centre(); 1217 + return true; 1218 +} 1219 + 1220 +void DefaultCharsetDialog::CreateControls() 1221 +{ 1222 +// 1223 +// creating individual control and setting initial values 1224 +// 1225 + wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL); 1226 + this->SetSizer(topSizer); 1227 + wxBoxSizer *boxSizer = new wxBoxSizer(wxVERTICAL); 1228 + topSizer->Add(boxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 1229 +// first row: the DEFAULT CHARSET 1230 + wxBoxSizer *csSizer = new wxBoxSizer(wxHORIZONTAL); 1231 + boxSizer->Add(csSizer, 0, wxALIGN_RIGHT | wxALL, 0); 1232 + wxStaticBox *charsetBox = new wxStaticBox(this, wxID_STATIC, 1233 + wxT("Default Output Charset"), 1234 + wxDefaultPosition, 1235 + wxDefaultSize); 1236 + wxBoxSizer *charsetSizer = new wxStaticBoxSizer(charsetBox, wxVERTICAL); 1237 + csSizer->Add(charsetSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 1238 + wxListBox *charsetCtrl = new wxListBox(this, ID_DFLT_CHARSET, 1239 + wxDefaultPosition, wxDefaultSize, 1240 + MainFrame->GetCharsetsLen(), 1241 + MainFrame->GetCharsetsNames(), 1242 + wxLB_SINGLE); 1243 + charsetCtrl-> 1244 + SetFont(wxFont 1245 + (8, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL)); 1246 + int idSel = MainFrame->GetCharsetIndex(Charset); 1247 + if (idSel != wxNOT_FOUND) 1248 + charsetCtrl->SetSelection(idSel); 1249 + charsetSizer->Add(charsetCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0); 1250 +// second row: the ASK CHARSET 1251 + wxBoxSizer *askSizer = new wxBoxSizer(wxHORIZONTAL); 1252 + charsetSizer->Add(askSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 1253 + wxCheckBox *askCtrl = new wxCheckBox(this, ID_DFLT_ASK, 1254 + wxT("Ask output charset every time"), 1255 + wxDefaultPosition, wxDefaultSize); 1256 + askCtrl->SetValue(AskCharset); 1257 + askSizer->Add(askCtrl, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 1258 +// OK - CANCEL buttons 1259 + wxBoxSizer *okCancelBox = new wxBoxSizer(wxHORIZONTAL); 1260 + boxSizer->Add(okCancelBox, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 1261 + wxButton *ok = new wxButton(this, wxID_OK, wxT("&OK")); 1262 + okCancelBox->Add(ok, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1263 + wxButton *cancel = new wxButton(this, wxID_CANCEL, wxT("&Cancel")); 1264 + okCancelBox->Add(cancel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1265 +// appends event handler for OK button 1266 + Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, 1267 + (wxObjectEventFunction) & DefaultCharsetDialog::OnOk); 1268 +} 1269 + 1270 +void DefaultCharsetDialog::OnOk(wxCommandEvent & event) 763 1271 { 764 1272 // 765 1273 // all done: 766 1274 // 767 - wxTextCtrl *tableCtrl = (wxTextCtrl *) FindWindow (ID_LDTXT_TABLE); 768 - Table = tableCtrl->GetValue (); 769 - if (Table.Len () < 1) 770 - { 771 - wxMessageBox (wxT ("You must specify the TABLE NAME !!!"), 772 - wxT ("spatialite-gui"), wxOK | wxICON_WARNING, this); 773 - return; 774 - } 775 - if (MainFrame->TableAlreadyExists (Table) == true) 776 - { 777 - wxMessageBox (wxT ("a table name '") + Table + 778 - wxT ("' already exists"), wxT ("spatialite-gui"), 779 - wxOK | wxICON_WARNING, this); 780 - return; 781 - } 782 - if (gaiaIllegalSqlName (Table.ToUTF8 ()) == 1 783 - || gaiaIsReservedSqlName (Table.ToUTF8 ()) == 1 784 - || gaiaIsReservedSqliteName (Table.ToUTF8 ()) == 1) 785 - { 786 - wxMessageBox (wxT ("'") + Table + 787 - wxT 788 - ("' is an invalid TABLE NAME\n\nillegal name or reserved keyword"), 789 - wxT ("spatialite-gui"), wxOK | wxICON_WARNING, this); 790 - return; 791 - } 792 - wxListBox *charsetCtrl = (wxListBox *) FindWindow (ID_LDTXT_CHARSET); 793 - int idSel = charsetCtrl->GetSelection (); 794 - if (idSel == wxNOT_FOUND) 795 - { 796 - wxMessageBox (wxT 797 - ("you must select some Charset Encoding from the list"), 798 - wxT ("spatialite-gui"), wxOK | wxICON_WARNING, this); 799 - return; 800 - } 801 - wxString *charsets = MainFrame->GetCharsets (); 802 - Charset = *(charsets + idSel); 803 - wxRadioBox *separatorCtrl = (wxRadioBox *) FindWindow (ID_LDTXT_SEPARATOR); 804 - if (separatorCtrl->GetSelection () == 5) 805 - { 806 - wxTextCtrl *charSeparatorCtrl = 807 - (wxTextCtrl *) FindWindow (ID_LDTXT_CHARSEPARATOR); 808 - wxString separator = charSeparatorCtrl->GetValue (); 809 - if (separator.Len () != 1) 810 - { 811 - wxMessageBox (wxT 812 - ("you must specificy a single char as Custom Column Separator"), 813 - wxT ("spatialite-gui"), wxOK | wxICON_WARNING, 814 - this); 815 - return; 816 - } 817 - char dummy[64]; 818 - strcpy (dummy, separator.ToUTF8 ()); 819 - Separator = *dummy; 820 - } 821 - wxDialog::EndModal (wxID_OK); 822 -} 823 - 824 -bool 825 -LoadShpDialog::Create (MyFrame * parent, wxString & path, wxString & table, 826 - int srid, wxString & column, wxString & defCs) 1275 + wxListBox *charsetCtrl = (wxListBox *) FindWindow(ID_DFLT_CHARSET); 1276 + int idSel = charsetCtrl->GetSelection(); 1277 + if (idSel == wxNOT_FOUND) 1278 + { 1279 + wxMessageBox(wxT 1280 + ("you must select some Default Charset Encoding from the list"), 1281 + wxT("spatialite-gui"), wxOK | wxICON_WARNING, this); 1282 + return; 1283 + } 1284 + wxString *charsets = MainFrame->GetCharsets(); 1285 + Charset = *(charsets + idSel); 1286 + wxCheckBox *askCtrl = (wxCheckBox *) FindWindow(ID_DFLT_ASK); 1287 + AskCharset = askCtrl->GetValue(); 1288 + wxDialog::EndModal(wxID_OK); 1289 +} 1290 + 1291 +bool RecoverDialog::Create(MyFrame * parent, wxString & table, 1292 + wxString & column) 827 1293 { 828 1294 // 829 1295 // creating the dialog 830 1296 // 831 - MainFrame = parent; 832 - Path = path; 833 - Table = table; 834 - Srid = srid; 835 - Column = column; 836 - Default = defCs; 837 - if (wxDialog::Create (parent, wxID_ANY, wxT ("Load Shapefile")) == false) 838 - return false; 1297 + MainFrame = parent; 1298 + Table = table; 1299 + Column = column; 1300 + Srid = -1; 1301 + if (wxDialog::Create(parent, wxID_ANY, wxT("Recover Geometry Column")) == 1302 + false) 1303 + return false; 839 1304 // populates individual controls 840 - CreateControls (); 1305 + CreateControls(); 841 1306 // sets dialog sizer 842 - GetSizer ()->Fit (this); 843 - GetSizer ()->SetSizeHints (this); 1307 + GetSizer()->Fit(this); 1308 + GetSizer()->SetSizeHints(this); 844 1309 // centers the dialog window 845 - Centre (); 846 - return true; 1310 + Centre(); 1311 + return true; 847 1312 } 848 1313 849 -void 850 -LoadShpDialog::CreateControls () 1314 +void RecoverDialog::CreateControls() 851 1315 { 852 1316 // 853 1317 // creating individual control and setting initial values 854 1318 // 855 - wxBoxSizer *topSizer = new wxBoxSizer (wxVERTICAL); 856 - this->SetSizer (topSizer); 857 - wxBoxSizer *boxSizer = new wxBoxSizer (wxVERTICAL); 858 - topSizer->Add (boxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 859 -// first row: the Shapefile path 860 - wxBoxSizer *pathSizer = new wxBoxSizer (wxHORIZONTAL); 861 - boxSizer->Add (pathSizer, 0, wxALIGN_RIGHT | wxALL, 0); 862 - wxStaticText *pathLabel = 863 - new wxStaticText (this, wxID_STATIC, wxT ("&Path:")); 864 - pathSizer->Add (pathLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 865 - wxTextCtrl *pathValue = new wxTextCtrl (this, wxID_STATIC, 866 - Path, wxDefaultPosition, 867 - wxSize (350, 22), wxTE_READONLY); 868 - pathSizer->Add (pathValue, 0, wxALIGN_RIGHT | wxALL, 5); 869 -// second row: TABLE name 870 - wxBoxSizer *tableSizer = new wxBoxSizer (wxHORIZONTAL); 871 - boxSizer->Add (tableSizer, 0, wxALIGN_RIGHT | wxALL, 0); 872 - wxStaticText *tableLabel = 873 - new wxStaticText (this, wxID_STATIC, wxT ("&Table name:")); 874 - tableSizer->Add (tableLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 875 - wxTextCtrl *tableCtrl = new wxTextCtrl (this, ID_LDSHP_TABLE, Table, 876 - wxDefaultPosition, wxSize (350, 877 - 22)); 878 - tableSizer->Add (tableCtrl, 0, wxALIGN_RIGHT | wxALL, 5); 879 -// third row: GEOMETRY COLUMN name 880 - wxBoxSizer *colSizer = new wxBoxSizer (wxHORIZONTAL); 881 - boxSizer->Add (colSizer, 0, wxALIGN_RIGHT | wxALL, 0); 882 - wxStaticText *colLabel = 883 - new wxStaticText (this, wxID_STATIC, wxT ("&GeomColumn name:")); 884 - colSizer->Add (colLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 885 - wxTextCtrl *colCtrl = new wxTextCtrl (this, ID_LDSHP_COLUMN, Column, 886 - wxDefaultPosition, wxSize (350, 22)); 887 - colSizer->Add (colCtrl, 0, wxALIGN_RIGHT | wxALL, 5); 888 -// fourth row: SRID 889 - wxBoxSizer *sridSizer = new wxBoxSizer (wxHORIZONTAL); 890 - boxSizer->Add (sridSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 891 - wxStaticText *sridLabel = 892 - new wxStaticText (this, wxID_STATIC, wxT ("&SRID:")); 893 - sridSizer->Add (sridLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 894 - wxSpinCtrl *sridCtrl = new wxSpinCtrl (this, ID_LDSHP_SRID, wxEmptyString, 895 - wxDefaultPosition, wxSize (80, 20), 896 - wxSP_ARROW_KEYS, 897 - -1, 40000, Srid); 898 - sridSizer->Add (sridCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 899 -// fifth row: CHARSET 900 - wxStaticBox *charsetBox = new wxStaticBox (this, wxID_STATIC, 901 - wxT ("Charset Encoding"), 902 - wxDefaultPosition, 903 - wxDefaultSize); 904 - wxBoxSizer *charsetSizer = new wxStaticBoxSizer (charsetBox, wxHORIZONTAL); 905 - sridSizer->Add (charsetSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 906 - wxListBox *charsetCtrl = new wxListBox (this, ID_LDSHP_CHARSET, 907 - wxDefaultPosition, wxDefaultSize, 908 - MainFrame->GetCharsetsLen (), 909 - MainFrame->GetCharsetsNames (), 910 - wxLB_SINGLE); 911 - charsetCtrl->SetFont (wxFont 912 - (8, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, 913 - wxFONTWEIGHT_NORMAL)); 914 - int idSel = MainFrame->GetCharsetIndex (Default); 915 - if (idSel != wxNOT_FOUND) 916 - charsetCtrl->SetSelection (idSel); 917 - charsetSizer->Add (charsetCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0); 1319 + wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL); 1320 + this->SetSizer(topSizer); 1321 + wxBoxSizer *boxSizer = new wxBoxSizer(wxVERTICAL); 1322 + topSizer->Add(boxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 1323 +// First row: TABLE name 1324 + wxBoxSizer *tableSizer = new wxBoxSizer(wxHORIZONTAL); 1325 + boxSizer->Add(tableSizer, 0, wxALIGN_RIGHT | wxALL, 0); 1326 + wxStaticText *tableLabel = 1327 + new wxStaticText(this, wxID_STATIC, wxT("&Table name:")); 1328 + tableSizer->Add(tableLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1329 + wxTextCtrl *tableCtrl = new wxTextCtrl(this, wxID_ANY, Table, 1330 + wxDefaultPosition, wxSize(350, 22), 1331 + wxTE_READONLY); 1332 + tableCtrl->Enable(false); 1333 + tableSizer->Add(tableCtrl, 0, wxALIGN_RIGHT | wxALL, 5); 1334 +// second row: GEOMETRY COLUMN name 1335 + wxBoxSizer *colSizer = new wxBoxSizer(wxHORIZONTAL); 1336 + boxSizer->Add(colSizer, 0, wxALIGN_RIGHT | wxALL, 0); 1337 + wxStaticText *colLabel = 1338 + new wxStaticText(this, wxID_STATIC, wxT("&Column name:")); 1339 + colSizer->Add(colLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1340 + wxTextCtrl *colCtrl = new wxTextCtrl(this, wxID_ANY, Column, 1341 + wxDefaultPosition, wxSize(350, 22), 1342 + wxTE_READONLY); 1343 + colCtrl->Enable(false); 1344 + colSizer->Add(colCtrl, 0, wxALIGN_RIGHT | wxALL, 5); 1345 +// third row: SRID 1346 + wxBoxSizer *sridSizer = new wxBoxSizer(wxHORIZONTAL); 1347 + boxSizer->Add(sridSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 1348 + wxStaticText *sridLabel = new wxStaticText(this, wxID_STATIC, wxT("&SRID:")); 1349 + sridSizer->Add(sridLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1350 + wxSpinCtrl *sridCtrl = new wxSpinCtrl(this, ID_RCVR_SRID, wxEmptyString, 1351 + wxDefaultPosition, wxSize(80, 20), 1352 + wxSP_ARROW_KEYS, 1353 + -1, 40000, Srid); 1354 + sridSizer->Add(sridCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1355 +// fourth row: GEOMETRY TYPE 1356 + wxStaticBox *typeBox = new wxStaticBox(this, wxID_STATIC, 1357 + wxT("Geometry Type"), 1358 + wxDefaultPosition, wxDefaultSize); 1359 + wxBoxSizer *typeSizer = new wxStaticBoxSizer(typeBox, wxHORIZONTAL); 1360 + sridSizer->Add(typeSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 1361 + wxString types[7]; 1362 + types[0] = wxT("POINT"); 1363 + types[1] = wxT("MULTIPOINT"); 1364 + types[2] = wxT("LINESTRING"); 1365 + types[3] = wxT("MULTILINESTRING"); 1366 + types[4] = wxT("POLYGON"); 1367 + types[5] = wxT("MULTIPOLYGON"); 1368 + types[6] = wxT("GEOMETRYCOLLECTION"); 1369 + wxListBox *geomType = new wxListBox(this, ID_RCVR_TYPE, 1370 + wxDefaultPosition, wxDefaultSize, 7, 1371 + types, wxLB_SINGLE); 1372 + typeSizer->Add(geomType, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0); 918 1373 // OK - CANCEL buttons 919 - wxBoxSizer *okCancelBox = new wxBoxSizer (wxHORIZONTAL); 920 - boxSizer->Add (okCancelBox, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 921 - wxButton *ok = new wxButton (this, wxID_OK, wxT ("&OK")); 922 - okCancelBox->Add (ok, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 923 - wxButton *cancel = new wxButton (this, wxID_CANCEL, wxT ("&Cancel")); 924 - okCancelBox->Add (cancel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1374 + wxBoxSizer *okCancelBox = new wxBoxSizer(wxHORIZONTAL); 1375 + boxSizer->Add(okCancelBox, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 1376 + wxButton *ok = new wxButton(this, wxID_OK, wxT("&OK")); 1377 + okCancelBox->Add(ok, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1378 + wxButton *cancel = new wxButton(this, wxID_CANCEL, wxT("&Cancel")); 1379 + okCancelBox->Add(cancel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 925 1380 // appends event handler for OK button 926 - Connect (wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, 927 - (wxObjectEventFunction) & LoadShpDialog::OnOk); 1381 + Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, 1382 + (wxObjectEventFunction) & RecoverDialog::OnOk); 928 1383 } 929 1384 930 -void 931 -LoadShpDialog::OnOk (wxCommandEvent & event) 1385 +void RecoverDialog::OnOk(wxCommandEvent & event) 932 1386 { 933 1387 // 934 1388 // all done: 935 1389 // 936 - wxTextCtrl *tableCtrl = (wxTextCtrl *) FindWindow (ID_LDSHP_TABLE); 937 - Table = tableCtrl->GetValue (); 938 - if (Table.Len () < 1) 939 - { 940 - wxMessageBox (wxT ("You must specify the TABLE NAME !!!"), 941 - wxT ("spatialite-gui"), wxOK | wxICON_WARNING, this); 942 - return; 943 - } 944 - if (MainFrame->TableAlreadyExists (Table) == true) 945 - { 946 - wxMessageBox (wxT ("a table name '") + Table + 947 - wxT ("' already exists"), wxT ("spatialite-gui"), 948 - wxOK | wxICON_WARNING, this); 949 - return; 950 - } 951 - if (gaiaIllegalSqlName (Table.ToUTF8 ()) == 1 952 - || gaiaIsReservedSqlName (Table.ToUTF8 ()) == 1 953 - || gaiaIsReservedSqliteName (Table.ToUTF8 ()) == 1) 954 - { 955 - wxMessageBox (wxT ("'") + Table + 956 - wxT 957 - ("' is an invalid TABLE NAME\n\nillegal name or reserved keyword"), 958 - wxT ("spatialite-gui"), wxOK | wxICON_WARNING, this); 959 - return; 960 - } 961 - wxTextCtrl *columnCtrl = (wxTextCtrl *) FindWindow (ID_LDSHP_COLUMN); 962 - Column = columnCtrl->GetValue (); 963 - if (Column.Len () < 1) 964 - { 965 - wxMessageBox (wxT ("You must specify the GEOMETRY COLUMN NAME !!!"), 966 - wxT ("spatialite-gui"), wxOK | wxICON_WARNING, this); 967 - return; 968 - } 969 - if (gaiaIllegalSqlName (Column.ToUTF8 ()) == 1 970 - || gaiaIsReservedSqlName (Column.ToUTF8 ()) == 1 971 - || gaiaIsReservedSqliteName (Column.ToUTF8 ()) == 1) 972 - { 973 - wxMessageBox (wxT ("'") + Column + 974 - wxT 975 - ("' is an invalid COLUMN NAME\n\nsame as SQL reserved keyword"), 976 - wxT ("spatialite-gui"), wxOK | wxICON_WARNING, this); 977 - return; 978 - } 979 - wxSpinCtrl *sridCtrl = (wxSpinCtrl *) FindWindow (ID_LDSHP_SRID); 980 - Srid = sridCtrl->GetValue (); 981 - if (MainFrame->SridNotExists (Srid) == true) 982 - { 983 - wxMessageBox (wxT ("invalid SRID value"), 984 - wxT ("spatialite-gui"), wxOK | wxICON_WARNING, this); 985 - return; 986 - } 987 - wxListBox *charsetCtrl = (wxListBox *) FindWindow (ID_LDSHP_CHARSET); 988 - int idSel = charsetCtrl->GetSelection (); 989 - if (idSel == wxNOT_FOUND) 990 - { 991 - wxMessageBox (wxT 992 - ("you must select some Charset Encoding from the list"), 993 - wxT ("spatialite-gui"), wxOK | wxICON_WARNING, this); 994 - return; 995 - } 996 - wxString *charsets = MainFrame->GetCharsets (); 997 - Charset = *(charsets + idSel); 998 - wxDialog::EndModal (wxID_OK); 999 -} 1000 - 1001 -bool 1002 -DumpShpDialog::Create (MyFrame * parent, wxString & path, wxString & table, 1003 - wxString & column, wxString & defCs) 1390 + wxSpinCtrl *sridCtrl = (wxSpinCtrl *) FindWindow(ID_RCVR_SRID); 1391 + wxListBox *geomType = (wxListBox *) FindWindow(ID_RCVR_TYPE); 1392 + Srid = sridCtrl->GetValue(); 1393 + if (MainFrame->SridNotExists(Srid) == true) 1394 + { 1395 + wxMessageBox(wxT("invalid SRID value"), wxT("spatialite-gui"), 1396 + wxOK | wxICON_WARNING, this); 1397 + return; 1398 + } 1399 + Type = geomType->GetStringSelection(); 1400 + if (Type.Len() < 1) 1401 + { 1402 + wxMessageBox(wxT("you must select some Geometry Type from the list"), 1403 + wxT("spatialite-gui"), wxOK | wxICON_WARNING, this); 1404 + return; 1405 + } 1406 + wxDialog::EndModal(wxID_OK); 1407 +} 1408 + 1409 +bool SetSridDialog::Create(MyFrame * parent, wxString & table, 1410 + wxString & column) 1004 1411 { 1005 1412 // 1006 1413 // creating the dialog 1007 1414 // 1008 - MainFrame = parent; 1009 - Path = path; 1010 - Table = table; 1011 - Column = column; 1012 - Default = defCs; 1013 - if (wxDialog::Create (parent, wxID_ANY, wxT ("Dump Shapefile")) == false) 1014 - return false; 1415 + MainFrame = parent; 1416 + Table = table; 1417 + Column = column; 1418 + OldSrid = -1; 1419 + Srid = -1; 1420 + if (wxDialog::Create(parent, wxID_ANY, wxT("Changing SRID")) == false) 1421 + return false; 1015 1422 // populates individual controls 1016 - CreateControls (); 1423 + CreateControls(); 1017 1424 // sets dialog sizer 1018 - GetSizer ()->Fit (this); 1019 - GetSizer ()->SetSizeHints (this); 1425 + GetSizer()->Fit(this); 1426 + GetSizer()->SetSizeHints(this); 1020 1427 // centers the dialog window 1021 - Centre (); 1022 - return true; 1428 + Centre(); 1429 + return true; 1023 1430 } 1024 1431 1025 -void 1026 -DumpShpDialog::CreateControls () 1432 +void SetSridDialog::CreateControls() 1027 1433 { 1028 1434 // 1029 1435 // creating individual control and setting initial values 1030 1436 // 1031 - wxBoxSizer *topSizer = new wxBoxSizer (wxVERTICAL); 1032 - this->SetSizer (topSizer); 1033 - wxBoxSizer *boxSizer = new wxBoxSizer (wxVERTICAL); 1034 - topSizer->Add (boxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 1035 -// first row: the Shapefile path 1036 - wxBoxSizer *pathSizer = new wxBoxSizer (wxHORIZONTAL); 1037 - boxSizer->Add (pathSizer, 0, wxALIGN_RIGHT | wxALL, 0); 1038 - wxStaticText *pathLabel = 1039 - new wxStaticText (this, wxID_STATIC, wxT ("&Path:")); 1040 - pathSizer->Add (pathLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1041 - wxTextCtrl *pathValue = new wxTextCtrl (this, wxID_STATIC, 1042 - Path, wxDefaultPosition, 1043 - wxSize (350, 22), wxTE_READONLY); 1044 - pathSizer->Add (pathValue, 0, wxALIGN_RIGHT | wxALL, 5); 1045 -// second row: TABLE name 1046 - wxBoxSizer *tableSizer = new wxBoxSizer (wxHORIZONTAL); 1047 - boxSizer->Add (tableSizer, 0, wxALIGN_RIGHT | wxALL, 0); 1048 - wxStaticText *tableLabel = 1049 - new wxStaticText (this, wxID_STATIC, wxT ("&Table name:")); 1050 - tableSizer->Add (tableLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1051 - wxTextCtrl *tableCtrl = new wxTextCtrl (this, wxID_STATIC, Table, 1052 - wxDefaultPosition, wxSize (350, 1053 - 22)); 1054 - tableCtrl->Enable (false); 1055 - tableSizer->Add (tableCtrl, 0, wxALIGN_RIGHT | wxALL, 5); 1056 -// third row: GEOMETRY COLUMN name 1057 - wxBoxSizer *colSizer = new wxBoxSizer (wxHORIZONTAL); 1058 - boxSizer->Add (colSizer, 0, wxALIGN_RIGHT | wxALL, 0); 1059 - wxStaticText *colLabel = 1060 - new wxStaticText (this, wxID_STATIC, wxT ("&GeomColumn name:")); 1061 - colSizer->Add (colLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1062 - wxTextCtrl *colCtrl = new wxTextCtrl (this, wxID_STATIC, Column, 1063 - wxDefaultPosition, wxSize (350, 22)); 1064 - colCtrl->Enable (false); 1065 - colSizer->Add (colCtrl, 0, wxALIGN_RIGHT | wxALL, 5); 1066 -// fourth row: CHARSET 1067 - wxBoxSizer *csSizer = new wxBoxSizer (wxHORIZONTAL); 1068 - boxSizer->Add (csSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 1069 - wxStaticBox *charsetBox = new wxStaticBox (this, wxID_STATIC, 1070 - wxT ("Charset Encoding"), 1071 - wxDefaultPosition, 1072 - wxDefaultSize); 1073 - wxBoxSizer *charsetSizer = new wxStaticBoxSizer (charsetBox, wxHORIZONTAL); 1074 - csSizer->Add (charsetSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 1075 - wxListBox *charsetCtrl = new wxListBox (this, ID_DMPSHP_CHARSET, 1076 - wxDefaultPosition, wxDefaultSize, 1077 - MainFrame->GetCharsetsLen (), 1078 - MainFrame->GetCharsetsNames (), 1079 - wxLB_SINGLE); 1080 - charsetCtrl->SetFont (wxFont 1081 - (8, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, 1082 - wxFONTWEIGHT_NORMAL)); 1083 - int idSel = MainFrame->GetCharsetIndex (Default); 1084 - if (idSel != wxNOT_FOUND) 1085 - charsetCtrl->SetSelection (idSel); 1086 - charsetSizer->Add (charsetCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0); 1437 + wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL); 1438 + this->SetSizer(topSizer); 1439 + wxBoxSizer *boxSizer = new wxBoxSizer(wxVERTICAL); 1440 + topSizer->Add(boxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 1441 +// First row: TABLE name 1442 + wxBoxSizer *tableSizer = new wxBoxSizer(wxHORIZONTAL); 1443 + boxSizer->Add(tableSizer, 0, wxALIGN_RIGHT | wxALL, 0); 1444 + wxStaticText *tableLabel = 1445 + new wxStaticText(this, wxID_STATIC, wxT("&Table name:")); 1446 + tableSizer->Add(tableLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1447 + wxTextCtrl *tableCtrl = new wxTextCtrl(this, wxID_ANY, Table, 1448 + wxDefaultPosition, wxSize(350, 22), 1449 + wxTE_READONLY); 1450 + tableCtrl->Enable(false); 1451 + tableSizer->Add(tableCtrl, 0, wxALIGN_RIGHT | wxALL, 5); 1452 +// second row: GEOMETRY COLUMN name 1453 + wxBoxSizer *colSizer = new wxBoxSizer(wxHORIZONTAL); 1454 + boxSizer->Add(colSizer, 0, wxALIGN_RIGHT | wxALL, 0); 1455 + wxStaticText *colLabel = 1456 + new wxStaticText(this, wxID_STATIC, wxT("&Column name:")); 1457 + colSizer->Add(colLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1458 + wxTextCtrl *colCtrl = new wxTextCtrl(this, wxID_ANY, Column, 1459 + wxDefaultPosition, wxSize(350, 22), 1460 + wxTE_READONLY); 1461 + colCtrl->Enable(false); 1462 + colSizer->Add(colCtrl, 0, wxALIGN_RIGHT | wxALL, 5); 1463 +// third row: SRID 1464 + wxBoxSizer *mySizer = new wxBoxSizer(wxHORIZONTAL); 1465 + boxSizer->Add(mySizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 1466 + wxBoxSizer *oldSridSizer = new wxBoxSizer(wxHORIZONTAL); 1467 + mySizer->Add(oldSridSizer, 0, wxALIGN_LEFT | wxALL, 0); 1468 + wxStaticText *oldSridLabel = 1469 + new wxStaticText(this, wxID_STATIC, wxT("&old SRID:")); 1470 + oldSridSizer->Add(oldSridLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1471 + wxSpinCtrl *oldSridCtrl = new wxSpinCtrl(this, ID_SRID_OLD, wxEmptyString, 1472 + wxDefaultPosition, wxSize(80, 1473 + 20), 1474 + wxSP_ARROW_KEYS, 1475 + -1, 40000, OldSrid); 1476 + oldSridSizer->Add(oldSridCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1477 +// fourth row: SRID 1478 + wxBoxSizer *sridSizer = new wxBoxSizer(wxHORIZONTAL); 1479 + mySizer->Add(sridSizer, 0, wxALIGN_RIGHT | wxLEFT, 20); 1480 + wxStaticText *sridLabel = 1481 + new wxStaticText(this, wxID_STATIC, wxT("&new SRID:")); 1482 + sridSizer->Add(sridLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1483 + wxSpinCtrl *sridCtrl = new wxSpinCtrl(this, ID_SRID_SRID, wxEmptyString, 1484 + wxDefaultPosition, wxSize(80, 20), 1485 + wxSP_ARROW_KEYS, 1486 + -1, 40000, Srid); 1487 + sridSizer->Add(sridCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1087 1488 // OK - CANCEL buttons 1088 - wxBoxSizer *okCancelBox = new wxBoxSizer (wxHORIZONTAL); 1089 - boxSizer->Add (okCancelBox, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 1090 - wxButton *ok = new wxButton (this, wxID_OK, wxT ("&OK")); 1091 - okCancelBox->Add (ok, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1092 - wxButton *cancel = new wxButton (this, wxID_CANCEL, wxT ("&Cancel")); 1093 - okCancelBox->Add (cancel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1489 + wxBoxSizer *okCancelBox = new wxBoxSizer(wxHORIZONTAL); 1490 + boxSizer->Add(okCancelBox, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 1491 + wxButton *ok = new wxButton(this, wxID_OK, wxT("&OK")); 1492 + okCancelBox->Add(ok, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1493 + wxButton *cancel = new wxButton(this, wxID_CANCEL, wxT("&Cancel")); 1494 + okCancelBox->Add(cancel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1094 1495 // appends event handler for OK button 1095 - Connect (wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, 1096 - (wxObjectEventFunction) & DumpShpDialog::OnOk); 1496 + Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, 1497 + (wxObjectEventFunction) & SetSridDialog::OnOk); 1097 1498 } 1098 1499 1099 -void 1100 -DumpShpDialog::OnOk (wxCommandEvent & event) 1500 +void SetSridDialog::OnOk(wxCommandEvent & event) 1101 1501 { 1102 1502 // 1103 1503 // all done: 1104 1504 // 1105 - wxListBox *charsetCtrl = (wxListBox *) FindWindow (ID_DMPSHP_CHARSET); 1106 - int idSel = charsetCtrl->GetSelection (); 1107 - if (idSel == wxNOT_FOUND) 1108 - { 1109 - wxMessageBox (wxT 1110 - ("you must select some Charset Encoding from the list"), 1111 - wxT ("spatialite-gui"), wxOK | wxICON_WARNING, this); 1112 - return; 1113 - } 1114 - wxString *charsets = MainFrame->GetCharsets (); 1115 - Charset = *(charsets + idSel); 1116 - wxDialog::EndModal (wxID_OK); 1505 + wxSpinCtrl *oldSridCtrl = (wxSpinCtrl *) FindWindow(ID_SRID_OLD); 1506 + wxSpinCtrl *sridCtrl = (wxSpinCtrl *) FindWindow(ID_SRID_SRID); 1507 + OldSrid = oldSridCtrl->GetValue(); 1508 + Srid = sridCtrl->GetValue(); 1509 + wxDialog::EndModal(wxID_OK); 1117 1510 } 1118 1511 1119 -bool 1120 -DumpTxtDialog::Create (MyFrame * parent, wxString & path, 1121 - wxString & target, wxString & defCs) 1512 +bool SearchSridDialog::Create(MyFrame * parent) 1122 1513 { 1123 1514 // 1124 1515 // creating the dialog 1125 1516 // 1126 - MainFrame = parent; 1127 - Path = path; 1128 - Default = defCs; 1129 - if (wxDialog::Create (parent, wxID_ANY, wxT ("Dump ") + target) == false) 1130 - return false; 1517 + MainFrame = parent; 1518 + if (wxDialog::Create(parent, wxID_ANY, wxT("Searching a SRID by its name")) == 1519 + false) 1520 + return false; 1131 1521 // populates individual controls 1132 - CreateControls (); 1522 + CreateControls(); 1133 1523 // sets dialog sizer 1134 - GetSizer ()->Fit (this); 1135 - GetSizer ()->SetSizeHints (this); 1524 + GetSizer()->Fit(this); 1525 + GetSizer()->SetSizeHints(this); 1136 1526 // centers the dialog window 1137 - Centre (); 1138 - return true; 1139 -} 1140 - 1141 -void 1142 -DumpTxtDialog::CreateControls () 1143 -{ 1144 -// 1145 -// creating individual control and setting initial values 1146 -// 1147 - wxBoxSizer *topSizer = new wxBoxSizer (wxVERTICAL); 1148 - this->SetSizer (topSizer); 1149 - wxBoxSizer *boxSizer = new wxBoxSizer (wxVERTICAL); 1150 - topSizer->Add (boxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 1151 -// first row: the Shapefile path 1152 - wxBoxSizer *pathSizer = new wxBoxSizer (wxHORIZONTAL); 1153 - boxSizer->Add (pathSizer, 0, wxALIGN_RIGHT | wxALL, 0); 1154 - wxStaticText *pathLabel = 1155 - new wxStaticText (this, wxID_STATIC, wxT ("&Path:")); 1156 - pathSizer->Add (pathLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1157 - wxTextCtrl *pathValue = new wxTextCtrl (this, wxID_STATIC, 1158 - Path, wxDefaultPosition, 1159 - wxSize (350, 22), wxTE_READONLY); 1160 - pathSizer->Add (pathValue, 0, wxALIGN_RIGHT | wxALL, 5); 1161 -// second row: CHARSET 1162 - wxBoxSizer *csSizer = new wxBoxSizer (wxHORIZONTAL); 1163 - boxSizer->Add (csSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 1164 - wxStaticBox *charsetBox = new wxStaticBox (this, wxID_STATIC, 1165 - wxT ("Charset Encoding"), 1166 - wxDefaultPosition, 1167 - wxDefaultSize); 1168 - wxBoxSizer *charsetSizer = new wxStaticBoxSizer (charsetBox, wxHORIZONTAL); 1169 - csSizer->Add (charsetSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 1170 - wxListBox *charsetCtrl = new wxListBox (this, ID_DMPTXT_CHARSET, 1171 - wxDefaultPosition, wxDefaultSize, 1172 - MainFrame->GetCharsetsLen (), 1173 - MainFrame->GetCharsetsNames (), 1174 - wxLB_SINGLE); 1175 - charsetCtrl->SetFont (wxFont 1176 - (8, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, 1177 - wxFONTWEIGHT_NORMAL)); 1178 - int idSel = MainFrame->GetCharsetIndex (Default); 1179 - if (idSel != wxNOT_FOUND) 1180 - charsetCtrl->SetSelection (idSel); 1181 - charsetSizer->Add (charsetCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0); 1182 -// OK - CANCEL buttons 1183 - wxBoxSizer *okCancelBox = new wxBoxSizer (wxHORIZONTAL); 1184 - boxSizer->Add (okCancelBox, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 1185 - wxButton *ok = new wxButton (this, wxID_OK, wxT ("&OK")); 1186 - okCancelBox->Add (ok, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1187 - wxButton *cancel = new wxButton (this, wxID_CANCEL, wxT ("&Cancel")); 1188 - okCancelBox->Add (cancel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1189 -// appends event handler for OK button 1190 - Connect (wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, 1191 - (wxObjectEventFunction) & DumpTxtDialog::OnOk); 1192 -} 1193 - 1194 -void 1195 -DumpTxtDialog::OnOk (wxCommandEvent & event) 1196 -{ 1197 -// 1198 -// all done: 1199 -// 1200 - wxListBox *charsetCtrl = (wxListBox *) FindWindow (ID_DMPTXT_CHARSET); 1201 - int idSel = charsetCtrl->GetSelection (); 1202 - if (idSel == wxNOT_FOUND) 1203 - { 1204 - wxMessageBox (wxT 1205 - ("you must select some Charset Encoding from the list"), 1206 - wxT ("spatialite-gui"), wxOK | wxICON_WARNING, this); 1207 - return; 1208 - } 1209 - wxString *charsets = MainFrame->GetCharsets (); 1210 - Charset = *(charsets + idSel); 1211 - wxDialog::EndModal (wxID_OK); 1212 -} 1213 - 1214 -bool 1215 -SqlScriptDialog::Create (MyFrame * parent, wxString & path, wxString & defCs) 1216 -{ 1217 -// 1218 -// creating the dialog 1219 -// 1220 - MainFrame = parent; 1221 - Path = path; 1222 - Default = defCs; 1223 - if (wxDialog::Create (parent, wxID_ANY, wxT ("SQL script execute")) == 1224 - false) 1225 - return false; 1226 -// populates individual controls 1227 - CreateControls (); 1228 -// sets dialog sizer 1229 - GetSizer ()->Fit (this); 1230 - GetSizer ()->SetSizeHints (this); 1231 -// centers the dialog window 1232 - Centre (); 1233 - return true; 1234 -} 1235 - 1236 -void 1237 -SqlScriptDialog::CreateControls () 1527 + Centre(); 1528 + return true; 1529 +} 1530 + 1531 +void SearchSridDialog::CreateControls() 1238 1532 { 1239 1533 // 1240 1534 // creating individual control and setting initial values 1241 1535 // 1242 - wxBoxSizer *topSizer = new wxBoxSizer (wxVERTICAL); 1243 - this->SetSizer (topSizer); 1244 - wxBoxSizer *boxSizer = new wxBoxSizer (wxVERTICAL); 1245 - topSizer->Add (boxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 1246 -// first row: the SQL script path 1247 - wxBoxSizer *pathSizer = new wxBoxSizer (wxHORIZONTAL); 1248 - boxSizer->Add (pathSizer, 0, wxALIGN_RIGHT | wxALL, 0); 1249 - wxStaticText *pathLabel = 1250 - new wxStaticText (this, wxID_STATIC, wxT ("&Path:")); 1251 - pathSizer->Add (pathLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1252 - wxTextCtrl *pathValue = new wxTextCtrl (this, wxID_STATIC, 1253 - Path, wxDefaultPosition, 1254 - wxSize (350, 22), wxTE_READONLY); 1255 - pathSizer->Add (pathValue, 0, wxALIGN_RIGHT | wxALL, 5); 1256 -// second row: CHARSET 1257 - wxBoxSizer *csSizer = new wxBoxSizer (wxHORIZONTAL); 1258 - boxSizer->Add (csSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 1259 - wxStaticBox *charsetBox = new wxStaticBox (this, wxID_STATIC, 1260 - wxT ("Charset Encoding"), 1261 - wxDefaultPosition, 1262 - wxDefaultSize); 1263 - wxBoxSizer *charsetSizer = new wxStaticBoxSizer (charsetBox, wxHORIZONTAL); 1264 - csSizer->Add (charsetSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 1265 - wxListBox *charsetCtrl = new wxListBox (this, ID_SCRIPT_CHARSET, 1266 - wxDefaultPosition, wxDefaultSize, 1267 - MainFrame->GetCharsetsLen (), 1268 - MainFrame->GetCharsetsNames (), 1269 - wxLB_SINGLE); 1270 - charsetCtrl->SetFont (wxFont 1271 - (8, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, 1272 - wxFONTWEIGHT_NORMAL)); 1273 - int idSel = MainFrame->GetCharsetIndex (Default); 1274 - if (idSel != wxNOT_FOUND) 1275 - charsetCtrl->SetSelection (idSel); 1276 - charsetSizer->Add (charsetCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0); 1536 + wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL); 1537 + this->SetSizer(topSizer); 1538 + wxBoxSizer *boxSizer = new wxBoxSizer(wxVERTICAL); 1539 + topSizer->Add(boxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 1540 +// First row: SEARCH string 1541 + wxBoxSizer *searchSizer = new wxBoxSizer(wxHORIZONTAL); 1542 + boxSizer->Add(searchSizer, 0, wxALIGN_RIGHT | wxALL, 0); 1543 + wxStaticText *searchLabel = 1544 + new wxStaticText(this, wxID_STATIC, wxT("&Search:")); 1545 + searchSizer->Add(searchLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1546 + wxTextCtrl *searchCtrl = new wxTextCtrl(this, ID_SEARCH, wxT(""), 1547 + wxDefaultPosition, wxSize(150, 1548 + 22)); 1549 + searchSizer->Add(searchCtrl, 0, wxALIGN_RIGHT | wxALL, 5); 1277 1550 // OK - CANCEL buttons 1278 - wxBoxSizer *okCancelBox = new wxBoxSizer (wxHORIZONTAL); 1279 - boxSizer->Add (okCancelBox, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 1280 - wxButton *ok = new wxButton (this, wxID_OK, wxT ("&OK")); 1281 - okCancelBox->Add (ok, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1282 - wxButton *cancel = new wxButton (this, wxID_CANCEL, wxT ("&Cancel")); 1283 - okCancelBox->Add (cancel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1551 + wxBoxSizer *okCancelBox = new wxBoxSizer(wxHORIZONTAL); 1552 + boxSizer->Add(okCancelBox, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 1553 + wxButton *ok = new wxButton(this, wxID_OK, wxT("&OK")); 1554 + okCancelBox->Add(ok, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1555 + wxButton *cancel = new wxButton(this, wxID_CANCEL, wxT("&Cancel")); 1556 + okCancelBox->Add(cancel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1284 1557 // appends event handler for OK button 1285 - Connect (wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, 1286 - (wxObjectEventFunction) & SqlScriptDialog::OnOk); 1558 + Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, 1559 + (wxObjectEventFunction) & SearchSridDialog::OnOk); 1287 1560 } 1288 1561 1289 -void 1290 -SqlScriptDialog::OnOk (wxCommandEvent & event) 1562 +void SearchSridDialog::OnOk(wxCommandEvent & event) 1291 1563 { 1292 1564 // 1293 1565 // all done: 1294 1566 // 1295 - wxListBox *charsetCtrl = (wxListBox *) FindWindow (ID_SCRIPT_CHARSET); 1296 - int idSel = charsetCtrl->GetSelection (); 1297 - if (idSel == wxNOT_FOUND) 1298 - { 1299 - wxMessageBox (wxT 1300 - ("you must select some Charset Encoding from the list"), 1301 - wxT ("spatialite-gui"), wxOK | wxICON_WARNING, this); 1302 - return; 1303 - } 1304 - wxString *charsets = MainFrame->GetCharsets (); 1305 - Charset = *(charsets + idSel); 1306 - wxDialog::EndModal (wxID_OK); 1567 + wxTextCtrl *searchCtrl = (wxTextCtrl *) FindWindow(ID_SEARCH); 1568 + String = searchCtrl->GetValue(); 1569 + if (String.Len() < 1) 1570 + { 1571 + wxMessageBox(wxT("You must specify a string to search for !!!"), 1572 + wxT("spatialite-gui"), wxOK | wxICON_WARNING, this); 1573 + return; 1574 + } 1575 + wxDialog::EndModal(wxID_OK); 1307 1576 } 1308 1577 1309 -bool 1310 -DefaultCharsetDialog::Create (MyFrame * parent, wxString & charset, bool ask) 1578 +bool HelpDialog::Create(MyFrame * parent) 1311 1579 { 1312 1580 // 1313 1581 // creating the dialog 1314 1582 // 1315 - MainFrame = parent; 1316 - Charset = charset; 1317 - AskCharset = ask; 1318 - if (wxDialog::Create (parent, wxID_ANY, wxT ("Charset settings")) == false) 1319 - return false; 1583 + MainFrame = parent; 1584 + if (wxDialog::Create(parent, wxID_ANY, wxT("SQLite + SpatiaLite help"), 1585 + wxDefaultPosition, wxDefaultSize, 1586 + wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) == false) 1587 + return false; 1320 1588 // populates individual controls 1321 - CreateControls (); 1589 + CreateControls(); 1322 1590 // sets dialog sizer 1323 - GetSizer ()->Fit (this); 1324 - GetSizer ()->SetSizeHints (this); 1591 + GetSizer()->Fit(this); 1592 + GetSizer()->SetSizeHints(this); 1325 1593 // centers the dialog window 1326 - Centre (); 1327 - return true; 1328 -} 1329 - 1330 -void 1331 -DefaultCharsetDialog::CreateControls () 1332 -{ 1333 -// 1334 -// creating individual control and setting initial values 1335 -// 1336 - wxBoxSizer *topSizer = new wxBoxSizer (wxVERTICAL); 1337 - this->SetSizer (topSizer); 1338 - wxBoxSizer *boxSizer = new wxBoxSizer (wxVERTICAL); 1339 - topSizer->Add (boxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 1340 -// first row: the DEFAULT CHARSET 1341 - wxBoxSizer *csSizer = new wxBoxSizer (wxHORIZONTAL); 1342 - boxSizer->Add (csSizer, 0, wxALIGN_RIGHT | wxALL, 0); 1343 - wxStaticBox *charsetBox = new wxStaticBox (this, wxID_STATIC, 1344 - wxT ("Default Output Charset"), 1345 - wxDefaultPosition, 1346 - wxDefaultSize); 1347 - wxBoxSizer *charsetSizer = new wxStaticBoxSizer (charsetBox, wxVERTICAL); 1348 - csSizer->Add (charsetSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 1349 - wxListBox *charsetCtrl = new wxListBox (this, ID_DFLT_CHARSET, 1350 - wxDefaultPosition, wxDefaultSize, 1351 - MainFrame->GetCharsetsLen (), 1352 - MainFrame->GetCharsetsNames (), 1353 - wxLB_SINGLE); 1354 - charsetCtrl->SetFont (wxFont 1355 - (8, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, 1356 - wxFONTWEIGHT_NORMAL)); 1357 - int idSel = MainFrame->GetCharsetIndex (Charset); 1358 - if (idSel != wxNOT_FOUND) 1359 - charsetCtrl->SetSelection (idSel); 1360 - charsetSizer->Add (charsetCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0); 1361 -// second row: the ASK CHARSET 1362 - wxBoxSizer *askSizer = new wxBoxSizer (wxHORIZONTAL); 1363 - charsetSizer->Add (askSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 1364 - wxCheckBox *askCtrl = new wxCheckBox (this, ID_DFLT_ASK, 1365 - wxT ("Ask output charset every time"), 1366 - wxDefaultPosition, wxDefaultSize); 1367 - askCtrl->SetValue (AskCharset); 1368 - askSizer->Add (askCtrl, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 1369 -// OK - CANCEL buttons 1370 - wxBoxSizer *okCancelBox = new wxBoxSizer (wxHORIZONTAL); 1371 - boxSizer->Add (okCancelBox, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 1372 - wxButton *ok = new wxButton (this, wxID_OK, wxT ("&OK")); 1373 - okCancelBox->Add (ok, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1374 - wxButton *cancel = new wxButton (this, wxID_CANCEL, wxT ("&Cancel")); 1375 - okCancelBox->Add (cancel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1376 -// appends event handler for OK button 1377 - Connect (wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, 1378 - (wxObjectEventFunction) & DefaultCharsetDialog::OnOk); 1379 -} 1380 - 1381 -void 1382 -DefaultCharsetDialog::OnOk (wxCommandEvent & event) 1383 -{ 1384 -// 1385 -// all done: 1386 -// 1387 - wxListBox *charsetCtrl = (wxListBox *) FindWindow (ID_DFLT_CHARSET); 1388 - int idSel = charsetCtrl->GetSelection (); 1389 - if (idSel == wxNOT_FOUND) 1390 - { 1391 - wxMessageBox (wxT 1392 - ("you must select some Default Charset Encoding from the list"), 1393 - wxT ("spatialite-gui"), wxOK | wxICON_WARNING, this); 1394 - return; 1395 - } 1396 - wxString *charsets = MainFrame->GetCharsets (); 1397 - Charset = *(charsets + idSel); 1398 - wxCheckBox *askCtrl = (wxCheckBox *) FindWindow (ID_DFLT_ASK); 1399 - AskCharset = askCtrl->GetValue (); 1400 - wxDialog::EndModal (wxID_OK); 1401 -} 1402 - 1403 -bool 1404 -RecoverDialog::Create (MyFrame * parent, wxString & table, wxString & column) 1405 -{ 1406 -// 1407 -// creating the dialog 1408 -// 1409 - MainFrame = parent; 1410 - Table = table; 1411 - Column = column; 1412 - Srid = -1; 1413 - if (wxDialog::Create (parent, wxID_ANY, wxT ("Recover Geometry Column")) == 1414 - false) 1415 - return false; 1416 -// populates individual controls 1417 - CreateControls (); 1418 -// sets dialog sizer 1419 - GetSizer ()->Fit (this); 1420 - GetSizer ()->SetSizeHints (this); 1421 -// centers the dialog window 1422 - Centre (); 1423 - return true; 1424 -} 1425 - 1426 -void 1427 -RecoverDialog::CreateControls () 1428 -{ 1429 -// 1430 -// creating individual control and setting initial values 1431 -// 1432 - wxBoxSizer *topSizer = new wxBoxSizer (wxVERTICAL); 1433 - this->SetSizer (topSizer); 1434 - wxBoxSizer *boxSizer = new wxBoxSizer (wxVERTICAL); 1435 - topSizer->Add (boxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 1436 -// First row: TABLE name 1437 - wxBoxSizer *tableSizer = new wxBoxSizer (wxHORIZONTAL); 1438 - boxSizer->Add (tableSizer, 0, wxALIGN_RIGHT | wxALL, 0); 1439 - wxStaticText *tableLabel = 1440 - new wxStaticText (this, wxID_STATIC, wxT ("&Table name:")); 1441 - tableSizer->Add (tableLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1442 - wxTextCtrl *tableCtrl = new wxTextCtrl (this, wxID_ANY, Table, 1443 - wxDefaultPosition, wxSize (350, 22), 1444 - wxTE_READONLY); 1445 - tableCtrl->Enable (false); 1446 - tableSizer->Add (tableCtrl, 0, wxALIGN_RIGHT | wxALL, 5); 1447 -// second row: GEOMETRY COLUMN name 1448 - wxBoxSizer *colSizer = new wxBoxSizer (wxHORIZONTAL); 1449 - boxSizer->Add (colSizer, 0, wxALIGN_RIGHT | wxALL, 0); 1450 - wxStaticText *colLabel = 1451 - new wxStaticText (this, wxID_STATIC, wxT ("&Column name:")); 1452 - colSizer->Add (colLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1453 - wxTextCtrl *colCtrl = new wxTextCtrl (this, wxID_ANY, Column, 1454 - wxDefaultPosition, wxSize (350, 22), 1455 - wxTE_READONLY); 1456 - colCtrl->Enable (false); 1457 - colSizer->Add (colCtrl, 0, wxALIGN_RIGHT | wxALL, 5); 1458 -// third row: SRID 1459 - wxBoxSizer *sridSizer = new wxBoxSizer (wxHORIZONTAL); 1460 - boxSizer->Add (sridSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 1461 - wxStaticText *sridLabel = 1462 - new wxStaticText (this, wxID_STATIC, wxT ("&SRID:")); 1463 - sridSizer->Add (sridLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1464 - wxSpinCtrl *sridCtrl = new wxSpinCtrl (this, ID_RCVR_SRID, wxEmptyString, 1465 - wxDefaultPosition, wxSize (80, 20), 1466 - wxSP_ARROW_KEYS, 1467 - -1, 40000, Srid); 1468 - sridSizer->Add (sridCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1469 -// fourth row: GEOMETRY TYPE 1470 - wxStaticBox *typeBox = new wxStaticBox (this, wxID_STATIC, 1471 - wxT ("Geometry Type"), 1472 - wxDefaultPosition, wxDefaultSize); 1473 - wxBoxSizer *typeSizer = new wxStaticBoxSizer (typeBox, wxHORIZONTAL); 1474 - sridSizer->Add (typeSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 1475 - wxString types[7]; 1476 - types[0] = wxT ("POINT"); 1477 - types[1] = wxT ("MULTIPOINT"); 1478 - types[2] = wxT ("LINESTRING"); 1479 - types[3] = wxT ("MULTILINESTRING"); 1480 - types[4] = wxT ("POLYGON"); 1481 - types[5] = wxT ("MULTIPOLYGON"); 1482 - types[6] = wxT ("GEOMETRYCOLLECTION"); 1483 - wxListBox *geomType = new wxListBox (this, ID_RCVR_TYPE, 1484 - wxDefaultPosition, wxDefaultSize, 7, 1485 - types, wxLB_SINGLE); 1486 - typeSizer->Add (geomType, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0); 1487 -// OK - CANCEL buttons 1488 - wxBoxSizer *okCancelBox = new wxBoxSizer (wxHORIZONTAL); 1489 - boxSizer->Add (okCancelBox, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 1490 - wxButton *ok = new wxButton (this, wxID_OK, wxT ("&OK")); 1491 - okCancelBox->Add (ok, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1492 - wxButton *cancel = new wxButton (this, wxID_CANCEL, wxT ("&Cancel")); 1493 - okCancelBox->Add (cancel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1494 -// appends event handler for OK button 1495 - Connect (wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, 1496 - (wxObjectEventFunction) & RecoverDialog::OnOk); 1497 -} 1498 - 1499 -void 1500 -RecoverDialog::OnOk (wxCommandEvent & event) 1501 -{ 1502 -// 1503 -// all done: 1504 -// 1505 - wxSpinCtrl *sridCtrl = (wxSpinCtrl *) FindWindow (ID_RCVR_SRID); 1506 - wxListBox *geomType = (wxListBox *) FindWindow (ID_RCVR_TYPE); 1507 - Srid = sridCtrl->GetValue (); 1508 - if (MainFrame->SridNotExists (Srid) == true) 1509 - { 1510 - wxMessageBox (wxT ("invalid SRID value"), 1511 - wxT ("spatialite-gui"), wxOK | wxICON_WARNING, this); 1512 - return; 1513 - } 1514 - Type = geomType->GetStringSelection (); 1515 - if (Type.Len () < 1) 1516 - { 1517 - wxMessageBox (wxT 1518 - ("you must select some Geometry Type from the list"), 1519 - wxT ("spatialite-gui"), wxOK | wxICON_WARNING, this); 1520 - return; 1521 - } 1522 - wxDialog::EndModal (wxID_OK); 1523 -} 1524 - 1525 -bool 1526 -SetSridDialog::Create (MyFrame * parent, wxString & table, wxString & column) 1527 -{ 1528 -// 1529 -// creating the dialog 1530 -// 1531 - MainFrame = parent; 1532 - Table = table; 1533 - Column = column; 1534 - OldSrid = -1; 1535 - Srid = -1; 1536 - if (wxDialog::Create (parent, wxID_ANY, wxT ("Changing SRID")) == false) 1537 - return false; 1538 -// populates individual controls 1539 - CreateControls (); 1540 -// sets dialog sizer 1541 - GetSizer ()->Fit (this); 1542 - GetSizer ()->SetSizeHints (this); 1543 -// centers the dialog window 1544 - Centre (); 1545 - return true; 1546 -} 1547 - 1548 -void 1549 -SetSridDialog::CreateControls () 1550 -{ 1551 -// 1552 -// creating individual control and setting initial values 1553 -// 1554 - wxBoxSizer *topSizer = new wxBoxSizer (wxVERTICAL); 1555 - this->SetSizer (topSizer); 1556 - wxBoxSizer *boxSizer = new wxBoxSizer (wxVERTICAL); 1557 - topSizer->Add (boxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 1558 -// First row: TABLE name 1559 - wxBoxSizer *tableSizer = new wxBoxSizer (wxHORIZONTAL); 1560 - boxSizer->Add (tableSizer, 0, wxALIGN_RIGHT | wxALL, 0); 1561 - wxStaticText *tableLabel = 1562 - new wxStaticText (this, wxID_STATIC, wxT ("&Table name:")); 1563 - tableSizer->Add (tableLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1564 - wxTextCtrl *tableCtrl = new wxTextCtrl (this, wxID_ANY, Table, 1565 - wxDefaultPosition, wxSize (350, 22), 1566 - wxTE_READONLY); 1567 - tableCtrl->Enable (false); 1568 - tableSizer->Add (tableCtrl, 0, wxALIGN_RIGHT | wxALL, 5); 1569 -// second row: GEOMETRY COLUMN name 1570 - wxBoxSizer *colSizer = new wxBoxSizer (wxHORIZONTAL); 1571 - boxSizer->Add (colSizer, 0, wxALIGN_RIGHT | wxALL, 0); 1572 - wxStaticText *colLabel = 1573 - new wxStaticText (this, wxID_STATIC, wxT ("&Column name:")); 1574 - colSizer->Add (colLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1575 - wxTextCtrl *colCtrl = new wxTextCtrl (this, wxID_ANY, Column, 1576 - wxDefaultPosition, wxSize (350, 22), 1577 - wxTE_READONLY); 1578 - colCtrl->Enable (false); 1579 - colSizer->Add (colCtrl, 0, wxALIGN_RIGHT | wxALL, 5); 1580 -// third row: SRID 1581 - wxBoxSizer *mySizer = new wxBoxSizer (wxHORIZONTAL); 1582 - boxSizer->Add (mySizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 1583 - wxBoxSizer *oldSridSizer = new wxBoxSizer (wxHORIZONTAL); 1584 - mySizer->Add (oldSridSizer, 0, wxALIGN_LEFT | wxALL, 0); 1585 - wxStaticText *oldSridLabel = 1586 - new wxStaticText (this, wxID_STATIC, wxT ("&old SRID:")); 1587 - oldSridSizer->Add (oldSridLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1588 - wxSpinCtrl *oldSridCtrl = new wxSpinCtrl (this, ID_SRID_OLD, wxEmptyString, 1589 - wxDefaultPosition, wxSize (80, 1590 - 20), 1591 - wxSP_ARROW_KEYS, 1592 - -1, 40000, OldSrid); 1593 - oldSridSizer->Add (oldSridCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1594 -// fourth row: SRID 1595 - wxBoxSizer *sridSizer = new wxBoxSizer (wxHORIZONTAL); 1596 - mySizer->Add (sridSizer, 0, wxALIGN_RIGHT | wxLEFT, 20); 1597 - wxStaticText *sridLabel = 1598 - new wxStaticText (this, wxID_STATIC, wxT ("&new SRID:")); 1599 - sridSizer->Add (sridLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1600 - wxSpinCtrl *sridCtrl = new wxSpinCtrl (this, ID_SRID_SRID, wxEmptyString, 1601 - wxDefaultPosition, wxSize (80, 20), 1602 - wxSP_ARROW_KEYS, 1603 - -1, 40000, Srid); 1604 - sridSizer->Add (sridCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1605 -// OK - CANCEL buttons 1606 - wxBoxSizer *okCancelBox = new wxBoxSizer (wxHORIZONTAL); 1607 - boxSizer->Add (okCancelBox, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 1608 - wxButton *ok = new wxButton (this, wxID_OK, wxT ("&OK")); 1609 - okCancelBox->Add (ok, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1610 - wxButton *cancel = new wxButton (this, wxID_CANCEL, wxT ("&Cancel")); 1611 - okCancelBox->Add (cancel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1612 -// appends event handler for OK button 1613 - Connect (wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, 1614 - (wxObjectEventFunction) & SetSridDialog::OnOk); 1615 -} 1616 - 1617 -void 1618 -SetSridDialog::OnOk (wxCommandEvent & event) 1619 -{ 1620 -// 1621 -// all done: 1622 -// 1623 - wxSpinCtrl *oldSridCtrl = (wxSpinCtrl *) FindWindow (ID_SRID_OLD); 1624 - wxSpinCtrl *sridCtrl = (wxSpinCtrl *) FindWindow (ID_SRID_SRID); 1625 - OldSrid = oldSridCtrl->GetValue (); 1626 - Srid = sridCtrl->GetValue (); 1627 - wxDialog::EndModal (wxID_OK); 1628 -} 1629 - 1630 -bool 1631 -SearchSridDialog::Create (MyFrame * parent) 1632 -{ 1633 -// 1634 -// creating the dialog 1635 -// 1636 - MainFrame = parent; 1637 - if (wxDialog::Create (parent, wxID_ANY, 1638 - wxT ("Searching a SRID by its name")) == false) 1639 - return false; 1640 -// populates individual controls 1641 - CreateControls (); 1642 -// sets dialog sizer 1643 - GetSizer ()->Fit (this); 1644 - GetSizer ()->SetSizeHints (this); 1645 -// centers the dialog window 1646 - Centre (); 1647 - return true; 1648 -} 1649 - 1650 -void 1651 -SearchSridDialog::CreateControls () 1652 -{ 1653 -// 1654 -// creating individual control and setting initial values 1655 -// 1656 - wxBoxSizer *topSizer = new wxBoxSizer (wxVERTICAL); 1657 - this->SetSizer (topSizer); 1658 - wxBoxSizer *boxSizer = new wxBoxSizer (wxVERTICAL); 1659 - topSizer->Add (boxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 1660 -// First row: SEARCH string 1661 - wxBoxSizer *searchSizer = new wxBoxSizer (wxHORIZONTAL); 1662 - boxSizer->Add (searchSizer, 0, wxALIGN_RIGHT | wxALL, 0); 1663 - wxStaticText *searchLabel = 1664 - new wxStaticText (this, wxID_STATIC, wxT ("&Search:")); 1665 - searchSizer->Add (searchLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1666 - wxTextCtrl *searchCtrl = new wxTextCtrl (this, ID_SEARCH, wxT (""), 1667 - wxDefaultPosition, wxSize (150, 1668 - 22)); 1669 - searchSizer->Add (searchCtrl, 0, wxALIGN_RIGHT | wxALL, 5); 1670 -// OK - CANCEL buttons 1671 - wxBoxSizer *okCancelBox = new wxBoxSizer (wxHORIZONTAL); 1672 - boxSizer->Add (okCancelBox, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 1673 - wxButton *ok = new wxButton (this, wxID_OK, wxT ("&OK")); 1674 - okCancelBox->Add (ok, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1675 - wxButton *cancel = new wxButton (this, wxID_CANCEL, wxT ("&Cancel")); 1676 - okCancelBox->Add (cancel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1677 -// appends event handler for OK button 1678 - Connect (wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, 1679 - (wxObjectEventFunction) & SearchSridDialog::OnOk); 1680 -} 1681 - 1682 -void 1683 -SearchSridDialog::OnOk (wxCommandEvent & event) 1684 -{ 1685 -// 1686 -// all done: 1687 -// 1688 - wxTextCtrl *searchCtrl = (wxTextCtrl *) FindWindow (ID_SEARCH); 1689 - String = searchCtrl->GetValue (); 1690 - if (String.Len () < 1) 1691 - { 1692 - wxMessageBox (wxT ("You must specify a string to search for !!!"), 1693 - wxT ("spatialite-gui"), wxOK | wxICON_WARNING, this); 1694 - return; 1695 - } 1696 - wxDialog::EndModal (wxID_OK); 1697 -} 1698 - 1699 -bool 1700 -HelpDialog::Create (MyFrame * parent) 1701 -{ 1702 -// 1703 -// creating the dialog 1704 -// 1705 - MainFrame = parent; 1706 - if (wxDialog::Create (parent, wxID_ANY, wxT ("SQLite + SpatiaLite help")) == 1707 - false) 1708 - return false; 1709 -// populates individual controls 1710 - CreateControls (); 1711 -// sets dialog sizer 1712 - GetSizer ()->Fit (this); 1713 - GetSizer ()->SetSizeHints (this); 1714 -// centers the dialog window 1715 - MainFrame->OpenHelpPane (); 1716 - Centre (); 1594 + MainFrame->OpenHelpPane(); 1595 + Centre(); 1717 1596 // setting up an event handler [dialog closing] 1718 - Connect (wxID_ANY, wxEVT_CLOSE_WINDOW, 1719 - (wxObjectEventFunction) & HelpDialog::OnClose); 1720 - return true; 1597 + Connect(wxID_ANY, wxEVT_CLOSE_WINDOW, 1598 + (wxObjectEventFunction) & HelpDialog::OnClose); 1599 + return true; 1721 1600 } 1722 1601 1723 -void 1724 -HelpDialog::OnClose (wxCloseEvent & event) 1602 +void HelpDialog::OnClose(wxCloseEvent & event) 1725 1603 { 1726 1604 // 1727 1605 // this window has been closed 1728 1606 // 1729 - MainFrame->CloseHelpPane (); 1730 - Destroy (); 1731 -} 1732 - 1733 -void 1734 -HelpDialog::CreateControls () 1607 + MainFrame->CloseHelpPane(); 1608 + Destroy(); 1609 +} 1610 + 1611 +void HelpDialog::CreateControls() 1612 +{ 1613 +// 1614 +// creating individual control and setting initial values 1615 +// 1616 + wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL); 1617 + this->SetSizer(topSizer); 1618 + wxBoxSizer *boxSizer = new wxBoxSizer(wxVERTICAL); 1619 + topSizer->Add(boxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 1620 + wxHtmlWindow *helpWin = new wxHtmlWindow(this, ID_HELP_HTML, 1621 + wxDefaultPosition, wxSize(400, 1622 + 200)); 1623 + wxString html; 1624 + MainFrame->GetHelp(html); 1625 + helpWin->SetPage(html); 1626 + topSizer->Add(helpWin, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 1627 + Connect(wxID_ANY, wxEVT_SIZE, (wxObjectEventFunction) & HelpDialog::OnSize); 1628 +} 1629 + 1630 +void HelpDialog::OnSize(wxSizeEvent & event) 1631 +{ 1632 +// 1633 +// this window has changed its size 1634 +// 1635 + wxSize sz = GetClientSize(); 1636 + wxHtmlWindow *helpWin = (wxHtmlWindow *) FindWindow(ID_HELP_HTML); 1637 + helpWin->SetSize(sz.GetWidth() - 6, sz.GetHeight() - 6); 1638 +} 1639 + 1640 +bool NetworkDialog::Create(MyFrame * parent) 1641 +{ 1642 +// 1643 +// creating the dialog 1644 +// 1645 + MainFrame = parent; 1646 + FromColumn = wxT(""); 1647 + ToColumn = wxT(""); 1648 + GeomColumn = wxT(""); 1649 + GeomLength = true; 1650 + CostColumn = wxT(""); 1651 + Bidirectional = true; 1652 + OneWays = false; 1653 + OneWayFromTo = wxT(""); 1654 + OneWayToFrom = wxT(""); 1655 + if (wxDialog::Create(parent, wxID_ANY, wxT("Build Network")) == false) 1656 + return false; 1657 +// populates individual controls 1658 + CreateControls(); 1659 +// sets dialog sizer 1660 + GetSizer()->Fit(this); 1661 + GetSizer()->SetSizeHints(this); 1662 +// centers the dialog window 1663 + Centre(); 1664 + return true; 1665 +} 1666 + 1667 +void NetworkDialog::CreateControls() 1668 +{ 1669 +// 1670 +// creating individual control and setting initial values 1671 +// 1672 + wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL); 1673 + this->SetSizer(topSizer); 1674 + wxBoxSizer *boxSizer = new wxBoxSizer(wxVERTICAL); 1675 + topSizer->Add(boxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 1676 + wxBoxSizer *row0Sizer = new wxBoxSizer(wxHORIZONTAL); 1677 + boxSizer->Add(row0Sizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 1678 +// first row: first column: the Main TABLE 1679 + wxBoxSizer *tableSizer = new wxBoxSizer(wxHORIZONTAL); 1680 + row0Sizer->Add(tableSizer, 0, wxALIGN_CENTRE_VERTICAL | wxALL, 0); 1681 + wxStaticBox *tableBox = new wxStaticBox(this, wxID_STATIC, 1682 + wxT("Base Table [graph]"), 1683 + wxDefaultPosition, 1684 + wxDefaultSize); 1685 + wxBoxSizer *tableNameSizer = new wxStaticBoxSizer(tableBox, wxVERTICAL); 1686 + tableSizer->Add(tableNameSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 1687 + int nTables; 1688 + wxString *tables = MainFrame->GetTables(&nTables); 1689 + wxListBox *tableCtrl = new wxListBox(this, ID_NET_TABLE, 1690 + wxDefaultPosition, wxDefaultSize, 1691 + nTables, tables, wxLB_SINGLE); 1692 + delete[]tables; 1693 + tableNameSizer->Add(tableCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0); 1694 + wxSize size = tableCtrl->GetSize(); 1695 + size.SetHeight(size.GetHeight() / 2); 1696 +// first row: second column: the NodeFrom COLUMN 1697 + wxBoxSizer *netSizer = new wxBoxSizer(wxHORIZONTAL); 1698 + row0Sizer->Add(netSizer, 0, wxALIGN_RIGHT | wxALL, 0); 1699 + wxStaticBox *netBox = new wxStaticBox(this, wxID_STATIC, 1700 + wxT("Network configuration"), 1701 + wxDefaultPosition, 1702 + wxDefaultSize); 1703 + wxBoxSizer *colSizer = new wxStaticBoxSizer(netBox, wxVERTICAL); 1704 + netSizer->Add(colSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 1705 + wxBoxSizer *row1Sizer = new wxBoxSizer(wxHORIZONTAL); 1706 + colSizer->Add(row1Sizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 1707 + wxBoxSizer *fromSizer = new wxBoxSizer(wxHORIZONTAL); 1708 + row1Sizer->Add(fromSizer, 0, wxALIGN_RIGHT | wxALL, 0); 1709 + wxStaticBox *fromBox = new wxStaticBox(this, wxID_STATIC, 1710 + wxT("NodeFrom Column"), 1711 + wxDefaultPosition, 1712 + wxDefaultSize); 1713 + wxBoxSizer *fromColSizer = new wxStaticBoxSizer(fromBox, wxVERTICAL); 1714 + fromSizer->Add(fromColSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 1715 + wxListBox *fromCtrl = new wxListBox(this, ID_NET_FROM, 1716 + wxDefaultPosition, size, 1717 + 0, NULL, wxLB_SINGLE); 1718 + fromCtrl->Enable(false); 1719 + fromColSizer->Add(fromCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0); 1720 +// first row: third column: the NodeTo COLUMN 1721 + wxBoxSizer *toSizer = new wxBoxSizer(wxHORIZONTAL); 1722 + row1Sizer->Add(toSizer, 0, wxALIGN_RIGHT | wxALL, 0); 1723 + wxStaticBox *toBox = new wxStaticBox(this, wxID_STATIC, 1724 + wxT("NodeTo Column"), 1725 + wxDefaultPosition, 1726 + wxDefaultSize); 1727 + wxBoxSizer *toColSizer = new wxStaticBoxSizer(toBox, wxVERTICAL); 1728 + toSizer->Add(toColSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 1729 + wxListBox *toCtrl = new wxListBox(this, ID_NET_TO, 1730 + wxDefaultPosition, size, 1731 + 0, NULL, wxLB_SINGLE); 1732 + toCtrl->Enable(false); 1733 + toColSizer->Add(toCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0); 1734 +// first row: fourth column: the Geometry COLUMN 1735 + wxBoxSizer *geoSizer = new wxBoxSizer(wxHORIZONTAL); 1736 + row1Sizer->Add(geoSizer, 0, wxALIGN_RIGHT | wxALL, 0); 1737 + wxStaticBox *geoBox = new wxStaticBox(this, wxID_STATIC, 1738 + wxT("Geometry Column"), 1739 + wxDefaultPosition, 1740 + wxDefaultSize); 1741 + wxBoxSizer *geoColSizer = new wxStaticBoxSizer(geoBox, wxVERTICAL); 1742 + toSizer->Add(geoColSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 1743 + wxListBox *geoCtrl = new wxListBox(this, ID_NET_GEOM, 1744 + wxDefaultPosition, size, 1745 + 0, NULL, wxLB_SINGLE); 1746 + geoCtrl->Enable(false); 1747 + geoColSizer->Add(geoCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0); 1748 +// second row: first column: UNIDIRECTIONAL / BIDIRECTIONAL 1749 + wxBoxSizer *row2Sizer = new wxBoxSizer(wxHORIZONTAL); 1750 + colSizer->Add(row2Sizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 1751 + wxString dirs[2]; 1752 + dirs[0] = wxT("&Uni-Directional"); 1753 + dirs[1] = wxT("&Bi-Directional"); 1754 + wxRadioBox *dirSel = new wxRadioBox(this, ID_NET_BIDIR, 1755 + wxT("&Arc connections"), 1756 + wxDefaultPosition, 1757 + wxDefaultSize, 2, 1758 + dirs, 2, 1759 + wxRA_SPECIFY_ROWS); 1760 + dirSel->SetSelection(1); 1761 + dirSel->Enable(false); 1762 + row2Sizer->Add(dirSel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0); 1763 +// second row: second column: the COST is GLenth selection 1764 + wxString costs[2]; 1765 + costs[0] = wxT("&Using GLength(Geometry) as Cost"); 1766 + costs[1] = wxT("&Using Cost Column"); 1767 + wxRadioBox *costSel = new wxRadioBox(this, ID_NET_LENGTH, 1768 + wxT("&Cost type"), 1769 + wxDefaultPosition, 1770 + wxDefaultSize, 2, 1771 + costs, 2, 1772 + wxRA_SPECIFY_ROWS); 1773 + costSel->SetSelection(0); 1774 + costSel->Enable(false); 1775 + row2Sizer->Add(costSel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1776 +// second row: third column: the COST COLUMN 1777 + wxBoxSizer *costSizer = new wxBoxSizer(wxHORIZONTAL); 1778 + row2Sizer->Add(costSizer, 0, wxALIGN_RIGHT | wxALL, 0); 1779 + wxStaticBox *costBox = new wxStaticBox(this, wxID_STATIC, 1780 + wxT("Cost Column"), 1781 + wxDefaultPosition, 1782 + wxDefaultSize); 1783 + wxBoxSizer *costColSizer = new wxStaticBoxSizer(costBox, wxVERTICAL); 1784 + costSizer->Add(costColSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 1785 + wxListBox *costCtrl = new wxListBox(this, ID_NET_COST, 1786 + wxDefaultPosition, size, 1787 + 0, NULL, wxLB_SINGLE); 1788 + costCtrl->Enable(false); 1789 + costColSizer->Add(costCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1790 +// third row: second column: the OneWay Selection 1791 + wxBoxSizer *row3Sizer = new wxBoxSizer(wxHORIZONTAL); 1792 + colSizer->Add(row3Sizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 1793 + wxString oneWays[2]; 1794 + oneWays[0] = wxT("&Not using OneWay Columns"); 1795 + oneWays[1] = wxT("&Using OneWay Columns"); 1796 + wxRadioBox *oneWaySel = new wxRadioBox(this, ID_NET_ONEWAY, 1797 + wxT("&OneWays"), 1798 + wxDefaultPosition, 1799 + wxDefaultSize, 2, 1800 + oneWays, 2, 1801 + wxRA_SPECIFY_ROWS); 1802 + oneWaySel->SetSelection(0); 1803 + oneWaySel->Enable(false); 1804 + row3Sizer->Add(oneWaySel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1805 +// third row: second column: the OneWay FromTo COLUMN 1806 + wxBoxSizer *fromToSizer = new wxBoxSizer(wxHORIZONTAL); 1807 + row3Sizer->Add(fromToSizer, 0, wxALIGN_RIGHT | wxALL, 0); 1808 + wxStaticBox *fromToBox = new wxStaticBox(this, wxID_STATIC, 1809 + wxT("From -> To Column"), 1810 + wxDefaultPosition, 1811 + wxDefaultSize); 1812 + wxBoxSizer *fromToColSizer = new wxStaticBoxSizer(fromToBox, wxVERTICAL); 1813 + fromToSizer->Add(fromToColSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 1814 + wxListBox *fromToCtrl = new wxListBox(this, ID_NET_FROM_TO, 1815 + wxDefaultPosition, size, 1816 + 0, NULL, wxLB_SINGLE); 1817 + fromToCtrl->Enable(false); 1818 + fromToColSizer->Add(fromToCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0); 1819 +// fourth row: second column: the OneWay To From COLUMN 1820 + wxBoxSizer *toFromSizer = new wxBoxSizer(wxHORIZONTAL); 1821 + row3Sizer->Add(toFromSizer, 0, wxALIGN_RIGHT | wxALL, 0); 1822 + wxStaticBox *toFromBox = new wxStaticBox(this, wxID_STATIC, 1823 + wxT("To -> From Column"), 1824 + wxDefaultPosition, 1825 + wxDefaultSize); 1826 + wxBoxSizer *toFromColSizer = new wxStaticBoxSizer(toFromBox, wxVERTICAL); 1827 + toFromSizer->Add(toFromColSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 1828 + wxListBox *toFromCtrl = new wxListBox(this, ID_NET_TO_FROM, 1829 + wxDefaultPosition, size, 1830 + 0, NULL, wxLB_SINGLE); 1831 + toFromCtrl->Enable(false); 1832 + toFromColSizer->Add(toFromCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0); 1833 +// OK - CANCEL buttons 1834 + wxBoxSizer *okCancelBox = new wxBoxSizer(wxHORIZONTAL); 1835 + boxSizer->Add(okCancelBox, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 1836 + wxButton *ok = new wxButton(this, wxID_OK, wxT("&OK")); 1837 + okCancelBox->Add(ok, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1838 + wxButton *cancel = new wxButton(this, wxID_CANCEL, wxT("&Cancel")); 1839 + okCancelBox->Add(cancel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 1840 +// appends event handler for OK button 1841 + Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, 1842 + (wxObjectEventFunction) & NetworkDialog::OnOk); 1843 +// appends event handlers for radio buttons etc 1844 + Connect(ID_NET_TABLE, wxEVT_COMMAND_LISTBOX_SELECTED, 1845 + (wxObjectEventFunction) & NetworkDialog::OnTable); 1846 + Connect(ID_NET_BIDIR, wxEVT_COMMAND_RADIOBOX_SELECTED, 1847 + (wxObjectEventFunction) & NetworkDialog::OnDirection); 1848 + Connect(ID_NET_LENGTH, wxEVT_COMMAND_RADIOBOX_SELECTED, 1849 + (wxObjectEventFunction) & NetworkDialog::OnCost); 1850 + Connect(ID_NET_ONEWAY, wxEVT_COMMAND_RADIOBOX_SELECTED, 1851 + (wxObjectEventFunction) & NetworkDialog::OnOneWay); 1852 +} 1853 + 1854 +void NetworkDialog::OnTable(wxCommandEvent & event) 1855 +{ 1856 +// 1857 +// TABLE selection changed 1858 +// 1859 + wxListBox *tableCtrl = (wxListBox *) FindWindow(ID_NET_TABLE); 1860 + TableName = tableCtrl->GetStringSelection(); 1861 + int n_cols; 1862 + wxString *columns = MainFrame->GetColumnNames(TableName, &n_cols); 1863 + wxListBox *fromCtrl = (wxListBox *) FindWindow(ID_NET_FROM); 1864 + fromCtrl->Clear(); 1865 + fromCtrl->InsertItems(n_cols, columns, 0); 1866 + fromCtrl->Enable(true); 1867 + wxListBox *toCtrl = (wxListBox *) FindWindow(ID_NET_TO); 1868 + toCtrl->Clear(); 1869 + toCtrl->InsertItems(n_cols, columns, 0); 1870 + toCtrl->Enable(true); 1871 + wxListBox *geomCtrl = (wxListBox *) FindWindow(ID_NET_GEOM); 1872 + geomCtrl->Clear(); 1873 + geomCtrl->InsertItems(n_cols, columns, 0); 1874 + geomCtrl->Enable(true); 1875 + wxListBox *costCtrl = (wxListBox *) FindWindow(ID_NET_COST); 1876 + costCtrl->Clear(); 1877 + costCtrl->InsertItems(n_cols, columns, 0); 1878 + costCtrl->Enable(false); 1879 + wxListBox *fromToCtrl = (wxListBox *) FindWindow(ID_NET_FROM_TO); 1880 + fromToCtrl->Clear(); 1881 + fromToCtrl->InsertItems(n_cols, columns, 0); 1882 + fromToCtrl->Enable(false); 1883 + wxListBox *toFromCtrl = (wxListBox *) FindWindow(ID_NET_TO_FROM); 1884 + toFromCtrl->Clear(); 1885 + toFromCtrl->InsertItems(n_cols, columns, 0); 1886 + toFromCtrl->Enable(false); 1887 + wxRadioBox *dirSel = (wxRadioBox *) FindWindow(ID_NET_BIDIR); 1888 + Bidirectional = true; 1889 + dirSel->SetSelection(1); 1890 + dirSel->Enable(true); 1891 + wxRadioBox *costSel = (wxRadioBox *) FindWindow(ID_NET_LENGTH); 1892 + GeomLength = true; 1893 + costSel->SetSelection(0); 1894 + costSel->Enable(true); 1895 + wxRadioBox *oneWaySel = (wxRadioBox *) FindWindow(ID_NET_ONEWAY); 1896 + OneWays = false; 1897 + oneWaySel->SetSelection(0); 1898 + oneWaySel->Enable(true); 1899 +} 1900 + 1901 +void NetworkDialog::OnDirection(wxCommandEvent & event) 1902 +{ 1903 +// 1904 +// BIDIRECTIONAL radio box 1905 +// 1906 + wxRadioBox *oneWaySel = (wxRadioBox *) FindWindow(ID_NET_ONEWAY); 1907 + wxRadioBox *dirSel = (wxRadioBox *) FindWindow(ID_NET_BIDIR); 1908 + wxListBox *fromToCtrl = (wxListBox *) FindWindow(ID_NET_FROM_TO); 1909 + wxListBox *toFromCtrl = (wxListBox *) FindWindow(ID_NET_TO_FROM); 1910 + if (Bidirectional == true) 1911 + { 1912 + Bidirectional = false; 1913 + dirSel->SetSelection(0); 1914 + OneWays = false; 1915 + oneWaySel->SetSelection(0); 1916 + oneWaySel->Enable(false); 1917 + fromToCtrl->Enable(false); 1918 + toFromCtrl->Enable(false); 1919 + } else 1920 + { 1921 + Bidirectional = true; 1922 + dirSel->SetSelection(1); 1923 + OneWays = false; 1924 + oneWaySel->SetSelection(0); 1925 + oneWaySel->Enable(true); 1926 + fromToCtrl->Enable(false); 1927 + toFromCtrl->Enable(false); 1928 + } 1929 +} 1930 + 1931 +void NetworkDialog::OnCost(wxCommandEvent & event) 1932 +{ 1933 +// 1934 +// COST radio box 1935 +// 1936 + wxRadioBox *costSel = (wxRadioBox *) FindWindow(ID_NET_LENGTH); 1937 + wxListBox *costCtrl = (wxListBox *) FindWindow(ID_NET_COST); 1938 + if (GeomLength == true) 1939 + { 1940 + GeomLength = false; 1941 + costSel->SetSelection(1); 1942 + costCtrl->Enable(true); 1943 + } else 1944 + { 1945 + GeomLength = true; 1946 + costSel->SetSelection(0); 1947 + costCtrl->Enable(false); 1948 + } 1949 +} 1950 + 1951 +void NetworkDialog::OnOneWay(wxCommandEvent & event) 1952 +{ 1953 +// 1954 +// OneWay radio box 1955 +// 1956 + wxRadioBox *oneWaySel = (wxRadioBox *) FindWindow(ID_NET_ONEWAY); 1957 + wxListBox *fromToCtrl = (wxListBox *) FindWindow(ID_NET_FROM_TO); 1958 + wxListBox *toFromCtrl = (wxListBox *) FindWindow(ID_NET_TO_FROM); 1959 + if (OneWays == true) 1960 + { 1961 + OneWays = false; 1962 + oneWaySel->SetSelection(0); 1963 + fromToCtrl->Enable(false); 1964 + toFromCtrl->Enable(false); 1965 + } else 1966 + { 1967 + OneWays = true; 1968 + oneWaySel->SetSelection(1); 1969 + fromToCtrl->Enable(true); 1970 + toFromCtrl->Enable(true); 1971 + } 1972 +} 1973 + 1974 +void NetworkDialog::OnOk(wxCommandEvent & event) 1975 +{ 1976 +// 1977 +// all done: 1978 +// 1979 + wxListBox *tableCtrl = (wxListBox *) FindWindow(ID_NET_TABLE); 1980 + TableName = tableCtrl->GetStringSelection(); 1981 + if (TableName.Len() < 1) 1982 + { 1983 + wxMessageBox(wxT("You must select some TABLE NAME !!!"), 1984 + wxT("spatialite-gui"), wxOK | wxICON_WARNING, this); 1985 + return; 1986 + } 1987 + wxListBox *fromCtrl = (wxListBox *) FindWindow(ID_NET_FROM); 1988 + FromColumn = fromCtrl->GetStringSelection(); 1989 + if (FromColumn.Len() < 1) 1990 + { 1991 + wxMessageBox(wxT("You must select some 'NodeFrom' COLUMN !!!"), 1992 + wxT("spatialite-gui"), wxOK | wxICON_WARNING, this); 1993 + return; 1994 + } 1995 + wxListBox *toCtrl = (wxListBox *) FindWindow(ID_NET_TO); 1996 + ToColumn = toCtrl->GetStringSelection(); 1997 + if (ToColumn.Len() < 1) 1998 + { 1999 + wxMessageBox(wxT("You must select some 'NodeTo' COLUMN !!!"), 2000 + wxT("spatialite-gui"), wxOK | wxICON_WARNING, this); 2001 + return; 2002 + } 2003 + wxListBox *geomCtrl = (wxListBox *) FindWindow(ID_NET_GEOM); 2004 + GeomColumn = geomCtrl->GetStringSelection(); 2005 + if (GeomColumn.Len() < 1) 2006 + { 2007 + wxMessageBox(wxT("You must select some 'Geometry' COLUMN !!!"), 2008 + wxT("spatialite-gui"), wxOK | wxICON_WARNING, this); 2009 + return; 2010 + } 2011 + if (GeomLength == true) 2012 + CostColumn = wxT(""); 2013 + else 2014 + { 2015 + wxListBox *costCtrl = (wxListBox *) FindWindow(ID_NET_COST); 2016 + CostColumn = costCtrl->GetStringSelection(); 2017 + if (CostColumn.Len() < 1) 2018 + { 2019 + wxMessageBox(wxT("You must select some 'Cost' COLUMN !!!"), 2020 + wxT("spatialite-gui"), wxOK | wxICON_WARNING, this); 2021 + return; 2022 + } 2023 + } 2024 + if (Bidirectional == true && OneWays == true) 2025 + { 2026 + wxListBox *fromToCtrl = (wxListBox *) FindWindow(ID_NET_FROM_TO); 2027 + OneWayFromTo = fromToCtrl->GetStringSelection(); 2028 + if (OneWayFromTo.Len() < 1) 2029 + { 2030 + wxMessageBox(wxT("You must select some 'OneWay From->To' COLUMN !!!"), 2031 + wxT("spatialite-gui"), wxOK | wxICON_WARNING, this); 2032 + return; 2033 + } 2034 + wxListBox *toFromCtrl = (wxListBox *) FindWindow(ID_NET_TO_FROM); 2035 + OneWayToFrom = toFromCtrl->GetStringSelection(); 2036 + if (OneWayToFrom.Len() < 1) 2037 + { 2038 + wxMessageBox(wxT("You must select some 'OneWay To->From' COLUMN !!!"), 2039 + wxT("spatialite-gui"), wxOK | wxICON_WARNING, this); 2040 + return; 2041 + } 2042 + } else 2043 + { 2044 + OneWayFromTo = wxT(""); 2045 + OneWayToFrom = wxT(""); 2046 + } 2047 + wxDialog::EndModal(wxID_OK); 2048 +} 2049 + 2050 +bool ExifDialog::Create(MyFrame * parent, wxString & dir_path, 2051 + wxString & img_path) 2052 +{ 2053 +// 2054 +// creating the dialog 2055 +// 2056 + MainFrame = parent; 2057 + DirPath = dir_path; 2058 + ImgPath = img_path; 2059 + Folder = false; 2060 + Metadata = true; 2061 + GpsOnly = false; 2062 + if (wxDialog::Create(parent, wxID_ANY, wxT("Import EXIF Photos")) == false) 2063 + return false; 2064 +// populates individual controls 2065 + CreateControls(); 2066 +// sets dialog sizer 2067 + GetSizer()->Fit(this); 2068 + GetSizer()->SetSizeHints(this); 2069 +// centers the dialog window 2070 + Centre(); 2071 + return true; 2072 +} 2073 + 2074 +void ExifDialog::CreateControls() 1735 2075 { 1736 2076 // 1737 2077 // creating individual control and setting initial values 1738 2078 // 1739 - wxBoxSizer *topSizer = new wxBoxSizer (wxVERTICAL); 1740 - this->SetSizer (topSizer); 1741 - wxBoxSizer *boxSizer = new wxBoxSizer (wxVERTICAL); 1742 - topSizer->Add (boxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 1743 - wxHtmlWindow *helpWin = new wxHtmlWindow (this, wxID_ANY, 1744 - wxDefaultPosition, wxSize (620, 1745 - 420)); 1746 - wxString html; 1747 - MainFrame->GetHelp (html); 1748 - helpWin->SetPage (html); 1749 - topSizer->Add (helpWin, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 2079 + wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL); 2080 + this->SetSizer(topSizer); 2081 + wxBoxSizer *boxSizer = new wxBoxSizer(wxVERTICAL); 2082 + topSizer->Add(boxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 2083 + wxBoxSizer *row0Sizer = new wxBoxSizer(wxVERTICAL); 2084 + boxSizer->Add(row0Sizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 2085 +// first row: the path and file/folder selection 2086 + wxBoxSizer *pathSizer = new wxBoxSizer(wxHORIZONTAL); 2087 + row0Sizer->Add(pathSizer, 0, wxALIGN_CENTRE_VERTICAL | wxALL, 0); 2088 + wxStaticBox *pathBox = new wxStaticBox(this, wxID_STATIC, 2089 + wxT("Import from source"), 2090 + wxDefaultPosition, 2091 + wxDefaultSize); 2092 + wxBoxSizer *pthSizer = new wxStaticBoxSizer(pathBox, wxVERTICAL); 2093 + pathSizer->Add(pthSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 2094 + wxStaticText *pathLabel = new wxStaticText(this, ID_EXIF_PATH, ImgPath); 2095 + pthSizer->Add(pathLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0); 2096 + wxString imgFolder[2]; 2097 + imgFolder[0] = wxT("Import &selected image only"); 2098 + imgFolder[1] = wxT("Import &any EXIF from selected folder"); 2099 + wxRadioBox *imgFolderSel = new wxRadioBox(this, ID_EXIF_FOLDER, 2100 + wxT("&Source selection"), 2101 + wxDefaultPosition, 2102 + wxDefaultSize, 2, 2103 + imgFolder, 2, 2104 + wxRA_SPECIFY_ROWS); 2105 + imgFolderSel->SetSelection(0); 2106 + pthSizer->Add(imgFolderSel, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 2107 +// second row: the metadata and gps-only selection 2108 + wxBoxSizer *modeSizer = new wxBoxSizer(wxHORIZONTAL); 2109 + boxSizer->Add(modeSizer, 0, wxALIGN_CENTRE_HORIZONTAL | wxALL, 0); 2110 + wxString metadata[2]; 2111 + metadata[0] = wxT("Feed full EXIF &Metadata"); 2112 + metadata[1] = wxT("&Skip EXIF Metadata"); 2113 + wxRadioBox *metadataSel = new wxRadioBox(this, ID_EXIF_METADATA, 2114 + wxT("&EXIF Metadata tables"), 2115 + wxDefaultPosition, 2116 + wxDefaultSize, 2, 2117 + metadata, 2, 2118 + wxRA_SPECIFY_ROWS); 2119 + metadataSel->SetSelection(0); 2120 + modeSizer->Add(metadataSel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 2121 + wxString gpsOnly[2]; 2122 + gpsOnly[0] = wxT("Import any EXIF file"); 2123 + gpsOnly[1] = wxT("Import EXIF only if containing &GPS tags"); 2124 + wxRadioBox *gpsOnlySel = new wxRadioBox(this, ID_EXIF_GPS_ONLY, 2125 + wxT("&GPS position"), 2126 + wxDefaultPosition, 2127 + wxDefaultSize, 2, 2128 + gpsOnly, 2, 2129 + wxRA_SPECIFY_ROWS); 2130 + gpsOnlySel->SetSelection(0); 2131 + modeSizer->Add(gpsOnlySel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 2132 +// OK - CANCEL buttons 2133 + wxBoxSizer *okCancelBox = new wxBoxSizer(wxHORIZONTAL); 2134 + boxSizer->Add(okCancelBox, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 2135 + wxButton *ok = new wxButton(this, wxID_OK, wxT("&OK")); 2136 + okCancelBox->Add(ok, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 2137 + wxButton *cancel = new wxButton(this, wxID_CANCEL, wxT("&Cancel")); 2138 + okCancelBox->Add(cancel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 2139 +// appends event handler for OK button 2140 + Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, 2141 + (wxObjectEventFunction) & ExifDialog::OnOk); 2142 +// appends event handlers for radio buttons etc 2143 + Connect(ID_EXIF_FOLDER, wxEVT_COMMAND_RADIOBOX_SELECTED, 2144 + (wxObjectEventFunction) & ExifDialog::OnFolder); 2145 + Connect(ID_EXIF_METADATA, wxEVT_COMMAND_RADIOBOX_SELECTED, 2146 + (wxObjectEventFunction) & ExifDialog::OnMetadata); 2147 + Connect(ID_EXIF_GPS_ONLY, wxEVT_COMMAND_RADIOBOX_SELECTED, 2148 + (wxObjectEventFunction) & ExifDialog::OnGpsOnly); 2149 +} 2150 + 2151 +void ExifDialog::OnFolder(wxCommandEvent & event) 2152 +{ 2153 +// 2154 +// File/Folder radio box 2155 +// 2156 + wxRadioBox *folderSel = (wxRadioBox *) FindWindow(ID_EXIF_FOLDER); 2157 + wxStaticText *pathLabel = (wxStaticText *) FindWindow(ID_EXIF_PATH); 2158 + if (Folder == true) 2159 + { 2160 + Folder = false; 2161 + folderSel->SetSelection(0); 2162 + pathLabel->SetLabel(ImgPath); 2163 + } else 2164 + { 2165 + Folder = true; 2166 + folderSel->SetSelection(1); 2167 + pathLabel->SetLabel(DirPath); 2168 + } 2169 +} 2170 + 2171 +void ExifDialog::OnMetadata(wxCommandEvent & event) 2172 +{ 2173 +// 2174 +// Metadata radio box 2175 +// 2176 + wxRadioBox *metadataSel = (wxRadioBox *) FindWindow(ID_EXIF_METADATA); 2177 + if (Metadata == true) 2178 + { 2179 + Metadata = false; 2180 + metadataSel->SetSelection(1); 2181 + } else 2182 + { 2183 + Metadata = true; 2184 + metadataSel->SetSelection(0); 2185 + } 2186 +} 2187 + 2188 +void ExifDialog::OnGpsOnly(wxCommandEvent & event) 2189 +{ 2190 +// 2191 +// GpsOnly radio box 2192 +// 2193 + wxRadioBox *gpsOnlySel = (wxRadioBox *) FindWindow(ID_EXIF_GPS_ONLY); 2194 + if (GpsOnly == true) 2195 + { 2196 + GpsOnly = false; 2197 + gpsOnlySel->SetSelection(0); 2198 + } else 2199 + { 2200 + GpsOnly = true; 2201 + gpsOnlySel->SetSelection(1); 2202 + } 2203 +} 2204 + 2205 +void ExifDialog::OnOk(wxCommandEvent & event) 2206 +{ 2207 +// 2208 +// all done: 2209 +// 2210 + wxDialog::EndModal(wxID_OK); 2211 +} 2212 + 2213 +bool AutoSaveDialog::Create(MyFrame * parent, wxString & path, int secs) 2214 +{ 2215 +// 2216 +// creating the dialog 2217 +// 2218 + MainFrame = parent; 2219 + Path = path; 2220 + Seconds = secs; 2221 + if (wxDialog::Create(parent, wxID_ANY, wxT("MEMORY-DB AutoSave settings")) == 2222 + false) 2223 + return false; 2224 +// populates individual controls 2225 + CreateControls(); 2226 +// sets dialog sizer 2227 + GetSizer()->Fit(this); 2228 + GetSizer()->SetSizeHints(this); 2229 +// centers the dialog window 2230 + Centre(); 2231 + return true; 2232 +} 2233 + 2234 +void AutoSaveDialog::CreateControls() 2235 +{ 2236 +// 2237 +// creating individual controls and setting initial values 2238 +// 2239 + wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL); 2240 + this->SetSizer(topSizer); 2241 + wxBoxSizer *boxSizer = new wxBoxSizer(wxVERTICAL); 2242 + topSizer->Add(boxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 2243 +// first row: export path 2244 + wxBoxSizer *pathSizer = new wxBoxSizer(wxHORIZONTAL); 2245 + boxSizer->Add(pathSizer, 0, wxALIGN_RIGHT | wxALL, 0); 2246 + wxStaticText *pathLabel = 2247 + new wxStaticText(this, wxID_STATIC, wxT("&Save as:")); 2248 + pathSizer->Add(pathLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 2249 + wxString pth = Path; 2250 + if (pth.Len() == 0) 2251 + pth = wxT("*** not set: AutoSave IS DISABLED ***"); 2252 + PathCtrl = new wxTextCtrl(this, ID_AUTO_SAVE_PATH, pth, wxDefaultPosition, 2253 + wxSize(350, 22), wxTE_READONLY); 2254 + pathSizer->Add(PathCtrl, 0, wxALIGN_RIGHT | wxALL, 5); 2255 +// second row: CHANGE PATH button 2256 + wxBoxSizer *changeBox = new wxBoxSizer(wxHORIZONTAL); 2257 + boxSizer->Add(changeBox, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 2258 + wxButton *change = 2259 + new wxButton(this, ID_AUTO_SAVE_CHANGE_PATH, wxT("&Set the export path")); 2260 + changeBox->Add(change, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 2261 +// third row: INTERVAL 2262 + wxBoxSizer *modeSizer = new wxBoxSizer(wxHORIZONTAL); 2263 + boxSizer->Add(modeSizer, 0, wxALIGN_LEFT | wxALL, 0); 2264 + wxString modes[6]; 2265 + modes[0] = wxT("&Disable AutoSaving"); 2266 + modes[1] = wxT("Every &30 seconds"); 2267 + modes[2] = wxT("Every &minute"); 2268 + modes[3] = wxT("Every &2 minutes"); 2269 + modes[4] = wxT("Every &5 minutes"); 2270 + modes[5] = wxT("Every &10 minutes"); 2271 + IntervalCtrl = new wxRadioBox(this, ID_AUTO_SAVE_INTERVAL, 2272 + wxT("&AutoSave interval"), 2273 + wxDefaultPosition, wxDefaultSize, 6, modes, 6, 2274 + wxRA_SPECIFY_ROWS); 2275 + if (Seconds <= 0) 2276 + IntervalCtrl->SetSelection(0); 2277 + else if (Seconds <= 30) 2278 + IntervalCtrl->SetSelection(1); 2279 + else if (Seconds <= 60) 2280 + IntervalCtrl->SetSelection(2); 2281 + else if (Seconds <= 120) 2282 + IntervalCtrl->SetSelection(3); 2283 + else if (Seconds <= 300) 2284 + IntervalCtrl->SetSelection(4); 2285 + else 2286 + IntervalCtrl->SetSelection(5); 2287 + modeSizer->Add(IntervalCtrl, 0, wxALIGN_RIGHT | wxALL, 5); 2288 + 2289 +// OK - CANCEL buttons 2290 + wxBoxSizer *okCancelBox = new wxBoxSizer(wxHORIZONTAL); 2291 + boxSizer->Add(okCancelBox, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0); 2292 + wxButton *ok = new wxButton(this, wxID_OK, wxT("&OK")); 2293 + okCancelBox->Add(ok, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 2294 + wxButton *cancel = new wxButton(this, wxID_CANCEL, wxT("&Cancel")); 2295 + okCancelBox->Add(cancel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); 2296 +// appends event handler for OK button 2297 + Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, 2298 + (wxObjectEventFunction) & AutoSaveDialog::OnOk); 2299 + Connect(ID_AUTO_SAVE_CHANGE_PATH, wxEVT_COMMAND_BUTTON_CLICKED, 2300 + (wxObjectEventFunction) & AutoSaveDialog::OnChangePath); 2301 + Connect(ID_AUTO_SAVE_INTERVAL, wxEVT_COMMAND_RADIOBOX_SELECTED, 2302 + (wxObjectEventFunction) & AutoSaveDialog::OnIntervalChanged); 2303 +} 2304 + 2305 +void AutoSaveDialog::OnChangePath(wxCommandEvent & WXUNUSED(event)) 2306 +{ 2307 +// 2308 +// exporting the MEMORY-DB into an external DB 2309 +// 2310 + int retdlg; 2311 + wxString lastDir; 2312 + wxFileDialog *fileDialog = new wxFileDialog(this, wxT("Saving the MEMORY-DB"), 2313 + wxT(""), wxT("db.sqlite"), 2314 + wxT 2315 + ("SQLite DB (*.sqlite)|*.sqlite|All files (*.*)|*.*"), 2316 + wxFD_SAVE | wxFD_OVERWRITE_PROMPT, 2317 + wxDefaultPosition, 2318 + wxDefaultSize, 2319 + wxT("filedlg")); 2320 + lastDir = MainFrame->GetLastDirectory(); 2321 + if (lastDir.Len() >= 1) 2322 + fileDialog->SetDirectory(lastDir); 2323 + retdlg = fileDialog->ShowModal(); 2324 + if (retdlg == wxID_OK) 2325 + { 2326 + // exporting the external DB 2327 + wxString pth = fileDialog->GetPath(); 2328 + wxString extPth = wxT("*** not set: AutoSave IS DISABLED ***"); 2329 + MainFrame->SetExternalSqlitePath(pth); 2330 + if (MainFrame->MemoryDbSave() == true) 2331 + { 2332 + wxMessageBox(wxT("Ok, MEMORY-DB was succesfully saved"), 2333 + wxT("spatialite-gui"), wxOK | wxICON_INFORMATION, this); 2334 + wxFileName file(fileDialog->GetPath()); 2335 + lastDir = file.GetPath(); 2336 + MainFrame->SetLastDirectory(lastDir); 2337 + extPth = MainFrame->GetExternalSqlitePath(); 2338 + PathCtrl->SetValue(extPth); 2339 + } else 2340 + PathCtrl->SetValue(extPth); 2341 + } 2342 +} 2343 + 2344 +void AutoSaveDialog::OnIntervalChanged(wxCommandEvent & event) 2345 +{ 2346 +// 2347 +// Interval selection changed 2348 +// 2349 + if (IntervalCtrl->GetSelection() == 0) 2350 + Seconds = 0; 2351 + else if (IntervalCtrl->GetSelection() == 1) 2352 + Seconds = 30; 2353 + else if (IntervalCtrl->GetSelection() == 2) 2354 + Seconds = 60; 2355 + else if (IntervalCtrl->GetSelection() == 3) 2356 + Seconds = 120; 2357 + else if (IntervalCtrl->GetSelection() == 4) 2358 + Seconds = 300; 2359 + else 2360 + Seconds = 600; 2361 +} 2362 + 2363 +void AutoSaveDialog::OnOk(wxCommandEvent & event) 2364 +{ 2365 +// 2366 +// all done: 2367 +// 2368 + wxDialog::EndModal(wxID_OK); 1750 2369 }
Added Exif.cpp.
1 +/* 2 +/ Exif.cpp 3 +/ methods related to EXIF import 4 +/ 5 +/ version 1.2, 2008 October 9 6 +/ 7 +/ Author: Sandro Furieri a-furieri@lqt.it 8 +/ 9 +/ Copyright (C) 2008 Alessandro Furieri 10 +/ 11 +/ This program is free software: you can redistribute it and/or modify 12 +/ it under the terms of the GNU General Public License as published by 13 +/ the Free Software Foundation, either version 3 of the License, or 14 +/ (at your option) any later version. 15 +/ 16 +/ This program is distributed in the hope that it will be useful, 17 +/ but WITHOUT ANY WARRANTY; without even the implied warranty of 18 +/ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 +/ GNU General Public License for more details. 20 +/ 21 +/ You should have received a copy of the GNU General Public License 22 +/ along with this program. If not, see <http://www.gnu.org/licenses/>. 23 +/ 24 +*/ 25 + 26 +#include "Classdef.h" 27 + 28 +#include <sys/types.h> 29 +#include <dirent.h> 30 +#include <float.h> 31 + 32 +void MyFrame::ImportExifPhotos(wxString & path, bool folder, bool metadata, 33 + bool gps_only) 34 +{ 35 +// 36 +// trying to import EXIF photos 37 +// 38 + int cnt; 39 + char msg[256]; 40 + ::wxBeginBusyCursor(); 41 + if (CheckExifTables() == false) 42 + { 43 + ::wxEndBusyCursor(); 44 + wxMessageBox(wxT 45 + ("An EXIF table is already defined, but has incompatibles columns"), 46 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 47 + return; 48 + } 49 + if (folder == true) 50 + cnt = ExifLoadDir(path, gps_only, metadata); 51 + else 52 + cnt = ExifLoadFile(path, gps_only, metadata); 53 + ::wxEndBusyCursor(); 54 + sprintf(msg, "%d EXIF photo%s succesfully inserted into the DB\n", cnt, 55 + (cnt > 1) ? "s where" : " was"); 56 + wxMessageBox(wxString::FromUTF8(msg), wxT("spatialite-gui"), 57 + wxOK | wxICON_INFORMATION, this); 58 + InitTableTree(); 59 +} 60 + 61 +bool MyFrame::CheckExifTables() 62 +{ 63 +// 64 +// creates the EXIF DB tables / or checks existing ones for validity 65 +// 66 + int ret; 67 + wxString sql; 68 + char xsql[1024]; 69 + char *errMsg; 70 + bool ok_photoId; 71 + bool ok_photo; 72 + bool ok_pixelX; 73 + bool ok_pixelY; 74 + bool ok_cameraMake; 75 + bool ok_cameraModel; 76 + bool ok_shotDateTime; 77 + bool ok_gpsGeometry; 78 + bool ok_gpsDirection; 79 + bool ok_gpsSatellites; 80 + bool ok_gpsTimestamp; 81 + bool ok_fromPath; 82 + bool ok_tagId; 83 + bool ok_tagName; 84 + bool ok_gpsTag; 85 + bool ok_valueType; 86 + bool ok_typeName; 87 + bool ok_countValues; 88 + bool ok_valueIndex; 89 + bool ok_byteValue; 90 + bool ok_stringValue; 91 + bool ok_numValue; 92 + bool ok_numValueBis; 93 + bool ok_doubleValue; 94 + bool ok_humanReadable; 95 + bool err_pk; 96 + bool ok_photoIdPk; 97 + bool ok_tagIdPk; 98 + bool ok_valueIndexPk; 99 + bool pKey; 100 + const char *name; 101 + int i; 102 + char **results; 103 + int rows; 104 + int columns; 105 +// creating the ExifPhoto table 106 + sql = wxT("CREATE TABLE IF NOT EXISTS ExifPhoto (\n"); 107 + sql += wxT("PhotoId INTEGER PRIMARY KEY AUTOINCREMENT,\n"); 108 + sql += wxT("Photo BLOB NOT NULL,\n"); 109 + sql += wxT("PixelX INTEGER,\n"); 110 + sql += wxT("PixelY INTEGER,\n"); 111 + sql += wxT("CameraMake TEXT,\n"); 112 + sql += wxT("CameraModel TEXT,\n"); 113 + sql += wxT("ShotDateTime DOUBLE,\n"); 114 + sql += wxT("GpsGeometry BLOB,\n"); 115 + sql += wxT("GpsDirection DOUBLE, "); 116 + sql += wxT("GpsSatellites TEXT,\n"); 117 + sql += wxT("GpsTimestamp DOUBLE,\n"); 118 + sql += wxT("FromPath TEXT"); 119 + sql += wxT(")"); 120 + strcpy(xsql, sql.ToUTF8()); 121 + ret = sqlite3_exec(SqliteHandle, xsql, NULL, NULL, &errMsg); 122 + if (ret != SQLITE_OK) 123 + { 124 + wxMessageBox(wxT("CREATE TABLE ExifPhoto error: ") + 125 + wxString::FromUTF8(errMsg), wxT("spatialite-gui"), 126 + wxOK | wxICON_ERROR, this); 127 + sqlite3_free(errMsg); 128 + goto abort; 129 + } 130 +// checking the ExifPhoto table for sanity 131 + ok_photoId = false; 132 + ok_photo = false; 133 + ok_pixelX = false; 134 + ok_pixelY = false; 135 + ok_cameraMake = false; 136 + ok_cameraModel = false; 137 + ok_shotDateTime = false; 138 + ok_gpsGeometry = false; 139 + ok_gpsDirection = false; 140 + ok_gpsSatellites = false; 141 + ok_gpsTimestamp = false; 142 + ok_fromPath = false; 143 + ok_photoIdPk = false; 144 + err_pk = false; 145 + strcpy(xsql, "PRAGMA table_info(ExifPhoto)"); 146 + ret = 147 + sqlite3_get_table(SqliteHandle, xsql, &results, &rows, &columns, &errMsg); 148 + if (ret != SQLITE_OK) 149 + { 150 + wxMessageBox(wxT("PRAGMA table_info(ExifPhoto) error: ") + 151 + wxString::FromUTF8(errMsg), wxT("spatialite-gui"), 152 + wxOK | wxICON_ERROR, this); 153 + sqlite3_free(errMsg); 154 + goto abort; 155 + } 156 + if (rows < 1) 157 + ; 158 + else 159 + { 160 + for (i = 1; i <= rows; i++) 161 + { 162 + name = results[(i * columns) + 1]; 163 + if (atoi(results[(i * columns) + 5]) == 0) 164 + pKey = false; 165 + else 166 + pKey = true; 167 + if (strcasecmp(name, "PhotoId") == 0) 168 + ok_photoId = true; 169 + if (strcasecmp(name, "Photo") == 0) 170 + ok_photo = true; 171 + if (strcasecmp(name, "PixelX") == 0) 172 + ok_pixelX = true; 173 + if (strcasecmp(name, "PixelY") == 0) 174 + ok_pixelY = true; 175 + if (strcasecmp(name, "CameraMake") == 0) 176 + ok_cameraMake = true; 177 + if (strcasecmp(name, "CameraModel") == 0) 178 + ok_cameraModel = true; 179 + if (strcasecmp(name, "ShotDateTime") == 0) 180 + ok_shotDateTime = true; 181 + if (strcasecmp(name, "GpsGeometry") == 0) 182 + ok_gpsGeometry = true; 183 + if (strcasecmp(name, "GpsDirection") == 0) 184 + ok_gpsDirection = true; 185 + if (strcasecmp(name, "GpsTimestamp") == 0) 186 + ok_gpsTimestamp = true; 187 + if (strcasecmp(name, "FromPath") == 0) 188 + ok_fromPath = true; 189 + if (pKey == true) 190 + { 191 + if (strcasecmp(name, "PhotoId") == 0) 192 + ok_photoIdPk = true; 193 + else 194 + err_pk = true; 195 + } 196 + } 197 + } 198 + sqlite3_free_table(results); 199 + if (ok_photoId == true && ok_photo == true && ok_pixelX == true 200 + && ok_pixelY == true && ok_cameraMake == true && ok_cameraModel == true 201 + && ok_shotDateTime == true && ok_gpsGeometry == true 202 + && ok_gpsDirection == true && ok_gpsTimestamp == true 203 + && ok_fromPath == true && ok_photoIdPk == true && err_pk == false) 204 + ; 205 + else 206 + { 207 + wxMessageBox(wxT 208 + ("ERROR: table ExifPhoto already exists, but has incompatible columns"), 209 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 210 + sqlite3_free(errMsg); 211 + goto abort; 212 + } 213 +// creating the ExifTags table 214 + sql = wxT("CREATE TABLE IF NOT EXISTS ExifTags (\n"); 215 + sql += wxT("PhotoId INTEGER NOT NULL,\n"); 216 + sql += wxT("TagId INTEGER NOT NULL,\n"); 217 + sql += wxT("TagName TEXT NOT NULL,\n"); 218 + sql += wxT("GpsTag INTEGER NOT NULL CHECK (GpsTag IN (0, 1)),\n"); 219 + sql += 220 + wxT 221 + ("ValueType INTEGER NOT NULL CHECK (ValueType IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)),\n"); 222 + sql += wxT("TypeName TEXT NOT NULL,\n"); 223 + sql += wxT("CountValues INTEGER NOT NULL,\n"); 224 + sql += wxT("PRIMARY KEY (PhotoId, TagId)"); 225 + sql += wxT(")"); 226 + strcpy(xsql, sql.ToUTF8()); 227 + ret = sqlite3_exec(SqliteHandle, xsql, NULL, NULL, &errMsg); 228 + if (ret != SQLITE_OK) 229 + { 230 + wxMessageBox(wxT("CREATE TABLE ExifTags error: ") + 231 + wxString::FromUTF8(errMsg), wxT("spatialite-gui"), 232 + wxOK | wxICON_ERROR, this); 233 + sqlite3_free(errMsg); 234 + goto abort; 235 + } 236 +// checking the ExifTags table for sanity 237 + ok_photoId = false; 238 + ok_tagId = false; 239 + ok_tagName = false; 240 + ok_gpsTag = false; 241 + ok_valueType = false; 242 + ok_typeName = false; 243 + ok_countValues = false; 244 + ok_photoIdPk = false; 245 + ok_tagIdPk = false; 246 + err_pk = false; 247 + strcpy(xsql, "PRAGMA table_info(ExifTags)"); 248 + ret = 249 + sqlite3_get_table(SqliteHandle, xsql, &results, &rows, &columns, &errMsg); 250 + if (ret != SQLITE_OK) 251 + { 252 + wxMessageBox(wxT("PRAGMA table_info(ExifTags) error: ") + 253 + wxString::FromUTF8(errMsg), wxT("spatialite-gui"), 254 + wxOK | wxICON_ERROR, this); 255 + sqlite3_free(errMsg); 256 + goto abort; 257 + } 258 + if (rows < 1) 259 + ; 260 + else 261 + { 262 + for (i = 1; i <= rows; i++) 263 + { 264 + name = results[(i * columns) + 1]; 265 + if (atoi(results[(i * columns) + 5]) == 0) 266 + pKey = false; 267 + else 268 + pKey = true; 269 + if (strcasecmp(name, "PhotoId") == 0) 270 + ok_photoId = true; 271 + if (strcasecmp(name, "TagId") == 0) 272 + ok_tagId = true; 273 + if (strcasecmp(name, "TagName") == 0) 274 + ok_tagName = true; 275 + if (strcasecmp(name, "GpsTag") == 0) 276 + ok_gpsTag = true; 277 + if (strcasecmp(name, "ValueType") == 0) 278 + ok_valueType = true; 279 + if (strcasecmp(name, "TypeName") == 0) 280 + ok_typeName = true; 281 + if (strcasecmp(name, "CountValues") == 0) 282 + ok_countValues = true; 283 + if (pKey == true) 284 + { 285 + if (strcasecmp(name, "PhotoId") == 0) 286 + ok_photoIdPk = true; 287 + else if (strcasecmp(name, "TagId") == 0) 288 + ok_tagIdPk = true; 289 + else 290 + err_pk = true; 291 + } 292 + } 293 + } 294 + sqlite3_free_table(results); 295 + if (ok_photoId == true && ok_tagId == true && ok_tagName == true 296 + && ok_gpsTag == true && ok_valueType == true && ok_typeName == true 297 + && ok_countValues == true && ok_photoIdPk == true && ok_tagIdPk == true 298 + && err_pk == false) 299 + ; 300 + else 301 + { 302 + wxMessageBox(wxT 303 + ("ERROR: table ExifTags already exists, but has incompatible columns"), 304 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 305 + sqlite3_free(errMsg); 306 + goto abort; 307 + } 308 +// creating the ExifValues table 309 + sql = wxT("CREATE TABLE IF NOT EXISTS ExifValues (\n"); 310 + sql += wxT("PhotoId INTEGER NOT NULL,\n"); 311 + sql += wxT("TagId INTEGER NOT NULL,\n"); 312 + sql += wxT("ValueIndex INTEGER NOT NULL,\n"); 313 + sql += wxT("ByteValue BLOB,\n"); 314 + sql += wxT("StringValue TEXT,\n"); 315 + sql += wxT("NumValue INTEGER,\n"); 316 + sql += wxT("NumValueBis INTEGER,\n"); 317 + sql += wxT("DoubleValue DOUBLE,\n"); 318 + sql += wxT("HumanReadable TEXT,\n"); 319 + sql += wxT("PRIMARY KEY (PhotoId, TagId, ValueIndex)"); 320 + sql += wxT(")"); 321 + strcpy(xsql, sql.ToUTF8()); 322 + ret = sqlite3_exec(SqliteHandle, xsql, NULL, NULL, &errMsg); 323 + if (ret != SQLITE_OK) 324 + { 325 + wxMessageBox(wxT("CREATE TABLE ExifValues error: ") + 326 + wxString::FromUTF8(errMsg), wxT("spatialite-gui"), 327 + wxOK | wxICON_ERROR, this); 328 + sqlite3_free(errMsg); 329 + goto abort; 330 + } 331 +// checking the ExifValues table for sanity 332 + ok_photoId = false; 333 + ok_tagId = false; 334 + ok_valueIndex = false; 335 + ok_byteValue = false; 336 + ok_stringValue = false; 337 + ok_numValue = false; 338 + ok_numValueBis = false; 339 + ok_doubleValue = false; 340 + ok_humanReadable = false; 341 + ok_photoIdPk = false; 342 + ok_tagIdPk = false; 343 + ok_valueIndexPk = false; 344 + err_pk = false; 345 + strcpy(xsql, "PRAGMA table_info(ExifValues)"); 346 + ret = 347 + sqlite3_get_table(SqliteHandle, xsql, &results, &rows, &columns, &errMsg); 348 + if (ret != SQLITE_OK) 349 + { 350 + wxMessageBox(wxT("PRAGMA table_info(ExifValues) error: ") + 351 + wxString::FromUTF8(errMsg), wxT("spatialite-gui"), 352 + wxOK | wxICON_ERROR, this); 353 + sqlite3_free(errMsg); 354 + goto abort; 355 + } 356 + if (rows < 1) 357 + ; 358 + else 359 + { 360 + for (i = 1; i <= rows; i++) 361 + { 362 + name = results[(i * columns) + 1]; 363 + if (atoi(results[(i * columns) + 5]) == 0) 364 + pKey = false; 365 + else 366 + pKey = true; 367 + if (strcasecmp(name, "PhotoId") == 0) 368 + ok_photoId = true; 369 + if (strcasecmp(name, "TagId") == 0) 370 + ok_tagId = true; 371 + if (strcasecmp(name, "ValueIndex") == 0) 372 + ok_valueIndex = true; 373 + if (strcasecmp(name, "ByteValue") == 0) 374 + ok_byteValue = true; 375 + if (strcasecmp(name, "StringValue") == 0) 376 + ok_stringValue = true; 377 + if (strcasecmp(name, "NumValue") == 0) 378 + ok_numValue = true; 379 + if (strcasecmp(name, "NumValueBis") == 0) 380 + ok_numValueBis = true; 381 + if (strcasecmp(name, "DoubleValue") == 0) 382 + ok_doubleValue = true; 383 + if (strcasecmp(name, "HumanReadable") == 0) 384 + ok_humanReadable = true; 385 + if (pKey == true) 386 + { 387 + if (strcasecmp(name, "PhotoId") == 0) 388 + ok_photoIdPk = true; 389 + else if (strcasecmp(name, "TagId") == 0) 390 + ok_tagIdPk = true; 391 + else if (strcasecmp(name, "ValueIndex") == 0) 392 + ok_valueIndexPk = true; 393 + else 394 + err_pk = true; 395 + } 396 + } 397 + } 398 + sqlite3_free_table(results); 399 + if (ok_photoId == true && ok_tagId == true && ok_valueIndex == true 400 + && ok_byteValue == true && ok_stringValue == true && ok_numValue == true 401 + && ok_numValueBis == true && ok_doubleValue == true 402 + && ok_humanReadable == true && ok_photoIdPk == true && ok_tagIdPk == true 403 + && ok_valueIndexPk == true && err_pk == false) 404 + ; 405 + else 406 + { 407 + wxMessageBox(wxT 408 + ("ERROR: table ExifValues already exists, but has incompatible columns"), 409 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 410 + sqlite3_free(errMsg); 411 + goto abort; 412 + } 413 +// creating the ExifView view 414 + sql = wxT("CREATE VIEW IF NOT EXISTS ExifMetadata AS\n"); 415 + sql += wxT("SELECT p.PhotoId AS PhotoId, "); 416 + sql += wxT("t.TagId AS TagId, "); 417 + sql += wxT("t.TagName AS TagName,"); 418 + sql += wxT("t.GpsTag AS GpsTag,\n"); 419 + sql += wxT("t.ValueType AS ValueType,"); 420 + sql += wxT("t.TypeName AS TypeName, "); 421 + sql += wxT("t.CountValues AS CountValues, "); 422 + sql += wxT("v.ValueIndex AS ValueIndex,\n"); 423 + sql += wxT("v.ByteValue AS ByteValue, "); 424 + sql += wxT("v.StringValue AS StringValue, "); 425 + sql += wxT("v.NumValue AS NumValue, "); 426 + sql += wxT("v.NumValueBis AS NumValueBis,\n"); 427 + sql += wxT("v.DoubleValue AS DoubleValue, "); 428 + sql += wxT("v.HumanReadable AS HumanReadable\n"); 429 + sql += wxT("FROM ExifPhoto AS p, ExifTags AS t, ExifValues AS v\n"); 430 + sql += 431 + wxT 432 + ("WHERE t.PhotoId = p.PhotoId AND v.PhotoId = t.PhotoId AND v.TagId = t.TagId"); 433 + strcpy(xsql, sql.ToUTF8()); 434 + ret = sqlite3_exec(SqliteHandle, xsql, NULL, NULL, &errMsg); 435 + if (ret != SQLITE_OK) 436 + { 437 + wxMessageBox(wxT("CREATE VIEW ExifMetadata error: ") + 438 + wxString::FromUTF8(errMsg), wxT("spatialite-gui"), 439 + wxOK | wxICON_ERROR, this); 440 + sqlite3_free(errMsg); 441 + goto abort; 442 + } 443 + return true; 444 +abort: 445 + return false; 446 +} 447 + 448 +int MyFrame::ExifLoadDir(wxString & path, bool gps_only, bool metadata) 449 +{ 450 +// 451 +// importing EXIF files from a whole DIRECTORY 452 +// 453 + int cnt = 0; 454 + wxString filePath; 455 + struct dirent *entry; 456 + DIR *dir = opendir(path.ToUTF8()); 457 + if (!dir) 458 + return 0; 459 + while (1) 460 + { 461 + // scanning dir-entries 462 + entry = readdir(dir); 463 + if (!entry) 464 + break; 465 + filePath = path; 466 + filePath += wxT("/") + wxString::FromUTF8(entry->d_name); 467 + cnt += ExifLoadFile(filePath, gps_only, metadata); 468 + } 469 + closedir(dir); 470 + return cnt; 471 +} 472 + 473 +int MyFrame::ExifLoadFile(wxString & path, bool gps_only, bool metadata) 474 +{ 475 +// 476 +// importing a single EXIF file 477 +// 478 + FILE *fl; 479 + int sz = 0; 480 + int rd; 481 + int loaded = 0; 482 + unsigned char *blob = NULL; 483 + gaiaExifTagListPtr tag_list = NULL; 484 + fl = fopen(path.ToUTF8(), "rb"); 485 + if (!fl) 486 + return 0; 487 + if (fseek(fl, 0, SEEK_END) == 0) 488 + sz = ftell(fl); 489 + if (sz > 14) 490 + { 491 + blob = (unsigned char *) malloc(sz); 492 + rewind(fl); 493 + rd = fread(blob, 1, sz, fl); 494 + if (rd == sz) 495 + { 496 + tag_list = gaiaGetExifTags(blob, sz); 497 + if (tag_list) 498 + { 499 + if (gps_only && IsExifGps(tag_list) == false) 500 + goto stop; 501 + if (UpdateExifTables(blob, sz, tag_list, metadata, path) == false) 502 + goto stop; 503 + loaded = 1; 504 + } 505 + } 506 + } 507 +stop: 508 + if (blob) 509 + free(blob); 510 + if (tag_list) 511 + gaiaExifTagsFree(tag_list); 512 + fclose(fl); 513 + return loaded; 514 +} 515 + 516 +bool MyFrame::IsExifGps(gaiaExifTagListPtr tag_list) 517 +{ 518 +// 519 +// checks if this one is a GPS-tagged EXIF 520 +// 521 + bool gps_lat = false; 522 + bool gps_long = false; 523 + gaiaExifTagPtr pT = tag_list->First; 524 + while (pT) 525 + { 526 + if (pT->Gps && pT->TagId == 0x04) 527 + gps_long = true; 528 + if (pT->Gps && pT->TagId == 0x02) 529 + gps_lat = true; 530 + if (gps_long == true && gps_lat == true) 531 + return true; 532 + pT = pT->Next; 533 + } 534 + return false; 535 +} 536 + 537 +bool MyFrame::UpdateExifTables(unsigned char *blob, int sz, 538 + gaiaExifTagListPtr tag_list, bool metadata, 539 + wxString & path) 540 +{ 541 +// 542 +// inserting an EXIF photo into the DB 543 +// 544 + int i; 545 + int iv; 546 + bool ok; 547 + int xok; 548 + int ok_human; 549 + char tag_name[128]; 550 + gaiaExifTagPtr pT; 551 + int ret; 552 + char sql[1024]; 553 + char human[1024]; 554 + wxString make; 555 + wxString model; 556 + wxString satellites; 557 + wxString date; 558 + wxString timestamp; 559 + char *errMsg = NULL; 560 + sqlite3_stmt *stmt; 561 + sqlite3_int64 pk = 0; 562 + sqlite3_int64 val64; 563 + double dblval; 564 + const char *type_desc; 565 + double longitude; 566 + double latitude; 567 + gaiaGeomCollPtr geom; 568 + unsigned char *geoblob; 569 + int geosize; 570 +// starts a transaction 571 + strcpy(sql, "BEGIN"); 572 + ret = sqlite3_exec(SqliteHandle, sql, NULL, NULL, &errMsg); 573 + if (ret != SQLITE_OK) 574 + { 575 + wxMessageBox(wxT("BEGIN error: ") + wxString::FromUTF8(errMsg), 576 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 577 + sqlite3_free(errMsg); 578 + goto abort; 579 + } 580 +// feeding the ExifPhoto table; preparing the SQL statement 581 + strcpy(sql, 582 + "INSERT INTO ExifPhoto (PhotoId, Photo, PixelX, PixelY, CameraMake, CameraModel, "); 583 + strcat(sql, 584 + "ShotDateTime, GpsGeometry, GpsDirection, GpsSatellites, GpsTimestamp, FromPath) "); 585 + strcat(sql, 586 + "VALUES (NULL, ?, ?, ?, ?, ?, JulianDay(?), ?, ?, ?, JulianDay(?), ?)"); 587 + ret = sqlite3_prepare_v2(SqliteHandle, sql, strlen(sql), &stmt, NULL); 588 + if (ret != SQLITE_OK) 589 + { 590 + wxMessageBox(wxT("INSERT INTO ExifPhoto error: ") + 591 + wxString::FromUTF8(sqlite3_errmsg(SqliteHandle)), 592 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 593 + goto abort; 594 + } 595 + sqlite3_bind_blob(stmt, 1, blob, sz, SQLITE_STATIC); 596 + val64 = GetPixelX(tag_list, &ok); 597 + if (ok == true) 598 + sqlite3_bind_int64(stmt, 2, val64); 599 + else 600 + sqlite3_bind_null(stmt, 2); 601 + val64 = GetPixelY(tag_list, &ok); 602 + if (ok == true) 603 + sqlite3_bind_int64(stmt, 3, val64); 604 + else 605 + sqlite3_bind_null(stmt, 3); 606 + GetMake(tag_list, make, &ok); 607 + if (ok == true) 608 + sqlite3_bind_text(stmt, 4, make.ToUTF8(), make.Len(), SQLITE_TRANSIENT); 609 + else 610 + sqlite3_bind_null(stmt, 4); 611 + GetModel(tag_list, model, &ok); 612 + if (ok == true) 613 + sqlite3_bind_text(stmt, 5, model.ToUTF8(), model.Len(), SQLITE_TRANSIENT); 614 + else 615 + sqlite3_bind_null(stmt, 5); 616 + GetDate(tag_list, date, &ok); 617 + if (ok == true) 618 + sqlite3_bind_text(stmt, 6, date.ToUTF8(), date.Len(), SQLITE_TRANSIENT); 619 + else 620 + sqlite3_bind_text(stmt, 6, "0000-00-00 00:00:00", 19, SQLITE_TRANSIENT); 621 + GetGpsCoords(tag_list, &longitude, &latitude, &ok); 622 + if (ok == true) 623 + { 624 + geom = gaiaAllocGeomColl(); 625 + geom->Srid = 4326; 626 + gaiaAddPointToGeomColl(geom, longitude, latitude); 627 + gaiaToSpatiaLiteBlobWkb(geom, &geoblob, &geosize); 628 + gaiaFreeGeomColl(geom); 629 + sqlite3_bind_blob(stmt, 7, geoblob, geosize, SQLITE_TRANSIENT); 630 + free(geoblob); 631 + } else 632 + sqlite3_bind_null(stmt, 7); 633 + dblval = GetGpsDirection(tag_list, &ok); 634 + if (ok == true) 635 + sqlite3_bind_double(stmt, 8, dblval); 636 + else 637 + sqlite3_bind_null(stmt, 8); 638 + GetGpsSatellites(tag_list, satellites, &ok); 639 + if (ok == true) 640 + sqlite3_bind_text(stmt, 9, satellites.ToUTF8(), satellites.Len(), 641 + SQLITE_TRANSIENT); 642 + else 643 + sqlite3_bind_null(stmt, 9); 644 + GetGpsTimestamp(tag_list, timestamp, &ok); 645 + if (ok == true) 646 + sqlite3_bind_text(stmt, 10, timestamp.ToUTF8(), timestamp.Len(), 647 + SQLITE_TRANSIENT); 648 + else 649 + sqlite3_bind_text(stmt, 10, "0000-00-00 00:00:00", 19, SQLITE_TRANSIENT); 650 + sqlite3_bind_text(stmt, 11, path.ToUTF8(), path.Len(), SQLITE_TRANSIENT); 651 + ret = sqlite3_step(stmt); 652 + if (ret == SQLITE_DONE || ret == SQLITE_ROW) 653 + ; 654 + else 655 + { 656 + wxMessageBox(wxT("sqlite3_step() error: ") + 657 + wxString::FromUTF8(sqlite3_errmsg(SqliteHandle)), 658 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 659 + sqlite3_finalize(stmt); 660 + goto abort; 661 + } 662 + sqlite3_finalize(stmt); 663 + pk = sqlite3_last_insert_rowid(SqliteHandle); 664 + if (metadata) 665 + { 666 + // feeding the ExifTags table; preparing the SQL statement 667 + strcpy(sql, 668 + "INSERT OR IGNORE INTO ExifTags (PhotoId, TagId, TagName, GpsTag, ValueType, "); 669 + strcat(sql, "TypeName, CountValues) VALUES (?, ?, ?, ?, ?, ?, ?)"); 670 + ret = sqlite3_prepare_v2(SqliteHandle, sql, strlen(sql), &stmt, NULL); 671 + if (ret != SQLITE_OK) 672 + { 673 + wxMessageBox(wxT("INSERT INTO ExifTags error: ") + 674 + wxString::FromUTF8(sqlite3_errmsg(SqliteHandle)), 675 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 676 + goto abort; 677 + } 678 + for (i = 0; i < gaiaGetExifTagsCount(tag_list); i++) 679 + { 680 + pT = gaiaGetExifTagByPos(tag_list, i); 681 + if (pT) 682 + { 683 + gaiaExifTagGetName(pT, tag_name, 128); 684 + switch (gaiaExifTagGetValueType(pT)) 685 + { 686 + case 1: 687 + type_desc = "BYTE"; 688 + break; 689 + case 2: 690 + type_desc = "STRING"; 691 + break; 692 + case 3: 693 + type_desc = "SHORT"; 694 + break; 695 + case 4: 696 + type_desc = "LONG"; 697 + break; 698 + case 5: 699 + type_desc = "RATIONAL"; 700 + break; 701 + case 6: 702 + type_desc = "SBYTE"; 703 + break; 704 + case 7: 705 + type_desc = "UNDEFINED"; 706 + break; 707 + case 8: 708 + type_desc = "SSHORT"; 709 + break; 710 + case 9: 711 + type_desc = "SLONG"; 712 + break; 713 + case 10: 714 + type_desc = "SRATIONAL"; 715 + break; 716 + case 11: 717 + type_desc = "FLOAT"; 718 + break; 719 + case 12: 720 + type_desc = "DOUBLE"; 721 + break; 722 + default: 723 + type_desc = "UNKNOWN"; 724 + break; 725 + }; 726 + // INSERTing an Exif Tag 727 + sqlite3_reset(stmt); 728 + sqlite3_clear_bindings(stmt); 729 + sqlite3_bind_int64(stmt, 1, pk); 730 + sqlite3_bind_int(stmt, 2, gaiaExifTagGetId(pT)); 731 + sqlite3_bind_text(stmt, 3, tag_name, strlen(tag_name), 732 + SQLITE_STATIC); 733 + sqlite3_bind_int(stmt, 4, gaiaIsExifGpsTag(pT)); 734 + sqlite3_bind_int(stmt, 5, gaiaExifTagGetValueType(pT)); 735 + sqlite3_bind_text(stmt, 6, type_desc, strlen(type_desc), 736 + SQLITE_STATIC); 737 + sqlite3_bind_int(stmt, 7, gaiaExifTagGetNumValues(pT)); 738 + ret = sqlite3_step(stmt); 739 + if (ret == SQLITE_DONE || ret == SQLITE_ROW) 740 + ; 741 + else 742 + { 743 + wxMessageBox(wxT("sqlite3_step() error: ") + 744 + wxString::FromUTF8(sqlite3_errmsg(SqliteHandle)), 745 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, 746 + this); 747 + sqlite3_finalize(stmt); 748 + goto abort; 749 + } 750 + } 751 + } 752 + sqlite3_finalize(stmt); 753 + // feeding the ExifValues table; preparing the SQL statement 754 + strcpy(sql, 755 + "INSERT OR IGNORE INTO ExifValues (PhotoId, TagId, ValueIndex, ByteValue, "); 756 + strcat(sql, 757 + "StringValue, NumValue, NumValueBis, DoubleValue, HumanReadable) VALUES "); 758 + strcat(sql, "(?, ?, ?, ?, ?, ?, ?, ?, ?)"); 759 + ret = sqlite3_prepare_v2(SqliteHandle, sql, strlen(sql), &stmt, NULL); 760 + if (ret != SQLITE_OK) 761 + { 762 + wxMessageBox(wxT("NSERT INTO ExifValues error: ") + 763 + wxString::FromUTF8(sqlite3_errmsg(SqliteHandle)), 764 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 765 + goto abort; 766 + } 767 + for (i = 0; i < gaiaGetExifTagsCount(tag_list); i++) 768 + { 769 + pT = gaiaGetExifTagByPos(tag_list, i); 770 + if (pT) 771 + { 772 + gaiaExifTagGetHumanReadable(pT, human, 1024, &ok_human); 773 + for (iv = 0; iv < gaiaExifTagGetNumValues(pT); iv++) 774 + { 775 + // INSERTing an Exif Tag 776 + sqlite3_reset(stmt); 777 + sqlite3_clear_bindings(stmt); 778 + sqlite3_bind_int64(stmt, 1, pk); 779 + sqlite3_bind_int(stmt, 2, gaiaExifTagGetId(pT)); 780 + sqlite3_bind_int(stmt, 3, iv); 781 + if (gaiaExifTagGetValueType(pT) == 1 782 + || gaiaExifTagGetValueType(pT) == 6 783 + || gaiaExifTagGetValueType(pT) == 7) 784 + { 785 + sqlite3_bind_blob(stmt, 4, pT->ByteValue, pT->Count, 786 + SQLITE_STATIC); 787 + sqlite3_bind_null(stmt, 5); 788 + sqlite3_bind_null(stmt, 6); 789 + sqlite3_bind_null(stmt, 7); 790 + sqlite3_bind_null(stmt, 8); 791 + } 792 + if (gaiaExifTagGetValueType(pT) == 2) 793 + { 794 + sqlite3_bind_null(stmt, 4); 795 + sqlite3_bind_text(stmt, 5, pT->StringValue, 796 + strlen(pT->StringValue), SQLITE_STATIC); 797 + sqlite3_bind_null(stmt, 6); 798 + sqlite3_bind_null(stmt, 7); 799 + sqlite3_bind_null(stmt, 8); 800 + } 801 + if (gaiaExifTagGetValueType(pT) == 3) 802 + { 803 + sqlite3_bind_null(stmt, 4); 804 + sqlite3_bind_null(stmt, 5); 805 + val64 = gaiaExifTagGetShortValue(pT, iv, &xok); 806 + if (!ok) 807 + sqlite3_bind_null(stmt, 6); 808 + else 809 + sqlite3_bind_int64(stmt, 6, val64); 810 + sqlite3_bind_null(stmt, 7); 811 + sqlite3_bind_null(stmt, 8); 812 + } 813 + if (gaiaExifTagGetValueType(pT) == 4) 814 + { 815 + sqlite3_bind_null(stmt, 4); 816 + sqlite3_bind_null(stmt, 5); 817 + val64 = gaiaExifTagGetLongValue(pT, iv, &xok); 818 + if (!ok) 819 + sqlite3_bind_null(stmt, 6); 820 + else 821 + sqlite3_bind_int64(stmt, 6, val64); 822 + sqlite3_bind_null(stmt, 7); 823 + sqlite3_bind_null(stmt, 8); 824 + } 825 + if (gaiaExifTagGetValueType(pT) == 5) 826 + { 827 + sqlite3_bind_null(stmt, 4); 828 + sqlite3_bind_null(stmt, 5); 829 + val64 = gaiaExifTagGetRational1Value(pT, iv, &xok); 830 + if (!ok) 831 + sqlite3_bind_null(stmt, 6); 832 + else 833 + sqlite3_bind_int64(stmt, 6, val64); 834 + val64 = gaiaExifTagGetRational2Value(pT, iv, &xok); 835 + if (!ok) 836 + sqlite3_bind_null(stmt, 7); 837 + else 838 + sqlite3_bind_int64(stmt, 7, val64); 839 + dblval = gaiaExifTagGetRationalValue(pT, iv, &xok); 840 + if (!ok) 841 + sqlite3_bind_null(stmt, 8); 842 + else 843 + sqlite3_bind_double(stmt, 8, dblval); 844 + } 845 + if (gaiaExifTagGetValueType(pT) == 9) 846 + { 847 + sqlite3_bind_null(stmt, 4); 848 + sqlite3_bind_null(stmt, 5); 849 + val64 = gaiaExifTagGetSignedLongValue(pT, iv, &xok); 850 + if (!ok) 851 + sqlite3_bind_null(stmt, 6); 852 + else 853 + sqlite3_bind_int64(stmt, 6, val64); 854 + sqlite3_bind_null(stmt, 7); 855 + sqlite3_bind_null(stmt, 8); 856 + } 857 + if (gaiaExifTagGetValueType(pT) == 10) 858 + { 859 + sqlite3_bind_null(stmt, 4); 860 + sqlite3_bind_null(stmt, 5); 861 + val64 = gaiaExifTagGetSignedRational1Value(pT, iv, &xok); 862 + if (!ok) 863 + sqlite3_bind_null(stmt, 6); 864 + else 865 + sqlite3_bind_int64(stmt, 6, val64); 866 + val64 = gaiaExifTagGetSignedRational2Value(pT, iv, &xok); 867 + if (!ok) 868 + sqlite3_bind_null(stmt, 7); 869 + else 870 + sqlite3_bind_int64(stmt, 7, val64); 871 + dblval = gaiaExifTagGetSignedRationalValue(pT, iv, &xok); 872 + if (!ok) 873 + sqlite3_bind_null(stmt, 8); 874 + else 875 + sqlite3_bind_double(stmt, 8, dblval); 876 + } 877 + if (gaiaExifTagGetValueType(pT) == 11) 878 + { 879 + sqlite3_bind_null(stmt, 4); 880 + sqlite3_bind_null(stmt, 5); 881 + sqlite3_bind_null(stmt, 6); 882 + sqlite3_bind_null(stmt, 7); 883 + dblval = gaiaExifTagGetFloatValue(pT, iv, &xok); 884 + if (!ok) 885 + sqlite3_bind_null(stmt, 8); 886 + else 887 + sqlite3_bind_double(stmt, 8, dblval); 888 + } 889 + if (gaiaExifTagGetValueType(pT) == 12) 890 + { 891 + sqlite3_bind_null(stmt, 4); 892 + sqlite3_bind_null(stmt, 5); 893 + sqlite3_bind_null(stmt, 6); 894 + sqlite3_bind_null(stmt, 7); 895 + dblval = gaiaExifTagGetDoubleValue(pT, iv, &xok); 896 + if (!ok) 897 + sqlite3_bind_null(stmt, 8); 898 + else 899 + sqlite3_bind_double(stmt, 8, dblval); 900 + } 901 + if (!ok_human) 902 + sqlite3_bind_null(stmt, 9); 903 + else 904 + sqlite3_bind_text(stmt, 9, human, strlen(human), 905 + SQLITE_STATIC); 906 + ret = sqlite3_step(stmt); 907 + if (ret == SQLITE_DONE || ret == SQLITE_ROW) 908 + ; 909 + else 910 + { 911 + wxMessageBox(wxT("sqlite3_step() error: ") + 912 + wxString:: 913 + FromUTF8(sqlite3_errmsg(SqliteHandle)), 914 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, 915 + this); 916 + sqlite3_finalize(stmt); 917 + goto abort; 918 + } 919 + if (gaiaExifTagGetValueType(pT) == 1 920 + || gaiaExifTagGetValueType(pT) == 2 921 + || gaiaExifTagGetValueType(pT) == 6 922 + || gaiaExifTagGetValueType(pT) == 7) 923 + break; 924 + ok_human = 0; 925 + } 926 + } 927 + } 928 + sqlite3_finalize(stmt); 929 + } 930 +// commits the transaction 931 + strcpy(sql, "COMMIT"); 932 + ret = sqlite3_exec(SqliteHandle, sql, NULL, NULL, &errMsg); 933 + if (ret != SQLITE_OK) 934 + { 935 + wxMessageBox(wxT("COMMIT error: ") + wxString::FromUTF8(errMsg), 936 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 937 + sqlite3_free(errMsg); 938 + } 939 + return true; 940 +abort: 941 +// rolling back the transaction 942 + strcpy(sql, "ROLLBACK"); 943 + ret = sqlite3_exec(SqliteHandle, sql, NULL, NULL, &errMsg); 944 + if (ret != SQLITE_OK) 945 + { 946 + wxMessageBox(wxT("ROLLBACK error: ") + wxString::FromUTF8(errMsg), 947 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 948 + sqlite3_free(errMsg); 949 + } 950 + return false; 951 +} 952 + 953 +sqlite3_int64 MyFrame::GetPixelX(gaiaExifTagListPtr tag_list, bool * ok) 954 +{ 955 +// 956 +// trying to retrieve the ExifImageWidth 957 +// 958 + *ok = false; 959 + if (!tag_list) 960 + return 0; 961 + gaiaExifTagPtr tag = tag_list->First; 962 + while (tag) 963 + { 964 + if (tag->TagId == 0xA002) 965 + { 966 + // ok, this one is the ExifImageWidth tag 967 + if (tag->Type == 3 && tag->Count == 1) 968 + { 969 + *ok = true; 970 + return *(tag->ShortValues + 0); 971 + } else if (tag->Type == 4 && tag->Count == 1) 972 + { 973 + *ok = true; 974 + return *(tag->LongValues + 0); 975 + } 976 + } 977 + tag = tag->Next; 978 + } 979 + return false; 980 +} 981 + 982 +sqlite3_int64 MyFrame::GetPixelY(gaiaExifTagListPtr tag_list, bool * ok) 983 +{ 984 +// 985 +// trying to retrieve the ExifImageLength 986 +// 987 + *ok = false; 988 + if (!tag_list) 989 + return 0; 990 + gaiaExifTagPtr tag = tag_list->First; 991 + while (tag) 992 + { 993 + if (tag->TagId == 0xA003) 994 + { 995 + // ok, this one is the ExifImageLength tag 996 + if (tag->Type == 3 && tag->Count == 1) 997 + { 998 + *ok = true; 999 + return *(tag->ShortValues + 0); 1000 + } else if (tag->Type == 4 && tag->Count == 1) 1001 + { 1002 + *ok = true; 1003 + return *(tag->LongValues + 0); 1004 + } 1005 + } 1006 + tag = tag->Next; 1007 + } 1008 + return false; 1009 +} 1010 + 1011 +void MyFrame::GetMake(gaiaExifTagListPtr tag_list, wxString & str, bool * ok) 1012 +{ 1013 +// 1014 +// trying to retrieve the Make 1015 +// 1016 + *ok = false; 1017 + if (!tag_list) 1018 + return; 1019 + gaiaExifTagPtr tag = tag_list->First; 1020 + while (tag) 1021 + { 1022 + if (tag->TagId == 0x010F) 1023 + { 1024 + // ok, this one is the Make tag 1025 + if (tag->Type == 2) 1026 + { 1027 + *ok = true; 1028 + str = wxString::FromUTF8(tag->StringValue); 1029 + return; 1030 + } 1031 + } 1032 + tag = tag->Next; 1033 + } 1034 + return; 1035 +} 1036 + 1037 +void MyFrame::GetModel(gaiaExifTagListPtr tag_list, wxString & str, bool * ok) 1038 +{ 1039 +// 1040 +// trying to retrieve the Model 1041 +// 1042 + *ok = false; 1043 + if (!tag_list) 1044 + return; 1045 + gaiaExifTagPtr tag = tag_list->First; 1046 + while (tag) 1047 + { 1048 + if (tag->TagId == 0x0110) 1049 + { 1050 + // ok, this one is the Model tag 1051 + if (tag->Type == 2) 1052 + { 1053 + *ok = true; 1054 + str = wxString::FromUTF8(tag->StringValue); 1055 + return; 1056 + } 1057 + } 1058 + tag = tag->Next; 1059 + } 1060 + return; 1061 +} 1062 + 1063 +void MyFrame::GetDate(gaiaExifTagListPtr tag_list, wxString & str, bool * ok) 1064 +{ 1065 +// 1066 +// trying to retrieve the Date 1067 +// 1068 + *ok = false; 1069 + if (!tag_list) 1070 + return; 1071 + gaiaExifTagPtr tag = tag_list->First; 1072 + while (tag) 1073 + { 1074 + if (tag->TagId == 0x9003) 1075 + { 1076 + // ok, this one is the DateTimeOriginal tag 1077 + if (tag->Type == 2) 1078 + { 1079 + *ok = true; 1080 + str = wxString::FromUTF8(tag->StringValue); 1081 + if (str.Len() >= 19) 1082 + { 1083 + str.SetChar(4, '-'); 1084 + str.SetChar(7, '-'); 1085 + } 1086 + return; 1087 + } 1088 + } 1089 + tag = tag->Next; 1090 + } 1091 + return; 1092 +} 1093 + 1094 +void MyFrame::GetGpsCoords(gaiaExifTagListPtr tag_list, double *longitude, 1095 + double *latitude, bool * ok) 1096 +{ 1097 +// 1098 +// trying to retrieve the GPS coordinates 1099 +// 1100 + char lat_ref = '\0'; 1101 + char long_ref = '\0'; 1102 + double lat_degs = DBL_MIN; 1103 + double lat_mins = DBL_MIN; 1104 + double lat_secs = DBL_MIN; 1105 + double long_degs = DBL_MIN; 1106 + double long_mins = DBL_MIN; 1107 + double long_secs = DBL_MIN; 1108 + double dblval; 1109 + double sign; 1110 + int xok; 1111 + *ok = false; 1112 + if (!tag_list) 1113 + return; 1114 + gaiaExifTagPtr tag = tag_list->First; 1115 + while (tag) 1116 + { 1117 + if (tag->Gps && tag->TagId == 0x01) 1118 + { 1119 + // ok, this one is the GPSLatitudeRef tag 1120 + if (tag->Type == 2) 1121 + lat_ref = *(tag->StringValue); 1122 + } 1123 + if (tag->Gps && tag->TagId == 0x03) 1124 + { 1125 + // ok, this one is the GPSLongitudeRef tag 1126 + if (tag->Type == 2) 1127 + long_ref = *(tag->StringValue); 1128 + } 1129 + if (tag->Gps && tag->TagId == 0x02) 1130 + { 1131 + // ok, this one is the GPSLatitude tag 1132 + if (tag->Type == 5 && tag->Count == 3) 1133 + { 1134 + dblval = gaiaExifTagGetRationalValue(tag, 0, &xok); 1135 + if (xok) 1136 + lat_degs = dblval; 1137 + dblval = gaiaExifTagGetRationalValue(tag, 1, &xok); 1138 + if (xok) 1139 + lat_mins = dblval; 1140 + dblval = gaiaExifTagGetRationalValue(tag, 2, &xok); 1141 + if (xok) 1142 + lat_secs = dblval; 1143 + } 1144 + } 1145 + if (tag->Gps && tag->TagId == 0x04) 1146 + { 1147 + // ok, this one is the GPSLongitude tag 1148 + if (tag->Type == 5 && tag->Count == 3) 1149 + { 1150 + dblval = gaiaExifTagGetRationalValue(tag, 0, &xok); 1151 + if (xok) 1152 + long_degs = dblval; 1153 + dblval = gaiaExifTagGetRationalValue(tag, 1, &xok); 1154 + if (xok) 1155 + long_mins = dblval; 1156 + dblval = gaiaExifTagGetRationalValue(tag, 2, &xok); 1157 + if (xok) 1158 + long_secs = dblval; 1159 + } 1160 + } 1161 + tag = tag->Next; 1162 + } 1163 + if ((lat_ref == 'N' || lat_ref == 'S' || long_ref == 'E' || long_ref == 'W') 1164 + && lat_degs != DBL_MIN && lat_mins != DBL_MIN && lat_secs != DBL_MIN 1165 + && long_degs != DBL_MIN && long_mins != DBL_MIN && long_secs != DBL_MIN) 1166 + { 1167 + *ok = true; 1168 + if (lat_ref == 'S') 1169 + sign = -1.0; 1170 + else 1171 + sign = 1.0; 1172 + lat_degs = math_round(lat_degs * 1000000.0); 1173 + lat_mins = math_round(lat_mins * 1000000.0); 1174 + lat_secs = math_round(lat_secs * 1000000.0); 1175 + dblval = 1176 + math_round(lat_degs + (lat_mins / 60.0) + 1177 + (lat_secs / 3600.0)) * (sign / 1000000.0); 1178 + *latitude = dblval; 1179 + if (long_ref == 'W') 1180 + sign = -1.0; 1181 + else 1182 + sign = 1.0; 1183 + long_degs = math_round(long_degs * 1000000.0); 1184 + long_mins = math_round(long_mins * 1000000.0); 1185 + long_secs = math_round(long_secs * 1000000.0); 1186 + dblval = 1187 + math_round(long_degs + (long_mins / 60.0) + 1188 + (long_secs / 3600.0)) * (sign / 1000000.0); 1189 + *longitude = dblval; 1190 + } 1191 + return; 1192 +} 1193 + 1194 +void MyFrame::GetGpsSatellites(gaiaExifTagListPtr tag_list, wxString & str, 1195 + bool * ok) 1196 +{ 1197 +// 1198 +// trying to retrieve the GPSSatellites 1199 +// 1200 + *ok = false; 1201 + if (!tag_list) 1202 + return; 1203 + gaiaExifTagPtr tag = tag_list->First; 1204 + while (tag) 1205 + { 1206 + if (tag->Gps && tag->TagId == 0x08) 1207 + { 1208 + // ok, this one is the GPSSatellites tag 1209 + if (tag->Type == 2) 1210 + { 1211 + *ok = true; 1212 + str = wxString::FromUTF8(tag->StringValue); 1213 + return; 1214 + } 1215 + } 1216 + tag = tag->Next; 1217 + } 1218 + return; 1219 +} 1220 + 1221 +double MyFrame::GetGpsDirection(gaiaExifTagListPtr tag_list, bool * ok) 1222 +{ 1223 +// 1224 +// trying to retrieve the GPS direction 1225 +// 1226 + char dir_ref = '\0'; 1227 + double direction = DBL_MIN; 1228 + double dblval; 1229 + int xok; 1230 + *ok = false; 1231 + if (!tag_list) 1232 + return direction; 1233 + gaiaExifTagPtr tag = tag_list->First; 1234 + while (tag) 1235 + { 1236 + if (tag->Gps && tag->TagId == 0x10) 1237 + { 1238 + // ok, this one is the GPSDirectionRef tag 1239 + if (tag->Type == 2) 1240 + dir_ref = *(tag->StringValue); 1241 + } 1242 + if (tag->Gps && tag->TagId == 0x11) 1243 + { 1244 + // ok, this one is the GPSDirection tag 1245 + if (tag->Type == 5 && tag->Count == 1) 1246 + { 1247 + dblval = gaiaExifTagGetRationalValue(tag, 0, &xok); 1248 + if (xok) 1249 + direction = dblval; 1250 + } 1251 + } 1252 + tag = tag->Next; 1253 + } 1254 + if ((dir_ref == 'T' || dir_ref == 'M') && direction != DBL_MIN) 1255 + *ok = true; 1256 + return direction; 1257 +} 1258 + 1259 +void MyFrame::GetGpsTimestamp(gaiaExifTagListPtr tag_list, wxString & str, 1260 + bool * ok) 1261 +{ 1262 +// 1263 +// trying to retrieve the GPS Timestamp 1264 +// 1265 + char date[16]; 1266 + char timestamp[32]; 1267 + double hours = DBL_MIN; 1268 + double mins = DBL_MIN; 1269 + double secs = DBL_MIN; 1270 + double dblval; 1271 + int xok; 1272 + int hh; 1273 + int mm; 1274 + int ss; 1275 + int millis; 1276 + *ok = false; 1277 + if (!tag_list) 1278 + return; 1279 + strcpy(date, "0000-00-00"); 1280 + gaiaExifTagPtr tag = tag_list->First; 1281 + while (tag) 1282 + { 1283 + if (tag->Gps && tag->TagId == 0x1D) 1284 + { 1285 + // ok, this one is the GPSDateStamp tag 1286 + if (tag->Type == 2) 1287 + { 1288 + strcpy(date, tag->StringValue); 1289 + date[4] = '-'; 1290 + date[7] = '-'; 1291 + } 1292 + } 1293 + if (tag->Gps && tag->TagId == 0x07) 1294 + { 1295 + // ok, this one is the GPSTimeStamp tag 1296 + if (tag->Type == 5 && tag->Count == 3) 1297 + { 1298 + dblval = gaiaExifTagGetRationalValue(tag, 0, &xok); 1299 + if (xok) 1300 + hours = dblval; 1301 + dblval = gaiaExifTagGetRationalValue(tag, 1, &xok); 1302 + if (xok) 1303 + mins = dblval; 1304 + dblval = gaiaExifTagGetRationalValue(tag, 2, &xok); 1305 + if (xok) 1306 + secs = dblval; 1307 + } 1308 + } 1309 + tag = tag->Next; 1310 + } 1311 + if (hours != DBL_MIN && mins != DBL_MIN && secs != DBL_MIN) 1312 + { 1313 + *ok = true; 1314 + hh = (int) floor(hours); 1315 + mm = (int) floor(mins); 1316 + ss = (int) floor(secs); 1317 + millis = (int) ((secs - ss) * 1000); 1318 + sprintf(timestamp, "%s %02d:%02d:%02d.%03d", date, hh, mm, ss, millis); 1319 + str = wxString::FromUTF8(timestamp); 1320 + } 1321 + return; 1322 +}
Changes to Main.cpp.
1 1 /* 2 2 / Main.cpp 3 3 / the main core of spatialite-gui - a SQLite /SpatiaLite GUI tool 4 4 / 5 -/ version 1.1, 2008 September 13 5 +/ version 1.2, 2008 October 9 6 6 / 7 7 / Author: Sandro Furieri a-furieri@lqt.it 8 8 / 9 9 / Copyright (C) 2008 Alessandro Furieri 10 10 / 11 11 / This program is free software: you can redistribute it and/or modify 12 12 / it under the terms of the GNU General Public License as published by ................................................................................ 24 24 */ 25 25 26 26 #include "Classdef.h" 27 27 28 28 #include "wx/menu.h" 29 29 #include "wx/aboutdlg.h" 30 30 #include "wx/filename.h" 31 +#include "wx/config.h" 31 32 32 33 #include <spatialite.h> 33 34 #include <proj_api.h> 34 35 #include <geos_c.h> 35 36 36 37 // 37 38 // ICONs in XPM format [universally portable] 38 39 // 39 40 #include "icons/icon.xpm" 41 +#include "icons/icon_info.xpm" 40 42 #include "icons/create_new.xpm" 41 43 #include "icons/connect.xpm" 42 44 #include "icons/disconnect.xpm" 45 +#include "icons/memdb_load.xpm" 46 +#include "icons/memdb_new.xpm" 47 +#include "icons/memdb_clock.xpm" 48 +#include "icons/memdb_save.xpm" 43 49 #include "icons/vacuum.xpm" 44 50 #include "icons/sql_script.xpm" 45 51 #include "icons/loadshp.xpm" 46 52 #include "icons/virtshp.xpm" 47 53 #include "icons/loadtxt.xpm" 48 54 #include "icons/virttxt.xpm" 55 +#include "icons/network.xpm" 56 +#include "icons/exif.xpm" 49 57 #include "icons/srids.xpm" 50 58 #include "icons/charset.xpm" 51 59 #include "icons/help.xpm" 52 60 #include "icons/about.xpm" 53 61 #include "icons/exit.xpm" 54 62 55 -IMPLEMENT_APP (MyApp) 56 - bool MyApp::OnInit () 63 +IMPLEMENT_APP(MyApp) 64 + bool MyApp::OnInit() 57 65 { 58 66 // 59 67 // main APP implementation 60 68 // 61 - wxString path; 62 - if (argc > 1) 63 - path = argv[1]; 64 - MyFrame *frame = 65 - new 66 - MyFrame (wxT ("spatialite-gui [a GUI tool for SQLite/SpatiaLite]"), 67 - wxPoint (0, 0), wxSize (640, 480), path); 68 - frame->Show (true); 69 - SetTopWindow (frame); 70 - return true; 69 + wxString path; 70 + if (argc > 1) 71 + path = argv[1]; 72 + MyFrame *frame = 73 + new MyFrame(wxT("spatialite-gui [a GUI tool for SQLite/SpatiaLite]"), 74 + wxPoint(0, 0), wxSize(640, 480), path); 75 + frame->Show(true); 76 + SetTopWindow(frame); 77 + frame->LoadConfig(); 78 + return true; 71 79 } 72 80 73 -MyFrame::MyFrame (const wxString & title, const wxPoint & pos, const wxSize & size, wxString & path): 74 -wxFrame ((wxFrame *) NULL, -1, title, pos, 75 - size) 81 +MyFrame::MyFrame(const wxString & title, const wxPoint & pos, const wxSize & size, wxString & path): 82 +wxFrame((wxFrame *) NULL, -1, title, pos, size) 76 83 { 77 84 // 78 85 // main GUI frame constructor 79 86 // 80 - 81 -// 82 -// setting up the BLOB signatures 83 -// 84 - Jpeg1Signature[0] = 0xff; 85 - Jpeg1Signature[1] = 0xd8; 86 - Jpeg2Signature[0] = 0xff; 87 - Jpeg2Signature[1] = 0xd9; 88 - Jpeg3Signature[0] = 0xff; 89 - Jpeg3Signature[1] = 0xd8; 90 - Jpeg3Signature[2] = 0xff; 91 - Jpeg3Signature[3] = 0xe0; 92 - JfifSignature[0] = 0x4a; 93 - JfifSignature[1] = 0x46; 94 - JfifSignature[2] = 0x49; 95 - JfifSignature[3] = 0x46; 96 - ExifSignature[0] = 0x45; 97 - ExifSignature[1] = 0x78; 98 - ExifSignature[2] = 0x69; 99 - ExifSignature[3] = 0x66; 100 - PngSignature[0] = 0x89; 101 - PngSignature[1] = 0x50; 102 - PngSignature[2] = 0x4e; 103 - PngSignature[3] = 0x47; 104 - PngSignature[4] = 0x0d; 105 - PngSignature[5] = 0x0a; 106 - PngSignature[6] = 0x1a; 107 - PngSignature[7] = 0x0a; 108 - ZipSignature[0] = 0x50; 109 - ZipSignature[1] = 0x4b; 110 - ZipSignature[2] = 0x03; 111 - ZipSignature[3] = 0x04; 112 - 87 + MemoryDatabase = false; 88 + AutoSaveInterval = 0; 89 + LastTotalChanges = 0; 90 + TimerAutoSave = NULL; 113 91 // 114 92 // initializing CHARSET lists 115 93 // 116 - CharsetsLen = 79; 117 - Charsets = new wxString[CharsetsLen]; 118 - CharsetsNames = new wxString[CharsetsLen]; 119 - *(CharsetsNames + 0) = wxT ("ARMSCII-8 Armenian"); 120 - *(CharsetsNames + 1) = wxT ("ASCII US-ASCII"); 121 - *(CharsetsNames + 2) = wxT ("BIG5 Chinese/Traditional"); 122 - *(CharsetsNames + 3) = wxT ("BIG5-HKSCS Chinese/Hong Kong"); 123 - *(CharsetsNames + 4) = wxT ("BIG5-HKSCS:1999"); 124 - *(CharsetsNames + 5) = wxT ("BIG5-HKSCS:2001"); 125 - *(CharsetsNames + 6) = wxT ("CP850 DOS/OEM Western Europe"); 126 - *(CharsetsNames + 7) = wxT ("CP862 DOS/OEM Hebrew"); 127 - *(CharsetsNames + 8) = wxT ("CP866 DOS/OEM Cyrillic"); 128 - *(CharsetsNames + 9) = wxT ("CP874 DOS/OEM Thai"); 129 - *(CharsetsNames + 10) = wxT ("CP932 DOS/OEM Japanese"); 130 - *(CharsetsNames + 11) = wxT ("CP936 DOS/OEM Chinese"); 131 - *(CharsetsNames + 12) = wxT ("CP949 DOS/OEM Korean"); 132 - *(CharsetsNames + 13) = wxT ("CP950 DOS/OEM Chinese/Big5"); 133 - *(CharsetsNames + 14) = wxT ("CP1133 Laotian"); 134 - *(CharsetsNames + 15) = wxT ("CP1250 Windows Central Europe"); 135 - *(CharsetsNames + 16) = wxT ("CP1251 Windows Cyrillic"); 136 - *(CharsetsNames + 17) = wxT ("CP1252 Windows Latin 1"); 137 - *(CharsetsNames + 18) = wxT ("CP1253 Windows Greek"); 138 - *(CharsetsNames + 19) = wxT ("CP1254 Windows Turkish"); 139 - *(CharsetsNames + 20) = wxT ("CP1255 Windows Hebrew"); 140 - *(CharsetsNames + 21) = wxT ("CP1256 Windows Arabic"); 141 - *(CharsetsNames + 22) = wxT ("CP1257 Windows Baltic"); 142 - *(CharsetsNames + 23) = wxT ("CP1258 Windows Vietnamese"); 143 - *(CharsetsNames + 24) = wxT ("EUC-CN Chinese"); 144 - *(CharsetsNames + 25) = wxT ("EUC-JP Japanese"); 145 - *(CharsetsNames + 26) = wxT ("EUC-KR Korean"); 146 - *(CharsetsNames + 27) = wxT ("EUC-TW Taiwan"); 147 - *(CharsetsNames + 28) = wxT ("GB18030 Chinese/National Standard"); 148 - *(CharsetsNames + 29) = wxT ("GBK Chinese/Simplified"); 149 - *(CharsetsNames + 30) = wxT ("Georgian-Academy"); 150 - *(CharsetsNames + 31) = wxT ("Georgian-PS"); 151 - *(CharsetsNames + 32) = wxT ("HZ Chinese"); 152 - *(CharsetsNames + 33) = wxT ("ISO-2022-CN Chinese"); 153 - *(CharsetsNames + 34) = wxT ("ISO-2022-CN-EXT"); 154 - *(CharsetsNames + 35) = wxT ("ISO-2022-JP Japanese"); 155 - *(CharsetsNames + 36) = wxT ("ISO-2022-JP-1"); 156 - *(CharsetsNames + 37) = wxT ("ISO-2022-JP-2"); 157 - *(CharsetsNames + 38) = wxT ("ISO-2022-KR Korean"); 158 - *(CharsetsNames + 39) = wxT ("ISO-8859-1 Latin-1 Western European"); 159 - *(CharsetsNames + 40) = wxT ("ISO-8859-2 Latin-2 Central European"); 160 - *(CharsetsNames + 41) = wxT ("ISO-8859-3 Latin-3 South European"); 161 - *(CharsetsNames + 42) = wxT ("ISO-8859-4 Latin-4 North European"); 162 - *(CharsetsNames + 43) = wxT ("ISO-8859-5 Latin/Cyrillic"); 163 - *(CharsetsNames + 44) = wxT ("ISO-8859-6 Latin/Arabic"); 164 - *(CharsetsNames + 45) = wxT ("ISO-8859-7 Latin/Greek"); 165 - *(CharsetsNames + 46) = wxT ("ISO-8859-8 Latin/Hebrew"); 166 - *(CharsetsNames + 47) = wxT ("ISO-8859-9 Latin-5 Turkish"); 167 - *(CharsetsNames + 48) = wxT ("ISO-8859-10 Latin-6 Nordic"); 168 - *(CharsetsNames + 49) = wxT ("ISO-8859-11 Latin/Thai"); 169 - *(CharsetsNames + 50) = wxT ("ISO-8859-13 Latin-7 Baltic Rim"); 170 - *(CharsetsNames + 51) = wxT ("ISO-8859-14 Latin-8 Celtic"); 171 - *(CharsetsNames + 52) = wxT ("ISO-8859-15 Latin-9"); 172 - *(CharsetsNames + 53) = 173 - wxT ("ISO-8859-16 Latin-10 South-Eastern European"); 174 - *(CharsetsNames + 54) = wxT ("JOHAB Korean"); 175 - *(CharsetsNames + 55) = wxT ("KOI8-R Russian"); 176 - *(CharsetsNames + 56) = wxT ("KOI8-U Ukrainian"); 177 - *(CharsetsNames + 57) = wxT ("KOI8-RU Belarusian"); 178 - *(CharsetsNames + 58) = wxT ("KOI8-T Tajik"); 179 - *(CharsetsNames + 59) = wxT ("MacArabic MAC Arabic"); 180 - *(CharsetsNames + 60) = wxT ("MacCentralEurope"); 181 - *(CharsetsNames + 61) = wxT ("MacCroatian MAC Croatian"); 182 - *(CharsetsNames + 62) = wxT ("MacCyrillic MAC Cyrillic"); 183 - *(CharsetsNames + 63) = wxT ("MacGreek MAC Greek"); 184 - *(CharsetsNames + 64) = wxT ("MacHebrew MAC Hebrew"); 185 - *(CharsetsNames + 65) = wxT ("MacIceland MAC Iceland"); 186 - *(CharsetsNames + 66) = wxT ("Macintosh"); 187 - *(CharsetsNames + 67) = wxT ("MacRoman MAC European/Western languages"); 188 - *(CharsetsNames + 68) = wxT ("MacRomania MAC Romania"); 189 - *(CharsetsNames + 69) = wxT ("MacThai MAC Thai"); 190 - *(CharsetsNames + 70) = wxT ("MacTurkish MAC Turkish"); 191 - *(CharsetsNames + 71) = wxT ("MacUkraine MAC Ukraine"); 192 - *(CharsetsNames + 72) = wxT ("MuleLao-1 Laotian"); 193 - *(CharsetsNames + 73) = wxT ("PT154 Kazakh"); 194 - *(CharsetsNames + 74) = wxT ("RK1048 Kazakh"); 195 - *(CharsetsNames + 75) = wxT ("SHIFT_JIS Japanese"); 196 - *(CharsetsNames + 76) = wxT ("TCVN Vietnamese"); 197 - *(CharsetsNames + 77) = wxT ("TIS-620 Thai"); 198 - *(CharsetsNames + 77) = wxT ("UTF-8 UNICODE/Universal"); 199 - *(CharsetsNames + 78) = wxT ("VISCII Vietnamese"); 200 - *(Charsets + 0) = wxT ("ARMSCII-8"); 201 - *(Charsets + 1) = wxT ("ASCII"); 202 - *(Charsets + 2) = wxT ("BIG5"); 203 - *(Charsets + 3) = wxT ("BIG5-HKSCS"); 204 - *(Charsets + 4) = wxT ("BIG5-HKSCS:1999"); 205 - *(Charsets + 5) = wxT ("BIG5-HKSCS:2001"); 206 - *(Charsets + 6) = wxT ("CP850"); 207 - *(Charsets + 7) = wxT ("CP862"); 208 - *(Charsets + 8) = wxT ("CP866"); 209 - *(Charsets + 9) = wxT ("CP874"); 210 - *(Charsets + 10) = wxT ("CP932"); 211 - *(Charsets + 11) = wxT ("CP936"); 212 - *(Charsets + 12) = wxT ("CP949"); 213 - *(Charsets + 13) = wxT ("CP950"); 214 - *(Charsets + 14) = wxT ("CP1133"); 215 - *(Charsets + 15) = wxT ("CP1250"); 216 - *(Charsets + 16) = wxT ("CP1251"); 217 - *(Charsets + 17) = wxT ("CP1252"); 218 - *(Charsets + 18) = wxT ("CP1253"); 219 - *(Charsets + 19) = wxT ("CP1254"); 220 - *(Charsets + 20) = wxT ("CP1255"); 221 - *(Charsets + 21) = wxT ("CP1256"); 222 - *(Charsets + 22) = wxT ("CP1257"); 223 - *(Charsets + 23) = wxT ("CP1258"); 224 - *(Charsets + 24) = wxT ("EUC-CN"); 225 - *(Charsets + 25) = wxT ("EUC-JP"); 226 - *(Charsets + 26) = wxT ("EUC-KR"); 227 - *(Charsets + 27) = wxT ("EUC-TW"); 228 - *(Charsets + 28) = wxT ("GB18030"); 229 - *(Charsets + 29) = wxT ("GBK"); 230 - *(Charsets + 30) = wxT ("Georgian-Academy"); 231 - *(Charsets + 31) = wxT ("Georgian-PS"); 232 - *(Charsets + 32) = wxT ("HZ"); 233 - *(Charsets + 33) = wxT ("ISO-2022-CN"); 234 - *(Charsets + 34) = wxT ("ISO-2022-CN-EXT"); 235 - *(Charsets + 35) = wxT ("ISO-2022-JP"); 236 - *(Charsets + 36) = wxT ("ISO-2022-JP-1"); 237 - *(Charsets + 37) = wxT ("ISO-2022-JP-2"); 238 - *(Charsets + 38) = wxT ("ISO-2022-KR"); 239 - *(Charsets + 39) = wxT ("ISO-8859-1"); 240 - *(Charsets + 40) = wxT ("ISO-8859-2"); 241 - *(Charsets + 41) = wxT ("ISO-8859-3"); 242 - *(Charsets + 42) = wxT ("ISO-8859-4"); 243 - *(Charsets + 43) = wxT ("ISO-8859-5"); 244 - *(Charsets + 44) = wxT ("ISO-8859-6"); 245 - *(Charsets + 45) = wxT ("ISO-8859-7"); 246 - *(Charsets + 46) = wxT ("ISO-8859-8"); 247 - *(Charsets + 47) = wxT ("ISO-8859-9"); 248 - *(Charsets + 48) = wxT ("ISO-8859-10"); 249 - *(Charsets + 49) = wxT ("ISO-8859-11"); 250 - *(Charsets + 50) = wxT ("ISO-8859-13"); 251 - *(Charsets + 51) = wxT ("ISO-8859-14"); 252 - *(Charsets + 52) = wxT ("ISO-8859-15"); 253 - *(Charsets + 53) = wxT ("ISO-8859-16"); 254 - *(Charsets + 54) = wxT ("JOHAB"); 255 - *(Charsets + 55) = wxT ("KOI8-R"); 256 - *(Charsets + 56) = wxT ("KOI8-U"); 257 - *(Charsets + 57) = wxT ("KOI8-RU"); 258 - *(Charsets + 58) = wxT ("KOI8-T"); 259 - *(Charsets + 59) = wxT ("MacArabic"); 260 - *(Charsets + 60) = wxT ("MacCentralEurope"); 261 - *(Charsets + 61) = wxT ("MacCroatian"); 262 - *(Charsets + 62) = wxT ("MacCyrillic"); 263 - *(Charsets + 63) = wxT ("MacGreek"); 264 - *(Charsets + 64) = wxT ("MacHebrew"); 265 - *(Charsets + 65) = wxT ("MacIceland"); 266 - *(Charsets + 66) = wxT ("Macintosh"); 267 - *(Charsets + 67) = wxT ("MacRoman"); 268 - *(Charsets + 68) = wxT ("MacRomania"); 269 - *(Charsets + 69) = wxT ("MacThai"); 270 - *(Charsets + 70) = wxT ("MacTurkish"); 271 - *(Charsets + 71) = wxT ("MacUkraine"); 272 - *(Charsets + 72) = wxT ("MuleLao-1"); 273 - *(Charsets + 73) = wxT ("PT154"); 274 - *(Charsets + 74) = wxT ("RK1048"); 275 - *(Charsets + 75) = wxT ("SHIFT_JIS"); 276 - *(Charsets + 76) = wxT ("TCVN"); 277 - *(Charsets + 77) = wxT ("TIS-620"); 278 - *(Charsets + 77) = wxT ("UTF-8"); 279 - *(Charsets + 78) = wxT ("VISCII"); 280 - LocaleCharset = wxString::FromUTF8 (gaiaGetLocaleCharset ()); 281 - DefaultCharset = LocaleCharset; 282 - AskCharset = false; 283 - 284 - spatialite_init (0); // loading the SpatiaLite extension 285 - 286 - HelpPane = false; 287 - SqliteHandle = NULL; 288 - SqlitePath = wxT (""); 289 - BtnConnect = new wxBitmap (connect_xpm); 290 - BtnCreateNew = new wxBitmap (create_new_xpm); 291 - BtnDisconnect = new wxBitmap (disconnect_xpm); 292 - BtnVacuum = new wxBitmap (vacuum_xpm); 293 - BtnSqlScript = new wxBitmap (sql_script_xpm); 294 - BtnLoadShp = new wxBitmap (loadshp_xpm); 295 - BtnVirtualShp = new wxBitmap (virtshp_xpm); 296 - BtnLoadTxt = new wxBitmap (loadtxt_xpm); 297 - BtnVirtualTxt = new wxBitmap (virttxt_xpm); 298 - BtnSrids = new wxBitmap (srids_xpm); 299 - BtnCharset = new wxBitmap (charset_xpm); 300 - BtnHelp = new wxBitmap (help_xpm); 301 - BtnAbout = new wxBitmap (about_xpm); 302 - BtnExit = new wxBitmap (exit_xpm); 94 + CharsetsLen = 79; 95 + Charsets = new wxString[CharsetsLen]; 96 + CharsetsNames = new wxString[CharsetsLen]; 97 + *(CharsetsNames + 0) = wxT("ARMSCII-8 Armenian"); 98 + *(CharsetsNames + 1) = wxT("ASCII US-ASCII"); 99 + *(CharsetsNames + 2) = wxT("BIG5 Chinese/Traditional"); 100 + *(CharsetsNames + 3) = wxT("BIG5-HKSCS Chinese/Hong Kong"); 101 + *(CharsetsNames + 4) = wxT("BIG5-HKSCS:1999"); 102 + *(CharsetsNames + 5) = wxT("BIG5-HKSCS:2001"); 103 + *(CharsetsNames + 6) = wxT("CP850 DOS/OEM Western Europe"); 104 + *(CharsetsNames + 7) = wxT("CP862 DOS/OEM Hebrew"); 105 + *(CharsetsNames + 8) = wxT("CP866 DOS/OEM Cyrillic"); 106 + *(CharsetsNames + 9) = wxT("CP874 DOS/OEM Thai"); 107 + *(CharsetsNames + 10) = wxT("CP932 DOS/OEM Japanese"); 108 + *(CharsetsNames + 11) = wxT("CP936 DOS/OEM Chinese"); 109 + *(CharsetsNames + 12) = wxT("CP949 DOS/OEM Korean"); 110 + *(CharsetsNames + 13) = wxT("CP950 DOS/OEM Chinese/Big5"); 111 + *(CharsetsNames + 14) = wxT("CP1133 Laotian"); 112 + *(CharsetsNames + 15) = wxT("CP1250 Windows Central Europe"); 113 + *(CharsetsNames + 16) = wxT("CP1251 Windows Cyrillic"); 114 + *(CharsetsNames + 17) = wxT("CP1252 Windows Latin 1"); 115 + *(CharsetsNames + 18) = wxT("CP1253 Windows Greek"); 116 + *(CharsetsNames + 19) = wxT("CP1254 Windows Turkish"); 117 + *(CharsetsNames + 20) = wxT("CP1255 Windows Hebrew"); 118 + *(CharsetsNames + 21) = wxT("CP1256 Windows Arabic"); 119 + *(CharsetsNames + 22) = wxT("CP1257 Windows Baltic"); 120 + *(CharsetsNames + 23) = wxT("CP1258 Windows Vietnamese"); 121 + *(CharsetsNames + 24) = wxT("EUC-CN Chinese"); 122 + *(CharsetsNames + 25) = wxT("EUC-JP Japanese"); 123 + *(CharsetsNames + 26) = wxT("EUC-KR Korean"); 124 + *(CharsetsNames + 27) = wxT("EUC-TW Taiwan"); 125 + *(CharsetsNames + 28) = wxT("GB18030 Chinese/National Standard"); 126 + *(CharsetsNames + 29) = wxT("GBK Chinese/Simplified"); 127 + *(CharsetsNames + 30) = wxT("Georgian-Academy"); 128 + *(CharsetsNames + 31) = wxT("Georgian-PS"); 129 + *(CharsetsNames + 32) = wxT("HZ Chinese"); 130 + *(CharsetsNames + 33) = wxT("ISO-2022-CN Chinese"); 131 + *(CharsetsNames + 34) = wxT("ISO-2022-CN-EXT"); 132 + *(CharsetsNames + 35) = wxT("ISO-2022-JP Japanese"); 133 + *(CharsetsNames + 36) = wxT("ISO-2022-JP-1"); 134 + *(CharsetsNames + 37) = wxT("ISO-2022-JP-2"); 135 + *(CharsetsNames + 38) = wxT("ISO-2022-KR Korean"); 136 + *(CharsetsNames + 39) = wxT("ISO-8859-1 Latin-1 Western European"); 137 + *(CharsetsNames + 40) = wxT("ISO-8859-2 Latin-2 Central European"); 138 + *(CharsetsNames + 41) = wxT("ISO-8859-3 Latin-3 South European"); 139 + *(CharsetsNames + 42) = wxT("ISO-8859-4 Latin-4 North European"); 140 + *(CharsetsNames + 43) = wxT("ISO-8859-5 Latin/Cyrillic"); 141 + *(CharsetsNames + 44) = wxT("ISO-8859-6 Latin/Arabic"); 142 + *(CharsetsNames + 45) = wxT("ISO-8859-7 Latin/Greek"); 143 + *(CharsetsNames + 46) = wxT("ISO-8859-8 Latin/Hebrew"); 144 + *(CharsetsNames + 47) = wxT("ISO-8859-9 Latin-5 Turkish"); 145 + *(CharsetsNames + 48) = wxT("ISO-8859-10 Latin-6 Nordic"); 146 + *(CharsetsNames + 49) = wxT("ISO-8859-11 Latin/Thai"); 147 + *(CharsetsNames + 50) = wxT("ISO-8859-13 Latin-7 Baltic Rim"); 148 + *(CharsetsNames + 51) = wxT("ISO-8859-14 Latin-8 Celtic"); 149 + *(CharsetsNames + 52) = wxT("ISO-8859-15 Latin-9"); 150 + *(CharsetsNames + 53) = wxT("ISO-8859-16 Latin-10 South-Eastern European"); 151 + *(CharsetsNames + 54) = wxT("JOHAB Korean"); 152 + *(CharsetsNames + 55) = wxT("KOI8-R Russian"); 153 + *(CharsetsNames + 56) = wxT("KOI8-U Ukrainian"); 154 + *(CharsetsNames + 57) = wxT("KOI8-RU Belarusian"); 155 + *(CharsetsNames + 58) = wxT("KOI8-T Tajik"); 156 + *(CharsetsNames + 59) = wxT("MacArabic MAC Arabic"); 157 + *(CharsetsNames + 60) = wxT("MacCentralEurope"); 158 + *(CharsetsNames + 61) = wxT("MacCroatian MAC Croatian"); 159 + *(CharsetsNames + 62) = wxT("MacCyrillic MAC Cyrillic"); 160 + *(CharsetsNames + 63) = wxT("MacGreek MAC Greek"); 161 + *(CharsetsNames + 64) = wxT("MacHebrew MAC Hebrew"); 162 + *(CharsetsNames + 65) = wxT("MacIceland MAC Iceland"); 163 + *(CharsetsNames + 66) = wxT("Macintosh"); 164 + *(CharsetsNames + 67) = wxT("MacRoman MAC European/Western languages"); 165 + *(CharsetsNames + 68) = wxT("MacRomania MAC Romania"); 166 + *(CharsetsNames + 69) = wxT("MacThai MAC Thai"); 167 + *(CharsetsNames + 70) = wxT("MacTurkish MAC Turkish"); 168 + *(CharsetsNames + 71) = wxT("MacUkraine MAC Ukraine"); 169 + *(CharsetsNames + 72) = wxT("MuleLao-1 Laotian"); 170 + *(CharsetsNames + 73) = wxT("PT154 Kazakh"); 171 + *(CharsetsNames + 74) = wxT("RK1048 Kazakh"); 172 + *(CharsetsNames + 75) = wxT("SHIFT_JIS Japanese"); 173 + *(CharsetsNames + 76) = wxT("TCVN Vietnamese"); 174 + *(CharsetsNames + 77) = wxT("TIS-620 Thai"); 175 + *(CharsetsNames + 77) = wxT("UTF-8 UNICODE/Universal"); 176 + *(CharsetsNames + 78) = wxT("VISCII Vietnamese"); 177 + *(Charsets + 0) = wxT("ARMSCII-8"); 178 + *(Charsets + 1) = wxT("ASCII"); 179 + *(Charsets + 2) = wxT("BIG5"); 180 + *(Charsets + 3) = wxT("BIG5-HKSCS"); 181 + *(Charsets + 4) = wxT("BIG5-HKSCS:1999"); 182 + *(Charsets + 5) = wxT("BIG5-HKSCS:2001"); 183 + *(Charsets + 6) = wxT("CP850"); 184 + *(Charsets + 7) = wxT("CP862"); 185 + *(Charsets + 8) = wxT("CP866"); 186 + *(Charsets + 9) = wxT("CP874"); 187 + *(Charsets + 10) = wxT("CP932"); 188 + *(Charsets + 11) = wxT("CP936"); 189 + *(Charsets + 12) = wxT("CP949"); 190 + *(Charsets + 13) = wxT("CP950"); 191 + *(Charsets + 14) = wxT("CP1133"); 192 + *(Charsets + 15) = wxT("CP1250"); 193 + *(Charsets + 16) = wxT("CP1251"); 194 + *(Charsets + 17) = wxT("CP1252"); 195 + *(Charsets + 18) = wxT("CP1253"); 196 + *(Charsets + 19) = wxT("CP1254"); 197 + *(Charsets + 20) = wxT("CP1255"); 198 + *(Charsets + 21) = wxT("CP1256"); 199 + *(Charsets + 22) = wxT("CP1257"); 200 + *(Charsets + 23) = wxT("CP1258"); 201 + *(Charsets + 24) = wxT("EUC-CN"); 202 + *(Charsets + 25) = wxT("EUC-JP"); 203 + *(Charsets + 26) = wxT("EUC-KR"); 204 + *(Charsets + 27) = wxT("EUC-TW"); 205 + *(Charsets + 28) = wxT("GB18030"); 206 + *(Charsets + 29) = wxT("GBK"); 207 + *(Charsets + 30) = wxT("Georgian-Academy"); 208 + *(Charsets + 31) = wxT("Georgian-PS"); 209 + *(Charsets + 32) = wxT("HZ"); 210 + *(Charsets + 33) = wxT("ISO-2022-CN"); 211 + *(Charsets + 34) = wxT("ISO-2022-CN-EXT"); 212 + *(Charsets + 35) = wxT("ISO-2022-JP"); 213 + *(Charsets + 36) = wxT("ISO-2022-JP-1"); 214 + *(Charsets + 37) = wxT("ISO-2022-JP-2"); 215 + *(Charsets + 38) = wxT("ISO-2022-KR"); 216 + *(Charsets + 39) = wxT("ISO-8859-1"); 217 + *(Charsets + 40) = wxT("ISO-8859-2"); 218 + *(Charsets + 41) = wxT("ISO-8859-3"); 219 + *(Charsets + 42) = wxT("ISO-8859-4"); 220 + *(Charsets + 43) = wxT("ISO-8859-5"); 221 + *(Charsets + 44) = wxT("ISO-8859-6"); 222 + *(Charsets + 45) = wxT("ISO-8859-7"); 223 + *(Charsets + 46) = wxT("ISO-8859-8"); 224 + *(Charsets + 47) = wxT("ISO-8859-9"); 225 + *(Charsets + 48) = wxT("ISO-8859-10"); 226 + *(Charsets + 49) = wxT("ISO-8859-11"); 227 + *(Charsets + 50) = wxT("ISO-8859-13"); 228 + *(Charsets + 51) = wxT("ISO-8859-14"); 229 + *(Charsets + 52) = wxT("ISO-8859-15"); 230 + *(Charsets + 53) = wxT("ISO-8859-16"); 231 + *(Charsets + 54) = wxT("JOHAB"); 232 + *(Charsets + 55) = wxT("KOI8-R"); 233 + *(Charsets + 56) = wxT("KOI8-U"); 234 + *(Charsets + 57) = wxT("KOI8-RU"); 235 + *(Charsets + 58) = wxT("KOI8-T"); 236 + *(Charsets + 59) = wxT("MacArabic"); 237 + *(Charsets + 60) = wxT("MacCentralEurope"); 238 + *(Charsets + 61) = wxT("MacCroatian"); 239 + *(Charsets + 62) = wxT("MacCyrillic"); 240 + *(Charsets + 63) = wxT("MacGreek"); 241 + *(Charsets + 64) = wxT("MacHebrew"); 242 + *(Charsets + 65) = wxT("MacIceland"); 243 + *(Charsets + 66) = wxT("Macintosh"); 244 + *(Charsets + 67) = wxT("MacRoman"); 245 + *(Charsets + 68) = wxT("MacRomania"); 246 + *(Charsets + 69) = wxT("MacThai"); 247 + *(Charsets + 70) = wxT("MacTurkish"); 248 + *(Charsets + 71) = wxT("MacUkraine"); 249 + *(Charsets + 72) = wxT("MuleLao-1"); 250 + *(Charsets + 73) = wxT("PT154"); 251 + *(Charsets + 74) = wxT("RK1048"); 252 + *(Charsets + 75) = wxT("SHIFT_JIS"); 253 + *(Charsets + 76) = wxT("TCVN"); 254 + *(Charsets + 77) = wxT("TIS-620"); 255 + *(Charsets + 77) = wxT("UTF-8"); 256 + *(Charsets + 78) = wxT("VISCII"); 257 + LocaleCharset = wxString::FromUTF8(gaiaGetLocaleCharset()); 258 + DefaultCharset = LocaleCharset; 259 + AskCharset = false; 260 + 261 + spatialite_init(0); // loading the SpatiaLite extension 262 + 263 + HelpPane = false; 264 + SqliteHandle = NULL; 265 + SqlitePath = wxT(""); 266 + BtnConnect = new wxBitmap(connect_xpm); 267 + BtnCreateNew = new wxBitmap(create_new_xpm); 268 + BtnDisconnect = new wxBitmap(disconnect_xpm); 269 + BtnMemDbLoad = new wxBitmap(memdb_load_xpm); 270 + BtnMemDbNew = new wxBitmap(memdb_new_xpm); 271 + BtnMemDbClock = new wxBitmap(memdb_clock_xpm); 272 + BtnMemDbSave = new wxBitmap(memdb_save_xpm); 273 + BtnVacuum = new wxBitmap(vacuum_xpm); 274 + BtnSqlScript = new wxBitmap(sql_script_xpm); 275 + BtnLoadShp = new wxBitmap(loadshp_xpm); 276 + BtnVirtualShp = new wxBitmap(virtshp_xpm); 277 + BtnLoadTxt = new wxBitmap(loadtxt_xpm); 278 + BtnVirtualTxt = new wxBitmap(virttxt_xpm); 279 + BtnNetwork = new wxBitmap(network_xpm); 280 + BtnExif = new wxBitmap(exif_xpm); 281 + BtnSrids = new wxBitmap(srids_xpm); 282 + BtnCharset = new wxBitmap(charset_xpm); 283 + BtnHelp = new wxBitmap(help_xpm); 284 + BtnAbout = new wxBitmap(about_xpm); 285 + BtnExit = new wxBitmap(exit_xpm); 303 286 304 287 // 305 288 // setting up the application icon 306 289 // 307 - wxIcon MyIcon (icon_xpm); 308 - SetIcon (MyIcon); 290 + wxIcon MyIcon(icon_xpm); 291 + SetIcon(MyIcon); 309 292 310 293 // 311 294 // setting up panes 312 295 // 313 - TableTree = new MyTableTree (this); 314 - QueryView = new MyQueryView (this); 315 - Manager.SetManagedWindow (this); 316 - wxAuiPaneInfo paneView = wxAuiPaneInfo ().CenterPane (); 317 - paneView.Caption (wxT ("SQL Query")); 318 - paneView.Floatable (false); 319 - paneView.CloseButton (false); 320 - Manager.AddPane (QueryView, paneView); 321 - wxAuiPaneInfo paneTree = wxAuiPaneInfo ().Left (); 322 - paneTree.Caption (wxT ("DB Tables")); 323 - paneTree.Floatable (false); 324 - paneTree.CloseButton (false); 325 - paneTree.BestSize (wxSize (200, 480)); 326 - Manager.AddPane (TableTree, paneTree); 327 - Manager.Update (); 328 - Centre (); 296 + TableTree = new MyTableTree(this); 297 + QueryView = new MyQueryView(this); 298 + RsView = new MyResultSetView(this); 299 + Manager.SetManagedWindow(this); 300 + wxAuiPaneInfo paneSql = wxAuiPaneInfo().Top(); 301 + paneSql.Name(wxT("sql_stmt")); 302 + paneSql.CaptionVisible(false); 303 + paneSql.Floatable(true); 304 + paneSql.Dockable(true); 305 + paneSql.Movable(true); 306 + paneSql.Gripper(true); 307 + paneSql.CloseButton(false); 308 + paneSql.BestSize(wxSize(200, 120)); 309 + Manager.AddPane(QueryView, paneSql); 310 + wxAuiPaneInfo paneView = wxAuiPaneInfo().Centre(); 311 + paneView.Name(wxT("result_set")); 312 + paneView.CaptionVisible(false); 313 + paneView.Floatable(true); 314 + paneView.Dockable(true); 315 + paneView.Movable(true); 316 + paneView.Gripper(false); 317 + paneView.CloseButton(false); 318 + Manager.AddPane(RsView, paneView); 319 + wxAuiPaneInfo paneTree = wxAuiPaneInfo().Left(); 320 + paneTree.Name(wxT("tree_view")); 321 + paneTree.CaptionVisible(false); 322 + paneTree.Floatable(true); 323 + paneTree.Dockable(true); 324 + paneTree.Movable(true); 325 + paneTree.Gripper(true); 326 + paneTree.CloseButton(false); 327 + paneTree.BestSize(wxSize(200, 480)); 328 + Manager.AddPane(TableTree, paneTree, wxPoint(0, 10)); 329 + Manager.Update(); 330 + Centre(); 329 331 330 332 // 331 333 // setting up the status bar 332 334 // 333 - wxStatusBar *statusBar = new wxStatusBar (this); 334 - SetStatusBar (statusBar); 335 + wxStatusBar *statusBar = new wxStatusBar(this); 336 + SetStatusBar(statusBar); 335 337 336 338 // 337 339 // setting up the menu bar 338 340 // 339 - wxMenu *menuFile = new wxMenu; 340 - wxMenuItem *menuItem; 341 - menuItem = new wxMenuItem (menuFile, ID_Connect, 342 - wxT ("&Connecting an existing SQLite DB")); 343 - menuItem->SetBitmap (*BtnConnect); 344 - menuFile->Append (menuItem); 345 - menuItem = new wxMenuItem (menuFile, ID_CreateNew, 346 - wxT ("Creating a &New (empty) SQLite DB")); 347 - menuItem->SetBitmap (*BtnCreateNew); 348 - menuFile->Append (menuItem); 349 - menuItem = new wxMenuItem (menuFile, ID_Disconnect, 350 - wxT ("&Disconnecting current SQLite DB")); 351 - menuItem->SetBitmap (*BtnDisconnect); 352 - menuFile->Append (menuItem); 353 - menuItem = new wxMenuItem (menuFile, ID_Vacuum, 354 - wxT ("&Optimizing current SQLite DB [VACUUM]")); 355 - menuItem->SetBitmap (*BtnVacuum); 356 - menuFile->Append (menuItem); 357 - menuFile->AppendSeparator (); 358 - menuItem = new wxMenuItem (menuFile, ID_SqlScript, 359 - wxT ("&Execute SQL script")); 360 - menuItem->SetBitmap (*BtnSqlScript); 361 - menuFile->Append (menuItem); 362 - menuFile->AppendSeparator (); 363 - menuItem = new wxMenuItem (menuFile, ID_LoadShp, wxT ("&Load Shapefile")); 364 - menuItem->SetBitmap (*BtnLoadShp); 365 - menuFile->Append (menuItem); 366 - menuItem = new wxMenuItem (menuFile, ID_VirtualShp, 367 - wxT ("&Virtual Shapefile")); 368 - menuItem->SetBitmap (*BtnVirtualShp); 369 - menuFile->Append (menuItem); 370 - menuFile->AppendSeparator (); 371 - menuItem = new wxMenuItem (menuFile, ID_LoadTxt, wxT ("Load CSV/&TXT")); 372 - menuItem->SetBitmap (*BtnLoadTxt); 373 - menuFile->Append (menuItem); 374 - menuItem = new wxMenuItem (menuFile, ID_VirtualTxt, 375 - wxT ("Virtual &CSV/TXT")); 376 - menuItem->SetBitmap (*BtnVirtualTxt); 377 - menuFile->Append (menuItem); 378 - menuFile->AppendSeparator (); 379 - menuItem = new wxMenuItem (menuFile, ID_Srids, 380 - wxT ("&Search SRID by name")); 381 - menuItem->SetBitmap (*BtnSrids); 382 - menuFile->Append (menuItem); 383 - menuItem = new wxMenuItem (menuFile, ID_Charset, 384 - wxT ("&Default Output Charset")); 385 - menuItem->SetBitmap (*BtnCharset); 386 - menuFile->Append (menuItem); 387 - menuFile->AppendSeparator (); 388 - menuItem = new wxMenuItem (menuFile, ID_Help, wxT ("&Help")); 389 - menuItem->SetBitmap (*BtnHelp); 390 - menuItem = new wxMenuItem (menuFile, wxID_ABOUT, wxT ("&About ...")); 391 - menuItem->SetBitmap (*BtnAbout); 392 - menuFile->Append (menuItem); 393 - menuFile->AppendSeparator (); 394 - menuItem = new wxMenuItem (menuFile, wxID_EXIT, wxT ("&Quit")); 395 - menuItem->SetBitmap (*BtnExit); 396 - menuFile->Append (menuItem); 397 - wxMenuBar *menuBar = new wxMenuBar; 398 - menuBar->Append (menuFile, wxT ("&Files")); 399 - SetMenuBar (menuBar); 341 + wxMenu *menuFile = new wxMenu; 342 + wxMenuItem *menuItem; 343 + menuItem = 344 + new wxMenuItem(menuFile, ID_Connect, 345 + wxT("&Connecting an existing SQLite DB")); 346 + menuItem->SetBitmap(*BtnConnect); 347 + menuFile->Append(menuItem); 348 + menuItem = 349 + new wxMenuItem(menuFile, ID_CreateNew, 350 + wxT("Creating a &New (empty) SQLite DB")); 351 + menuItem->SetBitmap(*BtnCreateNew); 352 + menuFile->Append(menuItem); 353 + wxMenu *memoryMenu = new wxMenu(); 354 + menuItem = 355 + new wxMenuItem(memoryMenu, ID_MemoryDbLoad, 356 + wxT("&Loading an existing DB into the MEMORY-DB")); 357 + menuItem->SetBitmap(*BtnMemDbLoad); 358 + memoryMenu->Append(menuItem); 359 + menuItem = 360 + new wxMenuItem(memoryMenu, ID_MemoryDbNew, 361 + wxT("Creating a &New (empty) MEMORY-DB")); 362 + menuItem->SetBitmap(*BtnMemDbNew); 363 + memoryMenu->Append(menuItem); 364 + menuItem = 365 + new wxMenuItem(memoryMenu, ID_MemoryDbClock, 366 + wxT("&AutoSaving the current MEMORY-DB")); 367 + menuItem->SetBitmap(*BtnMemDbClock); 368 + memoryMenu->Append(menuItem); 369 + menuItem = 370 + new wxMenuItem(memoryMenu, ID_MemoryDbSave, 371 + wxT("&Saving the current MEMORY-DB")); 372 + menuItem->SetBitmap(*BtnMemDbSave); 373 + memoryMenu->Append(menuItem); 374 + menuFile->AppendSubMenu(memoryMenu, wxT("&MEMORY-DB")); 375 + menuItem = 376 + new wxMenuItem(menuFile, ID_Disconnect, 377 + wxT("&Disconnecting current SQLite DB")); 378 + menuItem->SetBitmap(*BtnDisconnect); 379 + menuFile->Append(menuItem); 380 + menuItem = 381 + new wxMenuItem(menuFile, ID_Disconnect, 382 + wxT("&Disconnecting current SQLite DB")); 383 + menuItem->SetBitmap(*BtnDisconnect); 384 + menuFile->Append(menuItem); 385 + menuItem = 386 + new wxMenuItem(menuFile, ID_Vacuum, 387 + wxT("&Optimizing current SQLite DB [VACUUM]")); 388 + menuItem->SetBitmap(*BtnVacuum); 389 + menuFile->Append(menuItem); 390 + menuFile->AppendSeparator(); 391 + menuItem = new wxMenuItem(menuFile, ID_SqlScript, wxT("&Execute SQL script")); 392 + menuItem->SetBitmap(*BtnSqlScript); 393 + menuFile->Append(menuItem); 394 + menuFile->AppendSeparator(); 395 + menuItem = new wxMenuItem(menuFile, ID_LoadShp, wxT("&Load Shapefile")); 396 + menuItem->SetBitmap(*BtnLoadShp); 397 + menuFile->Append(menuItem); 398 + menuItem = new wxMenuItem(menuFile, ID_VirtualShp, wxT("&Virtual Shapefile")); 399 + menuItem->SetBitmap(*BtnVirtualShp); 400 + menuFile->Append(menuItem); 401 + menuFile->AppendSeparator(); 402 + menuItem = new wxMenuItem(menuFile, ID_LoadTxt, wxT("Load CSV/&TXT")); 403 + menuItem->SetBitmap(*BtnLoadTxt); 404 + menuFile->Append(menuItem); 405 + menuItem = new wxMenuItem(menuFile, ID_VirtualTxt, wxT("Virtual &CSV/TXT")); 406 + menuItem->SetBitmap(*BtnVirtualTxt); 407 + menuFile->Append(menuItem); 408 + menuFile->AppendSeparator(); 409 + menuItem = new wxMenuItem(menuFile, ID_Network, wxT("Build &Network")); 410 + menuItem->SetBitmap(*BtnNetwork); 411 + menuFile->Append(menuItem); 412 + menuFile->AppendSeparator(); 413 + menuItem = new wxMenuItem(menuFile, ID_Exif, wxT("Import &EXIF photos")); 414 + menuItem->SetBitmap(*BtnExif); 415 + menuFile->Append(menuItem); 416 + menuFile->AppendSeparator(); 417 + menuItem = new wxMenuItem(menuFile, ID_Srids, wxT("&Search SRID by name")); 418 + menuItem->SetBitmap(*BtnSrids); 419 + menuFile->Append(menuItem); 420 + menuItem = 421 + new wxMenuItem(menuFile, ID_Charset, wxT("&Default Output Charset")); 422 + menuItem->SetBitmap(*BtnCharset); 423 + menuFile->Append(menuItem); 424 + menuFile->AppendSeparator(); 425 + menuItem = new wxMenuItem(menuFile, ID_Help, wxT("&Help")); 426 + menuItem->SetBitmap(*BtnHelp); 427 + menuItem = new wxMenuItem(menuFile, wxID_ABOUT, wxT("&About ...")); 428 + menuItem->SetBitmap(*BtnAbout); 429 + menuFile->Append(menuItem); 430 + menuFile->AppendSeparator(); 431 + menuItem = new wxMenuItem(menuFile, wxID_EXIT, wxT("&Quit")); 432 + menuItem->SetBitmap(*BtnExit); 433 + menuFile->Append(menuItem); 434 + wxMenuBar *menuBar = new wxMenuBar; 435 + menuBar->Append(menuFile, wxT("&Files")); 436 + SetMenuBar(menuBar); 400 437 401 438 // 402 439 // setting up menu initial state 403 440 // 404 - menuBar->Enable (ID_Disconnect, false); 405 - menuBar->Enable (ID_Vacuum, false); 406 - menuBar->Enable (ID_SqlScript, false); 407 - menuBar->Enable (ID_LoadShp, false); 408 - menuBar->Enable (ID_VirtualShp, false); 409 - menuBar->Enable (ID_LoadTxt, false); 410 - menuBar->Enable (ID_VirtualTxt, false); 411 - menuBar->Enable (ID_Srids, false); 441 + menuBar->Enable(ID_Disconnect, false); 442 + menuBar->Enable(ID_MemoryDbClock, false); 443 + menuBar->Enable(ID_MemoryDbSave, false); 444 + menuBar->Enable(ID_Vacuum, false); 445 + menuBar->Enable(ID_SqlScript, false); 446 + menuBar->Enable(ID_LoadShp, false); 447 + menuBar->Enable(ID_VirtualShp, false); 448 + menuBar->Enable(ID_LoadTxt, false); 449 + menuBar->Enable(ID_VirtualTxt, false); 450 + menuBar->Enable(ID_Network, false); 451 + menuBar->Enable(ID_Exif, false); 452 + menuBar->Enable(ID_Srids, false); 412 453 413 454 // 414 455 // setting up the toolbar 415 456 // 416 - wxToolBar *toolBar = CreateToolBar (); 417 - toolBar->AddTool (ID_Connect, wxT ("Connecting an existing SQLite DB"), 418 - *BtnConnect, wxNullBitmap, 419 - wxITEM_NORMAL, wxT ("Connecting an existing SQLite DB")); 420 - toolBar->AddTool (ID_CreateNew, wxT ("Creating a &New (empty) SQLite DB"), 421 - *BtnCreateNew, wxNullBitmap, 422 - wxITEM_NORMAL, wxT ("Creating a &New (empty) SQLite DB")); 423 - toolBar->AddTool (ID_Disconnect, wxT ("Disconnecting current SQLite DB"), 424 - *BtnDisconnect, wxNullBitmap, 425 - wxITEM_NORMAL, wxT ("Disconnecting current SQLite DB")); 426 - toolBar->AddTool (ID_Vacuum, wxT ("Optimizing current SQLite DB [VACUUM]"), 427 - *BtnVacuum, wxNullBitmap, 428 - wxITEM_NORMAL, 429 - wxT ("Optimizing current SQLite DB [VACUUM]")); 430 - toolBar->AddSeparator (); 431 - toolBar->AddTool (ID_SqlScript, wxT ("Execute SQL script"), 432 - *BtnSqlScript, wxNullBitmap, 433 - wxITEM_NORMAL, wxT ("Execute SQL script")); 434 - toolBar->AddSeparator (); 435 - toolBar->AddTool (ID_LoadShp, wxT ("Load Shapefile"), 436 - *BtnLoadShp, wxNullBitmap, 437 - wxITEM_NORMAL, wxT ("Load Shapefile")); 438 - toolBar->AddTool (ID_VirtualShp, wxT ("Virtual Shapefile"), 439 - *BtnVirtualShp, wxNullBitmap, 440 - wxITEM_NORMAL, wxT ("Virtual Shapefile")); 441 - toolBar->AddSeparator (); 442 - toolBar->AddTool (ID_LoadTxt, wxT ("Load CSV/TXT"), 443 - *BtnLoadTxt, wxNullBitmap, 444 - wxITEM_NORMAL, wxT ("Load CSV/TXT")); 445 - toolBar->AddTool (ID_VirtualTxt, wxT ("Virtual CSV/TXT"), 446 - *BtnVirtualTxt, wxNullBitmap, 447 - wxITEM_NORMAL, wxT ("Virtual CSV/TXT")); 448 - toolBar->AddSeparator (); 449 - toolBar->AddTool (ID_Srids, wxT ("Search SRID by name"), 450 - *BtnSrids, wxNullBitmap, 451 - wxITEM_NORMAL, wxT ("Search SRID by name")); 452 - toolBar->AddSeparator (); 453 - toolBar->AddTool (ID_Charset, wxT ("Default Output Charset"), 454 - *BtnCharset, wxNullBitmap, 455 - wxITEM_NORMAL, wxT ("Default Output Charset")); 456 - toolBar->AddSeparator (); 457 - toolBar->AddTool (ID_Help, wxT ("Help"), *BtnHelp, wxNullBitmap, 458 - wxITEM_NORMAL, wxT ("Help")); 459 - toolBar->AddTool (wxID_ABOUT, wxT ("About ..."), *BtnAbout, wxNullBitmap, 460 - wxITEM_NORMAL, wxT ("About ...")); 461 - toolBar->AddSeparator (); 462 - toolBar->AddTool (wxID_EXIT, wxT ("Quit"), *BtnExit, wxNullBitmap, 463 - wxITEM_NORMAL, wxT ("Quit")); 464 - toolBar->Realize (); 465 - SetToolBar (toolBar); 457 + wxToolBar *toolBar = CreateToolBar(); 458 + toolBar->AddTool(ID_Connect, wxT("Connecting an existing SQLite DB"), 459 + *BtnConnect, wxNullBitmap, wxITEM_NORMAL, 460 + wxT("Connecting an existing SQLite DB")); 461 + toolBar->AddTool(ID_CreateNew, wxT("Creating a &New (empty) SQLite DB"), 462 + *BtnCreateNew, wxNullBitmap, wxITEM_NORMAL, 463 + wxT("Creating a &New (empty) SQLite DB")); 464 + toolBar->AddTool(ID_MemoryDbLoad, 465 + wxT("Loading an existing DB into the MEMORY-DB"), 466 + *BtnMemDbLoad, wxNullBitmap, wxITEM_NORMAL, 467 + wxT("Loading an existing DB into the MEMORY-DB")); 468 + toolBar->AddTool(ID_MemoryDbNew, wxT("Creating a New (empty) MEMORY-DB"), 469 + *BtnMemDbNew, wxNullBitmap, wxITEM_NORMAL, 470 + wxT("Creating a New (empty) MEMORY-DB")); 471 + toolBar->AddTool(ID_MemoryDbClock, wxT("AutoSaving the current MEMORY-DB"), 472 + *BtnMemDbClock, wxNullBitmap, wxITEM_NORMAL, 473 + wxT("AutoSaving the current MEMORY-DB")); 474 + toolBar->AddTool(ID_MemoryDbSave, wxT("Saving the current MEMORY-DB"), 475 + *BtnMemDbSave, wxNullBitmap, wxITEM_NORMAL, 476 + wxT("Saving the current MEMORY-DB")); 477 + toolBar->AddTool(ID_Disconnect, wxT("Disconnecting current SQLite DB"), 478 + *BtnDisconnect, wxNullBitmap, wxITEM_NORMAL, 479 + wxT("Disconnecting current SQLite DB")); 480 + toolBar->AddTool(ID_Vacuum, wxT("Optimizing current SQLite DB [VACUUM]"), 481 + *BtnVacuum, wxNullBitmap, wxITEM_NORMAL, 482 + wxT("Optimizing current SQLite DB [VACUUM]")); 483 + toolBar->AddSeparator(); 484 + toolBar->AddTool(ID_SqlScript, wxT("Execute SQL script"), *BtnSqlScript, 485 + wxNullBitmap, wxITEM_NORMAL, wxT("Execute SQL script")); 486 + toolBar->AddSeparator(); 487 + toolBar->AddTool(ID_LoadShp, wxT("Load Shapefile"), *BtnLoadShp, wxNullBitmap, 488 + wxITEM_NORMAL, wxT("Load Shapefile")); 489 + toolBar->AddTool(ID_VirtualShp, wxT("Virtual Shapefile"), *BtnVirtualShp, 490 + wxNullBitmap, wxITEM_NORMAL, wxT("Virtual Shapefile")); 491 + toolBar->AddSeparator(); 492 + toolBar->AddTool(ID_LoadTxt, wxT("Load CSV/TXT"), *BtnLoadTxt, wxNullBitmap, 493 + wxITEM_NORMAL, wxT("Load CSV/TXT")); 494 + toolBar->AddTool(ID_VirtualTxt, wxT("Virtual CSV/TXT"), *BtnVirtualTxt, 495 + wxNullBitmap, wxITEM_NORMAL, wxT("Virtual CSV/TXT")); 496 + toolBar->AddSeparator(); 497 + toolBar->AddTool(ID_Network, wxT("Build Network"), *BtnNetwork, wxNullBitmap, 498 + wxITEM_NORMAL, wxT("Build Network")); 499 + toolBar->AddSeparator(); 500 + toolBar->AddTool(ID_Exif, wxT("Import EXIF photos"), *BtnExif, wxNullBitmap, 501 + wxITEM_NORMAL, wxT("Import EXIF photos")); 502 + toolBar->AddSeparator(); 503 + toolBar->AddTool(ID_Srids, wxT("Search SRID by name"), *BtnSrids, 504 + wxNullBitmap, wxITEM_NORMAL, wxT("Search SRID by name")); 505 + toolBar->AddSeparator(); 506 + toolBar->AddTool(ID_Charset, wxT("Default Output Charset"), *BtnCharset, 507 + wxNullBitmap, wxITEM_NORMAL, wxT("Default Output Charset")); 508 + toolBar->AddSeparator(); 509 + toolBar->AddTool(ID_Help, wxT("Help"), *BtnHelp, wxNullBitmap, wxITEM_NORMAL, 510 + wxT("Help")); 511 + toolBar->AddTool(wxID_ABOUT, wxT("About ..."), *BtnAbout, wxNullBitmap, 512 + wxITEM_NORMAL, wxT("About ...")); 513 + toolBar->AddSeparator(); 514 + toolBar->AddTool(wxID_EXIT, wxT("Quit"), *BtnExit, wxNullBitmap, 515 + wxITEM_NORMAL, wxT("Quit")); 516 + toolBar->Realize(); 517 + SetToolBar(toolBar); 466 518 467 519 // 468 520 // setting up the toolbar initial state 469 521 // 470 - toolBar->EnableTool (ID_Disconnect, false); 471 - toolBar->EnableTool (ID_Vacuum, false); 472 - toolBar->EnableTool (ID_SqlScript, false); 473 - toolBar->EnableTool (ID_LoadShp, false); 474 - toolBar->EnableTool (ID_VirtualShp, false); 475 - toolBar->EnableTool (ID_LoadTxt, false); 476 - toolBar->EnableTool (ID_VirtualTxt, false); 477 - toolBar->EnableTool (ID_Srids, false); 522 + toolBar->EnableTool(ID_Disconnect, false); 523 + toolBar->EnableTool(ID_MemoryDbClock, false); 524 + toolBar->EnableTool(ID_MemoryDbSave, false); 525 + toolBar->EnableTool(ID_Vacuum, false); 526 + toolBar->EnableTool(ID_SqlScript, false); 527 + toolBar->EnableTool(ID_LoadShp, false); 528 + toolBar->EnableTool(ID_VirtualShp, false); 529 + toolBar->EnableTool(ID_LoadTxt, false); 530 + toolBar->EnableTool(ID_VirtualTxt, false); 531 + toolBar->EnableTool(ID_Network, false); 532 + toolBar->EnableTool(ID_Exif, false); 533 + toolBar->EnableTool(ID_Srids, false); 478 534 479 535 // updating the status bar 480 - UpdateStatusBar (); 536 + UpdateStatusBar(); 481 537 482 538 // 483 539 // setting up event handlers for menu and toolbar 484 540 // 485 - Connect (ID_Connect, wxEVT_COMMAND_MENU_SELECTED, 486 - (wxObjectEventFunction) & MyFrame::OnConnect); 487 - Connect (ID_CreateNew, wxEVT_COMMAND_MENU_SELECTED, 488 - (wxObjectEventFunction) & MyFrame::OnCreateNew); 489 - Connect (ID_Disconnect, wxEVT_COMMAND_MENU_SELECTED, 490 - (wxObjectEventFunction) & MyFrame::OnDisconnect); 491 - Connect (ID_Vacuum, wxEVT_COMMAND_MENU_SELECTED, 492 - (wxObjectEventFunction) & MyFrame::OnVacuum); 493 - Connect (ID_SqlScript, wxEVT_COMMAND_MENU_SELECTED, 494 - (wxObjectEventFunction) & MyFrame::OnSqlScript); 495 - Connect (ID_LoadShp, wxEVT_COMMAND_MENU_SELECTED, 496 - (wxObjectEventFunction) & MyFrame::OnLoadShp); 497 - Connect (ID_VirtualShp, wxEVT_COMMAND_MENU_SELECTED, 498 - (wxObjectEventFunction) & MyFrame::OnVirtualShp); 499 - Connect (ID_LoadTxt, wxEVT_COMMAND_MENU_SELECTED, 500 - (wxObjectEventFunction) & MyFrame::OnLoadTxt); 501 - Connect (ID_VirtualTxt, wxEVT_COMMAND_MENU_SELECTED, 502 - (wxObjectEventFunction) & MyFrame::OnVirtualTxt); 503 - Connect (ID_Srids, wxEVT_COMMAND_MENU_SELECTED, 504 - (wxObjectEventFunction) & MyFrame::OnSrids); 505 - Connect (ID_Charset, wxEVT_COMMAND_MENU_SELECTED, 506 - (wxObjectEventFunction) & MyFrame::OnCharset); 507 - Connect (ID_Help, wxEVT_COMMAND_MENU_SELECTED, 508 - (wxObjectEventFunction) & MyFrame::OnHelp); 509 - Connect (wxID_ABOUT, wxEVT_COMMAND_MENU_SELECTED, 510 - (wxObjectEventFunction) & MyFrame::OnAbout); 511 - Connect (wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED, 512 - (wxObjectEventFunction) & MyFrame::OnQuit); 513 - Connect (wxID_ANY, wxEVT_MOTION, 514 - wxMouseEventHandler (MyFrame::OnMouseMove), NULL, this); 541 + Connect(ID_Connect, wxEVT_COMMAND_MENU_SELECTED, 542 + (wxObjectEventFunction) & MyFrame::OnConnect); 543 + Connect(ID_CreateNew, wxEVT_COMMAND_MENU_SELECTED, 544 + (wxObjectEventFunction) & MyFrame::OnCreateNew); 545 + Connect(ID_Disconnect, wxEVT_COMMAND_MENU_SELECTED, 546 + (wxObjectEventFunction) & MyFrame::OnDisconnect); 547 + Connect(ID_MemoryDbLoad, wxEVT_COMMAND_MENU_SELECTED, 548 + (wxObjectEventFunction) & MyFrame::OnMemoryDbLoad); 549 + Connect(ID_MemoryDbNew, wxEVT_COMMAND_MENU_SELECTED, 550 + (wxObjectEventFunction) & MyFrame::OnMemoryDbNew); 551 + Connect(ID_MemoryDbClock, wxEVT_COMMAND_MENU_SELECTED, 552 + (wxObjectEventFunction) & MyFrame::OnMemoryDbClock); 553 + Connect(ID_MemoryDbSave, wxEVT_COMMAND_MENU_SELECTED, 554 + (wxObjectEventFunction) & MyFrame::OnMemoryDbSave); 555 + Connect(ID_Vacuum, wxEVT_COMMAND_MENU_SELECTED, 556 + (wxObjectEventFunction) & MyFrame::OnVacuum); 557 + Connect(ID_SqlScript, wxEVT_COMMAND_MENU_SELECTED, 558 + (wxObjectEventFunction) & MyFrame::OnSqlScript); 559 + Connect(ID_LoadShp, wxEVT_COMMAND_MENU_SELECTED, 560 + (wxObjectEventFunction) & MyFrame::OnLoadShp); 561 + Connect(ID_VirtualShp, wxEVT_COMMAND_MENU_SELECTED, 562 + (wxObjectEventFunction) & MyFrame::OnVirtualShp); 563 + Connect(ID_LoadTxt, wxEVT_COMMAND_MENU_SELECTED, 564 + (wxObjectEventFunction) & MyFrame::OnLoadTxt); 565 + Connect(ID_VirtualTxt, wxEVT_COMMAND_MENU_SELECTED, 566 + (wxObjectEventFunction) & MyFrame::OnVirtualTxt); 567 + Connect(ID_Network, wxEVT_COMMAND_MENU_SELECTED, 568 + (wxObjectEventFunction) & MyFrame::OnNetwork); 569 + Connect(ID_Exif, wxEVT_COMMAND_MENU_SELECTED, 570 + (wxObjectEventFunction) & MyFrame::OnImportExifPhotos); 571 + Connect(ID_Srids, wxEVT_COMMAND_MENU_SELECTED, 572 + (wxObjectEventFunction) & MyFrame::OnSrids); 573 + Connect(ID_Charset, wxEVT_COMMAND_MENU_SELECTED, 574 + (wxObjectEventFunction) & MyFrame::OnCharset); 575 + Connect(ID_Help, wxEVT_COMMAND_MENU_SELECTED, 576 + (wxObjectEventFunction) & MyFrame::OnHelp); 577 + Connect(wxID_ABOUT, wxEVT_COMMAND_MENU_SELECTED, 578 + (wxObjectEventFunction) & MyFrame::OnAbout); 579 + Connect(wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED, 580 + (wxObjectEventFunction) & MyFrame::OnQuit); 581 + Connect(wxID_ANY, wxEVT_MOTION, wxMouseEventHandler(MyFrame::OnMouseMove), 582 + NULL, this); 515 583 516 584 // 517 585 // setting up event handlers for mouse 518 586 // 519 - TableTree->Connect (wxID_ANY, wxEVT_MOTION, 520 - wxMouseEventHandler (MyFrame::OnMouseMove), NULL, this); 521 - GetMenuBar ()->Connect (wxID_ANY, wxEVT_MOTION, 522 - wxMouseEventHandler (MyFrame::OnMouseMove), NULL, 523 - this); 524 - GetStatusBar ()->Connect (wxID_ANY, wxEVT_MOTION, 525 - wxMouseEventHandler (MyFrame::OnMouseMove), NULL, 526 - this); 587 + TableTree->Connect(wxID_ANY, wxEVT_MOTION, 588 + wxMouseEventHandler(MyFrame::OnMouseMove), NULL, this); 589 + GetMenuBar()->Connect(wxID_ANY, wxEVT_MOTION, 590 + wxMouseEventHandler(MyFrame::OnMouseMove), NULL, this); 591 + GetStatusBar()->Connect(wxID_ANY, wxEVT_MOTION, 592 + wxMouseEventHandler(MyFrame::OnMouseMove), NULL, 593 + this); 594 +// 595 +// setting up a Timer event handler for AutoSave 596 +// 597 + Connect(ID_AUTO_SAVE_TIMER, wxEVT_TIMER, 598 + wxTimerEventHandler(MyFrame::OnTimerAutoSave), NULL, this); 527 599 } 528 600 529 -MyFrame::~MyFrame () 601 +MyFrame::~MyFrame() 530 602 { 531 603 // 532 604 // main GUI frame destructor 533 605 // 534 - Manager.UnInit (); 535 - if (SqliteHandle) 536 - sqlite3_close (SqliteHandle); 537 - if (BtnConnect != NULL) 538 - delete BtnConnect; 539 - if (BtnCreateNew != NULL) 540 - delete BtnCreateNew; 541 - if (BtnDisconnect != NULL) 542 - delete BtnDisconnect; 543 - if (BtnVacuum != NULL) 544 - delete BtnVacuum; 545 - if (BtnSqlScript != NULL) 546 - delete BtnSqlScript; 547 - if (BtnLoadShp != NULL) 548 - delete BtnLoadShp; 549 - if (BtnVirtualShp != NULL) 550 - delete BtnVirtualShp; 551 - if (BtnLoadTxt != NULL) 552 - delete BtnLoadTxt; 553 - if (BtnVirtualTxt != NULL) 554 - delete BtnVirtualTxt; 555 - if (BtnSrids != NULL) 556 - delete BtnSrids; 557 - if (BtnHelp != NULL) 558 - delete BtnHelp; 559 - if (BtnAbout != NULL) 560 - delete BtnAbout; 561 - if (BtnExit != NULL) 562 - delete BtnExit; 563 - if (Charsets) 564 - delete[]Charsets; 565 - if (CharsetsNames) 566 - delete[]CharsetsNames; 567 -} 568 - 569 -void 570 -MyFrame::OnQuit (wxCommandEvent & WXUNUSED (event)) 606 + if (TimerAutoSave) 607 + { 608 + TimerAutoSave->Stop(); 609 + delete TimerAutoSave; 610 + } 611 + LastDitchMemoryDbSave(); 612 + ConfigLayout = Manager.SavePerspective(); 613 + GetPosition(&ConfigPaneX, &ConfigPaneY); 614 + GetSize(&ConfigPaneWidth, &ConfigPaneHeight); 615 + SaveConfig(); 616 + Manager.UnInit(); 617 + if (SqliteHandle) 618 + sqlite3_close(SqliteHandle); 619 + if (BtnConnect != NULL) 620 + delete BtnConnect; 621 + if (BtnCreateNew != NULL) 622 + delete BtnCreateNew; 623 + if (BtnDisconnect != NULL) 624 + delete BtnDisconnect; 625 + if (BtnMemDbLoad != NULL) 626 + delete BtnMemDbLoad; 627 + if (BtnMemDbNew != NULL) 628 + delete BtnMemDbNew; 629 + if (BtnMemDbClock != NULL) 630 + delete BtnMemDbClock; 631 + if (BtnMemDbSave != NULL) 632 + delete BtnMemDbSave; 633 + if (BtnVacuum != NULL) 634 + delete BtnVacuum; 635 + if (BtnSqlScript != NULL) 636 + delete BtnSqlScript; 637 + if (BtnLoadShp != NULL) 638 + delete BtnLoadShp; 639 + if (BtnVirtualShp != NULL) 640 + delete BtnVirtualShp; 641 + if (BtnLoadTxt != NULL) 642 + delete BtnLoadTxt; 643 + if (BtnVirtualTxt != NULL) 644 + delete BtnVirtualTxt; 645 + if (BtnNetwork != NULL) 646 + delete BtnNetwork; 647 + if (BtnExif != NULL) 648 + delete BtnExif; 649 + if (BtnSrids != NULL) 650 + delete BtnSrids; 651 + if (BtnHelp != NULL) 652 + delete BtnHelp; 653 + if (BtnAbout != NULL) 654 + delete BtnAbout; 655 + if (BtnExit != NULL) 656 + delete BtnExit; 657 + if (Charsets) 658 + delete[]Charsets; 659 + if (CharsetsNames) 660 + delete[]CharsetsNames; 661 +} 662 + 663 +void MyFrame::SaveConfig() 664 +{ 665 +// 666 +// saves layout configuration 667 +// 668 + 669 + wxConfig *config = new wxConfig(wxT("SpatialiteGui")); 670 + config->Write(wxT("Layout"), ConfigLayout); 671 + config->Write(wxT("PaneX"), ConfigPaneX); 672 + config->Write(wxT("PaneY"), ConfigPaneY); 673 + config->Write(wxT("PaneWidth"), ConfigPaneWidth); 674 + config->Write(wxT("PaneHeight"), ConfigPaneHeight); 675 + config->Write(wxT("SqlitePath"), SqlitePath); 676 + config->Write(wxT("LastDirectory"), LastDirectory); 677 + delete config; 678 +} 679 + 680 +void MyFrame::LoadConfig() 681 +{ 682 +// 683 +// loads layout configuration 684 +// 685 + ConfigLayout = wxT(""); 686 + ConfigDbPath = wxT(""); 687 + ConfigDir = wxT(""); 688 + wxConfig *config = new wxConfig(wxT("SpatialiteGui")); 689 + config->Read(wxT("Layout"), &ConfigLayout); 690 + config->Read(wxT("PaneX"), &ConfigPaneX, -1); 691 + config->Read(wxT("PaneY"), &ConfigPaneY, -1); 692 + config->Read(wxT("PaneWidth"), &ConfigPaneWidth, -1); 693 + config->Read(wxT("PaneHeight"), &ConfigPaneHeight, -1); 694 + config->Read(wxT("SqlitePath"), &ConfigDbPath); 695 + config->Read(wxT("LastDirectory"), &ConfigDir); 696 + delete config; 697 + Hide(); 698 + if (ConfigLayout.Len() > 0) 699 + Manager.LoadPerspective(ConfigLayout, true); 700 + if (ConfigPaneX >= 0 && ConfigPaneY >= 0 && ConfigPaneWidth > 0 701 + && ConfigPaneHeight > 0) 702 + SetSize(ConfigPaneX, ConfigPaneY, ConfigPaneWidth, ConfigPaneHeight); 703 + if (ConfigDir.Len() > 0) 704 + LastDirectory = ConfigDir; 705 + if (ConfigDbPath.Len() > 0) 706 + { 707 + SqlitePath = ConfigDbPath; 708 + if (OpenDB() == false) 709 + SqlitePath = wxT(""); 710 + else 711 + { 712 + bool metadata = CheckMetadata(); 713 + wxMenuBar *menuBar = GetMenuBar(); 714 + menuBar->Enable(ID_Connect, false); 715 + menuBar->Enable(ID_MemoryDbLoad, false); 716 + menuBar->Enable(ID_MemoryDbNew, false); 717 + if (MemoryDatabase == true) 718 + { 719 + menuBar->Enable(ID_MemoryDbSave, true); 720 + menuBar->Enable(ID_MemoryDbClock, true); 721 + } else 722 + { 723 + menuBar->Enable(ID_MemoryDbSave, false); 724 + menuBar->Enable(ID_MemoryDbClock, false); 725 + } 726 + menuBar->Enable(ID_CreateNew, false); 727 + menuBar->Enable(ID_Disconnect, true); 728 + menuBar->Enable(ID_Vacuum, true); 729 + menuBar->Enable(ID_SqlScript, true); 730 + menuBar->Enable(ID_LoadShp, true); 731 + menuBar->Enable(ID_VirtualShp, true); 732 + menuBar->Enable(ID_LoadTxt, true); 733 + menuBar->Enable(ID_VirtualTxt, true); 734 + menuBar->Enable(ID_Network, true); 735 + menuBar->Enable(ID_Exif, true); 736 + menuBar->Enable(ID_Srids, metadata); 737 + wxToolBar *toolBar = GetToolBar(); 738 + toolBar->EnableTool(ID_Connect, false); 739 + toolBar->EnableTool(ID_MemoryDbLoad, false); 740 + toolBar->EnableTool(ID_MemoryDbNew, false); 741 + if (MemoryDatabase == true) 742 + { 743 + toolBar->EnableTool(ID_MemoryDbSave, true); 744 + toolBar->EnableTool(ID_MemoryDbClock, true); 745 + } else 746 + { 747 + toolBar->EnableTool(ID_MemoryDbSave, false); 748 + toolBar->EnableTool(ID_MemoryDbClock, false); 749 + } 750 + toolBar->EnableTool(ID_CreateNew, false); 751 + toolBar->EnableTool(ID_Disconnect, true); 752 + toolBar->EnableTool(ID_Vacuum, true); 753 + toolBar->EnableTool(ID_SqlScript, true); 754 + toolBar->EnableTool(ID_LoadShp, true); 755 + toolBar->EnableTool(ID_VirtualShp, true); 756 + toolBar->EnableTool(ID_LoadTxt, true); 757 + toolBar->EnableTool(ID_VirtualTxt, true); 758 + toolBar->EnableTool(ID_Network, true); 759 + toolBar->EnableTool(ID_Exif, true); 760 + toolBar->EnableTool(ID_Srids, metadata); 761 + UpdateStatusBar(); 762 + } 763 + } 764 + Show(); 765 + if (AutoFDOmsg.Len() > 0) 766 + { 767 + wxMessageBox(AutoFDOmsg, wxT("spatialite-gui"), wxOK | wxICON_INFORMATION, 768 + this); 769 + AutoFDOmsg = wxT(""); 770 + } 771 +} 772 + 773 +void MyFrame::OnQuit(wxCommandEvent & WXUNUSED(event)) 571 774 { 572 775 // 573 776 // EXIT - event handler 574 777 // 575 - CloseDB (); 576 - Close (TRUE); 778 + CloseDB(); 779 + Close(true); 577 780 } 578 781 579 -void 580 -MyFrame::OnHelp (wxCommandEvent & WXUNUSED (event)) 782 +void MyFrame::OnHelp(wxCommandEvent & WXUNUSED(event)) 581 783 { 582 784 // 583 785 // HELP - event handler 584 786 // 585 - if (HelpPane == true) 586 - return; 587 - HelpDialog *help = new HelpDialog (this); 588 - help->Show (); 787 + if (HelpPane == true) 788 + return; 789 + HelpDialog *help = new HelpDialog(this); 790 + help->Show(); 589 791 } 590 792 591 -void 592 -MyFrame::OnAbout (wxCommandEvent & WXUNUSED (event)) 793 +void MyFrame::OnAbout(wxCommandEvent & WXUNUSED(event)) 593 794 { 594 795 // 595 796 // ABOUT dialog - event handler 596 797 // 597 - char ver[128]; 598 - wxAboutDialogInfo dlg; 599 - dlg.SetName (wxT ("spatialite-gui")); 600 - dlg.SetVersion (wxT ("v1.1")); 601 - wxString str = wxT ("a GUI-tool for SQLite / SpatiaLite\n\n"); 602 - strcpy (ver, spatialite_version ()); 603 - str += wxT ("SpatiaLite version ") + wxString::FromUTF8 (ver) + wxT ("\n"); 604 - strcpy (ver, sqlite3_libversion ()); 605 - str += wxT ("SQLite version ") + wxString::FromUTF8 (ver) + wxT ("\n"); 606 - strcpy (ver, GEOSversion ()); 607 - str += wxT ("GEOS version ") + wxString::FromUTF8 (ver) + wxT ("\n"); 608 - strcpy (ver, pj_get_release ()); 609 - str += wxT ("PROJ.4 version ") + wxString::FromUTF8 (ver) + wxT ("\n\n"); 610 - str += wxT ("SQLite's extension 'SpatiaLite' enabled\n"); 611 - str += wxT ("SQLite's extension 'VirtualShape' enabled\n"); 612 - str += wxT ("SQLite's extension 'VirtualText' enabled\n"); 613 - str += wxT ("SQLite's extension 'RTree' enabled\n"); 614 - str += wxT ("SQLite's extension 'MbrCache' enabled\n\n"); 615 - dlg.SetDescription (str); 616 - dlg.SetCopyright (wxT ("by Alessandro Furieri - 2008")); 617 - dlg.SetWebSite (wxT ("http://www.gaia-gis.it")); 618 - wxString license = 619 - wxT ("This program is free software; you can redistribute it\n"); 620 - license += 621 - wxT 622 - ("and/or modify it under the terms of the GNU General Public License\n"); 623 - license += wxT ("(GPL) as published by the Free Software Foundation\n\n"); 624 - license += 625 - wxT 626 - ("A copy of the GPL can be found at\nhttp://www.gnu.org/licenses/gpl.txt"); 627 - dlg.SetLicense (license); 628 - ::wxAboutBox (dlg); 629 -} 630 - 631 -void 632 -MyFrame::OnMouseMove (wxMouseEvent & event) 798 + char ver[128]; 799 + wxAboutDialogInfo dlg; 800 + dlg.SetIcon(wxIcon(icon_info_xpm)); 801 + dlg.SetName(wxT("spatialite-gui")); 802 + dlg.SetVersion(wxT("v1.2")); 803 + wxString str = wxT("a GUI-tool for SQLite / SpatiaLite\n\n"); 804 + sprintf(ver, "%d.%d.%d", wxMAJOR_VERSION, wxMINOR_VERSION, wxRELEASE_NUMBER); 805 + str += wxT("wxWidgets version ") + wxString::FromUTF8(ver) + wxT("\n"); 806 + strcpy(ver, spatialite_version()); 807 + str += wxT("SpatiaLite version ") + wxString::FromUTF8(ver) + wxT("\n"); 808 + strcpy(ver, sqlite3_libversion()); 809 + str += wxT("SQLite version ") + wxString::FromUTF8(ver) + wxT("\n"); 810 + strcpy(ver, GEOSversion()); 811 + str += wxT("GEOS version ") + wxString::FromUTF8(ver) + wxT("\n"); 812 + strcpy(ver, pj_get_release()); 813 + str += wxT("PROJ.4 version ") + wxString::FromUTF8(ver) + wxT("\n\n"); 814 + str += wxT("SQLite's extension 'SpatiaLite' enabled\n"); 815 + str += wxT("SQLite's extension 'VirtualShape' enabled\n"); 816 + str += wxT("SQLite's extension 'VirtualText' enabled\n"); 817 + str += wxT("SQLite's extension 'VirtualNetwork' enabled\n"); 818 + str += wxT("SQLite's extension 'RTree' enabled\n"); 819 + str += wxT("SQLite's extension 'MbrCache' enabled\n"); 820 + str += wxT("SQLite's extension 'VirtualFDO' enabled\n\n"); 821 + dlg.SetDescription(str); 822 + dlg.SetCopyright(wxT("by Alessandro Furieri - 2008")); 823 + dlg.SetWebSite(wxT("http://www.gaia-gis.it")); 824 + wxString license = 825 + wxT("This program is free software; you can redistribute it\n"); 826 + license += 827 + wxT("and/or modify it under the terms of the GNU General Public License\n"); 828 + license += wxT("(GPL) as published by the Free Software Foundation\n\n"); 829 + license += 830 + wxT 831 + ("A copy of the GPL can be found at\nhttp://www.gnu.org/licenses/gpl.txt"); 832 + dlg.SetLicense(license); 833 + ::wxAboutBox(dlg); 834 +} 835 + 836 +void MyFrame::OnMouseMove(wxMouseEvent & event) 633 837 { 634 838 // 635 839 // MOUSE motion - event handler 636 840 // 637 - UpdateStatusBar (); 841 + UpdateStatusBar(); 638 842 } 639 843 640 -void 641 -MyFrame::UpdateStatusBar () 844 +void MyFrame::UpdateStatusBar() 642 845 { 643 846 // 644 847 // updating the status bar 645 848 // 646 - if (GetStatusBar () == NULL) 647 - return; 648 - if (SqlitePath.Len () < 1) 649 - GetStatusBar ()->SetStatusText (wxT ("not connected"), 0); 650 - else 651 - GetStatusBar ()->SetStatusText (wxT ("Current SQLite DB: ") + 652 - SqlitePath, 0); 653 - if (SqlitePath.Len () < 1) 654 - QueryView->HideControls (); 655 - else 656 - QueryView->ShowSqlControls (); 849 + if (GetStatusBar() == NULL) 850 + return; 851 + if (MemoryDatabase == true) 852 + { 853 + GetStatusBar()->SetStatusText(wxT("Current SQLite DB: MEMORY-DB"), 0); 854 + QueryView->ShowControls(); 855 + } else 856 + { 857 + if (SqlitePath.Len() < 1) 858 + GetStatusBar()->SetStatusText(wxT("not connected"), 0); 859 + else 860 + GetStatusBar()->SetStatusText(wxT("Current SQLite DB: ") + SqlitePath, 861 + 0); 862 + if (SqlitePath.Len() < 1) 863 + { 864 + QueryView->HideControls(); 865 + RsView->HideControls(); 866 + } else 867 + QueryView->ShowControls(); 868 + } 657 869 } 658 870 659 -void 660 -MyFrame::OnConnect (wxCommandEvent & WXUNUSED (event)) 871 +void MyFrame::OnConnect(wxCommandEvent & WXUNUSED(event)) 661 872 { 662 873 // 663 874 // connecting to an existent SQLite DB 664 875 // 665 - int ret; 666 - wxString lastDir; 667 - wxFileDialog *fileDialog = new wxFileDialog (this, wxT ("DB connection"), 668 - wxT (""), wxT ("db.sqlite"), 669 - wxT 670 - ("SQLite DB (*.sqlite)|*.sqlite|All files (*.*)|*.*"), 671 - wxFD_OPEN | 672 - wxFD_FILE_MUST_EXIST, 673 - wxDefaultPosition, 674 - wxDefaultSize, 675 - wxT ("filedlg")); 676 - lastDir = GetLastDirectory (); 677 - if (lastDir.Len () >= 1) 678 - fileDialog->SetDirectory (lastDir); 679 - ret = fileDialog->ShowModal (); 680 - if (ret == wxID_OK) 681 - { 682 - SqlitePath = fileDialog->GetPath (); 683 - if (OpenDB () == false) 684 - SqlitePath = wxT (""); 685 - else 686 - { 687 - wxFileName file (fileDialog->GetPath ()); 688 - lastDir = file.GetPath (); 689 - SetLastDirectory (lastDir); 690 - bool metadata = CheckMetadata (); 691 - wxMenuBar *menuBar = GetMenuBar (); 692 - menuBar->Enable (ID_Connect, false); 693 - menuBar->Enable (ID_CreateNew, false); 694 - menuBar->Enable (ID_Disconnect, true); 695 - menuBar->Enable (ID_Vacuum, true); 696 - menuBar->Enable (ID_SqlScript, true); 697 - menuBar->Enable (ID_LoadShp, true); 698 - menuBar->Enable (ID_VirtualShp, true); 699 - menuBar->Enable (ID_LoadTxt, true); 700 - menuBar->Enable (ID_VirtualTxt, true); 701 - menuBar->Enable (ID_Srids, metadata); 702 - wxToolBar *toolBar = GetToolBar (); 703 - toolBar->EnableTool (ID_Connect, false); 704 - toolBar->EnableTool (ID_CreateNew, false); 705 - toolBar->EnableTool (ID_Disconnect, true); 706 - toolBar->EnableTool (ID_Vacuum, true); 707 - toolBar->EnableTool (ID_SqlScript, true); 708 - toolBar->EnableTool (ID_LoadShp, true); 709 - toolBar->EnableTool (ID_VirtualShp, true); 710 - toolBar->EnableTool (ID_LoadTxt, true); 711 - toolBar->EnableTool (ID_VirtualTxt, true); 712 - toolBar->EnableTool (ID_Srids, metadata); 713 - UpdateStatusBar (); 714 - } 715 - } 716 -} 717 - 718 -void 719 -MyFrame::OnDisconnect (wxCommandEvent & WXUNUSED (event)) 876 + int ret; 877 + wxString lastDir; 878 + wxFileDialog *fileDialog = new wxFileDialog(this, wxT("DB connection"), 879 + wxT(""), wxT("db.sqlite"), 880 + wxT 881 + ("SQLite DB (*.sqlite)|*.sqlite|All files (*.*)|*.*"), 882 + wxFD_OPEN | wxFD_FILE_MUST_EXIST, 883 + wxDefaultPosition, 884 + wxDefaultSize, 885 + wxT("filedlg")); 886 + lastDir = GetLastDirectory(); 887 + if (lastDir.Len() >= 1) 888 + fileDialog->SetDirectory(lastDir); 889 + ret = fileDialog->ShowModal(); 890 + if (ret == wxID_OK) 891 + { 892 + SqlitePath = fileDialog->GetPath(); 893 + if (OpenDB() == false) 894 + SqlitePath = wxT(""); 895 + else 896 + { 897 + wxFileName file(fileDialog->GetPath()); 898 + lastDir = file.GetPath(); 899 + SetLastDirectory(lastDir); 900 + bool metadata = CheckMetadata(); 901 + wxMenuBar *menuBar = GetMenuBar(); 902 + menuBar->Enable(ID_Connect, false); 903 + menuBar->Enable(ID_CreateNew, false); 904 + menuBar->Enable(ID_Disconnect, true); 905 + menuBar->Enable(ID_MemoryDbLoad, false); 906 + menuBar->Enable(ID_MemoryDbNew, false); 907 + if (MemoryDatabase == true) 908 + { 909 + menuBar->Enable(ID_MemoryDbSave, true); 910 + menuBar->Enable(ID_MemoryDbClock, true); 911 + } else 912 + { 913 + menuBar->Enable(ID_MemoryDbSave, false); 914 + menuBar->Enable(ID_MemoryDbClock, false); 915 + } 916 + menuBar->Enable(ID_Vacuum, true); 917 + menuBar->Enable(ID_SqlScript, true); 918 + menuBar->Enable(ID_LoadShp, true); 919 + menuBar->Enable(ID_VirtualShp, true); 920 + menuBar->Enable(ID_LoadTxt, true); 921 + menuBar->Enable(ID_VirtualTxt, true); 922 + menuBar->Enable(ID_Network, true); 923 + menuBar->Enable(ID_Exif, true); 924 + menuBar->Enable(ID_Srids, metadata); 925 + wxToolBar *toolBar = GetToolBar(); 926 + toolBar->EnableTool(ID_Connect, false); 927 + toolBar->EnableTool(ID_CreateNew, false); 928 + toolBar->EnableTool(ID_Disconnect, true); 929 + toolBar->EnableTool(ID_MemoryDbLoad, false); 930 + toolBar->EnableTool(ID_MemoryDbNew, false); 931 + if (MemoryDatabase == true) 932 + { 933 + toolBar->EnableTool(ID_MemoryDbSave, true); 934 + toolBar->EnableTool(ID_MemoryDbClock, true); 935 + } else 936 + { 937 + toolBar->EnableTool(ID_MemoryDbSave, false); 938 + toolBar->EnableTool(ID_MemoryDbClock, false); 939 + } 940 + toolBar->EnableTool(ID_Vacuum, true); 941 + toolBar->EnableTool(ID_SqlScript, true); 942 + toolBar->EnableTool(ID_LoadShp, true); 943 + toolBar->EnableTool(ID_VirtualShp, true); 944 + toolBar->EnableTool(ID_LoadTxt, true); 945 + toolBar->EnableTool(ID_VirtualTxt, true); 946 + toolBar->EnableTool(ID_Network, true); 947 + toolBar->EnableTool(ID_Exif, true); 948 + toolBar->EnableTool(ID_Srids, metadata); 949 + UpdateStatusBar(); 950 + } 951 + } 952 + if (AutoFDOmsg.Len() > 0) 953 + { 954 + wxMessageBox(AutoFDOmsg, wxT("spatialite-gui"), wxOK | wxICON_INFORMATION, 955 + this); 956 + AutoFDOmsg = wxT(""); 957 + } 958 +} 959 + 960 +void MyFrame::OnDisconnect(wxCommandEvent & WXUNUSED(event)) 720 961 { 721 962 // 722 963 // disconnecting current SQLite DB 723 964 // 724 - CloseDB (); 725 - wxMenuBar *menuBar = GetMenuBar (); 726 - menuBar->Enable (ID_Connect, true); 727 - menuBar->Enable (ID_CreateNew, true); 728 - menuBar->Enable (ID_Disconnect, false); 729 - menuBar->Enable (ID_Vacuum, false); 730 - menuBar->Enable (ID_SqlScript, false); 731 - menuBar->Enable (ID_LoadShp, false); 732 - menuBar->Enable (ID_VirtualShp, false); 733 - menuBar->Enable (ID_LoadTxt, false); 734 - menuBar->Enable (ID_VirtualTxt, false); 735 - menuBar->Enable (ID_Srids, false); 736 - wxToolBar *toolBar = GetToolBar (); 737 - toolBar->EnableTool (ID_Connect, true); 738 - toolBar->EnableTool (ID_CreateNew, true); 739 - toolBar->EnableTool (ID_Disconnect, false); 740 - toolBar->EnableTool (ID_Vacuum, false); 741 - toolBar->EnableTool (ID_SqlScript, false); 742 - toolBar->EnableTool (ID_LoadShp, false); 743 - toolBar->EnableTool (ID_VirtualShp, false); 744 - toolBar->EnableTool (ID_LoadTxt, false); 745 - toolBar->EnableTool (ID_VirtualTxt, false); 746 - toolBar->EnableTool (ID_Srids, false); 747 - UpdateStatusBar (); 748 -} 749 - 750 -void 751 -MyFrame::OnCreateNew (wxCommandEvent & WXUNUSED (event)) 965 + if (TimerAutoSave) 966 + { 967 + TimerAutoSave->Stop(); 968 + delete TimerAutoSave; 969 + TimerAutoSave = NULL; 970 + } 971 + CloseDB(); 972 + ExternalSqlitePath = wxT(""); 973 + wxMenuBar *menuBar = GetMenuBar(); 974 + menuBar->Enable(ID_Connect, true); 975 + menuBar->Enable(ID_CreateNew, true); 976 + menuBar->Enable(ID_Disconnect, false); 977 + menuBar->Enable(ID_MemoryDbLoad, true); 978 + menuBar->Enable(ID_MemoryDbNew, true); 979 + menuBar->Enable(ID_MemoryDbSave, false); 980 + menuBar->Enable(ID_MemoryDbClock, false); 981 + menuBar->Enable(ID_Vacuum, false); 982 + menuBar->Enable(ID_SqlScript, false); 983 + menuBar->Enable(ID_LoadShp, false); 984 + menuBar->Enable(ID_VirtualShp, false); 985 + menuBar->Enable(ID_LoadTxt, false); 986 + menuBar->Enable(ID_VirtualTxt, false); 987 + menuBar->Enable(ID_Network, false); 988 + menuBar->Enable(ID_Exif, false); 989 + menuBar->Enable(ID_Srids, false); 990 + wxToolBar *toolBar = GetToolBar(); 991 + toolBar->EnableTool(ID_Connect, true); 992 + toolBar->EnableTool(ID_CreateNew, true); 993 + toolBar->EnableTool(ID_Disconnect, false); 994 + toolBar->EnableTool(ID_MemoryDbLoad, true); 995 + toolBar->EnableTool(ID_MemoryDbNew, true); 996 + toolBar->EnableTool(ID_MemoryDbSave, false); 997 + toolBar->EnableTool(ID_MemoryDbClock, false); 998 + toolBar->EnableTool(ID_Vacuum, false); 999 + toolBar->EnableTool(ID_SqlScript, false); 1000 + toolBar->EnableTool(ID_LoadShp, false); 1001 + toolBar->EnableTool(ID_VirtualShp, false); 1002 + toolBar->EnableTool(ID_LoadTxt, false); 1003 + toolBar->EnableTool(ID_VirtualTxt, false); 1004 + toolBar->EnableTool(ID_Network, false); 1005 + toolBar->EnableTool(ID_Exif, false); 1006 + toolBar->EnableTool(ID_Srids, false); 1007 + UpdateStatusBar(); 1008 +} 1009 + 1010 +void MyFrame::OnCreateNew(wxCommandEvent & WXUNUSED(event)) 752 1011 { 753 1012 // 754 1013 // creating a new, empty SQLite DB 755 1014 // 756 - int retdlg; 757 - int ret; 758 - wxString lastDir; 759 - wxFileDialog *fileDialog = 760 - new wxFileDialog (this, wxT ("Creating a new, empty DB"), 761 - wxT (""), wxT ("db.sqlite"), 762 - wxT 763 - ("SQLite DB (*.sqlite)|*.sqlite|All files (*.*)|*.*"), 764 - wxFD_SAVE | wxFD_OVERWRITE_PROMPT, wxDefaultPosition, 765 - wxDefaultSize, 766 - wxT ("filedlg")); 767 - lastDir = GetLastDirectory (); 768 - if (lastDir.Len () >= 1) 769 - fileDialog->SetDirectory (lastDir); 770 - retdlg = fileDialog->ShowModal (); 771 - if (retdlg == wxID_OK) 772 - { 773 - // creating the new DB 774 - SqlitePath = fileDialog->GetPath (); 775 - ret = CreateDB (); 776 - if (ret == false) 777 - goto error; 778 - wxFileName file (fileDialog->GetPath ()); 779 - lastDir = file.GetPath (); 780 - SetLastDirectory (lastDir); 781 - wxMenuBar *menuBar = GetMenuBar (); 782 - menuBar->Enable (ID_Connect, false); 783 - menuBar->Enable (ID_CreateNew, false); 784 - menuBar->Enable (ID_Disconnect, true); 785 - menuBar->Enable (ID_Vacuum, true); 786 - menuBar->Enable (ID_SqlScript, true); 787 - menuBar->Enable (ID_LoadShp, true); 788 - menuBar->Enable (ID_VirtualShp, true); 789 - menuBar->Enable (ID_LoadTxt, true); 790 - menuBar->Enable (ID_VirtualTxt, true); 791 - menuBar->Enable (ID_Srids, false); 792 - wxToolBar *toolBar = GetToolBar (); 793 - toolBar->EnableTool (ID_Connect, false); 794 - toolBar->EnableTool (ID_CreateNew, false); 795 - toolBar->EnableTool (ID_Disconnect, true); 796 - toolBar->EnableTool (ID_Vacuum, true); 797 - toolBar->EnableTool (ID_SqlScript, true); 798 - toolBar->EnableTool (ID_LoadShp, true); 799 - toolBar->EnableTool (ID_VirtualShp, true); 800 - toolBar->EnableTool (ID_LoadTxt, true); 801 - toolBar->EnableTool (ID_VirtualTxt, true); 802 - toolBar->EnableTool (ID_Srids, false); 803 - UpdateStatusBar (); 804 - return; 805 - } 806 - else 807 - return; 808 - error: 809 - unlink (SqlitePath.ToUTF8 ()); 810 - wxString msg = wxT ("An error occurred\nno DB was created"); 811 - wxMessageBox (msg, wxT ("spatialite-gui"), wxOK | wxICON_ERROR, this); 1015 + int retdlg; 1016 + int ret; 1017 + wxString lastDir; 1018 + wxFileDialog *fileDialog = 1019 + new wxFileDialog(this, wxT("Creating a new, empty DB"), 1020 + wxT(""), wxT("db.sqlite"), 1021 + wxT("SQLite DB (*.sqlite)|*.sqlite|All files (*.*)|*.*"), 1022 + wxFD_SAVE | wxFD_OVERWRITE_PROMPT, wxDefaultPosition, 1023 + wxDefaultSize, 1024 + wxT("filedlg")); 1025 + lastDir = GetLastDirectory(); 1026 + if (lastDir.Len() >= 1) 1027 + fileDialog->SetDirectory(lastDir); 1028 + retdlg = fileDialog->ShowModal(); 1029 + if (retdlg == wxID_OK) 1030 + { 1031 + // creating the new DB 1032 + SqlitePath = fileDialog->GetPath(); 1033 + ret = CreateDB(); 1034 + if (ret == false) 1035 + goto error; 1036 + wxFileName file(fileDialog->GetPath()); 1037 + lastDir = file.GetPath(); 1038 + SetLastDirectory(lastDir); 1039 + wxMenuBar *menuBar = GetMenuBar(); 1040 + menuBar->Enable(ID_Connect, false); 1041 + menuBar->Enable(ID_CreateNew, false); 1042 + menuBar->Enable(ID_Disconnect, true); 1043 + menuBar->Enable(ID_MemoryDbLoad, false); 1044 + menuBar->Enable(ID_MemoryDbNew, false); 1045 + menuBar->Enable(ID_MemoryDbSave, false); 1046 + menuBar->Enable(ID_MemoryDbClock, false); 1047 + menuBar->Enable(ID_Vacuum, true); 1048 + menuBar->Enable(ID_SqlScript, true); 1049 + menuBar->Enable(ID_LoadShp, true); 1050 + menuBar->Enable(ID_VirtualShp, true); 1051 + menuBar->Enable(ID_LoadTxt, true); 1052 + menuBar->Enable(ID_VirtualTxt, true); 1053 + menuBar->Enable(ID_Network, true); 1054 + menuBar->Enable(ID_Exif, true); 1055 + menuBar->Enable(ID_Srids, false); 1056 + wxToolBar *toolBar = GetToolBar(); 1057 + toolBar->EnableTool(ID_Connect, false); 1058 + toolBar->EnableTool(ID_CreateNew, false); 1059 + toolBar->EnableTool(ID_Disconnect, true); 1060 + toolBar->EnableTool(ID_MemoryDbLoad, false); 1061 + toolBar->EnableTool(ID_MemoryDbNew, false); 1062 + toolBar->EnableTool(ID_MemoryDbSave, false); 1063 + toolBar->EnableTool(ID_MemoryDbClock, false); 1064 + toolBar->EnableTool(ID_Vacuum, true); 1065 + toolBar->EnableTool(ID_SqlScript, true); 1066 + toolBar->EnableTool(ID_LoadShp, true); 1067 + toolBar->EnableTool(ID_VirtualShp, true); 1068 + toolBar->EnableTool(ID_LoadTxt, true); 1069 + toolBar->EnableTool(ID_VirtualTxt, true); 1070 + toolBar->EnableTool(ID_Network, true); 1071 + toolBar->EnableTool(ID_Exif, true); 1072 + toolBar->EnableTool(ID_Srids, false); 1073 + UpdateStatusBar(); 1074 + return; 1075 + } else 812 1076 return; 813 -} 814 - 815 -void 816 -MyFrame::OnVacuum (wxCommandEvent & WXUNUSED (event)) 1077 +error: 1078 + unlink(SqlitePath.ToUTF8()); 1079 + wxString msg = wxT("An error occurred\nno DB was created"); 1080 + wxMessageBox(msg, wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 1081 + return; 1082 +} 1083 + 1084 +void MyFrame::OnMemoryDbLoad(wxCommandEvent & WXUNUSED(event)) 1085 +{ 1086 +// 1087 +// loading an external DB into the MEMORY-DB 1088 +// 1089 + sqlite3 *extSqlite = NULL; 1090 + sqlite3_backup *backup; 1091 + int retdlg; 1092 + int ret; 1093 + wxString lastDir; 1094 + char path[1024]; 1095 + wxString error; 1096 + wxFileDialog *fileDialog = 1097 + new wxFileDialog(this, wxT("Loading an existing DB into the MEMORY-DB"), 1098 + wxT(""), wxT("db.sqlite"), 1099 + wxT("SQLite DB (*.sqlite)|*.sqlite|All files (*.*)|*.*"), 1100 + wxFD_OPEN | wxFD_FILE_MUST_EXIST, 1101 + wxDefaultPosition, 1102 + wxDefaultSize, 1103 + wxT("filedlg")); 1104 + lastDir = GetLastDirectory(); 1105 + if (lastDir.Len() >= 1) 1106 + fileDialog->SetDirectory(lastDir); 1107 + retdlg = fileDialog->ShowModal(); 1108 + if (retdlg == wxID_OK) 1109 + { 1110 + // opening the external DB 1111 + ExternalSqlitePath = fileDialog->GetPath(); 1112 + strcpy(path, ExternalSqlitePath.ToUTF8()); 1113 + ret = sqlite3_open_v2(path, &extSqlite, SQLITE_OPEN_READWRITE, NULL); 1114 + if (ret) 1115 + { 1116 + // an error occurred 1117 + wxString errCause = wxString::FromUTF8(sqlite3_errmsg(SqliteHandle)); 1118 + error = wxT("Failure while connecting to DB\n\n"); 1119 + error += errCause; 1120 + error += wxT("\n"); 1121 + goto stop; 1122 + } 1123 + ret = 1124 + sqlite3_open_v2(":memory:", &SqliteHandle, 1125 + SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL); 1126 + if (ret) 1127 + { 1128 + // an error occurred 1129 + wxString errCause = wxString::FromUTF8(sqlite3_errmsg(SqliteHandle)); 1130 + error = wxT("MEMORY-DB: an error occurred \n\n"); 1131 + error += errCause; 1132 + error += +wxT("\n"); 1133 + goto stop; 1134 + } 1135 + wxFileName file(fileDialog->GetPath()); 1136 + lastDir = file.GetPath(); 1137 + SetLastDirectory(lastDir); 1138 + backup = sqlite3_backup_init(SqliteHandle, "main", extSqlite, "main"); 1139 + if (!backup) 1140 + goto stop; 1141 + while (1) 1142 + { 1143 + ret = sqlite3_backup_step(backup, 1024); 1144 + if (ret == SQLITE_DONE) 1145 + break; 1146 + } 1147 + ret = sqlite3_backup_finish(backup); 1148 + sqlite3_close(extSqlite); 1149 + MemoryDatabase = true; 1150 + AutoSaveInterval = 120; 1151 + AutoFDOStart(); 1152 + InitTableTree(); 1153 + bool metadata = CheckMetadata(); 1154 + wxMenuBar *menuBar = GetMenuBar(); 1155 + menuBar->Enable(ID_Connect, false); 1156 + menuBar->Enable(ID_CreateNew, false); 1157 + menuBar->Enable(ID_Disconnect, true); 1158 + menuBar->Enable(ID_MemoryDbLoad, false); 1159 + menuBar->Enable(ID_MemoryDbNew, false); 1160 + if (MemoryDatabase == true) 1161 + { 1162 + menuBar->Enable(ID_MemoryDbSave, true); 1163 + menuBar->Enable(ID_MemoryDbClock, true); 1164 + } else 1165 + { 1166 + menuBar->Enable(ID_MemoryDbSave, false); 1167 + menuBar->Enable(ID_MemoryDbClock, false); 1168 + } 1169 + menuBar->Enable(ID_Vacuum, true); 1170 + menuBar->Enable(ID_SqlScript, true); 1171 + menuBar->Enable(ID_LoadShp, true); 1172 + menuBar->Enable(ID_VirtualShp, true); 1173 + menuBar->Enable(ID_LoadTxt, true); 1174 + menuBar->Enable(ID_VirtualTxt, true); 1175 + menuBar->Enable(ID_Network, true); 1176 + menuBar->Enable(ID_Exif, true); 1177 + menuBar->Enable(ID_Srids, metadata); 1178 + wxToolBar *toolBar = GetToolBar(); 1179 + toolBar->EnableTool(ID_Connect, false); 1180 + toolBar->EnableTool(ID_CreateNew, false); 1181 + toolBar->EnableTool(ID_Disconnect, true); 1182 + toolBar->EnableTool(ID_MemoryDbLoad, false); 1183 + toolBar->EnableTool(ID_MemoryDbNew, false); 1184 + if (MemoryDatabase == true) 1185 + { 1186 + toolBar->EnableTool(ID_MemoryDbSave, true); 1187 + toolBar->EnableTool(ID_MemoryDbClock, true); 1188 + } else 1189 + { 1190 + toolBar->EnableTool(ID_MemoryDbSave, false); 1191 + toolBar->EnableTool(ID_MemoryDbClock, false); 1192 + } 1193 + toolBar->EnableTool(ID_Vacuum, true); 1194 + toolBar->EnableTool(ID_SqlScript, true); 1195 + toolBar->EnableTool(ID_LoadShp, true); 1196 + toolBar->EnableTool(ID_VirtualShp, true); 1197 + toolBar->EnableTool(ID_LoadTxt, true); 1198 + toolBar->EnableTool(ID_VirtualTxt, true); 1199 + toolBar->EnableTool(ID_Network, true); 1200 + toolBar->EnableTool(ID_Exif, true); 1201 + toolBar->EnableTool(ID_Srids, metadata); 1202 + UpdateStatusBar(); 1203 + if (AutoSaveInterval <= 0) 1204 + { 1205 + if (TimerAutoSave) 1206 + { 1207 + TimerAutoSave->Stop(); 1208 + delete TimerAutoSave; 1209 + TimerAutoSave = NULL; 1210 + } 1211 + } else 1212 + { 1213 + // 1214 + // starting the AutoSave timer 1215 + // 1216 + if (!TimerAutoSave) 1217 + TimerAutoSave = new wxTimer(this, ID_AUTO_SAVE_TIMER); 1218 + else 1219 + TimerAutoSave->Stop(); 1220 + LastTotalChanges = 0; 1221 + TimerAutoSave->Start(AutoSaveInterval * 1000, wxTIMER_ONE_SHOT); 1222 + } 1223 + } 1224 + if (AutoFDOmsg.Len() > 0) 1225 + { 1226 + wxMessageBox(AutoFDOmsg, wxT("spatialite-gui"), wxOK | wxICON_INFORMATION, 1227 + this); 1228 + AutoFDOmsg = wxT(""); 1229 + } 1230 + return; 1231 +stop: 1232 + MemoryDatabase = false; 1233 + if (SqliteHandle) 1234 + sqlite3_close(SqliteHandle); 1235 + if (extSqlite) 1236 + sqlite3_close(extSqlite); 1237 + wxString msg = wxT("MEMORY-DB wasn't loaded\n\n"); 1238 + msg += error; 1239 + wxMessageBox(msg, wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 1240 + SqliteHandle = NULL; 1241 +} 1242 + 1243 +void MyFrame::OnMemoryDbNew(wxCommandEvent & WXUNUSED(event)) 1244 +{ 1245 +// 1246 +//creating a new MEMORY-DB 1247 +// 1248 + int ret; 1249 + wxToolBar *toolBar; 1250 + wxMenuBar *menuBar; 1251 + bool metadata; 1252 + MemoryDatabase = true; 1253 + AutoSaveInterval = 120; 1254 + ExternalSqlitePath = wxT(""); 1255 +// creating the new MEMORY-DB 1256 + ret = CreateDB(); 1257 + if (ret == false) 1258 + goto error; 1259 + metadata = CheckMetadata(); 1260 + menuBar = GetMenuBar(); 1261 + menuBar->Enable(ID_Connect, false); 1262 + menuBar->Enable(ID_CreateNew, false); 1263 + menuBar->Enable(ID_Disconnect, true); 1264 + menuBar->Enable(ID_MemoryDbLoad, false); 1265 + menuBar->Enable(ID_MemoryDbNew, false); 1266 + menuBar->Enable(ID_MemoryDbSave, true); 1267 + menuBar->Enable(ID_MemoryDbClock, true); 1268 + menuBar->Enable(ID_Vacuum, true); 1269 + menuBar->Enable(ID_SqlScript, true); 1270 + menuBar->Enable(ID_LoadShp, true); 1271 + menuBar->Enable(ID_VirtualShp, true); 1272 + menuBar->Enable(ID_LoadTxt, true); 1273 + menuBar->Enable(ID_VirtualTxt, true); 1274 + menuBar->Enable(ID_Network, true); 1275 + menuBar->Enable(ID_Exif, true); 1276 + menuBar->Enable(ID_Srids, metadata); 1277 + toolBar = GetToolBar(); 1278 + toolBar->EnableTool(ID_Connect, false); 1279 + toolBar->EnableTool(ID_CreateNew, false); 1280 + toolBar->EnableTool(ID_Disconnect, true); 1281 + toolBar->EnableTool(ID_MemoryDbLoad, false); 1282 + toolBar->EnableTool(ID_MemoryDbNew, false); 1283 + toolBar->EnableTool(ID_MemoryDbSave, true); 1284 + toolBar->EnableTool(ID_MemoryDbClock, true); 1285 + toolBar->EnableTool(ID_Vacuum, true); 1286 + toolBar->EnableTool(ID_SqlScript, true); 1287 + toolBar->EnableTool(ID_LoadShp, true); 1288 + toolBar->EnableTool(ID_VirtualShp, true); 1289 + toolBar->EnableTool(ID_LoadTxt, true); 1290 + toolBar->EnableTool(ID_VirtualTxt, true); 1291 + toolBar->EnableTool(ID_Network, true); 1292 + toolBar->EnableTool(ID_Exif, true); 1293 + toolBar->EnableTool(ID_Srids, metadata); 1294 + UpdateStatusBar(); 1295 + if (AutoSaveInterval <= 0) 1296 + { 1297 + if (TimerAutoSave) 1298 + { 1299 + TimerAutoSave->Stop(); 1300 + delete TimerAutoSave; 1301 + TimerAutoSave = NULL; 1302 + } 1303 + } else 1304 + { 1305 + // 1306 + // starting the AutoSave timer 1307 + // 1308 + if (!TimerAutoSave) 1309 + TimerAutoSave = new wxTimer(this, ID_AUTO_SAVE_TIMER); 1310 + else 1311 + TimerAutoSave->Stop(); 1312 + LastTotalChanges = 0; 1313 + TimerAutoSave->Start(AutoSaveInterval * 1000, wxTIMER_ONE_SHOT); 1314 + } 1315 + return; 1316 +error: 1317 + wxString msg = wxT("An error occurred\nno MEMORY-DB was created"); 1318 + wxMessageBox(msg, wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 1319 + return; 1320 +} 1321 + 1322 +bool MyFrame::MemoryDbSave() 1323 +{ 1324 +// 1325 +// trying to export the MEMORY-DB into an external DB 1326 +// 1327 + sqlite3 *extSqlite = NULL; 1328 + sqlite3_backup *backup; 1329 + char path[1024]; 1330 + char bak_path[1024]; 1331 + int ret; 1332 + wxString error; 1333 + if (ExternalSqlitePath.Len() == 0) 1334 + return false; 1335 + ::wxBeginBusyCursor(); 1336 + strcpy(path, ExternalSqlitePath.ToUTF8()); 1337 + strcpy(bak_path, path); 1338 + strcat(bak_path, ".bak"); 1339 + unlink(bak_path); 1340 + rename(path, bak_path); 1341 + ret = 1342 + sqlite3_open_v2(path, &extSqlite, 1343 + SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL); 1344 + if (ret) 1345 + { 1346 + // an error occurred 1347 + wxString errCause = wxString::FromUTF8(sqlite3_errmsg(extSqlite)); 1348 + error = wxT("An error occurred\n\n"); 1349 + error += errCause; 1350 + error += +wxT("\n"); 1351 + error += ExternalSqlitePath; 1352 + goto stop; 1353 + } 1354 + backup = sqlite3_backup_init(extSqlite, "main", SqliteHandle, "main"); 1355 + if (!backup) 1356 + goto stop; 1357 + while (1) 1358 + { 1359 + ret = sqlite3_backup_step(backup, 1024); 1360 + if (ret == SQLITE_DONE) 1361 + break; 1362 + } 1363 + ret = sqlite3_backup_finish(backup); 1364 + sqlite3_close(extSqlite); 1365 + unlink(bak_path); 1366 + ::wxEndBusyCursor(); 1367 + LastTotalChanges = sqlite3_total_changes(SqliteHandle); 1368 + return true; 1369 +stop: 1370 + if (extSqlite) 1371 + sqlite3_close(extSqlite); 1372 + wxString msg = wxT("Backup failure: MEMORY-DB wasn't saved\n\n"); 1373 + msg += error; 1374 + wxMessageBox(msg, wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 1375 + ExternalSqlitePath = wxT(""); 1376 + ::wxEndBusyCursor(); 1377 + return false; 1378 +} 1379 + 1380 +void MyFrame::OnMemoryDbSave(wxCommandEvent & WXUNUSED(event)) 1381 +{ 1382 +// 1383 +// exporting the MEMORY-DB into an external DB 1384 +// 1385 + int retdlg; 1386 + wxString lastDir; 1387 + if (ExternalSqlitePath.Len() > 0) 1388 + { 1389 + if (MemoryDbSave() == true) 1390 + { 1391 + wxMessageBox(wxT("Ok, MEMORY-DB was succesfully saved"), 1392 + wxT("spatialite-gui"), wxOK | wxICON_INFORMATION, this); 1393 + if (AutoSaveInterval <= 0) 1394 + { 1395 + if (TimerAutoSave) 1396 + { 1397 + TimerAutoSave->Stop(); 1398 + delete TimerAutoSave; 1399 + TimerAutoSave = NULL; 1400 + } 1401 + } else 1402 + { 1403 + // 1404 + // restarting the AutoSave timer 1405 + // 1406 + if (!TimerAutoSave) 1407 + TimerAutoSave = new wxTimer(this, ID_AUTO_SAVE_TIMER); 1408 + else 1409 + TimerAutoSave->Stop(); 1410 + TimerAutoSave->Start(AutoSaveInterval * 1000, wxTIMER_ONE_SHOT); 1411 + } 1412 + return; 1413 + } 1414 + } 1415 + wxFileDialog *fileDialog = new wxFileDialog(this, wxT("Saving the MEMORY-DB"), 1416 + wxT(""), wxT("db.sqlite"), 1417 + wxT 1418 + ("SQLite DB (*.sqlite)|*.sqlite|All files (*.*)|*.*"), 1419 + wxFD_SAVE | wxFD_OVERWRITE_PROMPT, 1420 + wxDefaultPosition, 1421 + wxDefaultSize, 1422 + wxT("filedlg")); 1423 + lastDir = GetLastDirectory(); 1424 + if (lastDir.Len() >= 1) 1425 + fileDialog->SetDirectory(lastDir); 1426 + retdlg = fileDialog->ShowModal(); 1427 + if (retdlg == wxID_OK) 1428 + { 1429 + // exporting the external DB 1430 + ExternalSqlitePath = fileDialog->GetPath(); 1431 + if (MemoryDbSave() == true) 1432 + { 1433 + wxMessageBox(wxT("Ok, MEMORY-DB was succesfully saved"), 1434 + wxT("spatialite-gui"), wxOK | wxICON_INFORMATION, this); 1435 + wxFileName file(fileDialog->GetPath()); 1436 + lastDir = file.GetPath(); 1437 + SetLastDirectory(lastDir); 1438 + if (AutoSaveInterval <= 0) 1439 + { 1440 + if (TimerAutoSave) 1441 + { 1442 + TimerAutoSave->Stop(); 1443 + delete TimerAutoSave; 1444 + TimerAutoSave = NULL; 1445 + } 1446 + } else 1447 + { 1448 + // 1449 + // restarting the AutoSave timer 1450 + // 1451 + if (!TimerAutoSave) 1452 + TimerAutoSave = new wxTimer(this, ID_AUTO_SAVE_TIMER); 1453 + else 1454 + TimerAutoSave->Stop(); 1455 + TimerAutoSave->Start(AutoSaveInterval * 1000, wxTIMER_ONE_SHOT); 1456 + } 1457 + } 1458 + } 1459 +} 1460 + 1461 +void MyFrame::OnMemoryDbClock(wxCommandEvent & WXUNUSED(event)) 1462 +{ 1463 +// 1464 +// setting up AutoSave for MEMORY-DB 1465 +// 1466 + AutoSaveDialog dlg; 1467 + dlg.Create(this, ExternalSqlitePath, AutoSaveInterval); 1468 + int ret = dlg.ShowModal(); 1469 + if (ret == wxID_OK) 1470 + { 1471 + AutoSaveInterval = dlg.GetSeconds(); 1472 + if (AutoSaveInterval <= 0) 1473 + { 1474 + // 1475 + // stopping the AutoSave timer 1476 + // 1477 + if (TimerAutoSave) 1478 + { 1479 + TimerAutoSave->Stop(); 1480 + delete TimerAutoSave; 1481 + TimerAutoSave = NULL; 1482 + } 1483 + } else 1484 + { 1485 + // 1486 + // restarting the AutoSave timer 1487 + // 1488 + if (!TimerAutoSave) 1489 + TimerAutoSave = new wxTimer(this, ID_AUTO_SAVE_TIMER); 1490 + else 1491 + TimerAutoSave->Stop(); 1492 + TimerAutoSave->Start(AutoSaveInterval * 1000, wxTIMER_ONE_SHOT); 1493 + } 1494 + } 1495 +} 1496 + 1497 +void MyFrame::OnVacuum(wxCommandEvent & WXUNUSED(event)) 817 1498 { 818 1499 // 819 1500 // performing a VACUUM in order to reorganize the current DB 820 1501 // 821 - char *errMsg = NULL; 822 - ::wxBeginBusyCursor (); 823 - int ret = 824 - sqlite3_exec (SqliteHandle, "ANALYZE; VACUUM;", NULL, NULL, &errMsg); 825 - if (ret != SQLITE_OK) 826 - { 827 - wxMessageBox (wxT ("SQLite SQL error: ") + 828 - wxString::FromUTF8 (errMsg), wxT ("spatialite-gui"), 829 - wxOK | wxICON_ERROR, this); 830 - sqlite3_free (errMsg); 831 - } 832 - else 833 - { 834 - wxMessageBox (wxT ("Current DB was succesfully optimized"), 835 - wxT ("spatialite-gui"), wxOK | wxICON_INFORMATION, 836 - this); 837 - } 838 - ::wxEndBusyCursor (); 1502 + char *errMsg = NULL; 1503 + ::wxBeginBusyCursor(); 1504 + int ret = sqlite3_exec(SqliteHandle, "ANALYZE; VACUUM;", NULL, NULL, &errMsg); 1505 + if (ret != SQLITE_OK) 1506 + { 1507 + wxMessageBox(wxT("SQLite SQL error: ") + wxString::FromUTF8(errMsg), 1508 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 1509 + sqlite3_free(errMsg); 1510 + } else 1511 + { 1512 + wxMessageBox(wxT("Current DB was succesfully optimized"), 1513 + wxT("spatialite-gui"), wxOK | wxICON_INFORMATION, this); 1514 + } 1515 + ::wxEndBusyCursor(); 839 1516 } 840 1517 841 -char * 842 -MyFrame::ReadSqlLine (FILE * in, int *len, int *eof) 1518 +char *MyFrame::ReadSqlLine(FILE * in, int *len, int *eof) 843 1519 { 844 1520 // 845 1521 // reading an SQL script line 846 1522 // 847 - int c; 848 - *eof = 0; 849 - int size = 4096; 850 - char *line = (char *) malloc (size); 851 - int off = 0; 852 - while ((c = getc (in)) != EOF) 853 - { 854 - // consuming input one chat at each time 855 - if (off == size) 856 - { 857 - // buffer overflow; reallocating a bigger one 858 - // presumably this is because there is some BLOB, so we'll grow by 1MB at each time 859 - size += 1024 * 1024; 860 - line = (char *) realloc (line, size); 861 - } 862 - *(line + off) = c; 863 - off++; 864 - if (c == '\n') 865 - { 866 - // end of line marker 867 - *(line + off) = '\0'; 868 - *len = off; 869 - return line; 870 - } 871 - if (c == ';') 872 - { 873 - // end of SQL statement marker 874 - *(line + off) = '\0'; 875 - *len = off; 876 - return line; 877 - } 878 - } 1523 + int c; 1524 + *eof = 0; 1525 + int size = 4096; 1526 + char *line = (char *) malloc(size); 1527 + int off = 0; 1528 + while ((c = getc(in)) != EOF) 1529 + { 1530 + // consuming input one chat at each time 1531 + if (off == size) 1532 + { 1533 + // buffer overflow; reallocating a bigger one 1534 + // presumably this is because there is some BLOB, so we'll grow by 1MB at each time 1535 + size += 1024 * 1024; 1536 + line = (char *) realloc(line, size); 1537 + } 1538 + *(line + off) = c; 1539 + off++; 1540 + if (c == '\n') 1541 + { 1542 + // end of line marker 1543 + *(line + off) = '\0'; 1544 + *len = off; 1545 + return line; 1546 + } 1547 + if (c == ';') 1548 + { 1549 + // end of SQL statement marker 1550 + *(line + off) = '\0'; 1551 + *len = off; 1552 + return line; 1553 + } 1554 + } 879 1555 // EOF reached 880 - *len = off; 881 - *eof = 1; 882 - return line; 1556 + *len = off; 1557 + *eof = 1; 1558 + return line; 883 1559 } 884 1560 885 -void 886 -MyFrame::OnSqlScript (wxCommandEvent & WXUNUSED (event)) 1561 +void MyFrame::OnSqlScript(wxCommandEvent & WXUNUSED(event)) 887 1562 { 888 1563 // 889 1564 // executing an SQL Script 890 1565 // 891 - int ret; 892 - wxString lastDir; 893 - wxString path; 894 - wxString charset; 895 - FILE *sql; 896 - char *line = NULL; 897 - char *statement = NULL; 898 - int stmt_len = 0; 899 - char *prev_stmt; 900 - int prev_len; 901 - int eof; 902 - int rowNo = 1; 903 - int stmt = 0; 904 - int len; 905 - wxString msg; 906 - void *cvtCS = NULL; 907 - char *utf8stmt = NULL; 908 - int cvtErr; 909 - wxFileDialog *fileDialog = new wxFileDialog (this, wxT ("SQL Script"), 910 - wxT (""), 911 - wxT ("init_spatialite.sql"), 912 - wxT 913 - ("SQL script (*.sql)|*.sql|All files (*.*)|*.*"), 914 - wxFD_OPEN | 915 - wxFD_FILE_MUST_EXIST, 916 - wxDefaultPosition, 917 - wxDefaultSize, 918 - wxT ("filedlg")); 919 - lastDir = GetLastDirectory (); 920 - if (lastDir.Len () >= 1) 921 - fileDialog->SetDirectory (lastDir); 922 - ret = fileDialog->ShowModal (); 923 - if (ret == wxID_OK) 924 - { 925 - path = fileDialog->GetPath (); 926 - SqlScriptDialog dlg; 927 - dlg.Create (this, path, LocaleCharset); 928 - ret = dlg.ShowModal (); 929 - if (ret == wxID_OK) 930 - charset = dlg.GetCharset (); 931 - else 932 - return; 933 - // opening the SQL script 934 - sql = fopen (path.ToUTF8 (), "r"); 935 - if (sql == NULL) 936 - { 937 - wxMessageBox (wxT ("can't open: ") + fileDialog->GetPath (), 938 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 939 - this); 940 - } 941 - else 942 - { 943 - wxFileName file (fileDialog->GetPath ()); 944 - lastDir = file.GetPath (); 945 - SetLastDirectory (lastDir); 946 - cvtCS = gaiaCreateUTF8Converter (charset.ToUTF8 ()); 947 - if (!cvtCS) 948 - { 949 - msg = charset + wxT (": unsupported CharacterSet"); 950 - wxMessageBox (msg, wxT ("spatialite-gui"), 951 - wxOK | wxICON_WARNING, this); 952 - goto stop; 953 - } 954 - ::wxBeginBusyCursor (); 955 - while (1) 956 - { 957 - // reading the SQL script lines 958 - line = ReadSqlLine (sql, &len, &eof); 959 - if (len > 0) 960 - { 961 - if (statement == NULL) 962 - { 963 - statement = line; 964 - stmt_len = len; 965 - } 966 - else 967 - { 968 - // appending line to SQL statement 969 - prev_stmt = statement; 970 - prev_len = stmt_len; 971 - stmt_len = prev_len + len; 972 - statement = (char *) malloc (stmt_len + 1); 973 - memcpy (statement, prev_stmt, prev_len); 974 - memcpy (statement + prev_len, line, len); 975 - *(statement + stmt_len) = '\0'; 976 - free (prev_stmt); 977 - free (line); 978 - line = NULL; 979 - } 980 - } 981 - else 982 - { 983 - free (line); 984 - line = NULL; 985 - } 986 - if (statement) 987 - { 988 - if (sqlite3_complete (statement)) 989 - { 990 - // executing the SQL statement 991 - utf8stmt = 992 - gaiaConvertToUTF8 (cvtCS, statement, 993 - stmt_len, &cvtErr); 994 - free (statement); 995 - statement = NULL; 996 - stmt_len = 0; 997 - if (cvtErr || !utf8stmt) 998 - { 999 - Rollback (); 1000 - msg = 1001 - wxT 1002 - ("SQL Script abnormal termination\nillegal character sequence"); 1003 - msg += 1004 - wxT 1005 - ("\n\nROLLBACK was automatically performed"); 1006 - wxMessageBox (msg, 1007 - wxT ("spatialite-gui"), 1008 - wxOK | wxICON_WARNING, 1009 - this); 1010 - goto stop; 1011 - } 1012 - if (ExecuteSql (utf8stmt, rowNo) == false) 1013 - { 1014 - Rollback (); 1015 - msg = 1016 - wxT 1017 - ("SQL Script abnormal termination\nan error occurred"); 1018 - msg += 1019 - wxT 1020 - ("\n\nROLLBACK was automatically performed"); 1021 - wxMessageBox (msg, 1022 - wxT ("spatialite-gui"), 1023 - wxOK | wxICON_WARNING, 1024 - this); 1025 - goto stop; 1026 - } 1027 - else 1028 - { 1029 - stmt++; 1030 - free (utf8stmt); 1031 - utf8stmt = NULL; 1032 - } 1033 - } 1034 - } 1035 - rowNo++; 1036 - if (eof) 1037 - break; 1038 - } 1039 - msg.Printf (wxT 1040 - ("SQL Script normal termination\n\n%d SQL statements where performed"), 1041 - stmt); 1042 - wxMessageBox (msg, wxT ("spatialite-gui"), 1043 - wxOK | wxICON_INFORMATION, this); 1044 - stop: 1045 - if (cvtCS) 1046 - gaiaFreeUTF8Converter (cvtCS); 1047 - if (utf8stmt) 1048 - free (utf8stmt); 1049 - if (statement) 1050 - free (statement); 1051 - if (line) 1052 - free (line); 1053 - fclose (sql); 1054 - ::wxEndBusyCursor (); 1055 - } 1056 - } 1057 -} 1058 - 1059 -void 1060 -MyFrame::OnLoadShp (wxCommandEvent & WXUNUSED (event)) 1566 + int ret; 1567 + wxString lastDir; 1568 + wxString path; 1569 + wxString charset; 1570 + FILE *sql; 1571 + char *line = NULL; 1572 + char *statement = NULL; 1573 + int stmt_len = 0; 1574 + char *prev_stmt; 1575 + int prev_len; 1576 + int eof; 1577 + int rowNo = 1; 1578 + int stmt = 0; 1579 + int len; 1580 + wxString msg; 1581 + char dummy[128]; 1582 + void *cvtCS = NULL; 1583 + char *utf8stmt = NULL; 1584 + int cvtErr; 1585 + wxFileDialog *fileDialog = new wxFileDialog(this, wxT("SQL Script"), 1586 + wxT(""), 1587 + wxT("init_spatialite.sql"), 1588 + wxT 1589 + ("SQL script (*.sql)|*.sql|All files (*.*)|*.*"), 1590 + wxFD_OPEN | wxFD_FILE_MUST_EXIST, 1591 + wxDefaultPosition, 1592 + wxDefaultSize, 1593 + wxT("filedlg")); 1594 + lastDir = GetLastDirectory(); 1595 + if (lastDir.Len() >= 1) 1596 + fileDialog->SetDirectory(lastDir); 1597 + ret = fileDialog->ShowModal(); 1598 + if (ret == wxID_OK) 1599 + { 1600 + path = fileDialog->GetPath(); 1601 + SqlScriptDialog dlg; 1602 + dlg.Create(this, path, LocaleCharset); 1603 + ret = dlg.ShowModal(); 1604 + if (ret == wxID_OK) 1605 + charset = dlg.GetCharset(); 1606 + else 1607 + return; 1608 + // opening the SQL script 1609 + sql = fopen(path.ToUTF8(), "r"); 1610 + if (sql == NULL) 1611 + { 1612 + wxMessageBox(wxT("can't open: ") + fileDialog->GetPath(), 1613 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 1614 + } else 1615 + { 1616 + wxFileName file(fileDialog->GetPath()); 1617 + lastDir = file.GetPath(); 1618 + SetLastDirectory(lastDir); 1619 + cvtCS = gaiaCreateUTF8Converter(charset.ToUTF8()); 1620 + if (!cvtCS) 1621 + { 1622 + msg = charset + wxT(": unsupported CharacterSet"); 1623 + wxMessageBox(msg, wxT("spatialite-gui"), wxOK | wxICON_WARNING, 1624 + this); 1625 + goto stop; 1626 + } 1627 + ::wxBeginBusyCursor(); 1628 + while (1) 1629 + { 1630 + // reading the SQL script lines 1631 + line = ReadSqlLine(sql, &len, &eof); 1632 + if (len > 0) 1633 + { 1634 + if (statement == NULL) 1635 + { 1636 + statement = line; 1637 + stmt_len = len; 1638 + } else 1639 + { 1640 + // appending line to SQL statement 1641 + prev_stmt = statement; 1642 + prev_len = stmt_len; 1643 + stmt_len = prev_len + len; 1644 + statement = (char *) malloc(stmt_len + 1); 1645 + memcpy(statement, prev_stmt, prev_len); 1646 + memcpy(statement + prev_len, line, len); 1647 + *(statement + stmt_len) = '\0'; 1648 + free(prev_stmt); 1649 + free(line); 1650 + line = NULL; 1651 + } 1652 + } else 1653 + { 1654 + free(line); 1655 + line = NULL; 1656 + } 1657 + if (statement) 1658 + { 1659 + if (sqlite3_complete(statement)) 1660 + { 1661 + // executing the SQL statement 1662 + utf8stmt = 1663 + gaiaConvertToUTF8(cvtCS, statement, stmt_len, &cvtErr); 1664 + free(statement); 1665 + statement = NULL; 1666 + stmt_len = 0; 1667 + if (cvtErr || !utf8stmt) 1668 + { 1669 + Rollback(); 1670 + msg = 1671 + wxT 1672 + ("SQL Script abnormal termination\nillegal character sequence"); 1673 + msg += 1674 + wxT("\n\nROLLBACK was automatically performed"); 1675 + wxMessageBox(msg, wxT("spatialite-gui"), 1676 + wxOK | wxICON_WARNING, this); 1677 + goto stop; 1678 + } 1679 + if (ExecuteSql(utf8stmt, rowNo) == false) 1680 + { 1681 + Rollback(); 1682 + msg = 1683 + wxT 1684 + ("SQL Script abnormal termination\nan error occurred"); 1685 + msg += 1686 + wxT("\n\nROLLBACK was automatically performed"); 1687 + wxMessageBox(msg, wxT("spatialite-gui"), 1688 + wxOK | wxICON_WARNING, this); 1689 + goto stop; 1690 + } else 1691 + { 1692 + stmt++; 1693 + free(utf8stmt); 1694 + utf8stmt = NULL; 1695 + } 1696 + } 1697 + } 1698 + rowNo++; 1699 + if (eof) 1700 + break; 1701 + } 1702 + sprintf(dummy, 1703 + "SQL Script normal termination\n\n%d SQL statements where performed", 1704 + stmt); 1705 + msg = wxString::FromUTF8(dummy); 1706 + wxMessageBox(msg, wxT("spatialite-gui"), wxOK | wxICON_INFORMATION, 1707 + this); 1708 + stop: 1709 + if (cvtCS) 1710 + gaiaFreeUTF8Converter(cvtCS); 1711 + if (utf8stmt) 1712 + free(utf8stmt); 1713 + if (statement) 1714 + free(statement); 1715 + if (line) 1716 + free(line); 1717 + fclose(sql); 1718 + ::wxEndBusyCursor(); 1719 + } 1720 + } 1721 +} 1722 + 1723 +void MyFrame::OnLoadShp(wxCommandEvent & WXUNUSED(event)) 1061 1724 { 1062 1725 // 1063 1726 // loading a shapefile 1064 1727 // 1065 - int ret; 1066 - wxString table; 1067 - wxString column = wxT ("Geometry"); 1068 - wxString charset; 1069 - int srid = -1; 1070 - wxString path; 1071 - wxString lastDir; 1072 - wxFileDialog *fileDialog = new wxFileDialog (this, wxT ("Load Shapefile"), 1073 - wxT (""), 1074 - wxT ("shapefile.shp"), 1075 - wxT 1076 - ("Shapefile (*.shp)|*.shp|All files (*.*)|*.*"), 1077 - wxFD_OPEN | 1078 - wxFD_FILE_MUST_EXIST, 1079 - wxDefaultPosition, 1080 - wxDefaultSize, 1081 - wxT ("filedlg")); 1082 - lastDir = GetLastDirectory (); 1083 - if (lastDir.Len () >= 1) 1084 - fileDialog->SetDirectory (lastDir); 1085 - ret = fileDialog->ShowModal (); 1086 - if (ret == wxID_OK) 1087 - { 1088 - wxFileName file (fileDialog->GetPath ()); 1089 - lastDir = file.GetPath (); 1090 - table = file.GetName (); 1091 - path = file.GetPath (); 1092 - path += file.GetPathSeparator (); 1093 - path += file.GetName (); 1094 - LoadShpDialog dlg; 1095 - dlg.Create (this, path, table, srid, column, LocaleCharset); 1096 - ret = dlg.ShowModal (); 1097 - if (ret == wxID_OK) 1098 - { 1099 - SetLastDirectory (lastDir); 1100 - table = dlg.GetTable (); 1101 - srid = dlg.GetSrid (); 1102 - column = dlg.GetColumn (); 1103 - charset = dlg.GetCharset (); 1104 - LoadShapefile (path, table, srid, column, charset); 1105 - } 1106 - } 1107 -} 1108 - 1109 -void 1110 -MyFrame::OnVirtualShp (wxCommandEvent & WXUNUSED (event)) 1728 + int ret; 1729 + wxString table; 1730 + wxString column = wxT("Geometry"); 1731 + wxString charset; 1732 + int srid = -1; 1733 + wxString path; 1734 + wxString lastDir; 1735 + wxFileDialog *fileDialog = new wxFileDialog(this, wxT("Load Shapefile"), 1736 + wxT(""), 1737 + wxT("shapefile.shp"), 1738 + wxT 1739 + ("Shapefile (*.shp)|*.shp|All files (*.*)|*.*"), 1740 + wxFD_OPEN | wxFD_FILE_MUST_EXIST, 1741 + wxDefaultPosition, 1742 + wxDefaultSize, 1743 + wxT("filedlg")); 1744 + lastDir = GetLastDirectory(); 1745 + if (lastDir.Len() >= 1) 1746 + fileDialog->SetDirectory(lastDir); 1747 + ret = fileDialog->ShowModal(); 1748 + if (ret == wxID_OK) 1749 + { 1750 + wxFileName file(fileDialog->GetPath()); 1751 + lastDir = file.GetPath(); 1752 + table = file.GetName(); 1753 + path = file.GetPath(); 1754 + path += file.GetPathSeparator(); 1755 + path += file.GetName(); 1756 + LoadShpDialog dlg; 1757 + dlg.Create(this, path, table, srid, column, LocaleCharset); 1758 + ret = dlg.ShowModal(); 1759 + if (ret == wxID_OK) 1760 + { 1761 + SetLastDirectory(lastDir); 1762 + table = dlg.GetTable(); 1763 + srid = dlg.GetSrid(); 1764 + column = dlg.GetColumn(); 1765 + charset = dlg.GetCharset(); 1766 + LoadShapefile(path, table, srid, column, charset); 1767 + } 1768 + } 1769 +} 1770 + 1771 +void MyFrame::OnVirtualShp(wxCommandEvent & WXUNUSED(event)) 1111 1772 { 1112 1773 // 1113 1774 // creating a VirtualShape 1114 1775 // 1115 - int ret; 1116 - wxString charset; 1117 - int srid; 1118 - wxString xSrid; 1119 - wxString sql; 1120 - wxString path; 1121 - wxString table; 1122 - wxString lastDir; 1123 - char *errMsg = NULL; 1124 - sqlite3 *sqlite = GetSqlite (); 1125 - wxFileDialog *fileDialog = new wxFileDialog (this, wxT ("VirtualShape"), 1126 - wxT (""), 1127 - wxT ("shapefile.shp"), 1128 - wxT 1129 - ("Shapefile (*.shp)|*.shp|All files (*.*)|*.*"), 1130 - wxFD_OPEN | 1131 - wxFD_FILE_MUST_EXIST, 1132 - wxDefaultPosition, 1133 - wxDefaultSize, 1134 - wxT ("filedlg")); 1135 - lastDir = GetLastDirectory (); 1136 - if (lastDir.Len () >= 1) 1137 - fileDialog->SetDirectory (lastDir); 1138 - ret = fileDialog->ShowModal (); 1139 - if (ret == wxID_OK) 1140 - { 1141 - path = fileDialog->GetPath (); 1142 - wxFileName file (path); 1143 - table = file.GetName (); 1144 - VirtualShpDialog dlg; 1145 - dlg.Create (this, path, table, LocaleCharset); 1146 - ret = dlg.ShowModal (); 1147 - if (ret == wxID_OK) 1148 - { 1149 - table = dlg.GetTable (); 1150 - srid = dlg.GetSrid (); 1151 - charset = dlg.GetCharset (); 1152 - } 1153 - else 1154 - return; 1155 - lastDir = file.GetPath (); 1156 - SetLastDirectory (lastDir); 1157 - sql = wxT ("CREATE VIRTUAL TABLE "); 1158 - sql += table; 1159 - sql += wxT ("\nUSING VirtualShape('"); 1160 - sql += file.GetPath (); 1161 - sql += file.GetPathSeparator (); 1162 - sql += file.GetName (); 1163 - sql += wxT ("',\n'"); 1164 - sql += charset; 1165 - xSrid.Printf (wxT ("', %d"), srid); 1166 - sql += xSrid; 1167 - sql += wxT (")"); 1168 - ret = sqlite3_exec (sqlite, sql.ToUTF8 (), NULL, NULL, &errMsg); 1169 - if (ret != SQLITE_OK) 1170 - { 1171 - wxMessageBox (wxT ("SQLite SQL error: ") + 1172 - wxString::FromUTF8 (errMsg), 1173 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 1174 - this); 1175 - sqlite3_free (errMsg); 1176 - return; 1177 - } 1178 - wxMessageBox (wxT ("Virtual Table '") + table + 1179 - wxT ("' was successfully created"), 1180 - wxT ("spatialite-gui"), wxOK | wxICON_INFORMATION, 1181 - this); 1182 - ClearTableTree (); 1183 - InitTableTree (); 1184 - } 1185 -} 1186 - 1187 -void 1188 -MyFrame::OnLoadTxt (wxCommandEvent & WXUNUSED (event)) 1776 + int ret; 1777 + wxString charset; 1778 + int srid; 1779 + char dummy[128]; 1780 + wxString sql; 1781 + wxString path; 1782 + wxString table; 1783 + wxString lastDir; 1784 + char *errMsg = NULL; 1785 + sqlite3 *sqlite = GetSqlite(); 1786 + wxFileDialog *fileDialog = new wxFileDialog(this, wxT("VirtualShape"), 1787 + wxT(""), 1788 + wxT("shapefile.shp"), 1789 + wxT 1790 + ("Shapefile (*.shp)|*.shp|All files (*.*)|*.*"), 1791 + wxFD_OPEN | wxFD_FILE_MUST_EXIST, 1792 + wxDefaultPosition, 1793 + wxDefaultSize, 1794 + wxT("filedlg")); 1795 + lastDir = GetLastDirectory(); 1796 + if (lastDir.Len() >= 1) 1797 + fileDialog->SetDirectory(lastDir); 1798 + ret = fileDialog->ShowModal(); 1799 + if (ret == wxID_OK) 1800 + { 1801 + path = fileDialog->GetPath(); 1802 + wxFileName file(path); 1803 + table = file.GetName(); 1804 + VirtualShpDialog dlg; 1805 + dlg.Create(this, path, table, LocaleCharset); 1806 + ret = dlg.ShowModal(); 1807 + if (ret == wxID_OK) 1808 + { 1809 + table = dlg.GetTable(); 1810 + srid = dlg.GetSrid(); 1811 + charset = dlg.GetCharset(); 1812 + } else 1813 + return; 1814 + lastDir = file.GetPath(); 1815 + SetLastDirectory(lastDir); 1816 + sql = wxT("CREATE VIRTUAL TABLE \""); 1817 + sql += table; 1818 + sql += wxT("\"\nUSING VirtualShape('"); 1819 + sql += file.GetPath(); 1820 + sql += file.GetPathSeparator(); 1821 + sql += file.GetName(); 1822 + sql += wxT("',\n'"); 1823 + sql += charset; 1824 + sprintf(dummy, "', %d", srid); 1825 + sql += wxString::FromUTF8(dummy); 1826 + sql += wxT(")"); 1827 + ret = sqlite3_exec(sqlite, sql.ToUTF8(), NULL, NULL, &errMsg); 1828 + if (ret != SQLITE_OK) 1829 + { 1830 + wxMessageBox(wxT("SQLite SQL error: ") + wxString::FromUTF8(errMsg), 1831 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 1832 + sqlite3_free(errMsg); 1833 + return; 1834 + } 1835 + wxMessageBox(wxT("Virtual Table \"") + table + 1836 + wxT("\" was successfully created"), wxT("spatialite-gui"), 1837 + wxOK | wxICON_INFORMATION, this); 1838 + InitTableTree(); 1839 + } 1840 +} 1841 + 1842 +void MyFrame::OnLoadTxt(wxCommandEvent & WXUNUSED(event)) 1189 1843 { 1190 1844 // 1191 1845 // loading a CSV/TXT 1192 1846 // 1193 - int ret; 1194 - wxString charset; 1195 - wxString sql; 1196 - wxString path; 1197 - wxString table; 1198 - wxString lastDir; 1199 - bool first_titles; 1200 - bool decimal_comma; 1201 - char separator; 1202 - char text_separator; 1203 - wxString filelist = wxT ("TXT and CSV files (*.txt;*.csv)|*.txt;*.csv"); 1204 - filelist += 1205 - wxT 1206 - ("|Text file (*.txt)|*.txt|CSV file (*.csv)|*.csv|All files (*.*)|*.*"); 1207 - wxFileDialog *fileDialog = new wxFileDialog (this, wxT ("Load CSV/TXT"), 1208 - wxT (""), 1209 - wxT ("textfile.txt"), 1210 - filelist, 1211 - wxFD_OPEN | 1212 - wxFD_FILE_MUST_EXIST, 1213 - wxDefaultPosition, 1214 - wxDefaultSize, 1215 - wxT ("filedlg")); 1216 - lastDir = GetLastDirectory (); 1217 - if (lastDir.Len () >= 1) 1218 - fileDialog->SetDirectory (lastDir); 1219 - ret = fileDialog->ShowModal (); 1220 - if (ret == wxID_OK) 1221 - { 1222 - path = fileDialog->GetPath (); 1223 - wxFileName file (path); 1224 - table = file.GetName (); 1225 - LoadTxtDialog dlg; 1226 - dlg.Create (this, path, table, LocaleCharset); 1227 - ret = dlg.ShowModal (); 1228 - if (ret == wxID_OK) 1229 - { 1230 - SetLastDirectory (lastDir); 1231 - table = dlg.GetTable (); 1232 - charset = dlg.GetCharset (); 1233 - first_titles = dlg.IsFirstLineTitles (); 1234 - decimal_comma = dlg.IsDecimalPointComma (); 1235 - separator = dlg.GetSeparator (); 1236 - text_separator = dlg.GetTextSeparator (); 1237 - char decimal_separator = '.'; 1238 - if (decimal_comma == true) 1239 - decimal_separator = ','; 1240 - LoadText (path, table, charset, first_titles, decimal_separator, 1241 - separator, text_separator); 1242 - } 1243 - } 1244 -} 1245 - 1246 -void 1247 -MyFrame::OnVirtualTxt (wxCommandEvent & WXUNUSED (event)) 1847 + int ret; 1848 + wxString charset; 1849 + wxString sql; 1850 + wxString path; 1851 + wxString table; 1852 + wxString lastDir; 1853 + bool first_titles; 1854 + bool decimal_comma; 1855 + char separator; 1856 + char text_separator; 1857 + wxString filelist = wxT("TXT and CSV files (*.txt;*.csv)|*.txt;*.csv"); 1858 + filelist += 1859 + wxT("|Text file (*.txt)|*.txt|CSV file (*.csv)|*.csv|All files (*.*)|*.*"); 1860 + wxFileDialog *fileDialog = new wxFileDialog(this, wxT("Load CSV/TXT"), 1861 + wxT(""), 1862 + wxT("textfile.txt"), 1863 + filelist, 1864 + wxFD_OPEN | wxFD_FILE_MUST_EXIST, 1865 + wxDefaultPosition, 1866 + wxDefaultSize, 1867 + wxT("filedlg")); 1868 + lastDir = GetLastDirectory(); 1869 + if (lastDir.Len() >= 1) 1870 + fileDialog->SetDirectory(lastDir); 1871 + ret = fileDialog->ShowModal(); 1872 + if (ret == wxID_OK) 1873 + { 1874 + path = fileDialog->GetPath(); 1875 + wxFileName file(path); 1876 + table = file.GetName(); 1877 + LoadTxtDialog dlg; 1878 + dlg.Create(this, path, table, LocaleCharset); 1879 + ret = dlg.ShowModal(); 1880 + if (ret == wxID_OK) 1881 + { 1882 + SetLastDirectory(lastDir); 1883 + table = dlg.GetTable(); 1884 + charset = dlg.GetCharset(); 1885 + first_titles = dlg.IsFirstLineTitles(); 1886 + decimal_comma = dlg.IsDecimalPointComma(); 1887 + separator = dlg.GetSeparator(); 1888 + text_separator = dlg.GetTextSeparator(); 1889 + char decimal_separator = '.'; 1890 + if (decimal_comma == true) 1891 + decimal_separator = ','; 1892 + LoadText(path, table, charset, first_titles, decimal_separator, 1893 + separator, text_separator); 1894 + } 1895 + } 1896 +} 1897 + 1898 +void MyFrame::OnVirtualTxt(wxCommandEvent & WXUNUSED(event)) 1248 1899 { 1249 1900 // 1250 1901 // creating a VirtualText 1251 1902 // 1252 - int ret; 1253 - wxString charset; 1254 - wxString sql; 1255 - wxString path; 1256 - wxString table; 1257 - wxString lastDir; 1258 - bool first_titles; 1259 - bool decimal_comma; 1260 - char separator; 1261 - char text_separator; 1262 - char dummy[16]; 1263 - char *errMsg = NULL; 1264 - sqlite3 *sqlite = GetSqlite (); 1265 - wxString filelist = wxT ("TXT and CSV files (*.txt;*.csv)|*.txt;*.csv"); 1266 - filelist += 1267 - wxT 1268 - ("|Text file (*.txt)|*.txt|CSV file (*.csv)|*.csv|All files (*.*)|*.*"); 1269 - wxFileDialog *fileDialog = new wxFileDialog (this, wxT ("VirtualText"), 1270 - wxT (""), 1271 - wxT ("textfile.txt"), 1272 - filelist, 1273 - wxFD_OPEN | 1274 - wxFD_FILE_MUST_EXIST, 1275 - wxDefaultPosition, 1276 - wxDefaultSize, 1277 - wxT ("filedlg")); 1278 - lastDir = GetLastDirectory (); 1279 - if (lastDir.Len () >= 1) 1280 - fileDialog->SetDirectory (lastDir); 1281 - ret = fileDialog->ShowModal (); 1282 - if (ret == wxID_OK) 1283 - { 1284 - path = fileDialog->GetPath (); 1285 - wxFileName file (path); 1286 - table = file.GetName (); 1287 - VirtualTxtDialog dlg; 1288 - dlg.Create (this, path, table, LocaleCharset); 1289 - ret = dlg.ShowModal (); 1290 - if (ret == wxID_OK) 1291 - { 1292 - table = dlg.GetTable (); 1293 - charset = dlg.GetCharset (); 1294 - first_titles = dlg.IsFirstLineTitles (); 1295 - decimal_comma = dlg.IsDecimalPointComma (); 1296 - separator = dlg.GetSeparator (); 1297 - text_separator = dlg.GetTextSeparator (); 1298 - } 1299 - else 1300 - return; 1301 - lastDir = file.GetPath (); 1302 - SetLastDirectory (lastDir); 1303 - sql = wxT ("CREATE VIRTUAL TABLE "); 1304 - sql += table; 1305 - sql += wxT ("\nUSING VirtualText('"); 1306 - sql += path; 1307 - sql += wxT ("',\n'"); 1308 - sql += charset; 1309 - if (first_titles == true) 1310 - sql += wxT ("', 1"); 1311 - else 1312 - sql += wxT ("', 0"); 1313 - if (decimal_comma == true) 1314 - sql += wxT (", COMMA"); 1315 - else 1316 - sql += wxT (", POINT"); 1317 - if (text_separator == '\'') 1318 - sql += wxT (", SINGLEQUOTE"); 1319 - else 1320 - sql += wxT (", DOUBLEQUOTE"); 1321 - if (separator == '\t') 1322 - sql += wxT (", TAB"); 1323 - else 1324 - { 1325 - sprintf (dummy, ", '%c'", separator); 1326 - sql += wxString::FromUTF8 (dummy); 1327 - } 1328 - sql += wxT (")"); 1329 - ret = sqlite3_exec (sqlite, sql.ToUTF8 (), NULL, NULL, &errMsg); 1330 - if (ret != SQLITE_OK) 1331 - { 1332 - wxMessageBox (wxT ("SQLite SQL error: ") + 1333 - wxString::FromUTF8 (errMsg), 1334 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 1335 - this); 1336 - sqlite3_free (errMsg); 1337 - return; 1338 - } 1339 - wxMessageBox (wxT ("Virtual Table '") + table + 1340 - wxT ("' was successfully created"), 1341 - wxT ("spatialite-gui"), wxOK | wxICON_INFORMATION, 1342 - this); 1343 - ClearTableTree (); 1344 - InitTableTree (); 1345 - } 1346 -} 1347 - 1348 -void 1349 -MyFrame::OnSrids (wxCommandEvent & WXUNUSED (event)) 1903 + int ret; 1904 + wxString charset; 1905 + wxString sql; 1906 + wxString path; 1907 + wxString table; 1908 + wxString lastDir; 1909 + bool first_titles; 1910 + bool decimal_comma; 1911 + char separator; 1912 + char text_separator; 1913 + char dummy[16]; 1914 + char *errMsg = NULL; 1915 + sqlite3 *sqlite = GetSqlite(); 1916 + wxString filelist = wxT("TXT and CSV files (*.txt;*.csv)|*.txt;*.csv"); 1917 + filelist += 1918 + wxT("|Text file (*.txt)|*.txt|CSV file (*.csv)|*.csv|All files (*.*)|*.*"); 1919 + wxFileDialog *fileDialog = new wxFileDialog(this, wxT("VirtualText"), 1920 + wxT(""), 1921 + wxT("textfile.txt"), 1922 + filelist, 1923 + wxFD_OPEN | wxFD_FILE_MUST_EXIST, 1924 + wxDefaultPosition, 1925 + wxDefaultSize, 1926 + wxT("filedlg")); 1927 + lastDir = GetLastDirectory(); 1928 + if (lastDir.Len() >= 1) 1929 + fileDialog->SetDirectory(lastDir); 1930 + ret = fileDialog->ShowModal(); 1931 + if (ret == wxID_OK) 1932 + { 1933 + path = fileDialog->GetPath(); 1934 + wxFileName file(path); 1935 + table = file.GetName(); 1936 + VirtualTxtDialog dlg; 1937 + dlg.Create(this, path, table, LocaleCharset); 1938 + ret = dlg.ShowModal(); 1939 + if (ret == wxID_OK) 1940 + { 1941 + table = dlg.GetTable(); 1942 + charset = dlg.GetCharset(); 1943 + first_titles = dlg.IsFirstLineTitles(); 1944 + decimal_comma = dlg.IsDecimalPointComma(); 1945 + separator = dlg.GetSeparator(); 1946 + text_separator = dlg.GetTextSeparator(); 1947 + } else 1948 + return; 1949 + lastDir = file.GetPath(); 1950 + SetLastDirectory(lastDir); 1951 + sql = wxT("CREATE VIRTUAL TABLE \""); 1952 + sql += table; 1953 + sql += wxT("\"\nUSING VirtualText('"); 1954 + sql += path; 1955 + sql += wxT("',\n'"); 1956 + sql += charset; 1957 + if (first_titles == true) 1958 + sql += wxT("', 1"); 1959 + else 1960 + sql += wxT("', 0"); 1961 + if (decimal_comma == true) 1962 + sql += wxT(", COMMA"); 1963 + else 1964 + sql += wxT(", POINT"); 1965 + if (text_separator == '\'') 1966 + sql += wxT(", SINGLEQUOTE"); 1967 + else 1968 + sql += wxT(", DOUBLEQUOTE"); 1969 + if (separator == '\t') 1970 + sql += wxT(", TAB"); 1971 + else 1972 + { 1973 + sprintf(dummy, ", '%c'", separator); 1974 + sql += wxString::FromUTF8(dummy); 1975 + } 1976 + sql += wxT(")"); 1977 + ret = sqlite3_exec(sqlite, sql.ToUTF8(), NULL, NULL, &errMsg); 1978 + if (ret != SQLITE_OK) 1979 + { 1980 + wxMessageBox(wxT("SQLite SQL error: ") + wxString::FromUTF8(errMsg), 1981 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 1982 + sqlite3_free(errMsg); 1983 + return; 1984 + } 1985 + wxMessageBox(wxT("Virtual Table \"") + table + 1986 + wxT("\" was successfully created"), wxT("spatialite-gui"), 1987 + wxOK | wxICON_INFORMATION, this); 1988 + InitTableTree(); 1989 + } 1990 +} 1991 + 1992 +void MyFrame::OnNetwork(wxCommandEvent & WXUNUSED(event)) 1993 +{ 1994 +// 1995 +// building a Network 1996 +// 1997 + NetworkDialog dlg; 1998 + int ret; 1999 + wxString table; 2000 + wxString from; 2001 + wxString to; 2002 + wxString geom; 2003 + bool isGeomLength; 2004 + wxString cost; 2005 + bool isBidirectional; 2006 + bool isOneWays; 2007 + wxString oneWayToFrom; 2008 + wxString oneWayFromTo; 2009 + dlg.Create(this); 2010 + ret = dlg.ShowModal(); 2011 + if (ret == wxID_OK) 2012 + { 2013 + table = dlg.GetTableName(); 2014 + from = dlg.GetFromColumn(); 2015 + to = dlg.GetToColumn(); 2016 + geom = dlg.GetGeomColumn(); 2017 + isGeomLength = dlg.IsGeomLength(); 2018 + cost = dlg.GetCostColumn(); 2019 + isBidirectional = dlg.IsBidirectional(); 2020 + isOneWays = dlg.IsOneWays(); 2021 + oneWayToFrom = dlg.GetOneWayToFrom(); 2022 + oneWayFromTo = dlg.GetOneWayFromTo(); 2023 + BuildNetwork(table, from, to, geom, isGeomLength, cost, isBidirectional, 2024 + isOneWays, oneWayFromTo, oneWayToFrom); 2025 + } 2026 +} 2027 + 2028 +void MyFrame::OnImportExifPhotos(wxCommandEvent & WXUNUSED(event)) 2029 +{ 2030 +// 2031 +// importing EXIF Photos 2032 +// 2033 + ExifDialog dlg; 2034 + int ret; 2035 + wxString path; 2036 + bool isFolder; 2037 + bool isMetadata; 2038 + bool isGpsOnly; 2039 + wxString lastDir; 2040 + wxString dir_path; 2041 + wxString img_path; 2042 + wxString filelist = wxT("JPEG files (*.jpg;*.jpeg)|*.jpg;*.jpeg|"); 2043 + filelist += wxT("All files (*.*)|*.*"); 2044 + wxFileDialog *fileDialog = 2045 + new wxFileDialog(this, wxT("EXIF File/Folder selection"), 2046 + wxT(""), 2047 + wxT(""), 2048 + filelist, 2049 + wxFD_OPEN | wxFD_FILE_MUST_EXIST, 2050 + wxDefaultPosition, 2051 + wxDefaultSize, 2052 + wxT("filedlg")); 2053 + lastDir = GetLastDirectory(); 2054 + if (lastDir.Len() >= 1) 2055 + fileDialog->SetDirectory(lastDir); 2056 + ret = fileDialog->ShowModal(); 2057 + if (ret == wxID_OK) 2058 + { 2059 + img_path = fileDialog->GetPath(); 2060 + wxFileName file(img_path); 2061 + dir_path = file.GetPath(); 2062 + } else 2063 + return; 2064 + dlg.Create(this, dir_path, img_path); 2065 + ret = dlg.ShowModal(); 2066 + if (ret == wxID_OK) 2067 + { 2068 + SetLastDirectory(dir_path); 2069 + isFolder = dlg.IsFolder(); 2070 + if (isFolder == true) 2071 + path = dlg.GetDirPath(); 2072 + else 2073 + path = dlg.GetImgPath(); 2074 + isMetadata = dlg.IsMetadata(); 2075 + isGpsOnly = dlg.IsGpsOnly(); 2076 + ImportExifPhotos(path, isFolder, isMetadata, isGpsOnly); 2077 + } 2078 +} 2079 + 2080 +void MyFrame::OnSrids(wxCommandEvent & WXUNUSED(event)) 1350 2081 { 1351 2082 // 1352 2083 // searching a SRID by name 1353 2084 // 1354 - SearchSridDialog dlg; 1355 - int ret; 1356 - wxString string; 1357 - wxString sql; 1358 - dlg.Create (this); 1359 - ret = dlg.ShowModal (); 1360 - if (ret == wxID_OK) 1361 - { 1362 - string = dlg.GetString (); 1363 - sql = wxT ("SELECT * FROM spatial_ref_sys\n"); 1364 - sql += wxT ("WHERE ref_sys_name LIKE '%"); 1365 - sql += string; 1366 - sql += wxT ("%'\nORDER BY srid"); 1367 - QueryView->SetSql (sql, true); 1368 - } 2085 + SearchSridDialog dlg; 2086 + int ret; 2087 + wxString string; 2088 + wxString sql; 2089 + dlg.Create(this); 2090 + ret = dlg.ShowModal(); 2091 + if (ret == wxID_OK) 2092 + { 2093 + string = dlg.GetString(); 2094 + sql = wxT("SELECT * FROM spatial_ref_sys\n"); 2095 + sql += wxT("WHERE ref_sys_name LIKE '%"); 2096 + sql += string; 2097 + sql += wxT("%'\nORDER BY srid"); 2098 + QueryView->SetSql(sql, true); 2099 + } 1369 2100 } 1370 2101 1371 -void 1372 -MyFrame::OnCharset (wxCommandEvent & WXUNUSED (event)) 2102 +void MyFrame::OnCharset(wxCommandEvent & WXUNUSED(event)) 1373 2103 { 1374 2104 // 1375 2105 // setting the default CHARSET 1376 2106 // 1377 - DefaultCharsetDialog dlg; 1378 - int ret; 1379 - dlg.Create (this, DefaultCharset, AskCharset); 1380 - ret = dlg.ShowModal (); 1381 - if (ret == wxID_OK) 1382 - { 1383 - DefaultCharset = dlg.GetCharset (); 1384 - AskCharset = dlg.IsSetAskCharset (); 1385 - } 2107 + DefaultCharsetDialog dlg; 2108 + int ret; 2109 + dlg.Create(this, DefaultCharset, AskCharset); 2110 + ret = dlg.ShowModal(); 2111 + if (ret == wxID_OK) 2112 + { 2113 + DefaultCharset = dlg.GetCharset(); 2114 + AskCharset = dlg.IsSetAskCharset(); 2115 + } 1386 2116 } 1387 2117 1388 -bool 1389 -MyFrame::ExecuteSql (const char *sql, int rowNo) 2118 +void MyFrame::OnTimerAutoSave(wxTimerEvent & event) 2119 +{ 2120 +// 2121 +// AutoSave - Timer event handler 2122 +// 2123 + int tc = sqlite3_total_changes(SqliteHandle); 2124 + if (tc != LastTotalChanges) 2125 + MemoryDbSave(); 2126 + if (AutoSaveInterval <= 0) 2127 + { 2128 + delete TimerAutoSave; 2129 + TimerAutoSave = NULL; 2130 + } else 2131 + TimerAutoSave->Start(AutoSaveInterval * 1000, wxTIMER_ONE_SHOT); 2132 +} 2133 + 2134 +bool MyFrame::ExecuteSql(const char *sql, int rowNo) 1390 2135 { 1391 2136 // 1392 2137 // executes an SQL statement from the SQL script 1393 2138 // 1394 - int ret; 1395 - char *errMsg = NULL; 1396 - wxString msg; 1397 - ret = sqlite3_exec (SqliteHandle, sql, NULL, NULL, &errMsg); 1398 - if (ret != SQLITE_OK) 1399 - { 1400 - msg.Printf (wxT ("row %d\n\nSQLite SQL error: "), rowNo); 1401 - wxMessageBox (msg + wxString::FromUTF8 (errMsg), 1402 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, this); 1403 - sqlite3_free (errMsg); 1404 - return false; 1405 - } 1406 - return true; 2139 + int ret; 2140 + char *errMsg = NULL; 2141 + wxString msg; 2142 + char dummy[128]; 2143 + ret = sqlite3_exec(SqliteHandle, sql, NULL, NULL, &errMsg); 2144 + if (ret != SQLITE_OK) 2145 + { 2146 + sprintf(dummy, "row %d\n\nSQLite SQL error: ", rowNo); 2147 + msg = wxString::FromUTF8(dummy); 2148 + wxMessageBox(msg + wxString::FromUTF8(errMsg), wxT("spatialite-gui"), 2149 + wxOK | wxICON_ERROR, this); 2150 + sqlite3_free(errMsg); 2151 + return false; 2152 + } 2153 + return true; 1407 2154 } 1408 2155 1409 -void 1410 -MyFrame::Rollback () 2156 +void MyFrame::Rollback() 1411 2157 { 1412 2158 // 1413 2159 // performing a ROLLBACK 1414 2160 // 1415 - sqlite3_exec (SqliteHandle, "ROLLBACK", NULL, NULL, NULL); 2161 + sqlite3_exec(SqliteHandle, "ROLLBACK", NULL, NULL, NULL); 1416 2162 } 1417 2163 1418 -bool 1419 -MyFrame::OpenDB () 2164 +bool MyFrame::OpenDB() 1420 2165 { 1421 2166 // 1422 2167 // establishing a physical connetion to some DB SQLite 1423 2168 // 1424 - int ret; 1425 - ret = 1426 - sqlite3_open_v2 (SqlitePath.ToUTF8 (), &SqliteHandle, 1427 - SQLITE_OPEN_READWRITE, NULL); 1428 - if (ret) 1429 - { 1430 - // impossibile aprire il DB SQLite 1431 - wxString errCause; 1432 - errCause = wxString::FromUTF8 (sqlite3_errmsg (SqliteHandle)); 1433 - sqlite3_close (SqliteHandle); 1434 - wxMessageBox (wxT ("Failure while connecting to DB\n\n") + errCause + 1435 - wxT ("\n") + SqlitePath, wxT ("spatialite-gui"), 1436 - wxOK | wxICON_ERROR, this); 1437 - SqliteHandle = NULL; 1438 - ClearTableTree (); 1439 - return false; 1440 - } 1441 - InitTableTree (); 1442 - return true; 1443 -} 1444 - 1445 -void 1446 -MyFrame::CloseDB () 2169 + int ret; 2170 + ret = 2171 + sqlite3_open_v2(SqlitePath.ToUTF8(), &SqliteHandle, SQLITE_OPEN_READWRITE, 2172 + NULL); 2173 + if (ret) 2174 + { 2175 + // an error occurred 2176 + wxString errCause; 2177 + errCause = wxString::FromUTF8(sqlite3_errmsg(SqliteHandle)); 2178 + sqlite3_close(SqliteHandle); 2179 + wxMessageBox(wxT("Failure while connecting to DB\n\n") + errCause + 2180 + wxT("\n") + SqlitePath, wxT("spatialite-gui"), 2181 + wxOK | wxICON_ERROR, this); 2182 + SqliteHandle = NULL; 2183 + ClearTableTree(); 2184 + MemoryDatabase = false; 2185 + return false; 2186 + } 2187 + AutoFDOStart(); 2188 + InitTableTree(); 2189 + return true; 2190 +} 2191 + 2192 +void MyFrame::LastDitchMemoryDbSave() 2193 +{ 2194 +// 2195 +// performing the last desperate attempt to save a MEMORY-DB 2196 +// 2197 + int tc; 2198 + int ret; 2199 + wxString lastDir; 2200 + if (MemoryDatabase == false) 2201 + return; 2202 + if (!SqliteHandle) 2203 + return; 2204 + tc = sqlite3_total_changes(SqliteHandle); 2205 + if (tc == LastTotalChanges) 2206 + return; 2207 + while (1) 2208 + { 2209 + // OK, this MEMORY-DB needs to be saved 2210 + if (MemoryDbSave() == true) 2211 + break; 2212 + // we must ask the user 2213 + wxString msg = 2214 + wxT("WARNING: the MEMORY-DB contains uncommitted changes\n\n"); 2215 + msg += wxT("The MEMORY_DB is intrinsecally volatile, so these changes\n"); 2216 + msg += 2217 + wxT("will be irremediably lost if you don't export them to some\n"); 2218 + msg += wxT("persistent storage [i.e. on the file-system]\n\n"); 2219 + msg += 2220 + wxT 2221 + ("Do you want to export [SAVE] the MEMORY-DB to some external database ?"); 2222 + ret = 2223 + wxMessageBox(msg, wxT("spatialite-gui"), wxYES_NO | wxICON_QUESTION, 2224 + this); 2225 + if (ret != wxYES) 2226 + break; 2227 + // asking a PATHNAME to the user 2228 + wxFileDialog *fileDialog = 2229 + new wxFileDialog(this, wxT("Saving the MEMORY-DB"), 2230 + wxT(""), wxT("db.sqlite"), 2231 + wxT 2232 + ("SQLite DB (*.sqlite)|*.sqlite|All files (*.*)|*.*"), 2233 + wxFD_SAVE | wxFD_OVERWRITE_PROMPT, 2234 + wxDefaultPosition, 2235 + wxDefaultSize, 2236 + wxT("filedlg")); 2237 + lastDir = GetLastDirectory(); 2238 + if (lastDir.Len() >= 1) 2239 + fileDialog->SetDirectory(lastDir); 2240 + ret = fileDialog->ShowModal(); 2241 + if (ret == wxID_OK) 2242 + { 2243 + // exporting the external DB 2244 + ExternalSqlitePath = fileDialog->GetPath(); 2245 + if (MemoryDbSave() == true) 2246 + { 2247 + wxMessageBox(wxT("Ok, MEMORY-DB was succesfully saved"), 2248 + wxT("spatialite-gui"), wxOK | wxICON_INFORMATION, 2249 + this); 2250 + break; 2251 + } 2252 + } 2253 + } 2254 +} 2255 + 2256 +void MyFrame::CloseDB() 1447 2257 { 1448 2258 // 1449 2259 // disconnecting current SQLite DB 1450 2260 // 1451 - if (!SqliteHandle) 1452 - return; 1453 - sqlite3_close (SqliteHandle); 1454 - SqliteHandle = NULL; 1455 - SqlitePath = wxT (""); 1456 - ClearTableTree (); 2261 + if (!SqliteHandle) 2262 + return; 2263 + AutoFDOStop(); 2264 + if (AutoFDOmsg.Len() > 0) 2265 + wxMessageBox(AutoFDOmsg, wxT("spatialite-gui"), wxOK | wxICON_INFORMATION, 2266 + this); 2267 + LastDitchMemoryDbSave(); 2268 + sqlite3_close(SqliteHandle); 2269 + SqliteHandle = NULL; 2270 + SqlitePath = wxT(""); 2271 + MemoryDatabase = false; 2272 + ClearTableTree(); 1457 2273 } 1458 2274 1459 -bool 1460 -MyFrame::CreateDB () 2275 +bool MyFrame::CreateDB() 1461 2276 { 1462 2277 // creating a new, empty SQLite DB 1463 - unlink (SqlitePath.ToUTF8 ()); 1464 - int ret; 1465 - ret = sqlite3_open_v2 (SqlitePath.ToUTF8 (), &SqliteHandle, 1466 - SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL); 1467 - if (ret) 1468 - { 1469 - // an error occurred 1470 - wxString errCause; 1471 - errCause = wxString::FromUTF8 (sqlite3_errmsg (SqliteHandle)); 1472 - sqlite3_close (SqliteHandle); 1473 - wxMessageBox (wxT ("An error occurred\n\n") + errCause + wxT ("\n") + 1474 - SqlitePath, wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 1475 - this); 1476 - SqliteHandle = NULL; 1477 - ClearTableTree (); 1478 - return false; 1479 - } 1480 - InitTableTree (); 1481 - return true; 1482 -} 1483 - 1484 -void 1485 -MyFrame::CleanSql (char *buf) 2278 + int ret; 2279 + char path[1024]; 2280 + if (MemoryDatabase == true) 2281 + strcpy(path, ":memory:"); 2282 + else 2283 + { 2284 + strcpy(path, SqlitePath.ToUTF8()); 2285 + unlink(path); 2286 + } 2287 + ret = 2288 + sqlite3_open_v2(path, &SqliteHandle, 2289 + SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL); 2290 + if (ret) 2291 + { 2292 + // an error occurred 2293 + wxString errCause; 2294 + errCause = wxString::FromUTF8(sqlite3_errmsg(SqliteHandle)); 2295 + sqlite3_close(SqliteHandle); 2296 + wxMessageBox(wxT("An error occurred\n\n") + errCause + wxT("\n") + 2297 + SqlitePath, wxT("spatialite-gui"), wxOK | wxICON_ERROR, 2298 + this); 2299 + SqliteHandle = NULL; 2300 + ClearTableTree(); 2301 + MemoryDatabase = false; 2302 + return false; 2303 + } 2304 + if (CreateSpatialMetaData() == false) 2305 + wxMessageBox(wxT("Spatial Metadata tables creation error\n") + 2306 + SqlitePath, wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 2307 + AutoFDOStart(); 2308 + InitTableTree(); 2309 + return true; 2310 +} 2311 + 2312 +void MyFrame::CleanSql(char *buf) 1486 2313 { 1487 2314 // well-formatting a string to be used as an SQL string 1488 - char tmp[1024]; 1489 - char *in = tmp; 1490 - char *out = buf; 1491 - strcpy (tmp, buf); 1492 - while (*in != '\0') 1493 - { 1494 - if (*in == '\'') 1495 - *out++ = '\''; 1496 - *out++ = *in++; 1497 - } 1498 - *out = '\0'; 2315 + char tmp[1024]; 2316 + char *in = tmp; 2317 + char *out = buf; 2318 + strcpy(tmp, buf); 2319 + while (*in != '\0') 2320 + { 2321 + if (*in == '\'') 2322 + *out++ = '\''; 2323 + *out++ = *in++; 2324 + } 2325 + *out = '\0'; 1499 2326 } 1500 2327 1501 -void 1502 -MyFrame::InitTableTree () 2328 +void MyFrame::InitTableTree() 1503 2329 { 1504 2330 // loads the table TREE list 1505 - int i; 1506 - char **results; 1507 - int rows; 1508 - int columns; 1509 - char *errMsg = NULL; 1510 - char *name; 1511 - char *createSql; 1512 - char *type; 1513 - wxString tblName; 1514 - wxString sql; 1515 - bool virtualTable = false; 1516 - TableTree->SetPath (SqlitePath); 1517 - TableTree->FlushAll (); 1518 - sql = 1519 - wxT 1520 - ("SELECT name, sql, type FROM sqlite_master WHERE (type = 'table' OR type = 'view') ORDER BY name"); 1521 - int ret = sqlite3_get_table (SqliteHandle, sql.ToUTF8 (), &results, 1522 - &rows, &columns, &errMsg); 1523 - if (ret != SQLITE_OK) 1524 - { 1525 - wxMessageBox (wxT ("SQLite SQL error: ") + 1526 - wxString::FromUTF8 (errMsg), wxT ("spatialite-gui"), 1527 - wxOK | wxICON_ERROR, this); 1528 - sqlite3_free (errMsg); 1529 - return; 1530 - } 1531 - if (rows < 1) 1532 - ; 1533 - else 1534 - { 1535 - for (i = 1; i <= rows; i++) 1536 - { 1537 - name = results[(i * columns) + 0]; 1538 - createSql = results[(i * columns) + 1]; 1539 - type = results[(i * columns) + 2]; 1540 - if (strstr (createSql, "VIRTUAL") 1541 - || strstr (createSql, "virtual")) 1542 - virtualTable = true; 1543 - else 1544 - virtualTable = false; 1545 - tblName = wxString::FromUTF8 (name); 1546 - if (strcmp (type, "view") == 0) 1547 - TableTree->AddView (tblName); 1548 - else 1549 - TableTree->AddTable (tblName, virtualTable); 1550 - } 1551 - } 1552 - sqlite3_free_table (results); 1553 - TableTree->ExpandRoot (); 2331 + int i; 2332 + char **results; 2333 + int rows; 2334 + int columns; 2335 + char *errMsg = NULL; 2336 + char *name; 2337 + char *createSql; 2338 + char *type; 2339 + wxString tblName; 2340 + wxString sql; 2341 + bool virtualTable = false; 2342 + TableTree->Show(false); 2343 + if (MemoryDatabase == true) 2344 + { 2345 + wxString memory = wxT("MEMORY-DB"); 2346 + TableTree->SetPath(memory); 2347 + } else 2348 + TableTree->SetPath(SqlitePath); 2349 + TableTree->FlushAll(); 2350 + sql = 2351 + wxT 2352 + ("SELECT name, sql, type FROM sqlite_master WHERE (type = 'table' OR type = 'view') ORDER BY name"); 2353 + int ret = sqlite3_get_table(SqliteHandle, sql.ToUTF8(), &results, 2354 + &rows, &columns, &errMsg); 2355 + if (ret != SQLITE_OK) 2356 + { 2357 + wxMessageBox(wxT("SQLite SQL error: ") + wxString::FromUTF8(errMsg), 2358 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 2359 + sqlite3_free(errMsg); 2360 + return; 2361 + } 2362 + if (rows < 1) 2363 + ; 2364 + else 2365 + { 2366 + for (i = 1; i <= rows; i++) 2367 + { 2368 + name = results[(i * columns) + 0]; 2369 + createSql = results[(i * columns) + 1]; 2370 + type = results[(i * columns) + 2]; 2371 + if (strstr(createSql, "VIRTUAL") || strstr(createSql, "virtual")) 2372 + virtualTable = true; 2373 + else 2374 + virtualTable = false; 2375 + tblName = wxString::FromUTF8(name); 2376 + if (strcmp(type, "view") == 0) 2377 + TableTree->AddView(tblName); 2378 + else 2379 + TableTree->AddTable(tblName, virtualTable); 2380 + } 2381 + } 2382 + sqlite3_free_table(results); 2383 + TableTree->ExpandRoot(); 2384 + TableTree->Show(true); 2385 +} 2386 + 2387 +wxString *MyFrame::GetTables(int *n) 2388 +{ 2389 +// loads the table list 2390 + int i; 2391 + char **results; 2392 + int rows; 2393 + int columns; 2394 + char *errMsg = NULL; 2395 + char *name; 2396 + wxString *tables = NULL; 2397 + wxString sql; 2398 + *n = 0; 2399 + sql = 2400 + wxT("SELECT name FROM sqlite_master WHERE type = 'table' ORDER BY name"); 2401 + int ret = sqlite3_get_table(SqliteHandle, sql.ToUTF8(), &results, 2402 + &rows, &columns, &errMsg); 2403 + if (ret != SQLITE_OK) 2404 + { 2405 + wxMessageBox(wxT("SQLite SQL error: ") + wxString::FromUTF8(errMsg), 2406 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 2407 + sqlite3_free(errMsg); 2408 + return tables; 2409 + } 2410 + if (rows < 1) 2411 + ; 2412 + else 2413 + { 2414 + tables = new wxString[rows]; 2415 + *n = rows; 2416 + for (i = 1; i <= rows; i++) 2417 + { 2418 + name = results[(i * columns) + 0]; 2419 + tables[i - 1] = wxString::FromUTF8(name); 2420 + } 2421 + } 2422 + sqlite3_free_table(results); 2423 + return tables; 1554 2424 } 1555 2425 1556 -void 1557 -MyFrame::GetTableColumns (wxString & tableName, MyTableInfo * list) 2426 +void MyFrame::GetTableColumns(wxString & tableName, MyTableInfo * list) 1558 2427 { 1559 2428 // loads the table's column list 1560 - int i; 1561 - char **results; 1562 - int rows; 1563 - int columns; 1564 - char *errMsg = NULL; 1565 - char *name; 1566 - char *column; 1567 - wxString Name; 1568 - wxString Column; 1569 - bool pKey; 1570 - bool index; 1571 - bool cached; 1572 - wxString sql; 1573 - sql = wxT ("PRAGMA table_info("); 1574 - sql += tableName; 1575 - sql += wxT (")"); 1576 - int ret = sqlite3_get_table (SqliteHandle, sql.ToUTF8 (), &results, 1577 - &rows, &columns, &errMsg); 1578 - if (ret != SQLITE_OK) 1579 - { 1580 - wxMessageBox (wxT ("SQLite SQL error: ") + 1581 - wxString::FromUTF8 (errMsg), wxT ("spatialite-gui"), 1582 - wxOK | wxICON_ERROR, this); 1583 - sqlite3_free (errMsg); 1584 - return; 1585 - } 1586 - if (rows < 1) 1587 - ; 1588 - else 1589 - { 1590 - for (i = 1; i <= rows; i++) 1591 - { 1592 - name = results[(i * columns) + 1]; 1593 - if (atoi (results[(i * columns) + 5]) == 0) 1594 - pKey = false; 1595 - else 1596 - pKey = true; 1597 - Name = wxString::FromUTF8 (name); 1598 - list->AddColumn (Name, pKey); 1599 - } 1600 - } 1601 - sqlite3_free_table (results); 1602 - if (CheckMetadata () == true) 1603 - { 1604 - // ok, Spatial MetaData exists; retrieving Geometries and Spatial Indices 1605 - sql = 1606 - wxT 1607 - ("SELECT f_geometry_column, spatial_index_enabled FROM geometry_columns "); 1608 - sql += wxT ("WHERE f_table_name = '"); 1609 - sql += tableName; 1610 - sql += wxT ("'"); 1611 - ret = sqlite3_get_table (SqliteHandle, sql.ToUTF8 (), &results, 1612 - &rows, &columns, &errMsg); 1613 - if (ret != SQLITE_OK) 1614 - { 1615 - wxMessageBox (wxT ("SQLite SQL error: ") + 1616 - wxString::FromUTF8 (errMsg), 1617 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 1618 - this); 1619 - sqlite3_free (errMsg); 1620 - return; 1621 - } 1622 - if (rows < 1) 1623 - ; 1624 - else 1625 - { 1626 - for (i = 1; i <= rows; i++) 1627 - { 1628 - column = results[(i * columns) + 0]; 1629 - if (atoi (results[(i * columns) + 1]) == 1) 1630 - index = true; 1631 - else 1632 - index = false; 1633 - if (atoi (results[(i * columns) + 1]) == 2) 1634 - cached = true; 1635 - else 1636 - cached = false; 1637 - Column = wxString::FromUTF8 (column); 1638 - list->SetGeometry (Column, index, cached); 1639 - } 1640 - } 1641 - sqlite3_free_table (results); 1642 - } 2429 + int i; 2430 + char **results; 2431 + int rows; 2432 + int columns; 2433 + char *errMsg = NULL; 2434 + char *name; 2435 + char *column; 2436 + wxString Name; 2437 + wxString Column; 2438 + bool pKey; 2439 + bool index; 2440 + bool cached; 2441 + wxString sql; 2442 + sql = wxT("PRAGMA table_info(\""); 2443 + sql += tableName; 2444 + sql += wxT("\")"); 2445 + int ret = sqlite3_get_table(SqliteHandle, sql.ToUTF8(), &results, 2446 + &rows, &columns, &errMsg); 2447 + if (ret != SQLITE_OK) 2448 + { 2449 + wxMessageBox(wxT("SQLite SQL error: ") + wxString::FromUTF8(errMsg), 2450 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 2451 + sqlite3_free(errMsg); 2452 + return; 2453 + } 2454 + if (rows < 1) 2455 + ; 2456 + else 2457 + { 2458 + for (i = 1; i <= rows; i++) 2459 + { 2460 + name = results[(i * columns) + 1]; 2461 + if (atoi(results[(i * columns) + 5]) == 0) 2462 + pKey = false; 2463 + else 2464 + pKey = true; 2465 + Name = wxString::FromUTF8(name); 2466 + list->AddColumn(Name, pKey); 2467 + } 2468 + } 2469 + sqlite3_free_table(results); 2470 + if (CheckMetadata() == true) 2471 + { 2472 + // ok, Spatial MetaData exists; retrieving Geometries and Spatial Indices 2473 + sql = 2474 + wxT 2475 + ("SELECT f_geometry_column, spatial_index_enabled FROM geometry_columns "); 2476 + sql += wxT("WHERE f_table_name = '"); 2477 + sql += tableName; 2478 + sql += wxT("'"); 2479 + ret = 2480 + sqlite3_get_table(SqliteHandle, sql.ToUTF8(), &results, &rows, &columns, 2481 + &errMsg); 2482 + if (ret != SQLITE_OK) 2483 + { 2484 + wxMessageBox(wxT("SQLite SQL error: ") + wxString::FromUTF8(errMsg), 2485 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 2486 + sqlite3_free(errMsg); 2487 + return; 2488 + } 2489 + if (rows < 1) 2490 + ; 2491 + else 2492 + { 2493 + for (i = 1; i <= rows; i++) 2494 + { 2495 + column = results[(i * columns) + 0]; 2496 + if (atoi(results[(i * columns) + 1]) == 1) 2497 + index = true; 2498 + else 2499 + index = false; 2500 + if (atoi(results[(i * columns) + 1]) == 2) 2501 + cached = true; 2502 + else 2503 + cached = false; 2504 + Column = wxString::FromUTF8(column); 2505 + list->SetGeometry(Column, index, cached); 2506 + } 2507 + } 2508 + sqlite3_free_table(results); 2509 + } 1643 2510 } 1644 2511 1645 -void 1646 -MyFrame::GetViewColumns (wxString & tableName, MyViewInfo * list) 2512 +void MyFrame::GetViewColumns(wxString & tableName, MyViewInfo * list) 1647 2513 { 1648 2514 // loads the view's column list 1649 - int i; 1650 - char **results; 1651 - int rows; 1652 - int columns; 1653 - char *errMsg = NULL; 1654 - char *name; 1655 - wxString Name; 1656 - wxString sql; 1657 - sql = wxT ("PRAGMA table_info("); 1658 - sql += tableName; 1659 - sql += wxT (")"); 1660 - int ret = sqlite3_get_table (SqliteHandle, sql.ToUTF8 (), &results, 1661 - &rows, &columns, &errMsg); 1662 - if (ret != SQLITE_OK) 1663 - { 1664 - wxMessageBox (wxT ("SQLite SQL error: ") + 1665 - wxString::FromUTF8 (errMsg), wxT ("spatialite-gui"), 1666 - wxOK | wxICON_ERROR, this); 1667 - sqlite3_free (errMsg); 1668 - return; 1669 - } 1670 - if (rows < 1) 1671 - ; 1672 - else 1673 - { 1674 - for (i = 1; i <= rows; i++) 1675 - { 1676 - name = results[(i * columns) + 1]; 1677 - Name = wxString::FromUTF8 (name); 1678 - list->AddColumn (Name); 1679 - } 1680 - } 1681 - sqlite3_free_table (results); 2515 + int i; 2516 + char **results; 2517 + int rows; 2518 + int columns; 2519 + char *errMsg = NULL; 2520 + char *name; 2521 + wxString Name; 2522 + wxString sql; 2523 + sql = wxT("PRAGMA table_info(\""); 2524 + sql += tableName; 2525 + sql += wxT("\")"); 2526 + int ret = sqlite3_get_table(SqliteHandle, sql.ToUTF8(), &results, 2527 + &rows, &columns, &errMsg); 2528 + if (ret != SQLITE_OK) 2529 + { 2530 + wxMessageBox(wxT("SQLite SQL error: ") + wxString::FromUTF8(errMsg), 2531 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 2532 + sqlite3_free(errMsg); 2533 + return; 2534 + } 2535 + if (rows < 1) 2536 + ; 2537 + else 2538 + { 2539 + for (i = 1; i <= rows; i++) 2540 + { 2541 + name = results[(i * columns) + 1]; 2542 + Name = wxString::FromUTF8(name); 2543 + list->AddColumn(Name); 2544 + } 2545 + } 2546 + sqlite3_free_table(results); 1682 2547 } 1683 2548 1684 -void 1685 -MyFrame::GetTableIndices (wxString & tableName, MyTableInfo * list) 2549 +void MyFrame::GetTableIndices(wxString & tableName, MyTableInfo * list) 1686 2550 { 1687 2551 // loads the table's indices list 1688 - int i; 1689 - char **results; 1690 - int rows; 1691 - int columns; 1692 - char *errMsg = NULL; 1693 - char *name; 1694 - wxString Name; 1695 - wxString sql; 1696 - sql = wxT ("PRAGMA index_list("); 1697 - sql += tableName; 1698 - sql += wxT (")"); 1699 - int ret = sqlite3_get_table (SqliteHandle, sql.ToUTF8 (), &results, 1700 - &rows, &columns, &errMsg); 1701 - if (ret != SQLITE_OK) 1702 - { 1703 - wxMessageBox (wxT ("SQLite SQL error: ") + 1704 - wxString::FromUTF8 (errMsg), wxT ("spatialite-gui"), 1705 - wxOK | wxICON_ERROR, this); 1706 - sqlite3_free (errMsg); 1707 - return; 1708 - } 1709 - if (rows < 1) 1710 - ; 1711 - else 1712 - { 1713 - for (i = 1; i <= rows; i++) 1714 - { 1715 - name = results[(i * columns) + 1]; 1716 - Name = wxString::FromUTF8 (name); 1717 - list->AddIndex (Name); 1718 - } 1719 - } 1720 - sqlite3_free_table (results); 2552 + int i; 2553 + char **results; 2554 + int rows; 2555 + int columns; 2556 + char *errMsg = NULL; 2557 + char *name; 2558 + wxString Name; 2559 + wxString sql; 2560 + sql = wxT("PRAGMA index_list(\""); 2561 + sql += tableName; 2562 + sql += wxT("\")"); 2563 + int ret = sqlite3_get_table(SqliteHandle, sql.ToUTF8(), &results, 2564 + &rows, &columns, &errMsg); 2565 + if (ret != SQLITE_OK) 2566 + { 2567 + wxMessageBox(wxT("SQLite SQL error: ") + wxString::FromUTF8(errMsg), 2568 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 2569 + sqlite3_free(errMsg); 2570 + return; 2571 + } 2572 + if (rows < 1) 2573 + ; 2574 + else 2575 + { 2576 + for (i = 1; i <= rows; i++) 2577 + { 2578 + name = results[(i * columns) + 1]; 2579 + Name = wxString::FromUTF8(name); 2580 + list->AddIndex(Name); 2581 + } 2582 + } 2583 + sqlite3_free_table(results); 1721 2584 } 1722 2585 1723 -void 1724 -MyFrame::GetTableTriggers (wxString & tableName, MyTableInfo * list) 2586 +void MyFrame::GetTableTriggers(wxString & tableName, MyTableInfo * list) 1725 2587 { 1726 2588 // loads the table's indices list 1727 - int i; 1728 - char **results; 1729 - int rows; 1730 - int columns; 1731 - char *errMsg = NULL; 1732 - char *name; 1733 - wxString Name; 1734 - wxString sql; 1735 - sql = 1736 - wxT 1737 - ("SELECT name FROM sqlite_master WHERE type = 'trigger' AND tbl_name = '"); 1738 - sql += tableName; 1739 - sql += wxT ("' ORDER BY name"); 1740 - int ret = sqlite3_get_table (SqliteHandle, sql.ToUTF8 (), &results, 1741 - &rows, &columns, &errMsg); 1742 - if (ret != SQLITE_OK) 1743 - { 1744 - wxMessageBox (wxT ("SQLite SQL error: ") + 1745 - wxString::FromUTF8 (errMsg), wxT ("spatialite-gui"), 1746 - wxOK | wxICON_ERROR, this); 1747 - sqlite3_free (errMsg); 1748 - return; 1749 - } 1750 - if (rows < 1) 1751 - ; 1752 - else 1753 - { 1754 - for (i = 1; i <= rows; i++) 1755 - { 1756 - name = results[(i * columns) + 0]; 1757 - Name = wxString::FromUTF8 (name); 1758 - list->AddTrigger (Name); 1759 - } 1760 - } 1761 - sqlite3_free_table (results); 1762 - TableTree->ExpandRoot (); 2589 + int i; 2590 + char **results; 2591 + int rows; 2592 + int columns; 2593 + char *errMsg = NULL; 2594 + char *name; 2595 + wxString Name; 2596 + wxString sql; 2597 + sql = 2598 + wxT 2599 + ("SELECT name FROM sqlite_master WHERE type = 'trigger' AND tbl_name = '"); 2600 + sql += tableName; 2601 + sql += wxT("' ORDER BY \"name\""); 2602 + int ret = sqlite3_get_table(SqliteHandle, sql.ToUTF8(), &results, 2603 + &rows, &columns, &errMsg); 2604 + if (ret != SQLITE_OK) 2605 + { 2606 + wxMessageBox(wxT("SQLite SQL error: ") + wxString::FromUTF8(errMsg), 2607 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 2608 + sqlite3_free(errMsg); 2609 + return; 2610 + } 2611 + if (rows < 1) 2612 + ; 2613 + else 2614 + { 2615 + for (i = 1; i <= rows; i++) 2616 + { 2617 + name = results[(i * columns) + 0]; 2618 + Name = wxString::FromUTF8(name); 2619 + list->AddTrigger(Name); 2620 + } 2621 + } 2622 + sqlite3_free_table(results); 2623 + TableTree->ExpandRoot(); 1763 2624 } 1764 2625 1765 -wxString * 1766 -MyFrame::GetColumnNames (wxString & tableName, int *n_cols) 2626 +wxString *MyFrame::GetColumnNames(wxString & tableName, int *n_cols) 1767 2627 { 1768 2628 // loads the table's column names list 1769 - wxString *cols = NULL; 1770 - int nCols = 0; 1771 - char **results; 1772 - int rows; 1773 - int columns; 1774 - int i; 1775 - char *errMsg = NULL; 1776 - wxString sql; 1777 - char *column; 1778 - sql = wxT ("PRAGMA table_info("); 1779 - sql += tableName; 1780 - sql += wxT (")"); 1781 - int ret = sqlite3_get_table (SqliteHandle, sql.ToUTF8 (), &results, 1782 - &rows, &columns, &errMsg); 1783 - if (ret != SQLITE_OK) 1784 - { 1785 - wxMessageBox (wxT ("SQLite SQL error: ") + 1786 - wxString::FromUTF8 (errMsg), wxT ("spatialite-gui"), 1787 - wxOK | wxICON_ERROR, this); 1788 - sqlite3_free (errMsg); 1789 - return NULL; 1790 - } 1791 - sql = wxT (""); 1792 - if (rows < 1) 1793 - ; 1794 - else 1795 - { 1796 - nCols = rows; 1797 - cols = new wxString[rows]; 1798 - for (i = 1; i <= rows; i++) 1799 - { 1800 - column = results[(i * columns) + 1]; 1801 - *(cols + i - 1) += wxString::FromUTF8 (column); 1802 - } 1803 - } 1804 - sqlite3_free_table (results); 1805 - *n_cols = nCols; 1806 - return cols; 2629 + wxString *cols = NULL; 2630 + int nCols = 0; 2631 + char **results; 2632 + int rows; 2633 + int columns; 2634 + int i; 2635 + char *errMsg = NULL; 2636 + wxString sql; 2637 + char *column; 2638 + sql = wxT("PRAGMA table_info(\""); 2639 + sql += tableName; 2640 + sql += wxT("\")"); 2641 + int ret = sqlite3_get_table(SqliteHandle, sql.ToUTF8(), &results, 2642 + &rows, &columns, &errMsg); 2643 + if (ret != SQLITE_OK) 2644 + { 2645 + wxMessageBox(wxT("SQLite SQL error: ") + wxString::FromUTF8(errMsg), 2646 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 2647 + sqlite3_free(errMsg); 2648 + return NULL; 2649 + } 2650 + sql = wxT(""); 2651 + if (rows < 1) 2652 + ; 2653 + else 2654 + { 2655 + nCols = rows; 2656 + cols = new wxString[rows]; 2657 + for (i = 1; i <= rows; i++) 2658 + { 2659 + column = results[(i * columns) + 1]; 2660 + *(cols + i - 1) += wxString::FromUTF8(column); 2661 + } 2662 + } 2663 + sqlite3_free_table(results); 2664 + *n_cols = nCols; 2665 + return cols; 1807 2666 } 1808 2667 1809 -int 1810 -MyFrame::GetCharsetIndex (wxString & charset) 2668 +int MyFrame::GetCharsetIndex(wxString & charset) 1811 2669 { 1812 2670 // identifies the INDEX for a given charset 1813 - int i; 1814 - for (i = 0; i < CharsetsLen; i++) 1815 - { 1816 - if (*(Charsets + i) == charset) 1817 - return i; 1818 - } 1819 - return wxNOT_FOUND; 2671 + int i; 2672 + for (i = 0; i < CharsetsLen; i++) 2673 + { 2674 + if (*(Charsets + i) == charset) 2675 + return i; 2676 + } 2677 + return wxNOT_FOUND; 1820 2678 } 1821 2679 1822 -wxString & MyFrame::GetCharsetName (wxString & charset) 2680 +wxString & MyFrame::GetCharsetName(wxString & charset) 1823 2681 { 1824 2682 // identifies the full name for a given charset code 1825 - int 1826 - i; 1827 - for (i = 0; i < CharsetsLen; i++) 1828 - { 1829 - if (*(Charsets + i) == charset) 1830 - return *(CharsetsNames + i); 1831 - } 1832 - return charset; 2683 + int i; 2684 + for (i = 0; i < CharsetsLen; i++) 2685 + { 2686 + if (*(Charsets + i) == charset) 2687 + return *(CharsetsNames + i); 2688 + } 2689 + return charset; 1833 2690 } 1834 2691 1835 -void 1836 -MyFrame::ClearTableTree () 2692 +void MyFrame::ClearTableTree() 1837 2693 { 1838 2694 // resets the table TREE list to the empty state 1839 - wxString path = wxT ("no current DB"); 1840 - TableTree->SetPath (path); 1841 - TableTree->FlushAll (); 2695 + wxString path = wxT("no current DB"); 2696 + TableTree->SetPath(path); 2697 + TableTree->FlushAll(); 2698 +} 2699 + 2700 +void MyFrame::AutoFDOStart() 2701 +{ 2702 +// 2703 +// trying to start the FDO-OGR auto-wrapper 2704 +// 2705 + int ret; 2706 + const char *name; 2707 + int i; 2708 + char **results; 2709 + int rows; 2710 + int columns; 2711 + char sql[1024]; 2712 + int count = 0; 2713 + int len; 2714 + int spatial_type = 0; 2715 + AutoFDOTables tables; 2716 + AutoFDOTable *p; 2717 + wxString fdoNames[5]; 2718 + SpatiaLiteMetadata = false; 2719 + AutoFDOmsg = wxT(""); 2720 + strcpy(sql, "SELECT CheckSpatialMetadata()"); 2721 + ret = sqlite3_get_table(SqliteHandle, sql, &results, &rows, &columns, NULL); 2722 + if (ret != SQLITE_OK) 2723 + goto error1; 2724 + if (rows < 1) 2725 + ; 2726 + else 2727 + { 2728 + for (i = 1; i <= rows; i++) 2729 + spatial_type = atoi(results[(i * columns) + 0]); 2730 + } 2731 + sqlite3_free_table(results); 2732 +error1: 2733 + if (spatial_type == 1) 2734 + SpatiaLiteMetadata = true; 2735 + if (spatial_type == 2) 2736 + { 2737 + // 2738 + // ok, creating VirtualFDO tables 2739 + // 2740 + strcpy(sql, "SELECT DISTINCT f_table_name FROM geometry_columns"); 2741 + ret = 2742 + sqlite3_get_table(SqliteHandle, sql, &results, &rows, &columns, NULL); 2743 + if (ret != SQLITE_OK) 2744 + goto error; 2745 + if (rows < 1) 2746 + ; 2747 + else 2748 + { 2749 + for (i = 1; i <= rows; i++) 2750 + { 2751 + name = results[(i * columns) + 0]; 2752 + if (name) 2753 + { 2754 + len = strlen(name); 2755 + tables.Add(name, len); 2756 + } 2757 + } 2758 + } 2759 + sqlite3_free_table(results); 2760 + p = tables.GetFirst(); 2761 + while (p) 2762 + { 2763 + // 2764 + // destroying the VirtualFDO table [if existing] 2765 + // 2766 + sprintf(sql, "DROP TABLE IF EXISTS \"fdo_%s\"", p->GetName()); 2767 + ret = sqlite3_exec(SqliteHandle, sql, NULL, 0, NULL); 2768 + if (ret != SQLITE_OK) 2769 + goto error; 2770 + // 2771 + // creating the VirtualFDO table 2772 + // 2773 + sprintf(sql, "CREATE VIRTUAL TABLE \"fdo_%s\" USING VirtualFDO(%s)", 2774 + p->GetName(), p->GetName()); 2775 + ret = sqlite3_exec(SqliteHandle, sql, NULL, 0, NULL); 2776 + if (ret != SQLITE_OK) 2777 + goto error; 2778 + if (count < 5) 2779 + fdoNames[count] = 2780 + wxT("- VirtualTable: \"fdo_") + wxString::FromUTF8(p->GetName()) + 2781 + wxT("\""); 2782 + else 2783 + fdoNames[4] = wxT("- ... and others ..."); 2784 + count++; 2785 + p = p->GetNext(); 2786 + } 2787 + error: 2788 + if (count++) 2789 + { 2790 + AutoFDOmsg = 2791 + wxT("FDO-OGR detected; activating FDO-OGR auto-wrapping ...\n\n"); 2792 + if (fdoNames[0].Len() > 0) 2793 + AutoFDOmsg += fdoNames[0] + wxT("\n"); 2794 + if (fdoNames[1].Len() > 0) 2795 + AutoFDOmsg += fdoNames[1] + wxT("\n"); 2796 + if (fdoNames[2].Len() > 0) 2797 + AutoFDOmsg += fdoNames[2] + wxT("\n"); 2798 + if (fdoNames[3].Len() > 0) 2799 + AutoFDOmsg += fdoNames[3] + wxT("\n"); 2800 + if (fdoNames[4].Len() > 0) 2801 + AutoFDOmsg += fdoNames[4] + wxT("\n"); 2802 + AutoFDOmsg += 2803 + wxT 2804 + ("\nAccessing these fdo_XX tables you can take full advantage of\n"); 2805 + AutoFDOmsg += wxT("FDO-OGR auto-wrapping facility\n"); 2806 + AutoFDOmsg += 2807 + wxT 2808 + ("This allows you to access any specific FDO-OGR Geometry as if it\n"); 2809 + AutoFDOmsg += 2810 + wxT 2811 + ("where native SpatiaLite ones in a completely transparent way.\n"); 2812 + } 2813 + return; 2814 + } 1842 2815 } 1843 2816 1844 -int 1845 -MyFrame::GuessBlobType (int size, unsigned char *blob) 2817 +void MyFrame::AutoFDOStop() 1846 2818 { 1847 2819 // 1848 -// trying to check the content-type for a BLOB value [using signatures] 2820 +// trying to stop the FDO-OGR auto-wrapper 1849 2821 // 1850 - bool geom; 1851 - if (size < 1 || !blob) 1852 - return BLOB_NULL; 1853 - if (size > 5) 1854 - { 1855 - if (strncmp ((char *) blob, "%PDF-", 5) == 0) 1856 - return BLOB_PDF; 1857 - } 1858 - if (size > 6) 1859 - { 1860 - if (strncmp ((char *) blob, "GIF87a", 6) == 0 1861 - || strncmp ((char *) blob, "GIF89a", 6) == 0) 1862 - return BLOB_GIF; 1863 - } 1864 - if (size > 4) 1865 - { 1866 - if (memcmp (blob, ZipSignature, 4) == 0) 1867 - return BLOB_ZIP; 1868 - if (memcmp (blob, Jpeg1Signature, 2) == 0 1869 - && memcmp (blob + size - 2, Jpeg2Signature, 2) == 0) 1870 - return BLOB_JPEG; // this one is the standard JPEG signature 1871 - if (memcmp (blob, Jpeg3Signature, 4) == 0) 1872 - return BLOB_JPEG; // another common JPEG signature 1873 - } 1874 - if (size > 8) 1875 - { 1876 - if (memcmp (blob, PngSignature, 8) == 0) 1877 - return BLOB_PNG; 1878 - } 1879 - if (size > 10) 1880 - { 1881 - if (memcmp (blob + 6, JfifSignature, 4) == 0) 1882 - return BLOB_JFIF; // standard JFIF signature 1883 - if (memcmp (blob + 6, ExifSignature, 4) == 0) 1884 - return BLOB_EXIF; // standard EXIF signature 1885 - } 1886 -// testing for GEOMETRY 1887 - geom = true; 1888 - if (size < 45) 1889 - geom = false; 1890 - else 1891 - { 1892 - if (*(blob + 0) != 0x00) 1893 - geom = false; 1894 - if (*(blob + (size - 1)) != 0xFE) 1895 - geom = false; 1896 - if (*(blob + 38) != 0x7C) 1897 - geom = false; 1898 - if (*(blob + 1) == 0 || *(blob + 1) == 1) 1899 - ; 1900 - else 1901 - geom = false; 1902 - } 1903 - if (geom == true) 1904 - return BLOB_GEOMETRY; 1905 - return BLOB_HEX; 2822 + int ret; 2823 + const char *name; 2824 + int i; 2825 + char **results; 2826 + int rows; 2827 + int columns; 2828 + char sql[1024]; 2829 + int count = 0; 2830 + int len; 2831 + int spatial_type = 0; 2832 + AutoFDOTables tables; 2833 + AutoFDOTable *p; 2834 + AutoFDOmsg = wxT(""); 2835 + strcpy(sql, "SELECT CheckSpatialMetadata()"); 2836 + ret = sqlite3_get_table(SqliteHandle, sql, &results, &rows, &columns, NULL); 2837 + if (ret != SQLITE_OK) 2838 + goto error1; 2839 + if (rows < 1) 2840 + ; 2841 + else 2842 + { 2843 + for (i = 1; i <= rows; i++) 2844 + spatial_type = atoi(results[(i * columns) + 0]); 2845 + } 2846 + sqlite3_free_table(results); 2847 +error1: 2848 + if (spatial_type == 2) 2849 + { 2850 + // 2851 + // ok, destroying VirtualFDO tables 2852 + // 2853 + strcpy(sql, "SELECT DISTINCT f_table_name FROM geometry_columns"); 2854 + ret = 2855 + sqlite3_get_table(SqliteHandle, sql, &results, &rows, &columns, NULL); 2856 + if (ret != SQLITE_OK) 2857 + goto error; 2858 + if (rows < 1) 2859 + ; 2860 + else 2861 + { 2862 + for (i = 1; i <= rows; i++) 2863 + { 2864 + name = results[(i * columns) + 0]; 2865 + if (name) 2866 + { 2867 + len = strlen(name); 2868 + tables.Add(name, len); 2869 + } 2870 + } 2871 + } 2872 + sqlite3_free_table(results); 2873 + p = tables.GetFirst(); 2874 + while (p) 2875 + { 2876 + // 2877 + // destroying the VirtualFDO table [if existing] 2878 + // 2879 + sprintf(sql, "DROP TABLE IF EXISTS \"fdo_%s\"", p->GetName()); 2880 + ret = sqlite3_exec(SqliteHandle, sql, NULL, 0, NULL); 2881 + if (ret != SQLITE_OK) 2882 + goto error; 2883 + count++; 2884 + p = p->GetNext(); 2885 + } 2886 + error: 2887 + if (count++) 2888 + AutoFDOmsg = wxT("FDO-OGR auto-wrapping shutdown done"); 2889 + return; 2890 + } 1906 2891 } 1907 2892 1908 -void 1909 -MyFrame::GetHelp (wxString & html) 2893 +void MyFrame::GetHelp(wxString & html) 1910 2894 { 1911 2895 // 1912 2896 // return the HTML Help 1913 2897 // 1914 - html = 1915 - wxT 1916 - ("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">"); 1917 - html += wxT ("<html>"); 1918 - html += wxT ("<head>"); 1919 - html += 1920 - wxT 1921 - ("<meta content=\"text/html; charset=ISO-8859-1\" http-equiv=\"content-type\">"); 1922 - html += wxT ("<title>SQLite + SpatiaLite quick Help</title>"); 1923 - html += wxT ("</head>"); 1924 - html += wxT ("<body bgcolor=\"#e8e8e8\">"); 1925 - html += 1926 - wxT ("<h1><a name=\"index\">SQLite + SpatiaLite quick Help</a></h1>"); 1927 - html += wxT ("<table cellspacing=\"2\" cellpadding=\"2\">"); 1928 - html += 1929 - wxT 1930 - ("<tr><td align=\"center\" bgcolor=\"#e0ffe0\" colspan=\"2\">Index of contents</td></tr>"); 1931 - html += 1932 - wxT 1933 - ("<tr><td bgcolor=\"#fffff0\">1.</td><td bgcolor=\"#f0fff0\"><a href=\"#c1\">SQLite SQL syntax</a></td></tr>"); 1934 - html += 1935 - wxT 1936 - ("<tr><td bgcolor=\"#fffff0\">2.</td><td bgcolor=\"#f0fff0\"><a href=\"#c2\">SQLite SQL functions</a><ul>"); 1937 - html += wxT ("<li><a href=\"#c21\">ordinary functions</a></li>"); 1938 - html += wxT ("<li><a href=\"#c22\">aggregate functions</a></li>"); 1939 - html += wxT ("</ul></td></tr>"); 1940 - html += 1941 - wxT 1942 - ("<tr><td bgcolor=\"#fffff0\">3.</td><td bgcolor=\"#f0fff0\"><a href=\"#c3\">SpatiaLite SQL Spatial functions</a><ul>"); 1943 - html += 1944 - wxT 1945 - ("<li><a href=\"#c30\">SQL utility functions [non-standard] for geometric objects</a></li>"); 1946 - html += 1947 - wxT 1948 - ("<li><a href=\"#c31\">functions for constructing a geometric object given its Well-known Text Representation</a></li>"); 1949 - html += 1950 - wxT 1951 - ("<li><a href=\"#c32\">functions for constructing a geometric object given its Well-known Binary Representation</a></li>"); 1952 - html += 1953 - wxT 1954 - ("<li><a href=\"#c33\">functions for obtaining the Well-known Text / Well-known Binary Representation of a geometric object</a></li>"); 1955 - html += wxT ("<li><a href=\"#c34\">functions on type Geometry</a></li>"); 1956 - html += wxT ("<li><a href=\"#c35\">functions on type Point</a></li>"); 1957 - html += 1958 - wxT 1959 - ("<li><a href=\"#c36\">functions on type Surface [Polygon or Ring]</a></li>"); 1960 - html += wxT ("<li><a href=\"#c37\">functions on type Polygon</a></li>"); 1961 - html += 1962 - wxT ("<li><a href=\"#c38\">functions on type GeomCollection</a></li>"); 1963 - html += 1964 - wxT 1965 - ("<li><a href=\"#c39\">functions testing approximative spatial relationships via MBRs</a></li>"); 1966 - html += 1967 - wxT 1968 - ("<li><a href=\"#c40\">functions testing spatial relationships</a></li>"); 1969 - html += 1970 - wxT 1971 - ("<li><a href=\"#c41\">functions implementing spatial operators</a></li>"); 1972 - html += 1973 - wxT 1974 - ("<li><a href=\"#c42\">functions for coordinate transformations</a></li>"); 1975 - html += 1976 - wxT 1977 - ("<li><a href=\"#c43\">functions for Spatial-MetaData and Spatial-Index handling</a></li>"); 1978 - html += wxT ("</ul></td></tr>"); 1979 - html += wxT ("</table>"); 1980 - html += wxT ("<h3><a name=\"c1\">SQLite SQL syntax</a></h3>"); 1981 - html += wxT ("<table cellspacing=\"4\" cellpadding=\"2\"width=\"100%\">"); 1982 - html += 1983 - wxT 1984 - ("<tr><td bgcolor=\"#fffff0\">ALTER TABLE</td><td bgcolor=\"#f0fff0\">sql-statement ::= ALTER TABLE [database-name .] table-name alteration<br>"); 1985 - html += wxT ("alteration ::= RENAME TO new-table-name<br>"); 1986 - html += wxT ("alteration ::= ADD [COLUMN] column-def<br></td></tr>"); 1987 - html += 1988 - wxT 1989 - ("<tr><td bgcolor=\"#fffff0\">ANALYZE</td><td bgcolor=\"#f0fff0\">sql-statement ::= ANALYZE<br>"); 1990 - html += wxT ("sql-statement ::= ANALYZE database-name<br>"); 1991 - html += 1992 - wxT 1993 - ("sql-statement ::= ANALYZE [database-name .] table-name<br></td></tr>"); 1994 - html += 1995 - wxT 1996 - ("<tr><td bgcolor=\"#fffff0\">ATTACH DATABASE</td><td bgcolor=\"#f0fff0\">sql-statement ::= ATTACH [DATABASE] database-filename AS database-name</td></tr>"); 1997 - html += 1998 - wxT 1999 - ("<tr><td bgcolor=\"#fffff0\">BEGIN TRANSACTION</td><td bgcolor=\"#f0fff0\">sql-statement ::= BEGIN [ DEFERRED | IMMEDIATE | EXCLUSIVE ] [TRANSACTION [name]]<br>"); 2000 - html += wxT ("sql-statement ::= END [TRANSACTION [name]]<br>"); 2001 - html += wxT ("sql-statement ::= COMMIT [TRANSACTION [name]]<br>"); 2002 - html += 2003 - wxT ("sql-statement ::= ROLLBACK [TRANSACTION [name]]<br></td></tr>"); 2004 - html += 2005 - wxT 2006 - ("<tr><td bgcolor=\"#fffff0\">COMMIT TRANSACTION</td><td bgcolor=\"#f0fff0\">sql-statement ::= BEGIN [ DEFERRED | IMMEDIATE | EXCLUSIVE ] [TRANSACTION [name]]<br>"); 2007 - html += wxT ("sql-statement ::= END [TRANSACTION [name]]<br>"); 2008 - html += wxT ("sql-statement ::= COMMIT [TRANSACTION [name]]<br>"); 2009 - html += 2010 - wxT ("sql-statement ::= ROLLBACK [TRANSACTION [name]]<br></td></tr>"); 2011 - html += 2012 - wxT 2013 - ("<tr><td bgcolor=\"#fffff0\">CREATE INDEX</td><td bgcolor=\"#f0fff0\">sql-statement ::= CREATE [UNIQUE] INDEX [IF NOT EXISTS] [database-name .] index-name<br>"); 2014 - html += wxT ("ON table-name ( column-name [, column-name]* )<br>"); 2015 - html += 2016 - wxT 2017 - ("column-name ::= name [ COLLATE collation-name] [ ASC | DESC ]</td></tr>"); 2018 - html += 2019 - wxT 2020 - ("<tr><td bgcolor=\"#fffff0\">CREATE TABLE</td><td bgcolor=\"#f0fff0\">sql-command ::= CREATE [TEMP | TEMPORARY] TABLE [IF NOT EXISTS] [database-name .] table-name (<br>"); 2021 - html += wxT ("column-def [, column-def]*<br>"); 2022 - html += wxT ("[, constraint]*<br>"); 2023 - html += wxT (")<br>"); 2024 - html += 2025 - wxT 2026 - ("sql-command ::= CREATE [TEMP | TEMPORARY] TABLE [database-name.] table-name AS select-statement<br>"); 2027 - html += 2028 - wxT 2029 - ("column-def ::= name [type] [[CONSTRAINT name] column-constraint]*<br>"); 2030 - html += wxT ("type ::= typename |<br>"); 2031 - html += wxT ("typename ( number ) |<br>"); 2032 - html += wxT ("typename ( number , number )<br>"); 2033 - html += wxT ("column-constraint ::= NOT NULL [ conflict-clause ] |<br>"); 2034 - html += 2035 - wxT 2036 - ("PRIMARY KEY [sort-order] [ conflict-clause ] [AUTOINCREMENT] |<br>"); 2037 - html += wxT ("UNIQUE [ conflict-clause ] |<br>"); 2038 - html += wxT ("CHECK ( expr ) |<br>"); 2039 - html += wxT ("DEFAULT value |<br>"); 2040 - html += wxT ("COLLATE collation-name<br>"); 2041 - html += 2042 - wxT 2043 - ("constraint ::= PRIMARY KEY ( column-list ) [ conflict-clause ] |<br>"); 2044 - html += wxT ("UNIQUE ( column-list ) [ conflict-clause ] |<br>"); 2045 - html += wxT ("CHECK ( expr )<br>"); 2046 - html += 2047 - wxT ("conflict-clause ::= ON CONFLICT conflict-algorithm</td></tr>"); 2048 - html += 2049 - wxT 2050 - ("<tr><td bgcolor=\"#fffff0\">CREATE TRIGGER</td><td bgcolor=\"#f0fff0\">sql-statement ::= CREATE [TEMP | TEMPORARY] TRIGGER [IF NOT EXISTS] trigger-name [ BEFORE | AFTER ]<br>"); 2051 - html += wxT ("database-event ON [database-name .] table-name<br>"); 2052 - html += wxT ("trigger-action<br>"); 2053 - html += 2054 - wxT 2055 - ("sql-statement ::= CREATE [TEMP | TEMPORARY] TRIGGER [IF NOT EXISTS] trigger-name INSTEAD OF<br>"); 2056 - html += wxT ("database-event ON [database-name .] view-name<br>"); 2057 - html += wxT ("trigger-action<br>"); 2058 - html += wxT ("database-event ::= DELETE |<br>"); 2059 - html += wxT ("INSERT |<br>"); 2060 - html += wxT ("UPDATE |<br>"); 2061 - html += wxT ("UPDATE OF column-list<br>"); 2062 - html += wxT ("trigger-action ::= [ FOR EACH ROW ] [ WHEN expression ]<br>"); 2063 - html += wxT ("BEGIN<br>"); 2064 - html += wxT ("trigger-step ; [ trigger-step ; ]*<br>"); 2065 - html += wxT ("END<br>"); 2066 - html += wxT ("trigger-step ::= update-statement | insert-statement |<br>"); 2067 - html += wxT ("delete-statement | select-statement</td></tr>"); 2068 - html += 2069 - wxT 2070 - ("<tr><td bgcolor=\"#fffff0\">CREATE VIEW</td><td bgcolor=\"#f0fff0\">sql-command ::= CREATE [TEMP | TEMPORARY] VIEW [IF NOT EXISTS] [database-name.] view-name AS select-statement</td></tr>"); 2071 - html += 2072 - wxT 2073 - ("<tr><td bgcolor=\"#fffff0\">CREATE VIRTUAL TABLE</td><td bgcolor=\"#f0fff0\">sql-command ::= CREATE VIRTUAL TABLE [database-name .] table-name USING module-name [( arguments )]</td></tr>"); 2074 - html += 2075 - wxT 2076 - ("<tr><td bgcolor=\"#fffff0\">DELETE</td><td bgcolor=\"#f0fff0\">sql-statement ::= DELETE FROM [database-name .] table-name [WHERE expr]</td></tr>"); 2077 - html += 2078 - wxT 2079 - ("<tr><td bgcolor=\"#fffff0\">DETACH DATABASE</td><td bgcolor=\"#f0fff0\">sql-command ::= DETACH [DATABASE] database-name</td></tr>"); 2080 - html += 2081 - wxT 2082 - ("<tr><td bgcolor=\"#fffff0\">DROP INDEX</td><td bgcolor=\"#f0fff0\">sql-command ::= DROP INDEX [IF EXISTS] [database-name .] index-name</td></tr>"); 2083 - html += 2084 - wxT 2085 - ("<tr><td bgcolor=\"#fffff0\">DROP TABLE</td><td bgcolor=\"#f0fff0\">sql-command ::= DROP TABLE [IF EXISTS] [database-name.] table-name</td></tr>"); 2086 - html += 2087 - wxT 2088 - ("<tr><td bgcolor=\"#fffff0\">DROP TRIGGER</td><td bgcolor=\"#f0fff0\">sql-statement ::= DROP TRIGGER [IF EXISTS] [database-name .] trigger-name</td></tr>"); 2089 - html += 2090 - wxT 2091 - ("<tr><td bgcolor=\"#fffff0\">DROP VIEW</td><td bgcolor=\"#f0fff0\">sql-command ::= DROP VIEW [IF EXISTS] view-name</td></tr>"); 2092 - html += 2093 - wxT 2094 - ("<tr><td bgcolor=\"#fffff0\">END TRANSACTION</td><td bgcolor=\"#f0fff0\">sql-statement ::= BEGIN [ DEFERRED | IMMEDIATE | EXCLUSIVE ] [TRANSACTION [name]]<br>"); 2095 - html += wxT ("sql-statement ::= END [TRANSACTION [name]]<br>"); 2096 - html += wxT ("sql-statement ::= COMMIT [TRANSACTION [name]]<br>"); 2097 - html += 2098 - wxT ("sql-statement ::= ROLLBACK [TRANSACTION [name]]<br></td></tr>"); 2099 - html += 2100 - wxT 2101 - ("<tr><td bgcolor=\"#fffff0\">EXPLAIN</td><td bgcolor=\"#f0fff0\">sql-statement ::= EXPLAIN sql-statement</td></tr>"); 2102 - html += 2103 - wxT 2104 - ("<tr><td bgcolor=\"#fffff0\">INSERT</td><td bgcolor=\"#f0fff0\">sql-statement ::= INSERT [OR conflict-algorithm] INTO [database-name .] table-name [(column-list)] VALUES(value-list) |<br>"); 2105 - html += 2106 - wxT 2107 - ("INSERT [OR conflict-algorithm] INTO [database-name .] table-name [(column-list)] select-statement</td></tr>"); 2108 - html += 2109 - wxT 2110 - ("<tr><td bgcolor=\"#fffff0\">ON CONFLICT clause</td><td bgcolor=\"#f0fff0\">conflict-clause ::= ON CONFLICT conflict-algorithm<br>"); 2111 - html += 2112 - wxT 2113 - ("conflict-algorithm ::= ROLLBACK | ABORT | FAIL | IGNORE | REPLACE</td></tr>"); 2114 - html += 2115 - wxT 2116 - ("<tr><td bgcolor=\"#fffff0\">PRAGMA</td><td bgcolor=\"#f0fff0\">sql-statement ::= PRAGMA name [= value] |<br>"); 2117 - html += wxT ("PRAGMA function(arg)<hr>"); 2118 - html += wxT ("PRAGMA auto_vacuum;<br>"); 2119 - html += 2120 - wxT ("PRAGMA auto_vacuum = 0 | none | 1 | full | 2 | incremental;<hr>"); 2121 - html += wxT ("PRAGMA cache_size;<br>"); 2122 - html += wxT ("PRAGMA cache_size = Number-of-pages;<hr>"); 2123 - html += wxT ("PRAGMA case_sensitive_like;<br>"); 2124 - html += wxT ("PRAGMA case_sensitive_like = 0 | 1;<hr>"); 2125 - html += wxT ("PRAGMA count_changes;<br>"); 2126 - html += wxT ("PRAGMA count_changes = 0 | 1;<hr>"); 2127 - html += wxT ("PRAGMA default_cache_size;<br>"); 2128 - html += wxT ("PRAGMA default_cache_size = Number-of-pages;<hr>"); 2129 - html += wxT ("PRAGMA empty_result_callbacks;<br>"); 2130 - html += wxT ("PRAGMA empty_result_callbacks = 0 | 1;<hr>"); 2131 - html += wxT ("PRAGMA encoding;<br>"); 2132 - html += wxT ("PRAGMA encoding = \"UTF-8\";<br>"); 2133 - html += wxT ("PRAGMA encoding = \"UTF-16\";<br>"); 2134 - html += wxT ("PRAGMA encoding = \"UTF-16le\";<br>"); 2135 - html += wxT ("PRAGMA encoding = \"UTF-16be\";<hr>"); 2136 - html += wxT ("PRAGMA full_column_names;<br>"); 2137 - html += wxT ("PRAGMA full_column_names = 0 | 1;<hr>"); 2138 - html += wxT ("PRAGMA fullfsync;<br>"); 2139 - html += wxT ("PRAGMA fullfsync = 0 | 1;<hr>"); 2140 - html += wxT ("PRAGMA journal_mode;<br>"); 2141 - html += wxT ("PRAGMA database.journal_mode;<br>"); 2142 - html += wxT ("PRAGMA journal_mode = DELETE | PERSIST | OFF<br>"); 2143 - html += wxT ("PRAGMA database.journal_mode = DELETE | PERSIST | OFF<hr>"); 2144 - html += wxT ("PRAGMA legacy_file_format;<br>"); 2145 - html += wxT ("PRAGMA legacy_file_format = ON | OFF<hr>"); 2146 - html += wxT ("PRAGMA locking_mode;<br>"); 2147 - html += wxT ("PRAGMA locking_mode = NORMAL | EXCLUSIVE<hr>"); 2148 - html += wxT ("PRAGMA page_size;<br>"); 2149 - html += wxT ("PRAGMA page_size = bytes;<hr>"); 2150 - html += wxT ("PRAGMA max_page_count;<br>"); 2151 - html += wxT ("PRAGMA max_page_count = N;<hr>"); 2152 - html += wxT ("PRAGMA read_uncommitted;<br>"); 2153 - html += wxT ("PRAGMA read_uncommitted = 0 | 1;<hr>"); 2154 - html += wxT ("PRAGMA short_column_names;<br>"); 2155 - html += wxT ("PRAGMA short_column_names = 0 | 1;<hr>"); 2156 - html += wxT ("PRAGMA synchronous;<br>"); 2157 - html += wxT ("PRAGMA synchronous = FULL; (2)<br>"); 2158 - html += wxT ("PRAGMA synchronous = NORMAL; (1)<br>"); 2159 - html += wxT ("PRAGMA synchronous = OFF; (0)<hr>"); 2160 - html += wxT ("PRAGMA temp_store;<br>"); 2161 - html += wxT ("PRAGMA temp_store = DEFAULT; (0)<br>"); 2162 - html += wxT ("PRAGMA temp_store = FILE; (1)<br>"); 2163 - html += wxT ("PRAGMA temp_store = MEMORY; (2)<hr>"); 2164 - html += wxT ("PRAGMA temp_store_directory;<br>"); 2165 - html += wxT ("PRAGMA temp_store_directory = 'directory-name';<hr>"); 2166 - html += wxT ("PRAGMA database_list;<hr>"); 2167 - html += wxT ("PRAGMA foreign_key_list(table-name);<hr>"); 2168 - html += wxT ("PRAGMA [database].freelist_count;<hr>"); 2169 - html += wxT ("PRAGMA index_info(index-name);<hr>"); 2170 - html += wxT ("PRAGMA index_list(table-name);<hr>"); 2171 - html += wxT ("PRAGMA table_info(table-name);<hr>"); 2172 - html += wxT ("PRAGMA [database.]schema_version;<br>"); 2173 - html += wxT ("PRAGMA [database.]schema_version = integer ;<br>"); 2174 - html += wxT ("PRAGMA [database.]user_version;<br>"); 2175 - html += wxT ("PRAGMA [database.]user_version = integer ;<hr>"); 2176 - html += wxT ("PRAGMA integrity_check;<br>"); 2177 - html += wxT ("PRAGMA integrity_check(integer)<hr>"); 2178 - html += wxT ("PRAGMA parser_trace = ON; (1)<br>"); 2179 - html += wxT ("PRAGMA parser_trace = OFF; (0)<hr>"); 2180 - html += wxT ("PRAGMA vdbe_trace = ON; (1)<br>"); 2181 - html += wxT ("PRAGMA vdbe_trace = OFF; (0)<hr>"); 2182 - html += wxT ("PRAGMA vdbe_listing = ON; (1)<br>"); 2183 - html += wxT ("PRAGMA vdbe_listing = OFF; (0)</td></tr>"); 2184 - html += 2185 - wxT 2186 - ("<tr><td bgcolor=\"#fffff0\">REINDEX</td><td bgcolor=\"#f0fff0\">sql-statement ::= REINDEX collation name<br>"); 2187 - html += 2188 - wxT 2189 - ("sql-statement ::= REINDEX [database-name .] table/index-name</td></tr>"); 2190 - html += 2191 - wxT 2192 - ("<tr><td bgcolor=\"#fffff0\">REPLACE</td><td bgcolor=\"#f0fff0\">sql-statement ::= REPLACE INTO [database-name .] table-name [( column-list )] VALUES ( value-list ) |<br>"); 2193 - html += 2194 - wxT 2195 - ("REPLACE INTO [database-name .] table-name [( column-list )] select-statement</td></tr>"); 2196 - html += 2197 - wxT 2198 - ("<tr><td bgcolor=\"#fffff0\">ROLLBACK TRANSACTION</td><td bgcolor=\"#f0fff0\">sql-statement ::= BEGIN [ DEFERRED | IMMEDIATE | EXCLUSIVE ] [TRANSACTION [name]]<br>"); 2199 - html += wxT ("sql-statement ::= END [TRANSACTION [name]]<br>"); 2200 - html += wxT ("sql-statement ::= COMMIT [TRANSACTION [name]]<br>"); 2201 - html += 2202 - wxT ("sql-statement ::= ROLLBACK [TRANSACTION [name]]<br></td></tr>"); 2203 - html += 2204 - wxT 2205 - ("<tr><td bgcolor=\"#fffff0\">SELECT</td><td bgcolor=\"#f0fff0\">sql-statement ::= SELECT [ALL | DISTINCT] result [FROM table-list]<br>"); 2206 - html += wxT ("[WHERE expr]<br>"); 2207 - html += wxT ("[GROUP BY expr-list]<br>"); 2208 - html += wxT ("[HAVING expr]<br>"); 2209 - html += wxT ("[compound-op select]*<br>"); 2210 - html += wxT ("[ORDER BY sort-expr-list]<br>"); 2211 - html += wxT ("[LIMIT integer [( OFFSET | , ) integer]]<br>"); 2212 - html += wxT ("result ::= result-column [, result-column]*<br>"); 2213 - html += 2214 - wxT ("result-column ::= * | table-name . * | expr [ [AS] string ]<br>"); 2215 - html += wxT ("table-list ::= table [join-op table join-args]*<br>"); 2216 - html += wxT ("table ::= table-name [AS alias] |<br>"); 2217 - html += wxT ("( select ) [AS alias]<br>"); 2218 - html += 2219 - wxT 2220 - ("join-op ::= , | [NATURAL] [LEFT | RIGHT | FULL] [OUTER | INNER | CROSS] JOIN<br>"); 2221 - html += wxT ("join-args ::= [ON expr] [USING ( id-list )]<br>"); 2222 - html += 2223 - wxT ("sort-expr-list ::= expr [sort-order] [, expr [sort-order]]*<br>"); 2224 - html += 2225 - wxT ("sort-order ::= [ COLLATE collation-name ] [ ASC | DESC ]<br>"); 2226 - html += 2227 - wxT 2228 - ("compound_op ::= UNION | UNION ALL | INTERSECT | EXCEPT</td></tr>"); 2229 - html += 2230 - wxT 2231 - ("<tr><td bgcolor=\"#fffff0\">UPDATE</td><td bgcolor=\"#f0fff0\">sql-statement ::= UPDATE [ OR conflict-algorithm ] [database-name .] table-name<br>"); 2232 - html += wxT ("SET assignment [, assignment]*<br>"); 2233 - html += wxT ("[WHERE expr]<br>"); 2234 - html += wxT ("assignment ::= column-name = expr</td></tr>"); 2235 - html += 2236 - wxT 2237 - ("<tr><td bgcolor=\"#fffff0\">VACUUM</td><td bgcolor=\"#f0fff0\">sql-statement ::= VACUUM</td></tr>"); 2238 - html += wxT ("</table>"); 2239 - html += wxT ("<a href=\"#index\">back to index</a>"); 2240 - html += 2241 - wxT 2242 - ("<h3><a align=\"center\" bgcolor=\"#e0ffe0\" name=\"c2\">SQLite SQL functions</a></h3>"); 2243 - html += wxT ("<table cellspacing=\"4\" cellpadding=\"2\" width=\"100%\">"); 2244 - html += 2245 - wxT 2246 - ("<tr><td align=\"center\" bgcolor=\"#e0ffe0\" colspan=\"2\"><a name=\"c21\">ordinary functions</a><br><a href=\"#index\">back to index</a></td></tr>"); 2247 - html += 2248 - wxT 2249 - ("<tr><td bgcolor=\"#fffff0\">abs(X)</td><td bgcolor=\"#f0fff0\">Return the absolute value of the numeric argument X. "); 2250 - html += 2251 - wxT 2252 - ("Return NULL if X is NULL. Return 0.0 if X is not a numeric value.</td></tr>"); 2253 - html += 2254 - wxT 2255 - ("<tr><td bgcolor=\"#fffff0\">coalesce(X,Y,...)</td><td bgcolor=\"#f0fff0\">Return a copy of the first non-NULL argument. "); 2256 - html += 2257 - wxT 2258 - ("If all arguments are NULL then NULL is returned. There must be at least 2 arguments.</td></tr>"); 2259 - html += 2260 - wxT 2261 - ("<tr><td bgcolor=\"#fffff0\">glob(X,Y)</td><td bgcolor=\"#f0fff0\">This function is used to implement the \"X GLOB Y\" syntax of SQLite. "); 2262 - html += 2263 - wxT 2264 - ("The sqlite3_create_function() interface can be used to override this function and thereby change the operation of the GLOB operator.</td></tr>"); 2265 - html += 2266 - wxT 2267 - ("<tr><td bgcolor=\"#fffff0\">ifnull(X,Y)</td><td bgcolor=\"#f0fff0\">Return a copy of the first non-NULL argument. "); 2268 - html += 2269 - wxT 2270 - ("If both arguments are NULL then NULL is returned. This behaves the same as coalesce().</td></tr>"); 2271 - html += 2272 - wxT 2273 - ("<tr><td bgcolor=\"#fffff0\">hex(X)</td><td bgcolor=\"#f0fff0\">The argument is interpreted as a BLOB. "); 2274 - html += 2275 - wxT 2276 - ("The result is a hexadecimal rendering of the content of that blob.</td></tr>"); 2277 - html += 2278 - wxT 2279 - ("<tr><td bgcolor=\"#fffff0\">last_insert_rowid()</td><td bgcolor=\"#f0fff0\">Return the ROWID of the last row insert from this connection to the database. "); 2280 - html += 2281 - wxT 2282 - ("This is the same value that would be returned from the sqlite3_last_insert_rowid() API function.</td></tr>"); 2283 - html += 2284 - wxT 2285 - ("<tr><td bgcolor=\"#fffff0\">length(X)</td><td bgcolor=\"#f0fff0\">Return the string length of X in characters. "); 2286 - html += 2287 - wxT 2288 - ("If SQLite is configured to support UTF-8, then the number of UTF-8 characters is returned, not the number of bytes.</td></tr>"); 2289 - html += 2290 - wxT 2291 - ("<tr><td bgcolor=\"#fffff0\">like(X,Y)<br>like(X,Y,Z)</td><td bgcolor=\"#f0fff0\">This function is used to implement the \"X LIKE Y [ESCAPE Z]\" syntax of SQL."); 2292 - html += 2293 - wxT 2294 - ("If the optional ESCAPE clause is present, then the user-function is invoked with three arguments. "); 2295 - html += wxT ("Otherwise, it is invoked with two arguments only. "); 2296 - html += 2297 - wxT 2298 - ("The sqlite3_create_function() interface can be used to override this function and thereby change the operation of the LIKE operator. "); 2299 - html += 2300 - wxT 2301 - ("When doing this, it may be important to override both the two and three argument versions of the like() function. "); 2302 - html += 2303 - wxT 2304 - ("Otherwise, different code may be called to implement the LIKE operator depending on whether or not an ESCAPE clause was specified.</td></tr>"); 2305 - html += 2306 - wxT 2307 - ("<tr><td bgcolor=\"#fffff0\">load_extension(X)</br>load_extension(X,Y)</td><td bgcolor=\"#f0fff0\">Load SQLite extensions "); 2308 - html += 2309 - wxT 2310 - ("out of the shared library file named X using the entry point Y. "); 2311 - html += 2312 - wxT 2313 - ("The result is a NULL. If Y is omitted then the default entry point of sqlite3_extension_init is used. "); 2314 - html += 2315 - wxT 2316 - ("This function raises an exception if the extension fails to load or initialize correctly.</td></tr>"); 2317 - html += 2318 - wxT 2319 - ("<tr><td bgcolor=\"#fffff0\">lower(X)</td><td bgcolor=\"#f0fff0\">Return a copy of string X will all ASCII characters converted to lower case. "); 2320 - html += 2321 - wxT 2322 - ("The C library tolower() routine is used for the conversion, which means that this function might not work correctly on non-ASCII UTF-8 characters.</td></tr>"); 2323 - html += 2324 - wxT 2325 - ("<tr><td bgcolor=\"#fffff0\">ltrim(X)<br>ltrim(X,Y)</td><td bgcolor=\"#f0fff0\">Return a string formed by removing any and all characters "); 2326 - html += 2327 - wxT 2328 - ("that appear in Y from the left side of X. If the Y argument is omitted, spaces are removed.</td></tr>"); 2329 - html += 2330 - wxT 2331 - ("<tr><td bgcolor=\"#fffff0\">max(X,Y,...)</td><td bgcolor=\"#f0fff0\">Return the argument with the maximum value. "); 2332 - html += wxT ("Arguments may be strings in addition to numbers. "); 2333 - html += wxT ("The maximum value is determined by the usual sort order. "); 2334 - html += 2335 - wxT 2336 - ("Note that max() is a simple function when it has 2 or more arguments but converts to an aggregate function if given only a single argument.</td></tr>"); 2337 - html += 2338 - wxT 2339 - ("<tr><td bgcolor=\"#fffff0\">min(X,Y,...)</td><td bgcolor=\"#f0fff0\">Return the argument with the minimum value. "); 2340 - html += wxT ("Arguments may be strings in addition to numbers. "); 2341 - html += wxT ("The minimum value is determined by the usual sort order. "); 2342 - html += 2343 - wxT 2344 - ("Note that min() is a simple function when it has 2 or more arguments but converts to an aggregate function if given only a single argument.</td></tr>"); 2345 - html += 2346 - wxT 2347 - ("<tr><td bgcolor=\"#fffff0\">nullif(X,Y)</td><td bgcolor=\"#f0fff0\">Return the first argument if the arguments are different, otherwise return NULL.</td></tr>"); 2348 - html += 2349 - wxT 2350 - ("<tr><td bgcolor=\"#fffff0\">quote(X)</td><td bgcolor=\"#f0fff0\">This routine return a string which is the value of its argument suitable for inclusion "); 2351 - html += 2352 - wxT 2353 - ("into another SQL statement. Strings are surrounded by single-quotes with escapes on interior quotes as needed. "); 2354 - html += 2355 - wxT 2356 - ("BLOBs are encoded as hexadecimal literals. The implementation of VACUUM uses this function. "); 2357 - html += 2358 - wxT 2359 - ("The function is also useful when writing triggers to implement undo/redo functionality.</td></tr>"); 2360 - html += 2361 - wxT 2362 - ("<tr><td bgcolor=\"#fffff0\">random()</td><td bgcolor=\"#f0fff0\">Return a pseudo-random integer between -9223372036854775808 and +9223372036854775807.</td></tr>"); 2363 - html += 2364 - wxT 2365 - ("<tr><td bgcolor=\"#fffff0\">randomblob(N)</td><td bgcolor=\"#f0fff0\">Return an N-byte blob containing pseudo-random bytes. N should be a postive integer.</td></tr>"); 2366 - html += 2367 - wxT 2368 - ("<tr><td bgcolor=\"#fffff0\">replace(X,Y,Z)</td><td bgcolor=\"#f0fff0\">Return a string formed by substituting string Z for every occurrance of string Y in string X. "); 2369 - html += 2370 - wxT 2371 - ("The BINARY collating sequence is used for comparisons.</td></tr>"); 2372 - html += 2373 - wxT 2374 - ("<tr><td bgcolor=\"#fffff0\">round(X)<br>round(X,Y)</td><td bgcolor=\"#f0fff0\">Round off the number X to Y digits to the right of the decimal point. "); 2375 - html += wxT ("If the Y argument is omitted, 0 is assumed.</td></tr>"); 2376 - html += 2377 - wxT 2378 - ("<tr><td bgcolor=\"#fffff0\">rtrim(X)<br>rtrim(X,Y)</td><td bgcolor=\"#f0fff0\">Return a string formed by removing any and all characters "); 2379 - html += 2380 - wxT 2381 - ("that appear in Y from the right side of X. If the Y argument is omitted, spaces are removed.</td></tr>"); 2382 - html += 2383 - wxT 2384 - ("<tr><td bgcolor=\"#fffff0\">sqlite_version(X)</td><td bgcolor=\"#f0fff0\">Return the version string for the SQLite library that is running. Example: \"3.5.9\"</td></tr>"); 2385 - html += 2386 - wxT 2387 - ("<tr><td bgcolor=\"#fffff0\">substr(X,Y,Z)<br>substr(X,Y)</td><td bgcolor=\"#f0fff0\">Return a substring of input string X that begins with the Y-th character "); 2388 - html += 2389 - wxT 2390 - ("and which is Z characters long. If Z is omitted then all character through the end of the string are returned. "); 2391 - html += wxT ("The left-most character of X is number 1. "); 2392 - html += 2393 - wxT 2394 - ("If Y is negative the the first character of the substring is found by counting from the right rather than the left. "); 2395 - html += 2396 - wxT 2397 - ("If X is string then characters indices refer to actual UTF-8 characters. If X is a BLOB then the indices refer to bytes.</td></tr>"); 2398 - html += 2399 - wxT 2400 - ("<tr><td bgcolor=\"#fffff0\">trim(X)<br>trim(X,Y)</td><td bgcolor=\"#f0fff0\">Return a string formed by removing any and all characters that appear in Y from both ends of X. "); 2401 - html += wxT ("If the Y argument is omitted, spaces are removed.</td></tr>"); 2402 - html += 2403 - wxT 2404 - ("<tr><td bgcolor=\"#fffff0\">typeof(X)</td><td bgcolor=\"#f0fff0\">Return the type of the expression X. "); 2405 - html += 2406 - wxT 2407 - ("The only return values are \"null\", \"integer\", \"real\", \"text\", and \"blob\".</td></tr>"); 2408 - html += 2409 - wxT 2410 - ("<tr><td bgcolor=\"#fffff0\">upper(X)</td><td bgcolor=\"#f0fff0\">Return a copy of input string X converted to all upper-case letters. "); 2411 - html += 2412 - wxT 2413 - ("The implementation of this function uses the C library routine toupper() which means it may not work correctly on non-ASCII UTF-8 strings.</td></tr>"); 2414 - html += 2415 - wxT 2416 - ("<tr><td bgcolor=\"#fffff0\">zeroblob(N)</td><td bgcolor=\"#f0fff0\">Return a BLOB consisting of N bytes of 0x00. "); 2417 - html += wxT ("SQLite manages these zeroblobs very efficiently. "); 2418 - html += 2419 - wxT 2420 - ("Zeroblobs can be used to reserve space for a BLOB that is later written using incremental BLOB I/O.</td></tr> "); 2421 - html += 2422 - wxT 2423 - ("<tr><td align=\"center\" bgcolor=\"#e0ffe0\" colspan=\"2\"><a name=\"c22\">aggregate functions</a><br><a href=\"#index\">back to index</a></td></tr>"); 2424 - html += 2425 - wxT 2426 - ("<tr><td bgcolor=\"#fffff0\">avg(X)</td><td bgcolor=\"#f0fff0\">Return the average value of all non-NULL X within a group. "); 2427 - html += 2428 - wxT 2429 - ("String and BLOB values that do not look like numbers are interpreted as 0. "); 2430 - html += 2431 - wxT 2432 - ("The result of avg() is always a floating point value even if all inputs are integers.</td></tr>"); 2433 - html += 2434 - wxT 2435 - ("<tr><td bgcolor=\"#fffff0\">count(X)<br>count(*)</td><td bgcolor=\"#f0fff0\">The first form return a count of the number of times that X is not NULL in a group. "); 2436 - html += 2437 - wxT 2438 - ("The second form (with no argument) return the total number of rows in the group.</td></tr>"); 2439 - html += 2440 - wxT 2441 - ("<tr><td bgcolor=\"#fffff0\">group_concat(X)<br>group_concat(X,Y)</td><td bgcolor=\"#f0fff0\">The result is a string which is the concatenation of all non-NULL values of X. "); 2442 - html += 2443 - wxT 2444 - ("If parameter Y is the separator between instances of X. A comma (\",\") is used as the separator if Y is omitted.</td></tr>"); 2445 - html += 2446 - wxT 2447 - ("<tr><td bgcolor=\"#fffff0\">max(X)</td><td bgcolor=\"#f0fff0\">Return the maximum value of all values in the group. "); 2448 - html += 2449 - wxT 2450 - ("The usual sort order is used to determine the maximum.</td></tr>"); 2451 - html += 2452 - wxT 2453 - ("<tr><td bgcolor=\"#fffff0\">min(X)</td><td bgcolor=\"#f0fff0\">Return the minimum non-NULL value of all values in the group. "); 2454 - html += 2455 - wxT 2456 - ("The usual sort order is used to determine the minimum. NULL is only returned if all values in the group are NULL.</td></tr>"); 2457 - html += 2458 - wxT 2459 - ("<tr><td bgcolor=\"#fffff0\">sum(X)<br>total(X)</td><td bgcolor=\"#f0fff0\">Return the numeric sum of all non-NULL values in the group. "); 2460 - html += 2461 - wxT 2462 - ("If there are no non-NULL input rows then sum() return NULL but total() return 0.0. "); 2463 - html += 2464 - wxT 2465 - ("NULL is not normally a helpful result for the sum of no rows but the SQL standard requires it and most other SQL "); 2466 - html += 2467 - wxT 2468 - ("database engines implement sum() that way so SQLite does it in the same way in order to be compatible. "); 2469 - html += 2470 - wxT 2471 - ("The non-standard total() function is provided as a convenient way to work around this design problem in the SQL language.<br>"); 2472 - html += 2473 - wxT 2474 - ("The result of total() is always a floating point value. The result of sum() is an integer value if all non-NULL inputs are integers. "); 2475 - html += 2476 - wxT 2477 - ("If any input to sum() is neither an integer or a NULL then sum() return a floating point value which might be an approximation to the true sum.<br>"); 2478 - html += 2479 - wxT 2480 - ("Sum() will throw an \"integer overflow\" exception if all inputs are integers or NULL and an integer overflow occurs at any point during the computation."); 2481 - html += wxT ("Total() never throws an exception.</td></tr> "); 2482 - html += wxT ("</table>"); 2483 - html += wxT ("<a href=\"#index\">back to index</a>"); 2484 - html += 2485 - wxT ("<h3><a name=\"c3\">SpatiaLite SQL Spatial functions</a></h3>"); 2486 - html += wxT ("<table cellspacing=\"4\" cellpadding=\"2\" width=\"100%\">"); 2487 - html += 2488 - wxT 2489 - ("<tr><td align=\"center\" bgcolor=\"#e0ffe0\" colspan=\"2\"><a name=\"c30\">SQL utility functions [<i>non-standard</i>] for geometric objects</a></a>"); 2490 - html += wxT ("<br><a href=\"#index\">back to index</a></td></tr>"); 2491 - html += 2492 - wxT 2493 - ("<tr><td bgcolor=\"#fffff0\">MakePoint( x Double precision , y Double precision, [ , SRID Integer] ) : Geometry</td>"); 2494 - html += 2495 - wxT 2496 - ("<td bgcolor=\"#f0fff0\">a Geometry will be returned representing the POINT defined by [x y] coordinates</td></tr>"); 2497 - html += 2498 - wxT 2499 - ("<tr><td bgcolor=\"#fffff0\">BuildMbr( x1 Double precision , y1 Double precision , x2 Double precision , y2 Double precision, [ , SRID Integer] ) : Geometry</td>"); 2500 - html += 2501 - wxT 2502 - ("<td bgcolor=\"#f0fff0\">[x1 y1] and [x2 y2] are assumed to be Points identifying a line segment;"); 2503 - html += 2504 - wxT 2505 - ("then a Geometry will be returned representing the MBR for this line segment</td></tr>"); 2506 - html += 2507 - wxT 2508 - ("<tr><td bgcolor=\"#fffff0\">BuildCircleMbr( x Double precision , y Double precision , radius Double precision [ , SRID Integer] ) : Geometry</td>"); 2509 - html += 2510 - wxT 2511 - ("<td bgcolor=\"#f0fff0\">[x y] is assumed to be the center of a circle of given radius; then a Geometry will be returned representing the MBR for this circle</td></tr>"); 2512 - html += 2513 - wxT 2514 - ("<tr><td bgcolor=\"#fffff0\">MbrMinX( geom Geometry) : Double precision</td>"); 2515 - html += 2516 - wxT 2517 - ("<td bgcolor=\"#f0fff0\">return the x-coordinate for geom MBR's leftmost side as a double precision number</td></tr>"); 2518 - html += 2519 - wxT 2520 - ("<tr><td bgcolor=\"#fffff0\">MbrMinY( geom Geometry) : Double precision</td>"); 2521 - html += 2522 - wxT 2523 - ("<td bgcolor=\"#f0fff0\">return the y-coordinate for geom MBR's lowermost side as a double precision number</td></tr>"); 2524 - html += 2525 - wxT 2526 - ("<tr><td bgcolor=\"#fffff0\">MbrMaxX( geom Geometry) : Double precision</td>"); 2527 - html += 2528 - wxT 2529 - ("<td bgcolor=\"#f0fff0\">return the x-coordinate for geom MBR's rightmost side as a double precision number</td></tr>"); 2530 - html += 2531 - wxT 2532 - ("<tr><td bgcolor=\"#fffff0\">MbrMaxY( geom Geometry) : Double precision</td>"); 2533 - html += 2534 - wxT 2535 - ("<td bgcolor=\"#f0fff0\">return the y-coordinate for geom MBR's uppermost side as a double precision number</td></tr>"); 2536 - html += 2537 - wxT 2538 - ("<tr><td align=\"center\" bgcolor=\"#e0ffe0\" colspan=\"2\"><a name=\"c31\">functions for constructing a geometric object given its Well-known Text Representation</a>"); 2539 - html += wxT ("<br><a href=\"#index\">back to index</a></td></tr>"); 2540 - html += 2541 - wxT 2542 - ("<tr><td bgcolor=\"#fffff0\">GeomFromText( wkt String [ , SRID Integer] ) : Geometry</td>"); 2543 - html += 2544 - wxT 2545 - ("<td bgcolor=\"#f0fff0\">construct a geometric object given its Well-known text Representation</td></tr>"); 2546 - html += 2547 - wxT 2548 - ("<tr><td bgcolor=\"#fffff0\">PointFromText( wktPoint String [ , SRID Integer] ) : Point</td>"); 2549 - html += wxT ("<td bgcolor=\"#f0fff0\">construct a Point</td></tr>"); 2550 - html += 2551 - wxT 2552 - ("<tr><td bgcolor=\"#fffff0\">LineFromText( wktLineString String [ , SRID Integer] ) : Linestring<hr>"); 2553 - html += 2554 - wxT 2555 - ("LineStringFromText( wktLineString String [ , SRID Integer] ) : Linestring</td>"); 2556 - html += wxT ("<td bgcolor=\"#f0fff0\">construct a Linestring</td></tr>"); 2557 - html += 2558 - wxT 2559 - ("<tr><td bgcolor=\"#fffff0\">PolyFromText( wktPolygon String [ , SRID Integer] ) : Polygon<hr>"); 2560 - html += 2561 - wxT 2562 - ("PolygonFromText( wktPolygon String [ , SRID Integer] ) : Polygon</td>"); 2563 - html += wxT ("<td bgcolor=\"#f0fff0\">construct a Polygon</td></tr>"); 2564 - html += 2565 - wxT 2566 - ("<tr><td bgcolor=\"#fffff0\">MPointFromText( wktMultiPoint String [ , SRID Integer] ) : MultiPoint<hr>"); 2567 - html += 2568 - wxT 2569 - ("MultiPointFromText( wktMultiPoint String [ , SRID Integer] ) : MultiPoint</td>"); 2570 - html += wxT ("<td bgcolor=\"#f0fff0\">construct a MultiPoint</td></tr>"); 2571 - html += 2572 - wxT 2573 - ("<tr><td bgcolor=\"#fffff0\">MLineFromText( wktMultiLineString String [ , SRID Integer] ) : MultiLinestring<hr>"); 2574 - html += 2575 - wxT 2576 - ("MultiLineStringFromText( wktMultiLineString String [ , SRID Integer] ) : MultiLinestring</td>"); 2577 - html += 2578 - wxT ("<td bgcolor=\"#f0fff0\">construct a MultiLinestring</td></tr>"); 2579 - html += 2580 - wxT 2581 - ("<tr><td bgcolor=\"#fffff0\">MPolyFromText( wktMultiPolygon String [ , SRID Integer] ) : MultiPolygon<hr>"); 2582 - html += 2583 - wxT 2584 - ("MultiPolygonFromText( wktMultiPolygon String [ , SRID Integer] ) : MultiPolygon</td>"); 2585 - html += wxT ("<td bgcolor=\"#f0fff0\">construct a MultiPolygon</td></tr>"); 2586 - html += 2587 - wxT 2588 - ("<tr><td bgcolor=\"#fffff0\">GeomCollFromText( wktGeometryCollection String [ , SRID Integer] ) : GeometryCollection<hr>"); 2589 - html += 2590 - wxT 2591 - ("GeometryCollectionFromText( wktGeometryCollection String [ , SRID Integer] ) : GeometryCollection</td>"); 2592 - html += 2593 - wxT 2594 - ("<td bgcolor=\"#f0fff0\">construct a GeometryCollection</td></tr>"); 2595 - html += 2596 - wxT 2597 - ("<tr><td align=\"center\" bgcolor=\"#e0ffe0\" colspan=\"2\"><a name=\"c32\">functions for constructing a geometric object given its Well-known Binary Representation</a>"); 2598 - html += wxT ("<br><a href=\"#index\">back to index</a></td></tr>"); 2599 - html += 2600 - wxT 2601 - ("<tr><td bgcolor=\"#fffff0\">GeomFromWKB( wkbGeometry Binary [ , SRID Integer] ) : Geometry</td>"); 2602 - html += 2603 - wxT 2604 - ("<td bgcolor=\"#f0fff0\">construct a geometric object given its Well-known binary Representation</td></tr>"); 2605 - html += 2606 - wxT 2607 - ("<tr><td bgcolor=\"#fffff0\">PointFromWKB( wkbPoint Binary [ , SRID Integer] ) : Point</td>"); 2608 - html += wxT ("<td bgcolor=\"#f0fff0\">construct a Point</td></tr>"); 2609 - html += 2610 - wxT 2611 - ("<tr><td bgcolor=\"#fffff0\">LineFromWKB( wkbLineString Binary [ , SRID Integer] ) : Linestring<hr>"); 2612 - html += 2613 - wxT 2614 - ("LineStringFromText( wkbLineString Binary [ , SRID Integer] ) : Linestring</td>"); 2615 - html += wxT ("<td bgcolor=\"#f0fff0\">construct a Linestring</td></tr>"); 2616 - html += 2617 - wxT 2618 - ("<tr><td bgcolor=\"#fffff0\">PolyFromWKB( wkbPolygon Binary [ , SRID Integer] ) : Polygon<br>"); 2619 - html += 2620 - wxT 2621 - ("PolygonFromWKB( wkbPolygon Binary [ , SRID Integer] ) : Polygon</td>"); 2622 - html += wxT ("<td bgcolor=\"#f0fff0\">construct a Polygon</td></tr>"); 2623 - html += 2624 - wxT 2625 - ("<tr><td bgcolor=\"#fffff0\">MPointFromWKB( wkbMultiPoint Binary [ , SRID Integer] ) : MultiPoint<hr>"); 2626 - html += 2627 - wxT 2628 - ("MultiPointFromWKB( wkbMultiPoint Binary [ , SRID Integer] ) : MultiPoint</td>"); 2629 - html += wxT ("<td bgcolor=\"#f0fff0\">construct a MultiPoint</td></tr>"); 2630 - html += 2631 - wxT 2632 - ("<tr><td bgcolor=\"#fffff0\">MLineFromWKB( wkbMultiLineString Binary [ , SRID Integer] ) : MultiLinestring<hr>"); 2633 - html += 2634 - wxT 2635 - ("MultiLineStringFromWKB( wkbMultiLineString Binary [ , SRID Integer] ) : MultiLinestring</td>"); 2636 - html += 2637 - wxT ("<td bgcolor=\"#f0fff0\">construct a MultiLinestring</td></tr>"); 2638 - html += 2639 - wxT 2640 - ("<tr><td bgcolor=\"#fffff0\">MPolyFromWKB( wkbMultiPolygon Binary [ , SRID Integer] ) : MultiPolygon<hr>"); 2641 - html += 2642 - wxT 2643 - ("MultiPolygonFromWKB( wkbMultiPolygon Binary [ , SRID Integer] ) : MultiPolygon</td>"); 2644 - html += wxT ("<td bgcolor=\"#f0fff0\">construct a MultiPolygon</td></tr>"); 2645 - html += 2646 - wxT 2647 - ("<tr><td bgcolor=\"#fffff0\">GeomCollFromWKB( wkbGeometryCollection Binary [ , SRID Integer] ) : GeometryCollection<hr>"); 2648 - html += 2649 - wxT 2650 - ("GeometryCollectionFromWKB( wkbGeometryCollection Binary [ , SRID Integer] ) : GeometryCollection</td>"); 2651 - html += 2652 - wxT 2653 - ("<td bgcolor=\"#f0fff0\">construct a GeometryCollection</td></tr>"); 2654 - html += 2655 - wxT 2656 - ("<tr><td align=\"center\" bgcolor=\"#e0ffe0\" colspan=\"2\"><a name=\"c33\">functions for obtaining the Well-known Text / Well-known Binary Representation of a geometric object</a>"); 2657 - html += wxT ("<br><a href=\"#index\">back to index</a></td></tr>"); 2658 - html += 2659 - wxT 2660 - ("<tr><td bgcolor=\"#fffff0\">AsText( geom Geometry ) : String</td><td bgcolor=\"#f0fff0\">return the Well-known Text representation</td></tr>"); 2661 - html += 2662 - wxT 2663 - ("<tr><td bgcolor=\"#fffff0\">AsBinary( geom Geometry ) : Binary</td><td bgcolor=\"#f0fff0\">return the Well-known Binary representation</td></tr>"); 2664 - html += 2665 - wxT 2666 - ("<tr><td align=\"center\" bgcolor=\"#e0ffe0\" colspan=\"2\"><a name=\"c34\">functions on type Geometry</a>"); 2667 - html += wxT ("<br><a href=\"#index\">back to index</a></td></tr>"); 2668 - html += 2669 - wxT 2670 - ("<tr><td bgcolor=\"#fffff0\">Dimension( geom Geometry ) : Integer</td>"); 2671 - html += 2672 - wxT 2673 - ("<td bgcolor=\"#f0fff0\">return the dimension of the geometric object, which is less than or equal to the dimension of the coordinate space</td></tr>"); 2674 - html += 2675 - wxT 2676 - ("<tr><td bgcolor=\"#fffff0\">GeometryType( geom Geometry ) : String</td>"); 2677 - html += 2678 - wxT 2679 - ("<td bgcolor=\"#f0fff0\">return the name of the instantiable subtype of Geometry of which this geometric object is a member, as a string</td></tr>"); 2680 - html += 2681 - wxT 2682 - ("<tr><td bgcolor=\"#fffff0\">SRID( geom Geometry ) : Integer</td>"); 2683 - html += 2684 - wxT 2685 - ("<td bgcolor=\"#f0fff0\">return the Spatial Reference System ID for this geometric object</td></tr>"); 2686 - html += 2687 - wxT 2688 - ("<tr><td bgcolor=\"#fffff0\">SetSRID( geom Geometry , SRID Integer ) : Integer</td>"); 2689 - html += 2690 - wxT 2691 - ("<td bgcolor=\"#f0fff0\">directly sets the Spatial Reference System ID for this geometric object [no reprojection is applied].<br>"); 2692 - html += 2693 - wxT 2694 - ("The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a "); 2695 - html += wxT ("function invocation on NULL arguments</td></tr>"); 2696 - html += 2697 - wxT 2698 - ("<tr><td bgcolor=\"#fffff0\">IsEmpty( geom Geometry ) : Integer</td>"); 2699 - html += 2700 - wxT 2701 - ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments.<br>"); 2702 - html += 2703 - wxT 2704 - ("TRUE if this geometric object corresponds to the empty set</td></tr>"); 2705 - html += 2706 - wxT 2707 - ("<tr><td bgcolor=\"#fffff0\">IsSimple( geom Geometry ) : Integer</td>"); 2708 - html += 2709 - wxT 2710 - ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments.<br>"); 2711 - html += 2712 - wxT 2713 - ("TRUE if this geometric object is simple, as defined in the Geometry Model</td></tr>"); 2714 - html += 2715 - wxT 2716 - ("<tr><td bgcolor=\"#fffff0\">IsValid( geom Geometry ) : Integer</td>"); 2717 - html += 2718 - wxT 2719 - ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments.<br>"); 2720 - html += 2721 - wxT 2722 - ("TRUE if this geometric object does not contains any topological error</td></tr>"); 2723 - html += 2724 - wxT 2725 - ("<tr><td bgcolor=\"#fffff0\">Boundary( geom Geometry ) : Geometry</td>"); 2726 - html += 2727 - wxT 2728 - ("<td bgcolor=\"#f0fff0\">return a geometric object that is the combinatorial boundary of g as defined in the Geometry Model</td></tr>"); 2729 - html += 2730 - wxT 2731 - ("<tr><td bgcolor=\"#fffff0\">Envelope( geom Geometry ) : Geometry</td>"); 2732 - html += 2733 - wxT 2734 - ("<td bgcolor=\"#f0fff0\">return the rectangle bounding g as a Polygon. "); 2735 - html += 2736 - wxT 2737 - ("The Polygon is defined by the corner points of the bounding box [(MINX, MINY),(MAXX, MINY), (MAXX, MAXY), (MINX, MAXY), (MINX, MINY)].</td></tr>"); 2738 - html += 2739 - wxT 2740 - ("<tr><td align=\"center\" bgcolor=\"#e0ffe0\" colspan=\"2\"><a name=\"c35\">functions on type Point</a>"); 2741 - html += wxT ("<br><a href=\"#index\">back to index</a></td></tr>"); 2742 - html += 2743 - wxT 2744 - ("<tr><td bgcolor=\"#fffff0\">X( pt Point ) : Double precision</td><td bgcolor=\"#f0fff0\">return the x-coordinate of Point p as a double precision number</td></tr>"); 2745 - html += 2746 - wxT 2747 - ("<tr><td bgcolor=\"#fffff0\">Y( pt Point ) : Double precision</td><td bgcolor=\"#f0fff0\">return the y-coordinate of Point p as a double precision number</td></tr>"); 2748 - html += 2749 - wxT 2750 - ("<tr><td align=\"center\" bgcolor=\"#e0ffe0\" colspan=\"2\">functions on type Curve [Linestring or Ring]</td></tr>"); 2751 - html += 2752 - wxT 2753 - ("<tr><td bgcolor=\"#fffff0\">StartPoint( c Curve ) : Point</td><td bgcolor=\"#f0fff0\">return a Point containing the first Point of c</td></tr>"); 2754 - html += 2755 - wxT 2756 - ("<tr><td bgcolor=\"#fffff0\">EndPoint( c Curve ) : Point</td><td bgcolor=\"#f0fff0\">return a Point containing the last Point of c</td></tr>"); 2757 - html += 2758 - wxT 2759 - ("<tr><td bgcolor=\"#fffff0\">NumPoints( line LineString ) : Integer</td><td bgcolor=\"#f0fff0\">return the number of Points in the LineString</td></tr>"); 2760 - html += 2761 - wxT 2762 - ("<tr><td bgcolor=\"#fffff0\">PointN( line LineString , n Integer ) : Point</td><td bgcolor=\"#f0fff0\">return a Point containing Point n of line</td></tr>"); 2763 - html += 2764 - wxT 2765 - ("<tr><td bgcolor=\"#fffff0\">GLength( c Curve ) : Double precision</td><td bgcolor=\"#f0fff0\">return the length of c</td></tr>"); 2766 - html += 2767 - wxT ("<tr><td bgcolor=\"#fffff0\">IsClosed( c Curve ) : Integer</td>"); 2768 - html += 2769 - wxT 2770 - ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments<br>"); 2771 - html += 2772 - wxT 2773 - ("return TRUE if c is closed, i.e., if StartPoint(c) = EndPoint(c)</td></tr>"); 2774 - html += 2775 - wxT ("<tr><td bgcolor=\"#fffff0\">IsRing( c Curve ) : Integer</td>"); 2776 - html += 2777 - wxT 2778 - ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments<br>"); 2779 - html += 2780 - wxT 2781 - ("return TRUE if c is a ring, i.e., if c is closed and simple. A simple Curve does not pass through the same Point more than once.</td></tr>"); 2782 - html += 2783 - wxT 2784 - ("<tr><td bgcolor=\"#fffff0\">Simplify( c Curve , tolerance Double precision ) : Curve</td>"); 2785 - html += 2786 - wxT 2787 - ("<td bgcolor=\"#f0fff0\">return a geometric object representing a simplified version of c applying the Douglas-Peukert algorithm with given tolerance</td></tr>"); 2788 - html += 2789 - wxT 2790 - ("<tr><td bgcolor=\"#fffff0\">SimplifyPreserveTopology( c Curve , tolerance Double precision ) : Curve</td>"); 2791 - html += 2792 - wxT 2793 - ("<td bgcolor=\"#f0fff0\">return a geometric object representing a simplified version of c "); 2794 - html += 2795 - wxT 2796 - ("applying the Douglas-Peukert algorithm with given tolerance and respecting topology</td></tr>"); 2797 - html += 2798 - wxT 2799 - ("<tr><td align=\"center\" bgcolor=\"#e0ffe0\" colspan=\"2\"><a name=\"c36\">functions on type Surface [Polygon or Ring]</a>"); 2800 - html += wxT ("<br><a href=\"#index\">back to index</a></td></tr>"); 2801 - html += 2802 - wxT 2803 - ("<tr><td bgcolor=\"#fffff0\">Centroid( s Surface ) : Point</td><td bgcolor=\"#f0fff0\">return the centroid of s, which may lie outside s</td></tr>"); 2804 - html += 2805 - wxT 2806 - ("<tr><td bgcolor=\"#fffff0\">PointOnSurface( s Surface ) : Point</td><td bgcolor=\"#f0fff0\">return a Point guaranteed to lie on the Surface</td></tr>"); 2807 - html += 2808 - wxT 2809 - ("<tr><td bgcolor=\"#fffff0\">Area( s Surface ) : Double precision</td><td bgcolor=\"#f0fff0\">return the area of s</td></tr>"); 2810 - html += 2811 - wxT 2812 - ("<tr><td align=\"center\" bgcolor=\"#e0ffe0\" colspan=\"2\"><a name=\"c37\">functions on type Polygon</a>"); 2813 - html += wxT ("<br><a href=\"#index\">back to index</a></td></tr>"); 2814 - html += 2815 - wxT 2816 - ("<tr><td bgcolor=\"#fffff0\">ExteriorRing( polyg Polygon ) : LineString</td><td bgcolor=\"#f0fff0\">return the exteriorRing of p</td></tr>"); 2817 - html += 2818 - wxT 2819 - ("<tr><td bgcolor=\"#fffff0\">NumInteriorRing( polyg Polygon ) : Integer<hr>NumInteriorRings( polyg Polygon ) : Integer</td>"); 2820 - html += 2821 - wxT 2822 - ("<td bgcolor=\"#f0fff0\">return the number of interiorRings</td></tr>"); 2823 - html += 2824 - wxT 2825 - ("<tr><td bgcolor=\"#fffff0\">InteriorRingN( polyg Polygon , n Integer ) : LineString</td>"); 2826 - html += 2827 - wxT 2828 - ("<td bgcolor=\"#f0fff0\">return the nth interiorRing. The order of Rings is not geometrically significant.</td></tr>"); 2829 - html += 2830 - wxT 2831 - ("<tr><td align=\"center\" bgcolor=\"#e0ffe0\" colspan=\"2\"><a name=\"c38\">functions on type GeomCollection</a>"); 2832 - html += wxT ("<br><a href=\"#index\">back to index</a></td></tr>"); 2833 - html += 2834 - wxT 2835 - ("<tr><td bgcolor=\"#fffff0\">NumGeometries( geom GeomCollection ) : Integer</td><td bgcolor=\"#f0fff0\">return the number of geometries</td></tr>"); 2836 - html += 2837 - wxT 2838 - ("<tr><td bgcolor=\"#fffff0\">GeometryN( geom GeomCollection , n Integer ) : Geometry</td>"); 2839 - html += 2840 - wxT 2841 - ("<td bgcolor=\"#f0fff0\">return the nth geometric object in the collection. The order of the elements in the collection is not geometrically significant.</td></tr>"); 2842 - html += 2843 - wxT 2844 - ("<tr><td align=\"center\" bgcolor=\"#e0ffe0\" colspan=\"2\"><a name=\"c39\">functions testing approximative spatial relationships via MBRs</a>"); 2845 - html += wxT ("<br><a href=\"#index\">back to index</a></td></tr>"); 2846 - html += 2847 - wxT 2848 - ("<tr><td bgcolor=\"#fffff0\">MbrEqual( geom1 Geometry , geom2 Geometry ) : Integer</td>"); 2849 - html += 2850 - wxT 2851 - ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments.<br>"); 2852 - html += wxT ("TRUE if g1 and g2 have equal MBRs</td></tr>"); 2853 - html += 2854 - wxT 2855 - ("<tr><td bgcolor=\"#fffff0\">MbrDisjoint( geom1 Geometry , geom2 Geometry ) : Integer</td>"); 2856 - html += 2857 - wxT 2858 - ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments.<br>"); 2859 - html += 2860 - wxT 2861 - ("TRUE if the intersection of g1 and g2 MBRs is the empty set</td></tr>"); 2862 - html += 2863 - wxT 2864 - ("<tr><td bgcolor=\"#fffff0\">MbrTouches( geom1 Geometry , geom2 Geometry ) : Integer</td>"); 2865 - html += 2866 - wxT 2867 - ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments.<br>"); 2868 - html += 2869 - wxT 2870 - ("TRUE if the only Points in common between g1 and g2 MBRs lie in the union of the boundaries of g1 and g2</td></tr>"); 2871 - html += 2872 - wxT 2873 - ("<tr><td bgcolor=\"#fffff0\">MbrWithin( geom1 Geometry , geom2 Geometry ) : Integer</td>"); 2874 - html += 2875 - wxT 2876 - ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments.<br>"); 2877 - html += wxT ("TRUE if g1 MBR is completely contained in g2 MBR</td></tr>"); 2878 - html += 2879 - wxT 2880 - ("<tr><td bgcolor=\"#fffff0\">MbrOverlaps( geom1 Geometry , geom2 Geometry ) : Integer</td>"); 2881 - html += 2882 - wxT 2883 - ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments.<br>"); 2884 - html += 2885 - wxT 2886 - ("TRUE if the intersection of g1 and g2 MBRs results in a value of the same dimension as g1 and g2 that is different from both g1 and g2</td></tr>"); 2887 - html += 2888 - wxT 2889 - ("<tr><td bgcolor=\"#fffff0\">MbrIntersects( geom1 Geometry , geom2 Geometry ) : Integer</td>"); 2890 - html += 2891 - wxT 2892 - ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments<br>"); 2893 - html += 2894 - wxT 2895 - ("convenience predicate: TRUE if the intersection of g1 and g2 MBRs is not empty</td></tr>"); 2896 - html += 2897 - wxT 2898 - ("<tr><td bgcolor=\"#fffff0\">MbrContains( geom1 Geometry , geom2 Geometry ) : Integer</td>"); 2899 - html += 2900 - wxT 2901 - ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments<br>"); 2902 - html += 2903 - wxT 2904 - ("convenience predicate: TRUE if g2 MBR is completely contained in g1 MBR</td></tr>"); 2905 - html += 2906 - wxT 2907 - ("<tr><td align=\"center\" bgcolor=\"#e0ffe0\" colspan=\"2\"><a name=\"c40\">functions testing spatial relationships</a>"); 2908 - html += wxT ("<br><a href=\"#index\">back to index</a></td></tr>"); 2909 - html += 2910 - wxT 2911 - ("<tr><td bgcolor=\"#fffff0\">Equals( geom1 Geometry , geom2 Geometry ) : Integer</td>"); 2912 - html += 2913 - wxT 2914 - ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments.<br>"); 2915 - html += wxT ("TRUE if g1 and g2 are equal</td></tr>"); 2916 - html += 2917 - wxT 2918 - ("<tr><td bgcolor=\"#fffff0\">Disjoint( geom1 Geometry , geom2 Geometry ) : Integer</td>"); 2919 - html += 2920 - wxT 2921 - ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments.<br>"); 2922 - html += 2923 - wxT 2924 - ("TRUE if the intersection of g1 and g2 is the empty set</td></tr>"); 2925 - html += 2926 - wxT 2927 - ("<tr><td bgcolor=\"#fffff0\">Touches( geom1 Geometry , geom2 Geometry ) : Integer</td>"); 2928 - html += 2929 - wxT 2930 - ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments.<br>"); 2931 - html += 2932 - wxT 2933 - ("TRUE if the only Points in common between g1 and g2 lie in the union of the boundaries of g1 and g2</td></tr>"); 2934 - html += 2935 - wxT 2936 - ("<tr><td bgcolor=\"#fffff0\">Within( geom1 Geometry , geom2 Geometry ) : Integer</td>"); 2937 - html += 2938 - wxT 2939 - ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments.<br>"); 2940 - html += wxT ("TRUE if g1 is completely contained in g2</td></tr>"); 2941 - html += 2942 - wxT 2943 - ("<tr><td bgcolor=\"#fffff0\">Overlaps( geom1 Geometry , geom2 Geometry ) : Integer</td>"); 2944 - html += 2945 - wxT 2946 - ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments.<br>"); 2947 - html += 2948 - wxT 2949 - ("TRUE if the intersection of g1 and g2 results in a value of the same dimension as g1 and g2 that is different from both g1 and g2</td></tr>"); 2950 - html += 2951 - wxT 2952 - ("<tr><td bgcolor=\"#fffff0\">Crosses( geom1 Geometry , geom2 Geometry ) : Integer</td>"); 2953 - html += 2954 - wxT 2955 - ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments.<br>"); 2956 - html += 2957 - wxT 2958 - ("TRUE if the intersection of g1 and g2 results in a value whose dimension is less than the maximum dimension of g1 and g2 "); 2959 - html += 2960 - wxT 2961 - ("and the intersection value includes Points interior to both g1 and g2, and the intersection value is not equal to either g1 or g2</td></tr>"); 2962 - html += 2963 - wxT 2964 - ("<tr><td bgcolor=\"#fffff0\">Intersects( geom1 Geometry , geom2 Geometry ) : Integer</td>"); 2965 - html += 2966 - wxT 2967 - ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments<br>"); 2968 - html += 2969 - wxT 2970 - ("convenience predicate: TRUE if the intersection of g1 and g2 is not empty</td></tr>"); 2971 - html += 2972 - wxT 2973 - ("<tr><td bgcolor=\"#fffff0\">Contains( geom1 Geometry , geom2 Geometry ) : Integer</td>"); 2974 - html += 2975 - wxT 2976 - ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments<br>"); 2977 - html += 2978 - wxT 2979 - ("convenience predicate: TRUE if g2 is completely contained in g1</td></tr>"); 2980 - html += 2981 - wxT 2982 - ("<tr><td bgcolor=\"#fffff0\">Relate( geom1 Geometry , geom2 Geometry , patternMatrix String ) : Integer</td>"); 2983 - html += 2984 - wxT 2985 - ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments.<br>"); 2986 - html += 2987 - wxT 2988 - ("return TRUE if the spatial relationship specified by the patternMatrix holds</td></tr>"); 2989 - html += 2990 - wxT 2991 - ("<tr><td bgcolor=\"#fffff0\">Distance( geom1 Geometry , geom2 Geometry ) : Double precision</td>"); 2992 - html += 2993 - wxT 2994 - ("<td bgcolor=\"#f0fff0\">return the distance between geom1 and geom2</td></tr>"); 2995 - html += 2996 - wxT 2997 - ("<tr><td align=\"center\" bgcolor=\"#e0ffe0\" colspan=\"2\"><a name=\"c41\">functions implementing spatial operators</a>"); 2998 - html += wxT ("<br><a href=\"#index\">back to index</a></td></tr>"); 2999 - html += 3000 - wxT 3001 - ("<tr><td bgcolor=\"#fffff0\">Intersection( geom1 Geometry , geom2 Geometry ) : Geometry</td>"); 3002 - html += 3003 - wxT 3004 - ("<td bgcolor=\"#f0fff0\">return a geometric object that is the intersection of geometric objects geom1 and geom2</td></tr>"); 3005 - html += 3006 - wxT 3007 - ("<tr><td bgcolor=\"#fffff0\">Difference( geom1 Geometry , geom2 Geometry ) : Geometry</td>"); 3008 - html += 3009 - wxT 3010 - ("<td bgcolor=\"#f0fff0\">return a geometric object that is the closure of the set difference of geom1 and geom2</td></tr>"); 3011 - html += 3012 - wxT 3013 - ("<tr><td bgcolor=\"#fffff0\">GUnion( geom1 Geometry , geom2 Geometry ) : Geometry</td>"); 3014 - html += 3015 - wxT 3016 - ("<td bgcolor=\"#f0fff0\">return a geometric object that is the set union of geom1 and geom2</td></tr>"); 3017 - html += 3018 - wxT 3019 - ("<tr><td bgcolor=\"#fffff0\">SymDifference( geom1 Geometry , geom2 Geometry ) : Geometry</td>"); 3020 - html += 3021 - wxT 3022 - ("<td bgcolor=\"#f0fff0\">return a geometric object that is the closure of the set symmetric difference of geom1 and geom2 (logical XOR of space)</td></tr>"); 3023 - html += 3024 - wxT 3025 - ("<tr><td bgcolor=\"#fffff0\">Buffer( geom Geometry , dist Double precision ) : Geometry</td>"); 3026 - html += 3027 - wxT 3028 - ("<td bgcolor=\"#f0fff0\">return a geometric object defined by buffering a distance d around geom, "); 3029 - html += 3030 - wxT 3031 - ("where dist is in the distance units for the Spatial Reference of geom</td></tr>"); 3032 - html += 3033 - wxT 3034 - ("<tr><td bgcolor=\"#fffff0\">ConvexHull( geom Geometry ) : Geometry</td>"); 3035 - html += 3036 - wxT 3037 - ("<td bgcolor=\"#f0fff0\">return a geometric object that is the convex hull of geom</td></tr>"); 3038 - html += 3039 - wxT 3040 - ("<tr><td align=\"center\" bgcolor=\"#e0ffe0\" colspan=\"2\"><a name=\"c42\">functions for coordinate transformations</a>"); 3041 - html += wxT ("<br><a href=\"#index\">back to index</a></td></tr>"); 3042 - html += 3043 - wxT 3044 - ("<tr><td bgcolor=\"#fffff0\">Transform( geom Geometry , newSRID Integer ) : Geometry</td>"); 3045 - html += 3046 - wxT 3047 - ("<td bgcolor=\"#f0fff0\">return a geometric object obtained by reprojecting coordinates into the Reference System identified by newSRID</td></tr>"); 3048 - html += 3049 - wxT 3050 - ("<tr><td bgcolor=\"#fffff0\">ShiftCoords( geom Geometry , shiftX Double precision , shiftY Double precision ) : Geometry<hr>"); 3051 - html += 3052 - wxT 3053 - ("ShiftCoordinates( geom Geometry , shiftX Double precision , shiftY Double precision ) : Geometry</td>"); 3054 - html += 3055 - wxT 3056 - ("<td bgcolor=\"#f0fff0\">return a geometric object obtained by translating coordinates according to shiftX and shiftY values</td></tr>"); 3057 - html += 3058 - wxT 3059 - ("<tr><td bgcolor=\"#fffff0\">ScaleCoords( geom Geometry , scaleX Double precision [ , scaleY Double precision ] ) : Geometry<hr>"); 3060 - html += 3061 - wxT 3062 - ("ScaleCoordinates( geom Geometry , scaleX Double precision [ , scaleY Double precision ] ) : Geometry</td>"); 3063 - html += 3064 - wxT 3065 - ("<td bgcolor=\"#f0fff0\">return a geometric object obtained by scaling coordinates according to scaleX and scaleY values<br>"); 3066 - html += 3067 - wxT 3068 - ("if only one scale factor is specified, then an isotropic scaling occurs [i.e. the same scale factor is applied to both axis]"); 3069 - html += 3070 - wxT 3071 - ("otherwise an anisotropic scaling occurs [i.e. each axis is scaled according to its own scale factor]</td></tr>"); 3072 - html += 3073 - wxT 3074 - ("<tr><td bgcolor=\"#fffff0\">RotateCoords( geom Geometry , angleInDegrees Double precision ) : Geometry<hr>"); 3075 - html += 3076 - wxT 3077 - ("RotateCoordinates( geom Geometry , angleInDegrees Double precision ) : Geometry</td>"); 3078 - html += 3079 - wxT 3080 - ("<td bgcolor=\"#f0fff0\">return a geometric object obtained by rotating coordinates according to angleInDegrees value</td></tr>"); 3081 - html += 3082 - wxT 3083 - ("<tr><td bgcolor=\"#fffff0\">ReflectCoords( geom Geometry , xAxis Integer , yAxis Integer ) : Geometry<hr>"); 3084 - html += 3085 - wxT 3086 - ("ReflectCoordinates( geom Geometry , xAxis Integer , yAxis Integer ) : Geometry</td>"); 3087 - html += 3088 - wxT 3089 - ("<td bgcolor=\"#f0fff0\">return a geometric object obtained by reflecting coordinates according to xAxis and yAxis switches<br>"); 3090 - html += 3091 - wxT 3092 - ("i.e. if xAxis is 0 (FALSE), then x-coordinates remains untouched; otherwise x-coordinates will be reflected</td></tr>"); 3093 - html += 3094 - wxT 3095 - ("<tr><td bgcolor=\"#fffff0\">SwapCoords( geom Geometry ) : Geometry<hr>SwapCoordinates( geom Geometry ) : Geometry</td>"); 3096 - html += 3097 - wxT 3098 - ("<td bgcolor=\"#f0fff0\">return a geometric object obtained by swapping x- and y-coordinates</td></tr>"); 3099 - html += 3100 - wxT 3101 - ("<tr><td align=\"center\" bgcolor=\"#e0ffe0\" colspan=\"2\"><a name=\"c43\">functions for Spatial-MetaData and Spatial-Index handling</a>"); 3102 - html += wxT ("<br><a href=\"#index\">back to index</a></td></tr>"); 3103 - html += 3104 - wxT 3105 - ("<tr><td bgcolor=\"#fffff0\">InitSpatialMetaData( void ) : Integer</td>"); 3106 - html += 3107 - wxT 3108 - ("<td bgcolor=\"#f0fff0\">Creates the geometry_columns and spatial_ref_sys metadata tables"); 3109 - html += 3110 - wxT 3111 - ("the return type is Integer, with a return value of 1 for TRUE or 0 for FALSE<br>"); 3112 - html += 3113 - wxT 3114 - ("direct invocation of these function is discouraged; you have to run the init_spatialite.sql "); 3115 - html += 3116 - wxT 3117 - ("script in order to fully initialize the Spatial MetaData tables</td></tr>"); 3118 - html += 3119 - wxT 3120 - ("<tr><td bgcolor=\"#fffff0\">AddGeometryColumn( table String , column String , srid Integer , geom_type String , dimension Integer ) : Integer</td>"); 3121 - html += 3122 - wxT 3123 - ("<td bgcolor=\"#f0fff0\">Creates a new geometry column updating the Spatial Metadata tables and creating any required trigger in order to enforce constraints<br>"); 3124 - html += 3125 - wxT 3126 - ("the return type is Integer, with a return value of 1 for TRUE or 0 for FALSE</td></tr>"); 3127 - html += 3128 - wxT 3129 - ("<tr><td bgcolor=\"#fffff0\">RecoverGeometryColumn( table String , column String , srid Integer , geom_type String , dimension Integer ) : Integer</td>"); 3130 - html += 3131 - wxT 3132 - ("<td bgcolor=\"#f0fff0\">Validates an existing ordinary column in order to possibly transform it in a real geometry column, "); 3133 - html += 3134 - wxT 3135 - ("thus updating the Spatial Metadata tables and creating any required trigger in order to enforce constraints<br>"); 3136 - html += 3137 - wxT 3138 - ("the return type is Integer, with a return value of 1 for TRUE or 0 for FALSE</td></tr>"); 3139 - html += 3140 - wxT 3141 - ("<tr><td bgcolor=\"#fffff0\">DiscardGeometryColumn( table String , column String ) : Integer</td>"); 3142 - html += 3143 - wxT 3144 - ("<td bgcolor=\"#f0fff0\">Removes a geometry column from Spatial MetaData tables and drops any related trigger<br>"); 3145 - html += 3146 - wxT 3147 - ("the column itself still continues to exist untouched as an ordinary, unconstrained column<br>"); 3148 - html += 3149 - wxT 3150 - ("the return type is Integer, with a return value of 1 for TRUE or 0 for FALSE</td></tr>"); 3151 - html += 3152 - wxT 3153 - ("<tr><td bgcolor=\"#fffff0\">CreateSpatialIndex( table String , column String ) : Integer</td>"); 3154 - html += 3155 - wxT 3156 - ("<td bgcolor=\"#f0fff0\">Builds an RTree Spatial Index on a geometry column, "); 3157 - html += 3158 - wxT 3159 - ("creating any required trigger required in order to enforce full data coherency between the main table and Spatial Index<br>"); 3160 - html += 3161 - wxT 3162 - ("the return type is Integer, with a return value of 1 for TRUE or 0 for FALSE</td></tr>"); 3163 - html += 3164 - wxT 3165 - ("<tr><td bgcolor=\"#fffff0\">DisableSpatialIndex( table String , column String ) : Integer</td>"); 3166 - html += 3167 - wxT 3168 - ("<td bgcolor=\"#f0fff0\">Disables an RTree Spatial Index, removing any related trigger<br>"); 3169 - html += 3170 - wxT 3171 - ("the return type is Integer, with a return value of 1 for TRUE or 0 for FALSE</td></tr>"); 3172 - html += wxT ("</table>"); 3173 - html += wxT ("<a href=\"#index\">back to index</a>"); 3174 - html += wxT ("</body>"); 3175 - html += wxT ("</html>"); 2898 + html = 2899 + wxT("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">"); 2900 + html += wxT("<html>"); 2901 + html += wxT("<head>"); 2902 + html += 2903 + wxT 2904 + ("<meta content=\"text/html; charset=UTF-8\" http-equiv=\"content-type\">"); 2905 + html += wxT("<title>SQLite + SpatiaLite quick Help</title>"); 2906 + html += wxT("</head>"); 2907 + html += wxT("<body bgcolor=\"#e8e8e8\">"); 2908 + html += wxT("<h1><a name=\"index\">SQLite + SpatiaLite quick Help</a></h1>"); 2909 + html += wxT("<table cellspacing=\"2\" cellpadding=\"2\">"); 2910 + html += 2911 + wxT 2912 + ("<tr><td align=\"center\" bgcolor=\"#e0ffe0\" colspan=\"2\">Index of contents</td></tr>"); 2913 + html += 2914 + wxT 2915 + ("<tr><td bgcolor=\"#fffff0\">1.</td><td bgcolor=\"#f0fff0\"><a href=\"#c1\">SQLite SQL syntax</a></td></tr>"); 2916 + html += 2917 + wxT 2918 + ("<tr><td bgcolor=\"#fffff0\">2.</td><td bgcolor=\"#f0fff0\"><a href=\"#c2\">SQLite SQL functions</a><ul>"); 2919 + html += wxT("<li><a href=\"#c21\">ordinary functions</a></li>"); 2920 + html += wxT("<li><a href=\"#c22\">aggregate functions</a></li>"); 2921 + html += wxT("</ul></td></tr>"); 2922 + html += 2923 + wxT 2924 + ("<tr><td bgcolor=\"#fffff0\">3.</td><td bgcolor=\"#f0fff0\"><a href=\"#c3\">SpatiaLite SQL Spatial functions</a><ul>"); 2925 + html += wxT("<li><a href=\"#math\">math functions</a></li>"); 2926 + html += 2927 + wxT("<li><a href=\"#blob\">utility functions for BLOB objects</a></li>"); 2928 + html += 2929 + wxT 2930 + ("<li><a href=\"#c30\">utility functions [non-standard] for geometric objects</a></li>"); 2931 + html += 2932 + wxT 2933 + ("<li><a href=\"#c31\">functions for constructing a geometric object given its Well-known Text Representation</a></li>"); 2934 + html += 2935 + wxT 2936 + ("<li><a href=\"#c32\">functions for constructing a geometric object given its Well-known Binary Representation</a></li>"); 2937 + html += 2938 + wxT 2939 + ("<li><a href=\"#c33\">functions for obtaining the Well-known Text / Well-known Binary Representation of a geometric object</a></li>"); 2940 + html += 2941 + wxT 2942 + ("<li><a href=\"#c33misc\">functions supporting exotic geometric formats</a></li>"); 2943 + html += wxT("<li><a href=\"#c34\">functions on type Geometry</a></li>"); 2944 + html += wxT("<li><a href=\"#c35\">functions on type Point</a></li>"); 2945 + html += 2946 + wxT 2947 + ("<li><a href=\"#c36\">functions on type Surface [Polygon or Ring]</a></li>"); 2948 + html += wxT("<li><a href=\"#c37\">functions on type Polygon</a></li>"); 2949 + html += wxT("<li><a href=\"#c38\">functions on type GeomCollection</a></li>"); 2950 + html += 2951 + wxT 2952 + ("<li><a href=\"#c39\">functions testing approximative spatial relationships via MBRs</a></li>"); 2953 + html += 2954 + wxT 2955 + ("<li><a href=\"#c40\">functions testing spatial relationships</a></li>"); 2956 + html += 2957 + wxT 2958 + ("<li><a href=\"#c41\">functions implementing spatial operators</a></li>"); 2959 + html += 2960 + wxT 2961 + ("<li><a href=\"#c42\">functions for coordinate transformations</a></li>"); 2962 + html += 2963 + wxT 2964 + ("<li><a href=\"#c43\">functions for Spatial-MetaData and Spatial-Index handling</a></li>"); 2965 + html += 2966 + wxT 2967 + ("<li><a href=\"#c43fdo\">functions implementing FDO/OGR compatibily</a></li>"); 2968 + html += 2969 + wxT("<li><a href=\"#c44\">functions for MbrCache-based queries</a></li>"); 2970 + html += wxT("</ul></td></tr>"); 2971 + html += wxT("</table>"); 2972 + html += wxT("<h3><a name=\"c1\">SQLite SQL syntax</a></h3>"); 2973 + html += wxT("<table cellspacing=\"4\" cellpadding=\"2\"width=\"100%\">"); 2974 + html += 2975 + wxT 2976 + ("<tr><td bgcolor=\"#fffff0\">ALTER TABLE</td><td bgcolor=\"#f0fff0\">sql-statement ::= ALTER TABLE [database-name .] table-name alteration<br>"); 2977 + html += wxT("alteration ::= RENAME TO new-table-name<br>"); 2978 + html += wxT("alteration ::= ADD [COLUMN] column-def<br></td></tr>"); 2979 + html += 2980 + wxT 2981 + ("<tr><td bgcolor=\"#fffff0\">ANALYZE</td><td bgcolor=\"#f0fff0\">sql-statement ::= ANALYZE<br>"); 2982 + html += wxT("sql-statement ::= ANALYZE database-name<br>"); 2983 + html += 2984 + wxT("sql-statement ::= ANALYZE [database-name .] table-name<br></td></tr>"); 2985 + html += 2986 + wxT 2987 + ("<tr><td bgcolor=\"#fffff0\">ATTACH DATABASE</td><td bgcolor=\"#f0fff0\">sql-statement ::= ATTACH [DATABASE] database-filename AS database-name</td></tr>"); 2988 + html += 2989 + wxT 2990 + ("<tr><td bgcolor=\"#fffff0\">BEGIN TRANSACTION</td><td bgcolor=\"#f0fff0\">sql-statement ::= BEGIN [ DEFERRED | IMMEDIATE | EXCLUSIVE ] [TRANSACTION [name]]<br>"); 2991 + html += wxT("sql-statement ::= END [TRANSACTION [name]]<br>"); 2992 + html += wxT("sql-statement ::= COMMIT [TRANSACTION [name]]<br>"); 2993 + html += wxT("sql-statement ::= ROLLBACK [TRANSACTION [name]]<br></td></tr>"); 2994 + html += 2995 + wxT 2996 + ("<tr><td bgcolor=\"#fffff0\">COMMIT TRANSACTION</td><td bgcolor=\"#f0fff0\">sql-statement ::= BEGIN [ DEFERRED | IMMEDIATE | EXCLUSIVE ] [TRANSACTION [name]]<br>"); 2997 + html += wxT("sql-statement ::= END [TRANSACTION [name]]<br>"); 2998 + html += wxT("sql-statement ::= COMMIT [TRANSACTION [name]]<br>"); 2999 + html += wxT("sql-statement ::= ROLLBACK [TRANSACTION [name]]<br></td></tr>"); 3000 + html += 3001 + wxT 3002 + ("<tr><td bgcolor=\"#fffff0\">CREATE INDEX</td><td bgcolor=\"#f0fff0\">sql-statement ::= CREATE [UNIQUE] INDEX [IF NOT EXISTS] [database-name .] index-name<br>"); 3003 + html += wxT("ON table-name ( column-name [, column-name]* )<br>"); 3004 + html += 3005 + wxT 3006 + ("column-name ::= name [ COLLATE collation-name] [ ASC | DESC ]</td></tr>"); 3007 + html += 3008 + wxT 3009 + ("<tr><td bgcolor=\"#fffff0\">CREATE TABLE</td><td bgcolor=\"#f0fff0\">sql-command ::= CREATE [TEMP | TEMPORARY] TABLE [IF NOT EXISTS] [database-name .] table-name (<br>"); 3010 + html += wxT("column-def [, column-def]*<br>"); 3011 + html += wxT("[, constraint]*<br>"); 3012 + html += wxT(")<br>"); 3013 + html += 3014 + wxT 3015 + ("sql-command ::= CREATE [TEMP | TEMPORARY] TABLE [database-name.] table-name AS select-statement<br>"); 3016 + html += 3017 + wxT 3018 + ("column-def ::= name [type] [[CONSTRAINT name] column-constraint]*<br>"); 3019 + html += wxT("type ::= typename |<br>"); 3020 + html += wxT("typename ( number ) |<br>"); 3021 + html += wxT("typename ( number , number )<br>"); 3022 + html += wxT("column-constraint ::= NOT NULL [ conflict-clause ] |<br>"); 3023 + html += 3024 + wxT("PRIMARY KEY [sort-order] [ conflict-clause ] [AUTOINCREMENT] |<br>"); 3025 + html += wxT("UNIQUE [ conflict-clause ] |<br>"); 3026 + html += wxT("CHECK ( expr ) |<br>"); 3027 + html += wxT("DEFAULT value |<br>"); 3028 + html += wxT("COLLATE collation-name<br>"); 3029 + html += 3030 + wxT("constraint ::= PRIMARY KEY ( column-list ) [ conflict-clause ] |<br>"); 3031 + html += wxT("UNIQUE ( column-list ) [ conflict-clause ] |<br>"); 3032 + html += wxT("CHECK ( expr )<br>"); 3033 + html += wxT("conflict-clause ::= ON CONFLICT conflict-algorithm</td></tr>"); 3034 + html += 3035 + wxT 3036 + ("<tr><td bgcolor=\"#fffff0\">CREATE TRIGGER</td><td bgcolor=\"#f0fff0\">sql-statement ::= CREATE [TEMP | TEMPORARY] TRIGGER [IF NOT EXISTS] trigger-name [ BEFORE | AFTER ]<br>"); 3037 + html += wxT("database-event ON [database-name .] table-name<br>"); 3038 + html += wxT("trigger-action<br>"); 3039 + html += 3040 + wxT 3041 + ("sql-statement ::= CREATE [TEMP | TEMPORARY] TRIGGER [IF NOT EXISTS] trigger-name INSTEAD OF<br>"); 3042 + html += wxT("database-event ON [database-name .] view-name<br>"); 3043 + html += wxT("trigger-action<br>"); 3044 + html += wxT("database-event ::= DELETE |<br>"); 3045 + html += wxT("INSERT |<br>"); 3046 + html += wxT("UPDATE |<br>"); 3047 + html += wxT("UPDATE OF column-list<br>"); 3048 + html += wxT("trigger-action ::= [ FOR EACH ROW ] [ WHEN expression ]<br>"); 3049 + html += wxT("BEGIN<br>"); 3050 + html += wxT("trigger-step ; [ trigger-step ; ]*<br>"); 3051 + html += wxT("END<br>"); 3052 + html += wxT("trigger-step ::= update-statement | insert-statement |<br>"); 3053 + html += wxT("delete-statement | select-statement</td></tr>"); 3054 + html += 3055 + wxT 3056 + ("<tr><td bgcolor=\"#fffff0\">CREATE VIEW</td><td bgcolor=\"#f0fff0\">sql-command ::= CREATE [TEMP | TEMPORARY] VIEW [IF NOT EXISTS] [database-name.] view-name AS select-statement</td></tr>"); 3057 + html += 3058 + wxT 3059 + ("<tr><td bgcolor=\"#fffff0\">CREATE VIRTUAL TABLE</td><td bgcolor=\"#f0fff0\">sql-command ::= CREATE VIRTUAL TABLE [database-name .] table-name USING module-name [( arguments )]</td></tr>"); 3060 + html += 3061 + wxT 3062 + ("<tr><td bgcolor=\"#fffff0\">DELETE</td><td bgcolor=\"#f0fff0\">sql-statement ::= DELETE FROM [database-name .] table-name [WHERE expr]</td></tr>"); 3063 + html += 3064 + wxT 3065 + ("<tr><td bgcolor=\"#fffff0\">DETACH DATABASE</td><td bgcolor=\"#f0fff0\">sql-command ::= DETACH [DATABASE] database-name</td></tr>"); 3066 + html += 3067 + wxT 3068 + ("<tr><td bgcolor=\"#fffff0\">DROP INDEX</td><td bgcolor=\"#f0fff0\">sql-command ::= DROP INDEX [IF EXISTS] [database-name .] index-name</td></tr>"); 3069 + html += 3070 + wxT 3071 + ("<tr><td bgcolor=\"#fffff0\">DROP TABLE</td><td bgcolor=\"#f0fff0\">sql-command ::= DROP TABLE [IF EXISTS] [database-name.] table-name</td></tr>"); 3072 + html += 3073 + wxT 3074 + ("<tr><td bgcolor=\"#fffff0\">DROP TRIGGER</td><td bgcolor=\"#f0fff0\">sql-statement ::= DROP TRIGGER [IF EXISTS] [database-name .] trigger-name</td></tr>"); 3075 + html += 3076 + wxT 3077 + ("<tr><td bgcolor=\"#fffff0\">DROP VIEW</td><td bgcolor=\"#f0fff0\">sql-command ::= DROP VIEW [IF EXISTS] view-name</td></tr>"); 3078 + html += 3079 + wxT 3080 + ("<tr><td bgcolor=\"#fffff0\">END TRANSACTION</td><td bgcolor=\"#f0fff0\">sql-statement ::= BEGIN [ DEFERRED | IMMEDIATE | EXCLUSIVE ] [TRANSACTION [name]]<br>"); 3081 + html += wxT("sql-statement ::= END [TRANSACTION [name]]<br>"); 3082 + html += wxT("sql-statement ::= COMMIT [TRANSACTION [name]]<br>"); 3083 + html += wxT("sql-statement ::= ROLLBACK [TRANSACTION [name]]<br></td></tr>"); 3084 + html += 3085 + wxT 3086 + ("<tr><td bgcolor=\"#fffff0\">EXPLAIN</td><td bgcolor=\"#f0fff0\">sql-statement ::= EXPLAIN sql-statement</td></tr>"); 3087 + html += 3088 + wxT 3089 + ("<tr><td bgcolor=\"#fffff0\">INSERT</td><td bgcolor=\"#f0fff0\">sql-statement ::= INSERT [OR conflict-algorithm] INTO [database-name .] table-name [(column-list)] VALUES(value-list) |<br>"); 3090 + html += 3091 + wxT 3092 + ("INSERT [OR conflict-algorithm] INTO [database-name .] table-name [(column-list)] select-statement</td></tr>"); 3093 + html += 3094 + wxT 3095 + ("<tr><td bgcolor=\"#fffff0\">ON CONFLICT clause</td><td bgcolor=\"#f0fff0\">conflict-clause ::= ON CONFLICT conflict-algorithm<br>"); 3096 + html += 3097 + wxT 3098 + ("conflict-algorithm ::= ROLLBACK | ABORT | FAIL | IGNORE | REPLACE</td></tr>"); 3099 + html += 3100 + wxT 3101 + ("<tr><td bgcolor=\"#fffff0\">PRAGMA</td><td bgcolor=\"#f0fff0\">sql-statement ::= PRAGMA name [= value] |<br>"); 3102 + html += wxT("PRAGMA function(arg)<hr>"); 3103 + html += wxT("PRAGMA auto_vacuum;<br>"); 3104 + html += 3105 + wxT("PRAGMA auto_vacuum = 0 | none | 1 | full | 2 | incremental;<hr>"); 3106 + html += wxT("PRAGMA cache_size;<br>"); 3107 + html += wxT("PRAGMA cache_size = Number-of-pages;<hr>"); 3108 + html += wxT("PRAGMA case_sensitive_like;<br>"); 3109 + html += wxT("PRAGMA case_sensitive_like = 0 | 1;<hr>"); 3110 + html += wxT("PRAGMA count_changes;<br>"); 3111 + html += wxT("PRAGMA count_changes = 0 | 1;<hr>"); 3112 + html += wxT("PRAGMA default_cache_size;<br>"); 3113 + html += wxT("PRAGMA default_cache_size = Number-of-pages;<hr>"); 3114 + html += wxT("PRAGMA empty_result_callbacks;<br>"); 3115 + html += wxT("PRAGMA empty_result_callbacks = 0 | 1;<hr>"); 3116 + html += wxT("PRAGMA encoding;<br>"); 3117 + html += wxT("PRAGMA encoding = \"UTF-8\";<br>"); 3118 + html += wxT("PRAGMA encoding = \"UTF-16\";<br>"); 3119 + html += wxT("PRAGMA encoding = \"UTF-16le\";<br>"); 3120 + html += wxT("PRAGMA encoding = \"UTF-16be\";<hr>"); 3121 + html += wxT("PRAGMA full_column_names;<br>"); 3122 + html += wxT("PRAGMA full_column_names = 0 | 1;<hr>"); 3123 + html += wxT("PRAGMA fullfsync;<br>"); 3124 + html += wxT("PRAGMA fullfsync = 0 | 1;<hr>"); 3125 + html += wxT("PRAGMA journal_mode;<br>"); 3126 + html += wxT("PRAGMA database.journal_mode;<br>"); 3127 + html += wxT("PRAGMA journal_mode = DELETE | PERSIST | OFF<br>"); 3128 + html += wxT("PRAGMA database.journal_mode = DELETE | PERSIST | OFF<hr>"); 3129 + html += wxT("PRAGMA legacy_file_format;<br>"); 3130 + html += wxT("PRAGMA legacy_file_format = ON | OFF<hr>"); 3131 + html += wxT("PRAGMA locking_mode;<br>"); 3132 + html += wxT("PRAGMA locking_mode = NORMAL | EXCLUSIVE<hr>"); 3133 + html += wxT("PRAGMA page_size;<br>"); 3134 + html += wxT("PRAGMA page_size = bytes;<hr>"); 3135 + html += wxT("PRAGMA max_page_count;<br>"); 3136 + html += wxT("PRAGMA max_page_count = N;<hr>"); 3137 + html += wxT("PRAGMA read_uncommitted;<br>"); 3138 + html += wxT("PRAGMA read_uncommitted = 0 | 1;<hr>"); 3139 + html += wxT("PRAGMA short_column_names;<br>"); 3140 + html += wxT("PRAGMA short_column_names = 0 | 1;<hr>"); 3141 + html += wxT("PRAGMA synchronous;<br>"); 3142 + html += wxT("PRAGMA synchronous = FULL; (2)<br>"); 3143 + html += wxT("PRAGMA synchronous = NORMAL; (1)<br>"); 3144 + html += wxT("PRAGMA synchronous = OFF; (0)<hr>"); 3145 + html += wxT("PRAGMA temp_store;<br>"); 3146 + html += wxT("PRAGMA temp_store = DEFAULT; (0)<br>"); 3147 + html += wxT("PRAGMA temp_store = FILE; (1)<br>"); 3148 + html += wxT("PRAGMA temp_store = MEMORY; (2)<hr>"); 3149 + html += wxT("PRAGMA temp_store_directory;<br>"); 3150 + html += wxT("PRAGMA temp_store_directory = 'directory-name';<hr>"); 3151 + html += wxT("PRAGMA database_list;<hr>"); 3152 + html += wxT("PRAGMA foreign_key_list(table-name);<hr>"); 3153 + html += wxT("PRAGMA [database].freelist_count;<hr>"); 3154 + html += wxT("PRAGMA index_info(index-name);<hr>"); 3155 + html += wxT("PRAGMA index_list(table-name);<hr>"); 3156 + html += wxT("PRAGMA table_info(table-name);<hr>"); 3157 + html += wxT("PRAGMA [database.]schema_version;<br>"); 3158 + html += wxT("PRAGMA [database.]schema_version = integer ;<br>"); 3159 + html += wxT("PRAGMA [database.]user_version;<br>"); 3160 + html += wxT("PRAGMA [database.]user_version = integer ;<hr>"); 3161 + html += wxT("PRAGMA integrity_check;<br>"); 3162 + html += wxT("PRAGMA integrity_check(integer)<hr>"); 3163 + html += wxT("PRAGMA parser_trace = ON; (1)<br>"); 3164 + html += wxT("PRAGMA parser_trace = OFF; (0)<hr>"); 3165 + html += wxT("PRAGMA vdbe_trace = ON; (1)<br>"); 3166 + html += wxT("PRAGMA vdbe_trace = OFF; (0)<hr>"); 3167 + html += wxT("PRAGMA vdbe_listing = ON; (1)<br>"); 3168 + html += wxT("PRAGMA vdbe_listing = OFF; (0)</td></tr>"); 3169 + html += 3170 + wxT 3171 + ("<tr><td bgcolor=\"#fffff0\">REINDEX</td><td bgcolor=\"#f0fff0\">sql-statement ::= REINDEX collation name<br>"); 3172 + html += 3173 + wxT 3174 + ("sql-statement ::= REINDEX [database-name .] table/index-name</td></tr>"); 3175 + html += 3176 + wxT 3177 + ("<tr><td bgcolor=\"#fffff0\">REPLACE</td><td bgcolor=\"#f0fff0\">sql-statement ::= REPLACE INTO [database-name .] table-name [( column-list )] VALUES ( value-list ) |<br>"); 3178 + html += 3179 + wxT 3180 + ("REPLACE INTO [database-name .] table-name [( column-list )] select-statement</td></tr>"); 3181 + html += 3182 + wxT 3183 + ("<tr><td bgcolor=\"#fffff0\">ROLLBACK TRANSACTION</td><td bgcolor=\"#f0fff0\">sql-statement ::= BEGIN [ DEFERRED | IMMEDIATE | EXCLUSIVE ] [TRANSACTION [name]]<br>"); 3184 + html += wxT("sql-statement ::= END [TRANSACTION [name]]<br>"); 3185 + html += wxT("sql-statement ::= COMMIT [TRANSACTION [name]]<br>"); 3186 + html += wxT("sql-statement ::= ROLLBACK [TRANSACTION [name]]<br></td></tr>"); 3187 + html += 3188 + wxT 3189 + ("<tr><td bgcolor=\"#fffff0\">SELECT</td><td bgcolor=\"#f0fff0\">sql-statement ::= SELECT [ALL | DISTINCT] result [FROM table-list]<br>"); 3190 + html += wxT("[WHERE expr]<br>"); 3191 + html += wxT("[GROUP BY expr-list]<br>"); 3192 + html += wxT("[HAVING expr]<br>"); 3193 + html += wxT("[compound-op select]*<br>"); 3194 + html += wxT("[ORDER BY sort-expr-list]<br>"); 3195 + html += wxT("[LIMIT integer [( OFFSET | , ) integer]]<br>"); 3196 + html += wxT("result ::= result-column [, result-column]*<br>"); 3197 + html += 3198 + wxT("result-column ::= * | table-name . * | expr [ [AS] string ]<br>"); 3199 + html += wxT("table-list ::= table [join-op table join-args]*<br>"); 3200 + html += wxT("table ::= table-name [AS alias] |<br>"); 3201 + html += wxT("( select ) [AS alias]<br>"); 3202 + html += 3203 + wxT 3204 + ("join-op ::= , | [NATURAL] [LEFT | RIGHT | FULL] [OUTER | INNER | CROSS] JOIN<br>"); 3205 + html += wxT("join-args ::= [ON expr] [USING ( id-list )]<br>"); 3206 + html += 3207 + wxT("sort-expr-list ::= expr [sort-order] [, expr [sort-order]]*<br>"); 3208 + html += wxT("sort-order ::= [ COLLATE collation-name ] [ ASC | DESC ]<br>"); 3209 + html += 3210 + wxT("compound_op ::= UNION | UNION ALL | INTERSECT | EXCEPT</td></tr>"); 3211 + html += 3212 + wxT 3213 + ("<tr><td bgcolor=\"#fffff0\">UPDATE</td><td bgcolor=\"#f0fff0\">sql-statement ::= UPDATE [ OR conflict-algorithm ] [database-name .] table-name<br>"); 3214 + html += wxT("SET assignment [, assignment]*<br>"); 3215 + html += wxT("[WHERE expr]<br>"); 3216 + html += wxT("assignment ::= column-name = expr</td></tr>"); 3217 + html += 3218 + wxT 3219 + ("<tr><td bgcolor=\"#fffff0\">VACUUM</td><td bgcolor=\"#f0fff0\">sql-statement ::= VACUUM</td></tr>"); 3220 + html += wxT("</table>"); 3221 + html += wxT("<a href=\"#index\">back to index</a>"); 3222 + html += 3223 + wxT 3224 + ("<h3><a align=\"center\" bgcolor=\"#e0ffe0\" name=\"c2\">SQLite SQL functions</a></h3>"); 3225 + html += wxT("<table cellspacing=\"4\" cellpadding=\"2\" width=\"100%\">"); 3226 + html += 3227 + wxT 3228 + ("<tr><td align=\"center\" bgcolor=\"#e0ffe0\" colspan=\"2\"><a name=\"c21\">ordinary functions</a><br><a href=\"#index\">back to index</a></td></tr>"); 3229 + html += 3230 + wxT 3231 + ("<tr><td bgcolor=\"#fffff0\">abs(X)</td><td bgcolor=\"#f0fff0\">Return the absolute value of the numeric argument X. "); 3232 + html += 3233 + wxT 3234 + ("Return NULL if X is NULL. Return 0.0 if X is not a numeric value.</td></tr>"); 3235 + html += 3236 + wxT 3237 + ("<tr><td bgcolor=\"#fffff0\">coalesce(X,Y,...)</td><td bgcolor=\"#f0fff0\">Return a copy of the first non-NULL argument. "); 3238 + html += 3239 + wxT 3240 + ("If all arguments are NULL then NULL is returned. There must be at least 2 arguments.</td></tr>"); 3241 + html += 3242 + wxT 3243 + ("<tr><td bgcolor=\"#fffff0\">glob(X,Y)</td><td bgcolor=\"#f0fff0\">This function is used to implement the \"X GLOB Y\" syntax of SQLite. "); 3244 + html += 3245 + wxT 3246 + ("The sqlite3_create_function() interface can be used to override this function and thereby change the operation of the GLOB operator.</td></tr>"); 3247 + html += 3248 + wxT 3249 + ("<tr><td bgcolor=\"#fffff0\">ifnull(X,Y)</td><td bgcolor=\"#f0fff0\">Return a copy of the first non-NULL argument. "); 3250 + html += 3251 + wxT 3252 + ("If both arguments are NULL then NULL is returned. This behaves the same as coalesce().</td></tr>"); 3253 + html += 3254 + wxT 3255 + ("<tr><td bgcolor=\"#fffff0\">hex(X)</td><td bgcolor=\"#f0fff0\">The argument is interpreted as a BLOB. "); 3256 + html += 3257 + wxT 3258 + ("The result is a hexadecimal rendering of the content of that blob.</td></tr>"); 3259 + html += 3260 + wxT 3261 + ("<tr><td bgcolor=\"#fffff0\">last_insert_rowid()</td><td bgcolor=\"#f0fff0\">Return the ROWID of the last row insert from this connection to the database. "); 3262 + html += 3263 + wxT 3264 + ("This is the same value that would be returned from the sqlite3_last_insert_rowid() API function.</td></tr>"); 3265 + html += 3266 + wxT 3267 + ("<tr><td bgcolor=\"#fffff0\">length(X)</td><td bgcolor=\"#f0fff0\">Return the string length of X in characters. "); 3268 + html += 3269 + wxT 3270 + ("If SQLite is configured to support UTF-8, then the number of UTF-8 characters is returned, not the number of bytes.</td></tr>"); 3271 + html += 3272 + wxT 3273 + ("<tr><td bgcolor=\"#fffff0\">like(X,Y)<br>like(X,Y,Z)</td><td bgcolor=\"#f0fff0\">This function is used to implement the \"X LIKE Y [ESCAPE Z]\" syntax of SQL."); 3274 + html += 3275 + wxT 3276 + ("If the optional ESCAPE clause is present, then the user-function is invoked with three arguments. "); 3277 + html += wxT("Otherwise, it is invoked with two arguments only. "); 3278 + html += 3279 + wxT 3280 + ("The sqlite3_create_function() interface can be used to override this function and thereby change the operation of the LIKE operator. "); 3281 + html += 3282 + wxT 3283 + ("When doing this, it may be important to override both the two and three argument versions of the like() function. "); 3284 + html += 3285 + wxT 3286 + ("Otherwise, different code may be called to implement the LIKE operator depending on whether or not an ESCAPE clause was specified.</td></tr>"); 3287 + html += 3288 + wxT 3289 + ("<tr><td bgcolor=\"#fffff0\">load_extension(X)</br>load_extension(X,Y)</td><td bgcolor=\"#f0fff0\">Load SQLite extensions "); 3290 + html += 3291 + wxT("out of the shared library file named X using the entry point Y. "); 3292 + html += 3293 + wxT 3294 + ("The result is a NULL. If Y is omitted then the default entry point of sqlite3_extension_init is used. "); 3295 + html += 3296 + wxT 3297 + ("This function raises an exception if the extension fails to load or initialize correctly.</td></tr>"); 3298 + html += 3299 + wxT 3300 + ("<tr><td bgcolor=\"#fffff0\">lower(X)</td><td bgcolor=\"#f0fff0\">Return a copy of string X will all ASCII characters converted to lower case. "); 3301 + html += 3302 + wxT 3303 + ("The C library tolower() routine is used for the conversion, which means that this function might not work correctly on non-ASCII UTF-8 characters.</td></tr>"); 3304 + html += 3305 + wxT 3306 + ("<tr><td bgcolor=\"#fffff0\">ltrim(X)<br>ltrim(X,Y)</td><td bgcolor=\"#f0fff0\">Return a string formed by removing any and all characters "); 3307 + html += 3308 + wxT 3309 + ("that appear in Y from the left side of X. If the Y argument is omitted, spaces are removed.</td></tr>"); 3310 + html += 3311 + wxT 3312 + ("<tr><td bgcolor=\"#fffff0\">max(X,Y,...)</td><td bgcolor=\"#f0fff0\">Return the argument with the maximum value. "); 3313 + html += wxT("Arguments may be strings in addition to numbers. "); 3314 + html += wxT("The maximum value is determined by the usual sort order. "); 3315 + html += 3316 + wxT 3317 + ("Note that max() is a simple function when it has 2 or more arguments but converts to an aggregate function if given only a single argument.</td></tr>"); 3318 + html += 3319 + wxT 3320 + ("<tr><td bgcolor=\"#fffff0\">min(X,Y,...)</td><td bgcolor=\"#f0fff0\">Return the argument with the minimum value. "); 3321 + html += wxT("Arguments may be strings in addition to numbers. "); 3322 + html += wxT("The minimum value is determined by the usual sort order. "); 3323 + html += 3324 + wxT 3325 + ("Note that min() is a simple function when it has 2 or more arguments but converts to an aggregate function if given only a single argument.</td></tr>"); 3326 + html += 3327 + wxT 3328 + ("<tr><td bgcolor=\"#fffff0\">nullif(X,Y)</td><td bgcolor=\"#f0fff0\">Return the first argument if the arguments are different, otherwise return NULL.</td></tr>"); 3329 + html += 3330 + wxT 3331 + ("<tr><td bgcolor=\"#fffff0\">quote(X)</td><td bgcolor=\"#f0fff0\">This routine return a string which is the value of its argument suitable for inclusion "); 3332 + html += 3333 + wxT 3334 + ("into another SQL statement. Strings are surrounded by single-quotes with escapes on interior quotes as needed. "); 3335 + html += 3336 + wxT 3337 + ("BLOBs are encoded as hexadecimal literals. The implementation of VACUUM uses this function. "); 3338 + html += 3339 + wxT 3340 + ("The function is also useful when writing triggers to implement undo/redo functionality.</td></tr>"); 3341 + html += 3342 + wxT 3343 + ("<tr><td bgcolor=\"#fffff0\">random()</td><td bgcolor=\"#f0fff0\">Return a pseudo-random integer between -9223372036854775808 and +9223372036854775807.</td></tr>"); 3344 + html += 3345 + wxT 3346 + ("<tr><td bgcolor=\"#fffff0\">randomblob(N)</td><td bgcolor=\"#f0fff0\">Return an N-byte blob containing pseudo-random bytes. N should be a postive integer.</td></tr>"); 3347 + html += 3348 + wxT 3349 + ("<tr><td bgcolor=\"#fffff0\">replace(X,Y,Z)</td><td bgcolor=\"#f0fff0\">Return a string formed by substituting string Z for every occurrance of string Y in string X. "); 3350 + html += 3351 + wxT("The BINARY collating sequence is used for comparisons.</td></tr>"); 3352 + html += 3353 + wxT 3354 + ("<tr><td bgcolor=\"#fffff0\">round(X)<br>round(X,Y)</td><td bgcolor=\"#f0fff0\">Round off the number X to Y digits to the right of the decimal point. "); 3355 + html += wxT("If the Y argument is omitted, 0 is assumed.</td></tr>"); 3356 + html += 3357 + wxT 3358 + ("<tr><td bgcolor=\"#fffff0\">rtrim(X)<br>rtrim(X,Y)</td><td bgcolor=\"#f0fff0\">Return a string formed by removing any and all characters "); 3359 + html += 3360 + wxT 3361 + ("that appear in Y from the right side of X. If the Y argument is omitted, spaces are removed.</td></tr>"); 3362 + html += 3363 + wxT 3364 + ("<tr><td bgcolor=\"#fffff0\">sqlite_version(X)</td><td bgcolor=\"#f0fff0\">Return the version string for the SQLite library that is running. Example: \"3.5.9\"</td></tr>"); 3365 + html += 3366 + wxT 3367 + ("<tr><td bgcolor=\"#fffff0\">substr(X,Y,Z)<br>substr(X,Y)</td><td bgcolor=\"#f0fff0\">Return a substring of input string X that begins with the Y-th character "); 3368 + html += 3369 + wxT 3370 + ("and which is Z characters long. If Z is omitted then all character through the end of the string are returned. "); 3371 + html += wxT("The left-most character of X is number 1. "); 3372 + html += 3373 + wxT 3374 + ("If Y is negative the the first character of the substring is found by counting from the right rather than the left. "); 3375 + html += 3376 + wxT 3377 + ("If X is string then characters indices refer to actual UTF-8 characters. If X is a BLOB then the indices refer to bytes.</td></tr>"); 3378 + html += 3379 + wxT 3380 + ("<tr><td bgcolor=\"#fffff0\">trim(X)<br>trim(X,Y)</td><td bgcolor=\"#f0fff0\">Return a string formed by removing any and all characters that appear in Y from both ends of X. "); 3381 + html += wxT("If the Y argument is omitted, spaces are removed.</td></tr>"); 3382 + html += 3383 + wxT 3384 + ("<tr><td bgcolor=\"#fffff0\">typeof(X)</td><td bgcolor=\"#f0fff0\">Return the type of the expression X. "); 3385 + html += 3386 + wxT 3387 + ("The only return values are \"null\", \"integer\", \"real\", \"text\", and \"blob\".</td></tr>"); 3388 + html += 3389 + wxT 3390 + ("<tr><td bgcolor=\"#fffff0\">upper(X)</td><td bgcolor=\"#f0fff0\">Return a copy of input string X converted to all upper-case letters. "); 3391 + html += 3392 + wxT 3393 + ("The implementation of this function uses the C library routine toupper() which means it may not work correctly on non-ASCII UTF-8 strings.</td></tr>"); 3394 + html += 3395 + wxT 3396 + ("<tr><td bgcolor=\"#fffff0\">zeroblob(N)</td><td bgcolor=\"#f0fff0\">Return a BLOB consisting of N bytes of 0x00. "); 3397 + html += wxT("SQLite manages these zeroblobs very efficiently. "); 3398 + html += 3399 + wxT 3400 + ("Zeroblobs can be used to reserve space for a BLOB that is later written using incremental BLOB I/O.</td></tr> "); 3401 + html += 3402 + wxT 3403 + ("<tr><td align=\"center\" bgcolor=\"#e0ffe0\" colspan=\"2\"><a name=\"c22\">aggregate functions</a><br><a href=\"#index\">back to index</a></td></tr>"); 3404 + html += 3405 + wxT 3406 + ("<tr><td bgcolor=\"#fffff0\">avg(X)</td><td bgcolor=\"#f0fff0\">Return the average value of all non-NULL X within a group. "); 3407 + html += 3408 + wxT 3409 + ("String and BLOB values that do not look like numbers are interpreted as 0. "); 3410 + html += 3411 + wxT 3412 + ("The result of avg() is always a floating point value even if all inputs are integers.</td></tr>"); 3413 + html += 3414 + wxT 3415 + ("<tr><td bgcolor=\"#fffff0\">count(X)<br>count(*)</td><td bgcolor=\"#f0fff0\">The first form return a count of the number of times that X is not NULL in a group. "); 3416 + html += 3417 + wxT 3418 + ("The second form (with no argument) return the total number of rows in the group.</td></tr>"); 3419 + html += 3420 + wxT 3421 + ("<tr><td bgcolor=\"#fffff0\">group_concat(X)<br>group_concat(X,Y)</td><td bgcolor=\"#f0fff0\">The result is a string which is the concatenation of all non-NULL values of X. "); 3422 + html += 3423 + wxT 3424 + ("If parameter Y is the separator between instances of X. A comma (\",\") is used as the separator if Y is omitted.</td></tr>"); 3425 + html += 3426 + wxT 3427 + ("<tr><td bgcolor=\"#fffff0\">max(X)</td><td bgcolor=\"#f0fff0\">Return the maximum value of all values in the group. "); 3428 + html += 3429 + wxT("The usual sort order is used to determine the maximum.</td></tr>"); 3430 + html += 3431 + wxT 3432 + ("<tr><td bgcolor=\"#fffff0\">min(X)</td><td bgcolor=\"#f0fff0\">Return the minimum non-NULL value of all values in the group. "); 3433 + html += 3434 + wxT 3435 + ("The usual sort order is used to determine the minimum. NULL is only returned if all values in the group are NULL.</td></tr>"); 3436 + html += 3437 + wxT 3438 + ("<tr><td bgcolor=\"#fffff0\">sum(X)<br>total(X)</td><td bgcolor=\"#f0fff0\">Return the numeric sum of all non-NULL values in the group. "); 3439 + html += 3440 + wxT 3441 + ("If there are no non-NULL input rows then sum() return NULL but total() return 0.0. "); 3442 + html += 3443 + wxT 3444 + ("NULL is not normally a helpful result for the sum of no rows but the SQL standard requires it and most other SQL "); 3445 + html += 3446 + wxT 3447 + ("database engines implement sum() that way so SQLite does it in the same way in order to be compatible. "); 3448 + html += 3449 + wxT 3450 + ("The non-standard total() function is provided as a convenient way to work around this design problem in the SQL language.<br>"); 3451 + html += 3452 + wxT 3453 + ("The result of total() is always a floating point value. The result of sum() is an integer value if all non-NULL inputs are integers. "); 3454 + html += 3455 + wxT 3456 + ("If any input to sum() is neither an integer or a NULL then sum() return a floating point value which might be an approximation to the true sum.<br>"); 3457 + html += 3458 + wxT 3459 + ("Sum() will throw an \"integer overflow\" exception if all inputs are integers or NULL and an integer overflow occurs at any point during the computation."); 3460 + html += wxT("Total() never throws an exception.</td></tr> "); 3461 + html += wxT("</table>"); 3462 + html += wxT("<a href=\"#index\">back to index</a>"); 3463 + html += wxT("<h3><a name=\"c3\">SpatiaLite SQL Spatial functions</a></h3>"); 3464 + html += wxT("<table cellspacing=\"4\" cellpadding=\"2\" width=\"100%\">"); 3465 + html += 3466 + wxT 3467 + ("<tr><td align=\"center\" bgcolor=\"#e0ffe0\" colspan=\"2\"><a name=\"math\">SQL math functions</a></a>"); 3468 + html += wxT("<br><a href=\"#index\">back to index</a></td></tr>"); 3469 + html += 3470 + wxT 3471 + ("<tr><td bgcolor=\"#fffff0\">Abs( x Double precision ) : Double precision</td>"); 3472 + html += 3473 + wxT 3474 + ("<td bgcolor=\"#f0fff0\">returns the absolute value of <i>x</i></td></tr>"); 3475 + html += 3476 + wxT 3477 + ("<tr><td bgcolor=\"#fffff0\">Acos( x Double precision ) : Double precision</td>"); 3478 + html += 3479 + wxT 3480 + ("<td bgcolor=\"#f0fff0\">returns the arc cosine of <i>x</i>, that is, the value whose cosine is <i>x</i><br>"); 3481 + html += wxT("returns NULL if <i>x</i> is not in the range -1 to 1</td></tr>"); 3482 + html += 3483 + wxT 3484 + ("<tr><td bgcolor=\"#fffff0\">Asin( x Double precision ) : Double precision</td>"); 3485 + html += 3486 + wxT 3487 + ("<td bgcolor=\"#f0fff0\">returns the arc sine of <i>x</i>, that is, the value whose sine is <i>x</i><br>"); 3488 + html += wxT("returns NULL if <i>x</i> is not in the range -1 to 1</td></tr>"); 3489 + html += 3490 + wxT 3491 + ("<tr><td bgcolor=\"#fffff0\">Atan( x Double precision ) : Double precision</td>"); 3492 + html += 3493 + wxT 3494 + ("<td bgcolor=\"#f0fff0\">returns the arc tangent of <i>x</i>, that is, the value whose tangent is <i>x</i></td></tr>"); 3495 + html += 3496 + wxT 3497 + ("<tr><td bgcolor=\"#fffff0\">Ceil( x Double precision ) : Double precision<hr>"); 3498 + html += wxT("Ceiling( x Double precision ) : Double precision</td>"); 3499 + html += 3500 + wxT 3501 + ("<td bgcolor=\"#f0fff0\">returns the smallest integer value not less than <i>x</i></td></tr>"); 3502 + html += 3503 + wxT 3504 + ("<tr><td bgcolor=\"#fffff0\">Cos( x Double precision ) : Double precision</td>"); 3505 + html += 3506 + wxT 3507 + ("<td bgcolor=\"#f0fff0\">returns the cosine of <i>x</i>, where <i>x</i> is given in <u>radians</u></td></tr>"); 3508 + html += 3509 + wxT 3510 + ("<tr><td bgcolor=\"#fffff0\">Cot( x Double precision ) : Double precision</td>"); 3511 + html += 3512 + wxT 3513 + ("<td bgcolor=\"#f0fff0\">returns the cotangent of <i>x</i>, where <i>x</i> is given in <u>radians</u></td></tr>"); 3514 + html += 3515 + wxT 3516 + ("<tr><td bgcolor=\"#fffff0\">Degrees( x Double precision ) : Double precision</td>"); 3517 + html += 3518 + wxT 3519 + ("<td bgcolor=\"#f0fff0\">returns the argument <i>x</i>, converted from radians to degrees</td></tr>"); 3520 + html += 3521 + wxT 3522 + ("<tr><td bgcolor=\"#fffff0\">Exp( x Double precision ) : Double precision</td>"); 3523 + html += 3524 + wxT 3525 + ("<td bgcolor=\"#f0fff0\">returns the value of <b><i>e</i></b> (the base of natural logarithms) raised to the power of <i>x</i><hr>"); 3526 + html += 3527 + wxT 3528 + ("the inverse of this function is <i>Log()</i> (using a single argument only) or <i>Ln()</i></td></tr>"); 3529 + html += 3530 + wxT 3531 + ("<tr><td bgcolor=\"#fffff0\">Floor( x Double precision ) : Double precision</td>"); 3532 + html += 3533 + wxT 3534 + ("<td bgcolor=\"#f0fff0\">returns the largest integer value not greater than <i>x</i></td></tr>"); 3535 + html += 3536 + wxT 3537 + ("<tr><td bgcolor=\"#fffff0\">Ln( x Double precision ) : Double precision<hr>"); 3538 + html += wxT("Log( x Double precision ) : Double precision</td>"); 3539 + html += 3540 + wxT 3541 + ("<td bgcolor=\"#f0fff0\">returns the natural logarithm of <i>x</i>; that is, the base-<b><i>e</i></b> logarithm of <i>x</i><br>"); 3542 + html += 3543 + wxT 3544 + ("If <i>x</i> is less than or equal to 0, then NULL is returned</td></tr>"); 3545 + html += 3546 + wxT 3547 + ("<tr><td bgcolor=\"#fffff0\">Log( b Double precision, x Double precision ) : Double precision</td>"); 3548 + html += 3549 + wxT 3550 + ("<td bgcolor=\"#f0fff0\">returns the logarithm of <i>x</i> to the base <i>b</i><br>"); 3551 + html += 3552 + wxT 3553 + ("If <i>x</i> is less than or equal to 0, or if <i>b</i> is less than or equal to 1, then NULL is returned<hr>"); 3554 + html += 3555 + wxT 3556 + ("<i>Log(b, x)</i> is equivalent to <i>Log(x)</i> / <i>Log(b)</i></td></tr>"); 3557 + html += 3558 + wxT 3559 + ("<tr><td bgcolor=\"#fffff0\">Log2( x Double precision ) : Double precision</td>"); 3560 + html += 3561 + wxT("<td bgcolor=\"#f0fff0\">returns the base-2 logarithm of <i>x</i><hr>"); 3562 + html += 3563 + wxT 3564 + ("<i>Log2(x)</i> is equivalent to <i>Log(x)</i> / <i>Log(2)</i></td></tr>"); 3565 + html += 3566 + wxT 3567 + ("<tr><td bgcolor=\"#fffff0\">Log10( x Double precision ) : Double precision</td>"); 3568 + html += 3569 + wxT 3570 + ("<td bgcolor=\"#f0fff0\">returns the base-10 logarithm of <i>x</i><hr>"); 3571 + html += 3572 + wxT 3573 + ("<i>Log10(x)</i> is equivalent to <i>Log(x)</i> / <i>Log(10)</i></td></tr>"); 3574 + html += wxT("<tr><td bgcolor=\"#fffff0\">PI( void ) : Double precision</td>"); 3575 + html += 3576 + wxT("<td bgcolor=\"#f0fff0\">returns the value of <i>PI</i></td></tr>"); 3577 + html += 3578 + wxT 3579 + ("<tr><td bgcolor=\"#fffff0\">Pow( x Double precision, y Double precision ) : Double precision<hr>"); 3580 + html += 3581 + wxT 3582 + ("Power( x Double precision, y Double precision ) : Double precision</td>"); 3583 + html += 3584 + wxT 3585 + ("<td bgcolor=\"#f0fff0\">returns the value of <i>x</i> raised to the power of <i>y</i></td></tr>"); 3586 + html += 3587 + wxT 3588 + ("<tr><td bgcolor=\"#fffff0\">Radians( x Double precision ) : Double precision</td>"); 3589 + html += 3590 + wxT 3591 + ("<td bgcolor=\"#f0fff0\">returns the argument <i>x</i>, converted from degrees to radians</td></tr>"); 3592 + html += 3593 + wxT 3594 + ("<tr><td bgcolor=\"#fffff0\">Round( x Double precision ) : Double precision</td>"); 3595 + html += 3596 + wxT 3597 + ("<td bgcolor=\"#f0fff0\">returns the integer value nearest to <i>x</i></td></tr>"); 3598 + html += 3599 + wxT 3600 + ("<tr><td bgcolor=\"#fffff0\">Sign( x Double precision ) : Double precision</td>"); 3601 + html += 3602 + wxT 3603 + ("<td bgcolor=\"#f0fff0\">returns the sign of the argument as -1, 0, or 1, "); 3604 + html += 3605 + wxT 3606 + ("depending on whether <i>x</i> is negative, zero, or positive.</td></tr>"); 3607 + html += 3608 + wxT 3609 + ("<tr><td bgcolor=\"#fffff0\">Sin( x Double precision ) : Double precision</td>"); 3610 + html += 3611 + wxT 3612 + ("<td bgcolor=\"#f0fff0\">returns the sine of <i>x</i>, where <i>x</i> is given in <u>radians</u></td></tr>"); 3613 + html += 3614 + wxT 3615 + ("<tr><td bgcolor=\"#fffff0\">Sqrt( x Double precision ) : Double precision</td>"); 3616 + html += 3617 + wxT 3618 + ("<td bgcolor=\"#f0fff0\">returns the square root of a non-negative number <i>x</i></td></tr>"); 3619 + html += 3620 + wxT 3621 + ("<tr><td bgcolor=\"#fffff0\">Stddev_pop( x Double precision ) : Double precision</td>"); 3622 + html += 3623 + wxT 3624 + ("<td bgcolor=\"#f0fff0\">returns the population standard deviation of the input values<br>"); 3625 + html += wxT("<b><u>aggregate function</u></b></u></td></tr>"); 3626 + html += 3627 + wxT 3628 + ("<tr><td bgcolor=\"#fffff0\">Stddev_samp( x Double precision ) : Double precision</td>"); 3629 + html += 3630 + wxT 3631 + ("<td bgcolor=\"#f0fff0\">returns the sample standard deviation of the input values<br>"); 3632 + html += wxT("<b><u>aggregate function</u></b></u></td></tr>"); 3633 + html += 3634 + wxT 3635 + ("<tr><td bgcolor=\"#fffff0\">Tan( x Double precision ) : Double precision</td>"); 3636 + html += 3637 + wxT 3638 + ("<td bgcolor=\"#f0fff0\">returns the tangent of <i>x</i>, where <i>x</i> is given in <u>radians</u></td></tr>"); 3639 + html += 3640 + wxT 3641 + ("<tr><td bgcolor=\"#fffff0\">Var_pop( x Double precision ) : Double precision</td>"); 3642 + html += 3643 + wxT 3644 + ("<td bgcolor=\"#f0fff0\">returns the population variance of the input values (<i>square of the population standard deviation</i>)<br>"); 3645 + html += wxT("<b><u>aggregate function</u></b></u></td></tr>"); 3646 + html += 3647 + wxT 3648 + ("<tr><td bgcolor=\"#fffff0\">Var_samp( x Double precision ) : Double precision</td>"); 3649 + html += 3650 + wxT 3651 + ("<td bgcolor=\"#f0fff0\">returns the sample variance of the input values (<i>square of the sample standard deviation</i>)<br>"); 3652 + html += wxT("<b><u>aggregate function</u></b></u></td></tr>"); 3653 + html += 3654 + wxT 3655 + ("<tr><td align=\"center\" bgcolor=\"#e0ffe0\" colspan=\"2\"><a name=\"blob\">SQL utility functions for BLOB objects</a></a>"); 3656 + html += wxT("<br><a href=\"#index\">back to index</a></td></tr>"); 3657 + html += 3658 + wxT("<tr><td bgcolor=\"#fffff0\">IsZipBlob( content Blob ) : Integer</td>"); 3659 + html += 3660 + wxT 3661 + ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments.<br>"); 3662 + html += 3663 + wxT 3664 + ("TRUE if this BLOB object corresponds to a valid ZIP-compressed file</td></tr>"); 3665 + html += 3666 + wxT("<tr><td bgcolor=\"#fffff0\">IsPdfBlob( content Blob ) : Integer</td>"); 3667 + html += 3668 + wxT 3669 + ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments.<br>"); 3670 + html += 3671 + wxT 3672 + ("TRUE if this BLOB object corresponds to a valid PDF document</td></tr>"); 3673 + html += 3674 + wxT("<tr><td bgcolor=\"#fffff0\">IsGifBlob( image Blob ) : Integer</td>"); 3675 + html += 3676 + wxT 3677 + ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments.<br>"); 3678 + html += 3679 + wxT("TRUE if this BLOB object corresponds to a valid GIF image</td></tr>"); 3680 + html += 3681 + wxT("<tr><td bgcolor=\"#fffff0\">IsPngBlob( image Blob ) : Integer</td>"); 3682 + html += 3683 + wxT 3684 + ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments.<br>"); 3685 + html += 3686 + wxT("TRUE if this BLOB object corresponds to a valid PNG image</td></tr>"); 3687 + html += 3688 + wxT("<tr><td bgcolor=\"#fffff0\">IsJpegBlob( image Blob ) : Integer</td>"); 3689 + html += 3690 + wxT 3691 + ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments.<br>"); 3692 + html += 3693 + wxT("TRUE if this BLOB object corresponds to a valid JPEG image</td></tr>"); 3694 + html += 3695 + wxT("<tr><td bgcolor=\"#fffff0\">IsExifBlob( image Blob ) : Integer</td>"); 3696 + html += 3697 + wxT 3698 + ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments.<br>"); 3699 + html += wxT("TRUE if this BLOB object corresponds to a valid EXIF image<br>"); 3700 + html += 3701 + wxT 3702 + ("<u>Please note:</u> any valid EXIF image is a valid JPEG as well</td></tr>"); 3703 + html += 3704 + wxT 3705 + ("<tr><td bgcolor=\"#fffff0\">IsExifGpsBlob( image Blob ) : Integer</td>"); 3706 + html += 3707 + wxT 3708 + ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments.<br>"); 3709 + html += 3710 + wxT("TRUE if this BLOB object corresponds to a valid EXIF-GPS image<br>"); 3711 + html += 3712 + wxT 3713 + ("<u>Please note:</u> any valid EXIF-GPS image is a valid EXIF and JPEG as well</td></tr>"); 3714 + html += 3715 + wxT 3716 + ("<tr><td align=\"center\" bgcolor=\"#e0ffe0\" colspan=\"2\"><a name=\"c30\">SQL utility functions [<i>non-standard</i>] for geometric objects</a></a>"); 3717 + html += wxT("<br><a href=\"#index\">back to index</a></td></tr>"); 3718 + html += 3719 + wxT 3720 + ("<tr><td bgcolor=\"#fffff0\">GeomFromExifGpsBlob( image Blob ) : Geometry</td>"); 3721 + html += 3722 + wxT 3723 + ("<td bgcolor=\"#f0fff0\">a POINT Geometry will be returned representing the GPS long/lat contained within EXIF-GPS <i>metadata</i> for the BLOB image<hr>"); 3724 + html += 3725 + wxT 3726 + ("NULL will be returned if for any reason it's not possible to build such a POINT</td></tr>"); 3727 + html += 3728 + wxT 3729 + ("<tr><td bgcolor=\"#fffff0\">MakePoint( x Double precision , y Double precision [ , SRID Integer] ) : Geometry</td>"); 3730 + html += 3731 + wxT 3732 + ("<td bgcolor=\"#f0fff0\">a Geometry will be returned representing the POINT defined by [x y] coordinates</td></tr>"); 3733 + html += 3734 + wxT 3735 + ("<tr><td bgcolor=\"#fffff0\">BuildMbr( x1 Double precision , y1 Double precision , x2 Double precision , y2 Double precision, [ , SRID Integer] ) : Geometry</td>"); 3736 + html += 3737 + wxT 3738 + ("<td bgcolor=\"#f0fff0\">[x1 y1] and [x2 y2] are assumed to be Points identifying a line segment;"); 3739 + html += 3740 + wxT 3741 + ("then a Geometry will be returned representing the MBR for this line segment</td></tr>"); 3742 + html += 3743 + wxT 3744 + ("<tr><td bgcolor=\"#fffff0\">BuildCircleMbr( x Double precision , y Double precision , radius Double precision [ , SRID Integer] ) : Geometry</td>"); 3745 + html += 3746 + wxT 3747 + ("<td bgcolor=\"#f0fff0\">[x y] is assumed to be the center of a circle of given radius; then a Geometry will be returned representing the MBR for this circle</td></tr>"); 3748 + html += 3749 + wxT 3750 + ("<tr><td bgcolor=\"#fffff0\">MbrMinX( geom Geometry) : Double precision</td>"); 3751 + html += 3752 + wxT 3753 + ("<td bgcolor=\"#f0fff0\">return the x-coordinate for geom MBR's leftmost side as a double precision number</td></tr>"); 3754 + html += 3755 + wxT 3756 + ("<tr><td bgcolor=\"#fffff0\">MbrMinY( geom Geometry) : Double precision</td>"); 3757 + html += 3758 + wxT 3759 + ("<td bgcolor=\"#f0fff0\">return the y-coordinate for geom MBR's lowermost side as a double precision number</td></tr>"); 3760 + html += 3761 + wxT 3762 + ("<tr><td bgcolor=\"#fffff0\">MbrMaxX( geom Geometry) : Double precision</td>"); 3763 + html += 3764 + wxT 3765 + ("<td bgcolor=\"#f0fff0\">return the x-coordinate for geom MBR's rightmost side as a double precision number</td></tr>"); 3766 + html += 3767 + wxT 3768 + ("<tr><td bgcolor=\"#fffff0\">MbrMaxY( geom Geometry) : Double precision</td>"); 3769 + html += 3770 + wxT 3771 + ("<td bgcolor=\"#f0fff0\">return the y-coordinate for geom MBR's uppermost side as a double precision number</td></tr>"); 3772 + html += 3773 + wxT 3774 + ("<tr><td align=\"center\" bgcolor=\"#e0ffe0\" colspan=\"2\"><a name=\"c31\">functions for constructing a geometric object given its Well-known Text Representation</a>"); 3775 + html += wxT("<br><a href=\"#index\">back to index</a></td></tr>"); 3776 + html += 3777 + wxT 3778 + ("<tr><td bgcolor=\"#fffff0\">GeomFromText( wkt String [ , SRID Integer] ) : Geometry</td>"); 3779 + html += 3780 + wxT 3781 + ("<td bgcolor=\"#f0fff0\">construct a geometric object given its Well-known text Representation</td></tr>"); 3782 + html += 3783 + wxT 3784 + ("<tr><td bgcolor=\"#fffff0\">PointFromText( wktPoint String [ , SRID Integer] ) : Point</td>"); 3785 + html += wxT("<td bgcolor=\"#f0fff0\">construct a Point</td></tr>"); 3786 + html += 3787 + wxT 3788 + ("<tr><td bgcolor=\"#fffff0\">LineFromText( wktLineString String [ , SRID Integer] ) : Linestring<hr>"); 3789 + html += 3790 + wxT 3791 + ("LineStringFromText( wktLineString String [ , SRID Integer] ) : Linestring</td>"); 3792 + html += wxT("<td bgcolor=\"#f0fff0\">construct a Linestring</td></tr>"); 3793 + html += 3794 + wxT 3795 + ("<tr><td bgcolor=\"#fffff0\">PolyFromText( wktPolygon String [ , SRID Integer] ) : Polygon<hr>"); 3796 + html += 3797 + wxT 3798 + ("PolygonFromText( wktPolygon String [ , SRID Integer] ) : Polygon</td>"); 3799 + html += wxT("<td bgcolor=\"#f0fff0\">construct a Polygon</td></tr>"); 3800 + html += 3801 + wxT 3802 + ("<tr><td bgcolor=\"#fffff0\">MPointFromText( wktMultiPoint String [ , SRID Integer] ) : MultiPoint<hr>"); 3803 + html += 3804 + wxT 3805 + ("MultiPointFromText( wktMultiPoint String [ , SRID Integer] ) : MultiPoint</td>"); 3806 + html += wxT("<td bgcolor=\"#f0fff0\">construct a MultiPoint</td></tr>"); 3807 + html += 3808 + wxT 3809 + ("<tr><td bgcolor=\"#fffff0\">MLineFromText( wktMultiLineString String [ , SRID Integer] ) : MultiLinestring<hr>"); 3810 + html += 3811 + wxT 3812 + ("MultiLineStringFromText( wktMultiLineString String [ , SRID Integer] ) : MultiLinestring</td>"); 3813 + html += wxT("<td bgcolor=\"#f0fff0\">construct a MultiLinestring</td></tr>"); 3814 + html += 3815 + wxT 3816 + ("<tr><td bgcolor=\"#fffff0\">MPolyFromText( wktMultiPolygon String [ , SRID Integer] ) : MultiPolygon<hr>"); 3817 + html += 3818 + wxT 3819 + ("MultiPolygonFromText( wktMultiPolygon String [ , SRID Integer] ) : MultiPolygon</td>"); 3820 + html += wxT("<td bgcolor=\"#f0fff0\">construct a MultiPolygon</td></tr>"); 3821 + html += 3822 + wxT 3823 + ("<tr><td bgcolor=\"#fffff0\">GeomCollFromText( wktGeometryCollection String [ , SRID Integer] ) : GeometryCollection<hr>"); 3824 + html += 3825 + wxT 3826 + ("GeometryCollectionFromText( wktGeometryCollection String [ , SRID Integer] ) : GeometryCollection</td>"); 3827 + html += 3828 + wxT("<td bgcolor=\"#f0fff0\">construct a GeometryCollection</td></tr>"); 3829 + html += 3830 + wxT 3831 + ("<tr><td align=\"center\" bgcolor=\"#e0ffe0\" colspan=\"2\"><a name=\"c32\">functions for constructing a geometric object given its Well-known Binary Representation</a>"); 3832 + html += wxT("<br><a href=\"#index\">back to index</a></td></tr>"); 3833 + html += 3834 + wxT 3835 + ("<tr><td bgcolor=\"#fffff0\">GeomFromWKB( wkbGeometry Binary [ , SRID Integer] ) : Geometry</td>"); 3836 + html += 3837 + wxT 3838 + ("<td bgcolor=\"#f0fff0\">construct a geometric object given its Well-known binary Representation</td></tr>"); 3839 + html += 3840 + wxT 3841 + ("<tr><td bgcolor=\"#fffff0\">PointFromWKB( wkbPoint Binary [ , SRID Integer] ) : Point</td>"); 3842 + html += wxT("<td bgcolor=\"#f0fff0\">construct a Point</td></tr>"); 3843 + html += 3844 + wxT 3845 + ("<tr><td bgcolor=\"#fffff0\">LineFromWKB( wkbLineString Binary [ , SRID Integer] ) : Linestring<hr>"); 3846 + html += 3847 + wxT 3848 + ("LineStringFromText( wkbLineString Binary [ , SRID Integer] ) : Linestring</td>"); 3849 + html += wxT("<td bgcolor=\"#f0fff0\">construct a Linestring</td></tr>"); 3850 + html += 3851 + wxT 3852 + ("<tr><td bgcolor=\"#fffff0\">PolyFromWKB( wkbPolygon Binary [ , SRID Integer] ) : Polygon<br>"); 3853 + html += 3854 + wxT("PolygonFromWKB( wkbPolygon Binary [ , SRID Integer] ) : Polygon</td>"); 3855 + html += wxT("<td bgcolor=\"#f0fff0\">construct a Polygon</td></tr>"); 3856 + html += 3857 + wxT 3858 + ("<tr><td bgcolor=\"#fffff0\">MPointFromWKB( wkbMultiPoint Binary [ , SRID Integer] ) : MultiPoint<hr>"); 3859 + html += 3860 + wxT 3861 + ("MultiPointFromWKB( wkbMultiPoint Binary [ , SRID Integer] ) : MultiPoint</td>"); 3862 + html += wxT("<td bgcolor=\"#f0fff0\">construct a MultiPoint</td></tr>"); 3863 + html += 3864 + wxT 3865 + ("<tr><td bgcolor=\"#fffff0\">MLineFromWKB( wkbMultiLineString Binary [ , SRID Integer] ) : MultiLinestring<hr>"); 3866 + html += 3867 + wxT 3868 + ("MultiLineStringFromWKB( wkbMultiLineString Binary [ , SRID Integer] ) : MultiLinestring</td>"); 3869 + html += wxT("<td bgcolor=\"#f0fff0\">construct a MultiLinestring</td></tr>"); 3870 + html += 3871 + wxT 3872 + ("<tr><td bgcolor=\"#fffff0\">MPolyFromWKB( wkbMultiPolygon Binary [ , SRID Integer] ) : MultiPolygon<hr>"); 3873 + html += 3874 + wxT 3875 + ("MultiPolygonFromWKB( wkbMultiPolygon Binary [ , SRID Integer] ) : MultiPolygon</td>"); 3876 + html += wxT("<td bgcolor=\"#f0fff0\">construct a MultiPolygon</td></tr>"); 3877 + html += 3878 + wxT 3879 + ("<tr><td bgcolor=\"#fffff0\">GeomCollFromWKB( wkbGeometryCollection Binary [ , SRID Integer] ) : GeometryCollection<hr>"); 3880 + html += 3881 + wxT 3882 + ("GeometryCollectionFromWKB( wkbGeometryCollection Binary [ , SRID Integer] ) : GeometryCollection</td>"); 3883 + html += 3884 + wxT("<td bgcolor=\"#f0fff0\">construct a GeometryCollection</td></tr>"); 3885 + html += 3886 + wxT 3887 + ("<tr><td align=\"center\" bgcolor=\"#e0ffe0\" colspan=\"2\"><a name=\"c33\">functions for obtaining the Well-known Text / Well-known Binary Representation of a geometric object</a>"); 3888 + html += wxT("<br><a href=\"#index\">back to index</a></td></tr>"); 3889 + html += 3890 + wxT 3891 + ("<tr><td bgcolor=\"#fffff0\">AsText( geom Geometry ) : String</td><td bgcolor=\"#f0fff0\">return the Well-known Text representation</td></tr>"); 3892 + html += 3893 + wxT 3894 + ("<tr><td bgcolor=\"#fffff0\">AsBinary( geom Geometry ) : Binary</td><td bgcolor=\"#f0fff0\">return the Well-known Binary representation</td></tr>"); 3895 + html += 3896 + wxT 3897 + ("<tr><td align=\"center\" bgcolor=\"#e0ffe0\" colspan=\"2\"><a name=\"c33misc\">SQL functions supporting exotic geometric formats</a>"); 3898 + html += wxT("<br><a href=\"#index\">back to index</a></td></tr>"); 3899 + html += 3900 + wxT 3901 + ("<tr><td bgcolor=\"#fffff0\">AsSVG( geom Geometry ) : String</td><td bgcolor=\"#f0fff0\">returns the SVG [<i>Scalable Vector Graphics</i>] representation</td></tr>"); 3902 + html += 3903 + wxT 3904 + ("<tr><td bgcolor=\"#fffff0\">AsFGF( geom Geometry ) : String</td><td bgcolor=\"#f0fff0\">returns the FGF [<i>FDO Geometry Binary Format</i>] representation</td></tr>"); 3905 + html += 3906 + wxT 3907 + ("<tr><td bgcolor=\"#fffff0\">GeomFromFGF( fgfGeometry Binary [ , SRID Integer] ) : Geometry</td><td bgcolor=\"#f0fff0\">construct a geometric object given its FGF binary Representation</td></tr>"); 3908 + html += 3909 + wxT 3910 + ("<tr><td align=\"center\" bgcolor=\"#e0ffe0\" colspan=\"2\"><a name=\"c34\">functions on type Geometry</a>"); 3911 + html += wxT("<br><a href=\"#index\">back to index</a></td></tr>"); 3912 + html += 3913 + wxT 3914 + ("<tr><td bgcolor=\"#fffff0\">Dimension( geom Geometry ) : Integer</td>"); 3915 + html += 3916 + wxT 3917 + ("<td bgcolor=\"#f0fff0\">return the dimension of the geometric object, which is less than or equal to the dimension of the coordinate space</td></tr>"); 3918 + html += 3919 + wxT 3920 + ("<tr><td bgcolor=\"#fffff0\">GeometryType( geom Geometry ) : String</td>"); 3921 + html += 3922 + wxT 3923 + ("<td bgcolor=\"#f0fff0\">return the name of the instantiable subtype of Geometry of which this geometric object is a member, as a string</td></tr>"); 3924 + html += 3925 + wxT("<tr><td bgcolor=\"#fffff0\">SRID( geom Geometry ) : Integer</td>"); 3926 + html += 3927 + wxT 3928 + ("<td bgcolor=\"#f0fff0\">return the Spatial Reference System ID for this geometric object</td></tr>"); 3929 + html += 3930 + wxT 3931 + ("<tr><td bgcolor=\"#fffff0\">SetSRID( geom Geometry , SRID Integer ) : Integer</td>"); 3932 + html += 3933 + wxT 3934 + ("<td bgcolor=\"#f0fff0\">directly sets the Spatial Reference System ID for this geometric object [no reprojection is applied].<br>"); 3935 + html += 3936 + wxT 3937 + ("The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a "); 3938 + html += wxT("function invocation on NULL arguments</td></tr>"); 3939 + html += 3940 + wxT("<tr><td bgcolor=\"#fffff0\">IsEmpty( geom Geometry ) : Integer</td>"); 3941 + html += 3942 + wxT 3943 + ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments.<br>"); 3944 + html += 3945 + wxT("TRUE if this geometric object corresponds to the empty set</td></tr>"); 3946 + html += 3947 + wxT("<tr><td bgcolor=\"#fffff0\">IsSimple( geom Geometry ) : Integer</td>"); 3948 + html += 3949 + wxT 3950 + ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments.<br>"); 3951 + html += 3952 + wxT 3953 + ("TRUE if this geometric object is simple, as defined in the Geometry Model</td></tr>"); 3954 + html += 3955 + wxT("<tr><td bgcolor=\"#fffff0\">IsValid( geom Geometry ) : Integer</td>"); 3956 + html += 3957 + wxT 3958 + ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments.<br>"); 3959 + html += 3960 + wxT 3961 + ("TRUE if this geometric object does not contains any topological error</td></tr>"); 3962 + html += 3963 + wxT 3964 + ("<tr><td bgcolor=\"#fffff0\">Boundary( geom Geometry ) : Geometry</td>"); 3965 + html += 3966 + wxT 3967 + ("<td bgcolor=\"#f0fff0\">return a geometric object that is the combinatorial boundary of g as defined in the Geometry Model</td></tr>"); 3968 + html += 3969 + wxT 3970 + ("<tr><td bgcolor=\"#fffff0\">Envelope( geom Geometry ) : Geometry</td>"); 3971 + html += 3972 + wxT 3973 + ("<td bgcolor=\"#f0fff0\">return the rectangle bounding g as a Polygon. "); 3974 + html += 3975 + wxT 3976 + ("The Polygon is defined by the corner points of the bounding box [(MINX, MINY),(MAXX, MINY), (MAXX, MAXY), (MINX, MAXY), (MINX, MINY)].</td></tr>"); 3977 + html += 3978 + wxT 3979 + ("<tr><td align=\"center\" bgcolor=\"#e0ffe0\" colspan=\"2\"><a name=\"c35\">functions on type Point</a>"); 3980 + html += wxT("<br><a href=\"#index\">back to index</a></td></tr>"); 3981 + html += 3982 + wxT 3983 + ("<tr><td bgcolor=\"#fffff0\">X( pt Point ) : Double precision</td><td bgcolor=\"#f0fff0\">return the x-coordinate of Point p as a double precision number</td></tr>"); 3984 + html += 3985 + wxT 3986 + ("<tr><td bgcolor=\"#fffff0\">Y( pt Point ) : Double precision</td><td bgcolor=\"#f0fff0\">return the y-coordinate of Point p as a double precision number</td></tr>"); 3987 + html += 3988 + wxT 3989 + ("<tr><td align=\"center\" bgcolor=\"#e0ffe0\" colspan=\"2\">functions on type Curve [Linestring or Ring]</td></tr>"); 3990 + html += 3991 + wxT 3992 + ("<tr><td bgcolor=\"#fffff0\">StartPoint( c Curve ) : Point</td><td bgcolor=\"#f0fff0\">return a Point containing the first Point of c</td></tr>"); 3993 + html += 3994 + wxT 3995 + ("<tr><td bgcolor=\"#fffff0\">EndPoint( c Curve ) : Point</td><td bgcolor=\"#f0fff0\">return a Point containing the last Point of c</td></tr>"); 3996 + html += 3997 + wxT 3998 + ("<tr><td bgcolor=\"#fffff0\">NumPoints( line LineString ) : Integer</td><td bgcolor=\"#f0fff0\">return the number of Points in the LineString</td></tr>"); 3999 + html += 4000 + wxT 4001 + ("<tr><td bgcolor=\"#fffff0\">PointN( line LineString , n Integer ) : Point</td><td bgcolor=\"#f0fff0\">return a Point containing Point n of line</td></tr>"); 4002 + html += 4003 + wxT 4004 + ("<tr><td bgcolor=\"#fffff0\">GLength( c Curve ) : Double precision</td><td bgcolor=\"#f0fff0\">return the length of c</td></tr>"); 4005 + html += wxT("<tr><td bgcolor=\"#fffff0\">IsClosed( c Curve ) : Integer</td>"); 4006 + html += 4007 + wxT 4008 + ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments<br>"); 4009 + html += 4010 + wxT 4011 + ("return TRUE if c is closed, i.e., if StartPoint(c) = EndPoint(c)</td></tr>"); 4012 + html += wxT("<tr><td bgcolor=\"#fffff0\">IsRing( c Curve ) : Integer</td>"); 4013 + html += 4014 + wxT 4015 + ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments<br>"); 4016 + html += 4017 + wxT 4018 + ("return TRUE if c is a ring, i.e., if c is closed and simple. A simple Curve does not pass through the same Point more than once.</td></tr>"); 4019 + html += 4020 + wxT 4021 + ("<tr><td bgcolor=\"#fffff0\">Simplify( c Curve , tolerance Double precision ) : Curve</td>"); 4022 + html += 4023 + wxT 4024 + ("<td bgcolor=\"#f0fff0\">return a geometric object representing a simplified version of c applying the Douglas-Peukert algorithm with given tolerance</td></tr>"); 4025 + html += 4026 + wxT 4027 + ("<tr><td bgcolor=\"#fffff0\">SimplifyPreserveTopology( c Curve , tolerance Double precision ) : Curve</td>"); 4028 + html += 4029 + wxT 4030 + ("<td bgcolor=\"#f0fff0\">return a geometric object representing a simplified version of c "); 4031 + html += 4032 + wxT 4033 + ("applying the Douglas-Peukert algorithm with given tolerance and respecting topology</td></tr>"); 4034 + html += 4035 + wxT 4036 + ("<tr><td align=\"center\" bgcolor=\"#e0ffe0\" colspan=\"2\"><a name=\"c36\">functions on type Surface [Polygon or Ring]</a>"); 4037 + html += wxT("<br><a href=\"#index\">back to index</a></td></tr>"); 4038 + html += 4039 + wxT 4040 + ("<tr><td bgcolor=\"#fffff0\">Centroid( s Surface ) : Point</td><td bgcolor=\"#f0fff0\">return the centroid of s, which may lie outside s</td></tr>"); 4041 + html += 4042 + wxT 4043 + ("<tr><td bgcolor=\"#fffff0\">PointOnSurface( s Surface ) : Point</td><td bgcolor=\"#f0fff0\">return a Point guaranteed to lie on the Surface</td></tr>"); 4044 + html += 4045 + wxT 4046 + ("<tr><td bgcolor=\"#fffff0\">Area( s Surface ) : Double precision</td><td bgcolor=\"#f0fff0\">return the area of s</td></tr>"); 4047 + html += 4048 + wxT 4049 + ("<tr><td align=\"center\" bgcolor=\"#e0ffe0\" colspan=\"2\"><a name=\"c37\">functions on type Polygon</a>"); 4050 + html += wxT("<br><a href=\"#index\">back to index</a></td></tr>"); 4051 + html += 4052 + wxT 4053 + ("<tr><td bgcolor=\"#fffff0\">ExteriorRing( polyg Polygon ) : LineString</td><td bgcolor=\"#f0fff0\">return the exteriorRing of p</td></tr>"); 4054 + html += 4055 + wxT 4056 + ("<tr><td bgcolor=\"#fffff0\">NumInteriorRing( polyg Polygon ) : Integer<hr>NumInteriorRings( polyg Polygon ) : Integer</td>"); 4057 + html += 4058 + wxT("<td bgcolor=\"#f0fff0\">return the number of interiorRings</td></tr>"); 4059 + html += 4060 + wxT 4061 + ("<tr><td bgcolor=\"#fffff0\">InteriorRingN( polyg Polygon , n Integer ) : LineString</td>"); 4062 + html += 4063 + wxT 4064 + ("<td bgcolor=\"#f0fff0\">return the nth interiorRing. The order of Rings is not geometrically significant.</td></tr>"); 4065 + html += 4066 + wxT 4067 + ("<tr><td align=\"center\" bgcolor=\"#e0ffe0\" colspan=\"2\"><a name=\"c38\">functions on type GeomCollection</a>"); 4068 + html += wxT("<br><a href=\"#index\">back to index</a></td></tr>"); 4069 + html += 4070 + wxT 4071 + ("<tr><td bgcolor=\"#fffff0\">NumGeometries( geom GeomCollection ) : Integer</td><td bgcolor=\"#f0fff0\">return the number of geometries</td></tr>"); 4072 + html += 4073 + wxT 4074 + ("<tr><td bgcolor=\"#fffff0\">GeometryN( geom GeomCollection , n Integer ) : Geometry</td>"); 4075 + html += 4076 + wxT 4077 + ("<td bgcolor=\"#f0fff0\">return the nth geometric object in the collection. The order of the elements in the collection is not geometrically significant.</td></tr>"); 4078 + html += 4079 + wxT 4080 + ("<tr><td align=\"center\" bgcolor=\"#e0ffe0\" colspan=\"2\"><a name=\"c39\">functions testing approximative spatial relationships via MBRs</a>"); 4081 + html += wxT("<br><a href=\"#index\">back to index</a></td></tr>"); 4082 + html += 4083 + wxT 4084 + ("<tr><td bgcolor=\"#fffff0\">MbrEqual( geom1 Geometry , geom2 Geometry ) : Integer</td>"); 4085 + html += 4086 + wxT 4087 + ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments.<br>"); 4088 + html += wxT("TRUE if g1 and g2 have equal MBRs</td></tr>"); 4089 + html += 4090 + wxT 4091 + ("<tr><td bgcolor=\"#fffff0\">MbrDisjoint( geom1 Geometry , geom2 Geometry ) : Integer</td>"); 4092 + html += 4093 + wxT 4094 + ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments.<br>"); 4095 + html += 4096 + wxT 4097 + ("TRUE if the intersection of g1 and g2 MBRs is the empty set</td></tr>"); 4098 + html += 4099 + wxT 4100 + ("<tr><td bgcolor=\"#fffff0\">MbrTouches( geom1 Geometry , geom2 Geometry ) : Integer</td>"); 4101 + html += 4102 + wxT 4103 + ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments.<br>"); 4104 + html += 4105 + wxT 4106 + ("TRUE if the only Points in common between g1 and g2 MBRs lie in the union of the boundaries of g1 and g2</td></tr>"); 4107 + html += 4108 + wxT 4109 + ("<tr><td bgcolor=\"#fffff0\">MbrWithin( geom1 Geometry , geom2 Geometry ) : Integer</td>"); 4110 + html += 4111 + wxT 4112 + ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments.<br>"); 4113 + html += wxT("TRUE if g1 MBR is completely contained in g2 MBR</td></tr>"); 4114 + html += 4115 + wxT 4116 + ("<tr><td bgcolor=\"#fffff0\">MbrOverlaps( geom1 Geometry , geom2 Geometry ) : Integer</td>"); 4117 + html += 4118 + wxT 4119 + ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments.<br>"); 4120 + html += 4121 + wxT 4122 + ("TRUE if the intersection of g1 and g2 MBRs results in a value of the same dimension as g1 and g2 that is different from both g1 and g2</td></tr>"); 4123 + html += 4124 + wxT 4125 + ("<tr><td bgcolor=\"#fffff0\">MbrIntersects( geom1 Geometry , geom2 Geometry ) : Integer</td>"); 4126 + html += 4127 + wxT 4128 + ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments<br>"); 4129 + html += 4130 + wxT 4131 + ("convenience predicate: TRUE if the intersection of g1 and g2 MBRs is not empty</td></tr>"); 4132 + html += 4133 + wxT 4134 + ("<tr><td bgcolor=\"#fffff0\">MbrContains( geom1 Geometry , geom2 Geometry ) : Integer</td>"); 4135 + html += 4136 + wxT 4137 + ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments<br>"); 4138 + html += 4139 + wxT 4140 + ("convenience predicate: TRUE if g2 MBR is completely contained in g1 MBR</td></tr>"); 4141 + html += 4142 + wxT 4143 + ("<tr><td align=\"center\" bgcolor=\"#e0ffe0\" colspan=\"2\"><a name=\"c40\">functions testing spatial relationships</a>"); 4144 + html += wxT("<br><a href=\"#index\">back to index</a></td></tr>"); 4145 + html += 4146 + wxT 4147 + ("<tr><td bgcolor=\"#fffff0\">Equals( geom1 Geometry , geom2 Geometry ) : Integer</td>"); 4148 + html += 4149 + wxT 4150 + ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments.<br>"); 4151 + html += wxT("TRUE if g1 and g2 are equal</td></tr>"); 4152 + html += 4153 + wxT 4154 + ("<tr><td bgcolor=\"#fffff0\">Disjoint( geom1 Geometry , geom2 Geometry ) : Integer</td>"); 4155 + html += 4156 + wxT 4157 + ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments.<br>"); 4158 + html += 4159 + wxT("TRUE if the intersection of g1 and g2 is the empty set</td></tr>"); 4160 + html += 4161 + wxT 4162 + ("<tr><td bgcolor=\"#fffff0\">Touches( geom1 Geometry , geom2 Geometry ) : Integer</td>"); 4163 + html += 4164 + wxT 4165 + ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments.<br>"); 4166 + html += 4167 + wxT 4168 + ("TRUE if the only Points in common between g1 and g2 lie in the union of the boundaries of g1 and g2</td></tr>"); 4169 + html += 4170 + wxT 4171 + ("<tr><td bgcolor=\"#fffff0\">Within( geom1 Geometry , geom2 Geometry ) : Integer</td>"); 4172 + html += 4173 + wxT 4174 + ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments.<br>"); 4175 + html += wxT("TRUE if g1 is completely contained in g2</td></tr>"); 4176 + html += 4177 + wxT 4178 + ("<tr><td bgcolor=\"#fffff0\">Overlaps( geom1 Geometry , geom2 Geometry ) : Integer</td>"); 4179 + html += 4180 + wxT 4181 + ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments.<br>"); 4182 + html += 4183 + wxT 4184 + ("TRUE if the intersection of g1 and g2 results in a value of the same dimension as g1 and g2 that is different from both g1 and g2</td></tr>"); 4185 + html += 4186 + wxT 4187 + ("<tr><td bgcolor=\"#fffff0\">Crosses( geom1 Geometry , geom2 Geometry ) : Integer</td>"); 4188 + html += 4189 + wxT 4190 + ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments.<br>"); 4191 + html += 4192 + wxT 4193 + ("TRUE if the intersection of g1 and g2 results in a value whose dimension is less than the maximum dimension of g1 and g2 "); 4194 + html += 4195 + wxT 4196 + ("and the intersection value includes Points interior to both g1 and g2, and the intersection value is not equal to either g1 or g2</td></tr>"); 4197 + html += 4198 + wxT 4199 + ("<tr><td bgcolor=\"#fffff0\">Intersects( geom1 Geometry , geom2 Geometry ) : Integer</td>"); 4200 + html += 4201 + wxT 4202 + ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments<br>"); 4203 + html += 4204 + wxT 4205 + ("convenience predicate: TRUE if the intersection of g1 and g2 is not empty</td></tr>"); 4206 + html += 4207 + wxT 4208 + ("<tr><td bgcolor=\"#fffff0\">Contains( geom1 Geometry , geom2 Geometry ) : Integer</td>"); 4209 + html += 4210 + wxT 4211 + ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments<br>"); 4212 + html += 4213 + wxT 4214 + ("convenience predicate: TRUE if g2 is completely contained in g1</td></tr>"); 4215 + html += 4216 + wxT 4217 + ("<tr><td bgcolor=\"#fffff0\">Relate( geom1 Geometry , geom2 Geometry , patternMatrix String ) : Integer</td>"); 4218 + html += 4219 + wxT 4220 + ("<td bgcolor=\"#f0fff0\">The return type is Integer, with a return value of 1 for TRUE, 0 for FALSE, and -1 for UNKNOWN corresponding to a function invocation on NULL arguments.<br>"); 4221 + html += 4222 + wxT 4223 + ("return TRUE if the spatial relationship specified by the patternMatrix holds</td></tr>"); 4224 + html += 4225 + wxT 4226 + ("<tr><td bgcolor=\"#fffff0\">Distance( geom1 Geometry , geom2 Geometry ) : Double precision</td>"); 4227 + html += 4228 + wxT 4229 + ("<td bgcolor=\"#f0fff0\">return the distance between geom1 and geom2</td></tr>"); 4230 + html += 4231 + wxT 4232 + ("<tr><td align=\"center\" bgcolor=\"#e0ffe0\" colspan=\"2\"><a name=\"c41\">functions implementing spatial operators</a>"); 4233 + html += wxT("<br><a href=\"#index\">back to index</a></td></tr>"); 4234 + html += 4235 + wxT 4236 + ("<tr><td bgcolor=\"#fffff0\">Intersection( geom1 Geometry , geom2 Geometry ) : Geometry</td>"); 4237 + html += 4238 + wxT 4239 + ("<td bgcolor=\"#f0fff0\">return a geometric object that is the intersection of geometric objects geom1 and geom2</td></tr>"); 4240 + html += 4241 + wxT 4242 + ("<tr><td bgcolor=\"#fffff0\">Difference( geom1 Geometry , geom2 Geometry ) : Geometry</td>"); 4243 + html += 4244 + wxT 4245 + ("<td bgcolor=\"#f0fff0\">return a geometric object that is the closure of the set difference of geom1 and geom2</td></tr>"); 4246 + html += 4247 + wxT 4248 + ("<tr><td bgcolor=\"#fffff0\">GUnion( geom1 Geometry , geom2 Geometry ) : Geometry</td>"); 4249 + html += 4250 + wxT 4251 + ("<td bgcolor=\"#f0fff0\">return a geometric object that is the set union of geom1 and geom2</td></tr>"); 4252 + html += 4253 + wxT("<tr><td bgcolor=\"#fffff0\">GUnion( geom Geometry ) : Geometry</td>"); 4254 + html += 4255 + wxT 4256 + ("<td bgcolor=\"#f0fff0\">return a geometric object that is the set union of input values<br>"); 4257 + html += wxT("<b><u>aggregate function</u></b></td></tr>"); 4258 + html += 4259 + wxT 4260 + ("<tr><td bgcolor=\"#fffff0\">SymDifference( geom1 Geometry , geom2 Geometry ) : Geometry</td>"); 4261 + html += 4262 + wxT 4263 + ("<td bgcolor=\"#f0fff0\">return a geometric object that is the closure of the set symmetric difference of geom1 and geom2 (logical XOR of space)</td></tr>"); 4264 + html += 4265 + wxT 4266 + ("<tr><td bgcolor=\"#fffff0\">Buffer( geom Geometry , dist Double precision ) : Geometry</td>"); 4267 + html += 4268 + wxT 4269 + ("<td bgcolor=\"#f0fff0\">return a geometric object defined by buffering a distance d around geom, "); 4270 + html += 4271 + wxT 4272 + ("where dist is in the distance units for the Spatial Reference of geom</td></tr>"); 4273 + html += 4274 + wxT 4275 + ("<tr><td bgcolor=\"#fffff0\">ConvexHull( geom Geometry ) : Geometry</td>"); 4276 + html += 4277 + wxT 4278 + ("<td bgcolor=\"#f0fff0\">return a geometric object that is the convex hull of geom</td></tr>"); 4279 + html += 4280 + wxT 4281 + ("<tr><td align=\"center\" bgcolor=\"#e0ffe0\" colspan=\"2\"><a name=\"c42\">functions for coordinate transformations</a>"); 4282 + html += wxT("<br><a href=\"#index\">back to index</a></td></tr>"); 4283 + html += 4284 + wxT 4285 + ("<tr><td bgcolor=\"#fffff0\">Transform( geom Geometry , newSRID Integer ) : Geometry</td>"); 4286 + html += 4287 + wxT 4288 + ("<td bgcolor=\"#f0fff0\">return a geometric object obtained by reprojecting coordinates into the Reference System identified by newSRID</td></tr>"); 4289 + html += 4290 + wxT 4291 + ("<tr><td bgcolor=\"#fffff0\">ShiftCoords( geom Geometry , shiftX Double precision , shiftY Double precision ) : Geometry<hr>"); 4292 + html += 4293 + wxT 4294 + ("ShiftCoordinates( geom Geometry , shiftX Double precision , shiftY Double precision ) : Geometry</td>"); 4295 + html += 4296 + wxT 4297 + ("<td bgcolor=\"#f0fff0\">return a geometric object obtained by translating coordinates according to shiftX and shiftY values</td></tr>"); 4298 + html += 4299 + wxT 4300 + ("<tr><td bgcolor=\"#fffff0\">ScaleCoords( geom Geometry , scaleX Double precision [ , scaleY Double precision ] ) : Geometry<hr>"); 4301 + html += 4302 + wxT 4303 + ("ScaleCoordinates( geom Geometry , scaleX Double precision [ , scaleY Double precision ] ) : Geometry</td>"); 4304 + html += 4305 + wxT 4306 + ("<td bgcolor=\"#f0fff0\">return a geometric object obtained by scaling coordinates according to scaleX and scaleY values<br>"); 4307 + html += 4308 + wxT 4309 + ("if only one scale factor is specified, then an isotropic scaling occurs [i.e. the same scale factor is applied to both axis]"); 4310 + html += 4311 + wxT 4312 + ("otherwise an anisotropic scaling occurs [i.e. each axis is scaled according to its own scale factor]</td></tr>"); 4313 + html += 4314 + wxT 4315 + ("<tr><td bgcolor=\"#fffff0\">RotateCoords( geom Geometry , angleInDegrees Double precision ) : Geometry<hr>"); 4316 + html += 4317 + wxT 4318 + ("RotateCoordinates( geom Geometry , angleInDegrees Double precision ) : Geometry</td>"); 4319 + html += 4320 + wxT 4321 + ("<td bgcolor=\"#f0fff0\">return a geometric object obtained by rotating coordinates according to angleInDegrees value</td></tr>"); 4322 + html += 4323 + wxT 4324 + ("<tr><td bgcolor=\"#fffff0\">ReflectCoords( geom Geometry , xAxis Integer , yAxis Integer ) : Geometry<hr>"); 4325 + html += 4326 + wxT 4327 + ("ReflectCoordinates( geom Geometry , xAxis Integer , yAxis Integer ) : Geometry</td>"); 4328 + html += 4329 + wxT 4330 + ("<td bgcolor=\"#f0fff0\">return a geometric object obtained by reflecting coordinates according to xAxis and yAxis switches<br>"); 4331 + html += 4332 + wxT 4333 + ("i.e. if xAxis is 0 (FALSE), then x-coordinates remains untouched; otherwise x-coordinates will be reflected</td></tr>"); 4334 + html += 4335 + wxT 4336 + ("<tr><td bgcolor=\"#fffff0\">SwapCoords( geom Geometry ) : Geometry<hr>SwapCoordinates( geom Geometry ) : Geometry</td>"); 4337 + html += 4338 + wxT 4339 + ("<td bgcolor=\"#f0fff0\">return a geometric object obtained by swapping x- and y-coordinates</td></tr>"); 4340 + html += 4341 + wxT 4342 + ("<tr><td align=\"center\" bgcolor=\"#e0ffe0\" colspan=\"2\"><a name=\"c43\">functions for Spatial-MetaData and Spatial-Index handling</a>"); 4343 + html += wxT("<br><a href=\"#index\">back to index</a></td></tr>"); 4344 + html += 4345 + wxT 4346 + ("<tr><td bgcolor=\"#fffff0\">InitSpatialMetaData( void ) : Integer</td>"); 4347 + html += 4348 + wxT 4349 + ("<td bgcolor=\"#f0fff0\">Creates the geometry_columns and spatial_ref_sys metadata tables"); 4350 + html += 4351 + wxT 4352 + ("the return type is Integer, with a return value of 1 for TRUE or 0 for FALSE<br>"); 4353 + html += 4354 + wxT 4355 + ("direct invocation of these function is discouraged; you have to run the init_spatialite.sql "); 4356 + html += 4357 + wxT 4358 + ("script in order to fully initialize the Spatial MetaData tables</td></tr>"); 4359 + html += 4360 + wxT 4361 + ("<tr><td bgcolor=\"#fffff0\">AddGeometryColumn( table String , column String , srid Integer , geom_type String , dimension Integer [ , not_null Integer ] ) : Integer</td>"); 4362 + html += 4363 + wxT 4364 + ("<td bgcolor=\"#f0fff0\">Creates a new geometry column updating the Spatial Metadata tables and creating any required trigger in order to enforce constraints<br>"); 4365 + html += 4366 + wxT 4367 + ("the return type is Integer, with a return value of 1 for TRUE or 0 for FALSE</td></tr>"); 4368 + html += 4369 + wxT 4370 + ("<tr><td bgcolor=\"#fffff0\">RecoverGeometryColumn( table String , column String , srid Integer , geom_type String , dimension Integer ) : Integer</td>"); 4371 + html += 4372 + wxT 4373 + ("<td bgcolor=\"#f0fff0\">Validates an existing ordinary column in order to possibly transform it in a real geometry column, "); 4374 + html += 4375 + wxT 4376 + ("thus updating the Spatial Metadata tables and creating any required trigger in order to enforce constraints<br>"); 4377 + html += 4378 + wxT 4379 + ("the return type is Integer, with a return value of 1 for TRUE or 0 for FALSE</td></tr>"); 4380 + html += 4381 + wxT 4382 + ("<tr><td bgcolor=\"#fffff0\">DiscardGeometryColumn( table String , column String ) : Integer</td>"); 4383 + html += 4384 + wxT 4385 + ("<td bgcolor=\"#f0fff0\">Removes a geometry column from Spatial MetaData tables and drops any related trigger<br>"); 4386 + html += 4387 + wxT 4388 + ("the column itself still continues to exist untouched as an ordinary, unconstrained column<br>"); 4389 + html += 4390 + wxT 4391 + ("the return type is Integer, with a return value of 1 for TRUE or 0 for FALSE</td></tr>"); 4392 + html += 4393 + wxT 4394 + ("<tr><td bgcolor=\"#fffff0\">CreateSpatialIndex( table String , column String ) : Integer</td>"); 4395 + html += 4396 + wxT 4397 + ("<td bgcolor=\"#f0fff0\">Builds an RTree Spatial Index on a geometry column, "); 4398 + html += 4399 + wxT 4400 + ("creating any required trigger required in order to enforce full data coherency between the main table and Spatial Index<br>"); 4401 + html += 4402 + wxT 4403 + ("the return type is Integer, with a return value of 1 for TRUE or 0 for FALSE</td></tr>"); 4404 + html += 4405 + wxT 4406 + ("<tr><td bgcolor=\"#fffff0\">DisableSpatialIndex( table String , column String ) : Integer</td>"); 4407 + html += 4408 + wxT 4409 + ("<td bgcolor=\"#f0fff0\">Disables an RTree Spatial Index, removing any related trigger<br>"); 4410 + html += 4411 + wxT 4412 + ("the return type is Integer, with a return value of 1 for TRUE or 0 for FALSE</td></tr>"); 4413 + html += 4414 + wxT 4415 + ("<tr><td align=\"center\" bgcolor=\"#e0ffe0\" colspan=\"2\"><a name=\"c43fdo\">functions implementing FDO/OGR compatibily</a>"); 4416 + html += wxT("<br><a href=\"#index\">back to index</a></td></tr>"); 4417 + html += 4418 + wxT 4419 + ("<tr><td bgcolor=\"#fffff0\">CheckSpatialMetaData( void ) : Integer</td>"); 4420 + html += 4421 + wxT 4422 + ("<td bgcolor=\"#f0fff0\">Checks the Spatial Metadata type, then returning:<br>"); 4423 + html += 4424 + wxT 4425 + ("<b>0</b> if <i>geometry_columns</i> and <i>spatial_ref_sys</i> tables does not exists<br>"); 4426 + html += 4427 + wxT 4428 + ("<b>1</b> if both tables exist, and their layout is the one used by <i>SpatiaLite</i><br>"); 4429 + html += 4430 + wxT 4431 + ("<b>2</b> if both tables exist, and their layout is the one used by <i>FDO/OGR</i></td></tr>"); 4432 + html += 4433 + wxT("<tr><td bgcolor=\"#fffff0\">AutoFDOStart( void ) : Integer</td>"); 4434 + html += 4435 + wxT 4436 + ("<td bgcolor=\"#f0fff0\">This function will inspect the Spatial Metadata, then automatically creating/refreshing a <i>VirtualFDO</i>"); 4437 + html += 4438 + wxT 4439 + (" wrapper for each FDO/OGR geometry table<br>the return type is Integer [how many VirtualFDO tables have been created]</td></tr>"); 4440 + html += wxT("<tr><td bgcolor=\"#fffff0\">AutoFDOStop( void ) : Integer</td>"); 4441 + html += 4442 + wxT 4443 + ("<td bgcolor=\"#f0fff0\">This function will inspect the Spatial Metadata, then automatically destroying any <i>VirtualFDO</i>"); 4444 + html += 4445 + wxT 4446 + (" wrapper found<br>the return type is Integer [how many VirtualFDO tables have been destroyed]</td></tr>"); 4447 + html += 4448 + wxT 4449 + ("<tr><td bgcolor=\"#fffff0\">InitFDOSpatialMetaData( void ) : Integer</td>"); 4450 + html += 4451 + wxT 4452 + ("<td bgcolor=\"#f0fff0\">Creates the geometry_columns and spatial_ref_sys metadata tables"); 4453 + html += 4454 + wxT 4455 + ("the return type is Integer, with a return value of 1 for TRUE or 0 for FALSE<br>"); 4456 + html += 4457 + wxT 4458 + ("<u>Please note:</u> Spatial Metadata created using this function will have the FDO/OGR layout, and not the SpatiaLite's own</td></tr>"); 4459 + html += 4460 + wxT 4461 + ("<tr><td bgcolor=\"#fffff0\">AddFDOGeometryColumn( table String , column String , srid Integer , geom_type String , dimension Integer , geometry_type String ) : Integer</td>"); 4462 + html += 4463 + wxT 4464 + ("<td bgcolor=\"#f0fff0\">Creates a new geometry column updating the FDO/OGR Spatial Metadata tables<br>"); 4465 + html += 4466 + wxT 4467 + ("the return type is Integer, with a return value of 1 for TRUE or 0 for FALSE</td></tr>"); 4468 + html += 4469 + wxT 4470 + ("<tr><td bgcolor=\"#fffff0\">RecoverFDOGeometryColumn( table String , column String , srid Integer , geom_type String , dimension Integer , geometry_type String ) : Integer</td>"); 4471 + html += 4472 + wxT 4473 + ("<td bgcolor=\"#f0fff0\">Validates an existing ordinary column in order to possibly transform it in a real geometry column, "); 4474 + html += wxT("thus updating the FDO/OGR Spatial Metadata tables<br>"); 4475 + html += 4476 + wxT 4477 + ("the return type is Integer, with a return value of 1 for TRUE or 0 for FALSE</td></tr>"); 4478 + html += 4479 + wxT 4480 + ("<tr><td bgcolor=\"#fffff0\">DiscardFDOGeometryColumn( table String , column String ) : Integer</td>"); 4481 + html += 4482 + wxT 4483 + ("<td bgcolor=\"#f0fff0\">Removes a geometry column from FDO/OGR Spatial MetaData tables<br>"); 4484 + html += 4485 + wxT 4486 + ("the column itself still continues to exist untouched as an ordinary column<br>"); 4487 + html += 4488 + wxT 4489 + ("the return type is Integer, with a return value of 1 for TRUE or 0 for FALSE</td></tr>"); 4490 + html += 4491 + wxT 4492 + ("<tr><td align=\"center\" bgcolor=\"#e0ffe0\" colspan=\"2\"><a name=\"c44\">functions for MbrCache-based queries</a>"); 4493 + html += wxT("<br><a href=\"#index\">back to index</a></td></tr>"); 4494 + html += 4495 + wxT 4496 + ("<tr><td bgcolor=\"#fffff0\">FilterMbrWithin( x1 Double precision , y1 Double precision , x2 Double precision , y2 Double precision ) : Integer</td>"); 4497 + html += 4498 + wxT 4499 + ("<td bgcolor=\"#f0fff0\">Retrieves from an MbrCache any entity whose MBR falls <u><i>within</i></u>"); 4500 + html += 4501 + wxT 4502 + (" the rectangle identified by extreme points <i>x1 y1</i> and <i>x2 y2</i></td></tr>"); 4503 + html += 4504 + wxT 4505 + ("<tr><td bgcolor=\"#fffff0\">FilterMbrContains( x1 Double precision , y1 Double precision , x2 Double precision , y2 Double precision ) : Integer</td>"); 4506 + html += 4507 + wxT 4508 + ("<td bgcolor=\"#f0fff0\">Retrieves from an MbrCache any entity whose MBR <u><i>contains</i></u>"); 4509 + html += 4510 + wxT 4511 + (" the rectangle identified by extreme points <i>x1 y1</i> and <i>x2 y2</i></td></tr>"); 4512 + html += 4513 + wxT 4514 + ("<tr><td bgcolor=\"#fffff0\">FilterMbrIntersects( x1 Double precision , y1 Double precision , x2 Double precision , y2 Double precision ) : Integer</td>"); 4515 + html += 4516 + wxT 4517 + ("<td bgcolor=\"#f0fff0\">Retrieves from an MbrCache any entity whose MBR <u><i>intersects</i></u>"); 4518 + html += 4519 + wxT 4520 + (" the rectangle identified by extreme points <i>x1 y1</i> and <i>x2 y2</i></td></tr>"); 4521 + 4522 + 4523 + html += wxT("</table>"); 4524 + html += wxT("<a href=\"#index\">back to index</a>"); 4525 + html += wxT("</body>"); 4526 + html += wxT("</html>"); 3176 4527 }
Changes to Makefile-MinGW.
1 1 # SandroFurieri (c) 2008 2 2 # Makefile ( Mingw & wxwidgets) for spatialite-GUI 3 3 4 -SRC = Main.cpp TableTree.cpp QueryView.cpp BlobExplorer.cpp Dialogs.cpp \ 5 - Shapefiles.cpp TextCsv.cpp Objects.cpp win_resource/resource.rc 6 -OBJ = Main.o TableTree.o QueryView.o BlobExplorer.o Dialogs.o Shapefiles.o \ 7 - TextCsv.o Objects.o win_resource/resource.o 4 +SRC = Main.cpp TableTree.cpp QueryView.cpp ResultSetView.cpp BlobExplorer.cpp \ 5 + Dialogs.cpp Shapefiles.cpp Network.cpp Exif.cpp TextCsv.cpp Objects.cpp \ 6 + MetadataInit.cpp win_resource/resource.rc 7 +OBJ = Main.o TableTree.o QueryView.o ResultSetView.o BlobExplorer.o \ 8 + Dialogs.o Shapefiles.o Network.o Exif.o TextCsv.o Objects.o \ 9 + MetadataInit.o win_resource/resource.o 8 10 EXE = ./bin/spatialite-gui.exe 9 11 INCLUDE = Classdef.h 10 12 11 13 # Define default flags: 12 14 CXXFLAGS = $(shell wx-config --cxxflags) 13 15 LIB = $(shell wx-config --libs) 14 -EXTRAFLAGS = -O3 -march=i686 -Wall -Wundef -Wno-ctor-dtor-privacy -fno-strict-aliasing -I/usr/local/include 16 +EXTRAFLAGS = -O3 -march=i686 -Wall -Wundef -Wno-ctor-dtor-privacy \ 17 + -fno-strict-aliasing -I/usr/local/include -D_LARGE_FILE=1 \ 18 + -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 15 19 REZ = $(shell wx-config --rescomp) 16 -EXTRALIBS = /usr/local/lib/libspatialite.a /usr/local/lib/libsqlite3.a \ 17 - /usr/local/lib/libgeos_c.a /usr/local/lib/libiconv.a \ 18 - /usr/local/lib/libgeos.a /usr/local/lib/libproj.a 20 +EXTRALIBS = /usr/local/lib/libspatialite.a /usr/local/lib/libgeos_c.a \ 21 + /usr/local/lib/libiconv.a /usr/local/lib/libgeos.a \ 22 + /usr/local/lib/libproj.a 19 23 20 24 all: $(EXE) 21 25 22 -$(EXE): $(OBJ) 26 +$(EXE): $(OBJ) $(EXTRALIBS) 23 27 $(CXX) $(OBJ) -o $(EXE) $(LIB) $(EXTRALIBS) 24 28 strip --strip-all $(EXE) 25 29 26 30 clean : 27 31 $(RM) $(OBJ) $(EXE) 28 32 29 33 Main.o: Main.cpp $(INCLUDE) ................................................................................ 31 35 32 36 TableTree.o: TableTree.cpp $(INCLUDE) 33 37 $(CXX) -c TableTree.cpp $(CXXFLAGS) $(EXTRAFLAGS) 34 38 35 39 QueryView.o: QueryView.cpp $(INCLUDE) 36 40 $(CXX) -c QueryView.cpp $(CXXFLAGS) $(EXTRAFLAGS) 37 41 42 +ResultSetView.o: ResultSetView.cpp $(INCLUDE) 43 + $(CXX) -c ResultSetView.cpp $(CXXFLAGS) $(EXTRAFLAGS) 44 + 38 45 BlobExplorer.o: BlobExplorer.cpp $(INCLUDE) 39 46 $(CXX) -c BlobExplorer.cpp $(CXXFLAGS) $(EXTRAFLAGS) 40 47 41 48 Dialogs.o: Dialogs.cpp $(INCLUDE) 42 49 $(CXX) -c Dialogs.cpp $(CXXFLAGS) $(EXTRAFLAGS) 43 50 44 51 Shapefiles.o: Shapefiles.cpp $(INCLUDE) 45 52 $(CXX) -c Shapefiles.cpp $(CXXFLAGS) $(EXTRAFLAGS) 46 53 54 +Network.o: Network.cpp $(INCLUDE) 55 + $(CXX) -c Network.cpp $(CXXFLAGS) $(EXTRAFLAGS) 56 + 57 +Exif.o: Exif.cpp $(INCLUDE) 58 + $(CXX) -c Exif.cpp $(CXXFLAGS) $(EXTRAFLAGS) 59 + 47 60 TextCsv.o: TextCsv.cpp $(INCLUDE) 48 61 $(CXX) -c TextCsv.cpp $(CXXFLAGS) $(EXTRAFLAGS) 49 62 50 63 Objects.o: Objects.cpp $(INCLUDE) 51 64 $(CXX) -c Objects.cpp $(CXXFLAGS) $(EXTRAFLAGS) 65 + 66 +MetadataInit.o: MetadataInit.cpp $(INCLUDE) 67 + $(CXX) -c MetadataInit.cpp $(CXXFLAGS) $(EXTRAFLAGS) 52 68 53 69 win_resource/resource.o: win_resource/resource.rc 54 70 $(REZ) -i win_resource/resource.rc -o win_resource/resource.o
Changes to Makefile-OsX.
1 1 # SandroFurieri (c) 2008 2 2 # Makefile ( wxwidgets MacOsX) for spatialite-GUI 3 3 4 -SRC = Main.cpp TableTree.cpp QueryView.cpp BlobExplorer.cpp Dialogs.cpp \ 5 - Shapefiles.cpp TextCsv.cpp Objects.cpp 6 -OBJ = Main.o TableTree.o QueryView.o BlobExplorer.o Dialogs.o Shapefiles.o \ 7 - TextCsv.o Objects.o 4 +SRC = Main.cpp TableTree.cpp QueryView.cpp ResultSetView.cpp BlobExplorer.cpp \ 5 + Dialogs.cpp Shapefiles.cpp Network.cpp Exif.cpp TextCsv.cpp Objects.cpp \ 6 + MetadataInit.cpp 7 +OBJ = Main.o TableTree.o QueryView.o ResultSetView.o BlobExplorer.o Dialogs.o \ 8 + Shapefiles.o Network.o Exif.o TextCsv.o Objects.o MetadataInit.o 8 9 EXE = ./bin/spatialite-gui 9 10 INCLUDE = Classdef.h 10 11 11 12 # Define default flags: 12 13 CXXFLAGS = $(shell wx-config --cxxflags) 13 14 LIB = $(shell wx-config --libs) 14 -EXTRAFLAGS = -O3 -Wall -Wundef -Wno-ctor-dtor-privacy -fno-strict-aliasing -I/usr/local/include 15 -EXTRALIBS = /usr/local/lib/libspatialite.a /usr/local/lib/libsqlite3.a \ 16 - /usr/local/lib/libgeos_c.a /usr/local/lib/libgeos.a \ 17 - /usr/local/lib/libproj.a \ 18 - -liconv 15 +EXTRAFLAGS = -O3 -Wall -Wundef -Wno-ctor-dtor-privacy \ 16 + -fno-strict-aliasing -I/usr/local/include -D_LARGE_FILE=1 \ 17 + -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 18 +EXTRALIBS = /usr/local/lib/libspatialite.a /usr/local/lib/libgeos_c.a \ 19 + /usr/local/lib/libgeos.a /usr/local/lib/libproj.a 20 +EXTRALIB2 = -liconv 19 21 20 22 all: $(EXE) 21 23 22 -$(EXE): $(OBJ) 23 - $(CXX) $(OBJ) -o $(EXE) $(LIB) $(EXTRALIBS) 24 +$(EXE): $(OBJ) $(EXTRALIBS) 25 + $(CXX) $(OBJ) -o $(EXE) $(LIB) $(EXTRALIBS) $(EXTRALIB2) 24 26 strip $(EXE) 25 27 26 28 clean : 27 29 $(RM) $(OBJ) $(EXE) 28 30 29 31 Main.o: Main.cpp $(INCLUDE) 30 32 $(CXX) -c Main.cpp $(CXXFLAGS) $(EXTRAFLAGS) ................................................................................ 31 33 32 34 TableTree.o: TableTree.cpp $(INCLUDE) 33 35 $(CXX) -c TableTree.cpp $(CXXFLAGS) $(EXTRAFLAGS) 34 36 35 37 QueryView.o: QueryView.cpp $(INCLUDE) 36 38 $(CXX) -c QueryView.cpp $(CXXFLAGS) $(EXTRAFLAGS) 37 39 40 +ResultSetView.o: ResultSetView.cpp $(INCLUDE) 41 + $(CXX) -c ResultSetView.cpp $(CXXFLAGS) $(EXTRAFLAGS) 42 + 38 43 BlobExplorer.o: BlobExplorer.cpp $(INCLUDE) 39 44 $(CXX) -c BlobExplorer.cpp $(CXXFLAGS) $(EXTRAFLAGS) 40 45 41 46 Dialogs.o: Dialogs.cpp $(INCLUDE) 42 47 $(CXX) -c Dialogs.cpp $(CXXFLAGS) $(EXTRAFLAGS) 43 48 44 49 Shapefiles.o: Shapefiles.cpp $(INCLUDE) 45 50 $(CXX) -c Shapefiles.cpp $(CXXFLAGS) $(EXTRAFLAGS) 46 51 52 +Network.o: Network.cpp $(INCLUDE) 53 + $(CXX) -c Network.cpp $(CXXFLAGS) $(EXTRAFLAGS) 54 + 55 +Exif.o: Exif.cpp $(INCLUDE) 56 + $(CXX) -c Exif.cpp $(CXXFLAGS) $(EXTRAFLAGS) 57 + 47 58 TextCsv.o: TextCsv.cpp $(INCLUDE) 48 59 $(CXX) -c TextCsv.cpp $(CXXFLAGS) $(EXTRAFLAGS) 49 60 50 61 Objects.o: Objects.cpp $(INCLUDE) 51 62 $(CXX) -c Objects.cpp $(CXXFLAGS) $(EXTRAFLAGS) 63 + 64 +MetadataInit.o: MetadataInit.cpp $(INCLUDE) 65 + $(CXX) -c MetadataInit.cpp $(CXXFLAGS) $(EXTRAFLAGS) 52 66
Changes to Makefile-linux32.
1 1 # SandroFurieri (c) 2008 2 2 # Makefile ( wxwidgets GTK) for spatialite-GUI 3 3 4 -SRC = Main.cpp TableTree.cpp QueryView.cpp BlobExplorer.cpp Dialogs.cpp \ 5 - Shapefiles.cpp TextCsv.cpp Objects.cpp 6 -OBJ = Main.o TableTree.o QueryView.o BlobExplorer.o Dialogs.o Shapefiles.o \ 7 - TextCsv.o Objects.o 4 +SRC = Main.cpp TableTree.cpp QueryView.cpp ResultSetView.cpp BlobExplorer.cpp \ 5 + Dialogs.cpp Shapefiles.cpp Network.cpp Exif.cpp TextCsv.cpp Objects.cpp \ 6 + MetadataInit.cpp 7 +OBJ = Main.o TableTree.o QueryView.o ResultSetView.o BlobExplorer.o Dialogs.o \ 8 + Shapefiles.o Network.o Exif.o TextCsv.o Objects.o MetadataInit.o 8 9 EXE = ./bin/spatialite-gui 9 10 INCLUDE = Classdef.h 10 11 11 12 # Define default flags: 12 13 CXXFLAGS = $(shell wx-config --cxxflags) 13 14 LIB = $(shell wx-config --libs) 14 -EXTRAFLAGS = -O3 -march=i686 -Wall -Wundef -Wno-ctor-dtor-privacy -fno-strict-aliasing -I/usr/local/include 15 -EXTRALIBS = /usr/local/lib/libspatialite.a /usr/local/lib/libsqlite3.a \ 16 - /usr/local/lib/libgeos_c.a /usr/local/lib/libgeos.a \ 17 - /usr/local/lib/libproj.a 15 +EXTRAFLAGS = -O3 -march=i686 -Wall -Wundef -Wno-ctor-dtor-privacy \ 16 + -fno-strict-aliasing -I/usr/local/include -D_LARGE_FILE=1 \ 17 + -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 18 +EXTRALIBS = /usr/local/lib/libspatialite.a /usr/local/lib/libgeos_c.a \ 19 + /usr/local/lib/libgeos.a /usr/local/lib/libproj.a 18 20 19 21 all: $(EXE) 20 22 21 -$(EXE): $(OBJ) 23 +$(EXE): $(OBJ) $(EXTRALIBS) 22 24 $(CXX) $(OBJ) -o $(EXE) $(LIB) $(EXTRALIBS) 23 25 strip --strip-all $(EXE) 24 26 25 27 clean : 26 28 $(RM) $(OBJ) $(EXE) 27 29 28 30 Main.o: Main.cpp $(INCLUDE) ................................................................................ 30 32 31 33 TableTree.o: TableTree.cpp $(INCLUDE) 32 34 $(CXX) -c TableTree.cpp $(CXXFLAGS) $(EXTRAFLAGS) 33 35 34 36 QueryView.o: QueryView.cpp $(INCLUDE) 35 37 $(CXX) -c QueryView.cpp $(CXXFLAGS) $(EXTRAFLAGS) 36 38 39 +ResultSetView.o: ResultSetView.cpp $(INCLUDE) 40 + $(CXX) -c ResultSetView.cpp $(CXXFLAGS) $(EXTRAFLAGS) 41 + 37 42 BlobExplorer.o: BlobExplorer.cpp $(INCLUDE) 38 43 $(CXX) -c BlobExplorer.cpp $(CXXFLAGS) $(EXTRAFLAGS) 39 44 40 45 Dialogs.o: Dialogs.cpp $(INCLUDE) 41 46 $(CXX) -c Dialogs.cpp $(CXXFLAGS) $(EXTRAFLAGS) 42 47 43 48 Shapefiles.o: Shapefiles.cpp $(INCLUDE) 44 49 $(CXX) -c Shapefiles.cpp $(CXXFLAGS) $(EXTRAFLAGS) 45 50 51 +Network.o: Network.cpp $(INCLUDE) 52 + $(CXX) -c Network.cpp $(CXXFLAGS) $(EXTRAFLAGS) 53 + 54 +Exif.o: Exif.cpp $(INCLUDE) 55 + $(CXX) -c Exif.cpp $(CXXFLAGS) $(EXTRAFLAGS) 56 + 46 57 TextCsv.o: TextCsv.cpp $(INCLUDE) 47 58 $(CXX) -c TextCsv.cpp $(CXXFLAGS) $(EXTRAFLAGS) 48 59 49 60 Objects.o: Objects.cpp $(INCLUDE) 50 61 $(CXX) -c Objects.cpp $(CXXFLAGS) $(EXTRAFLAGS) 51 - 62 + 63 +MetadataInit.o: MetadataInit.cpp $(INCLUDE) 64 + $(CXX) -c MetadataInit.cpp $(CXXFLAGS) $(EXTRAFLAGS)
Added MetadataInit.cpp.
more than 10,000 changes
Added Network.cpp.
1 +/* 2 +/ Network.cpp 3 +/ methods related to Network building 4 +/ 5 +/ version 1.2, 2008 October 9 6 +/ 7 +/ Author: Sandro Furieri a-furieri@lqt.it 8 +/ 9 +/ Copyright (C) 2008 Alessandro Furieri 10 +/ 11 +/ This program is free software: you can redistribute it and/or modify 12 +/ it under the terms of the GNU General Public License as published by 13 +/ the Free Software Foundation, either version 3 of the License, or 14 +/ (at your option) any later version. 15 +/ 16 +/ This program is distributed in the hope that it will be useful, 17 +/ but WITHOUT ANY WARRANTY; without even the implied warranty of 18 +/ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 +/ GNU General Public License for more details. 20 +/ 21 +/ You should have received a copy of the GNU General Public License 22 +/ along with this program. If not, see <http://www.gnu.org/licenses/>. 23 +/ 24 +*/ 25 + 26 +#include "Classdef.h" 27 +#include <float.h> 28 + 29 +#define MAX_BLOCK 1048576 30 + 31 +void 32 + MyFrame::BuildNetwork(wxString & table, wxString & from, wxString & to, 33 + wxString & geometry, bool cost_length, wxString & cost, 34 + bool bidirectional, bool one_way, 35 + wxString & one_way_from_to, wxString & one_way_to_from) 36 +{ 37 +// 38 +// trying to build a Network 39 +// 40 + int ret; 41 + sqlite3_stmt *stmt; 42 + Network *p_graph = NULL; 43 + wxString sql; 44 + char xsql[2048]; 45 + char **results; 46 + int n_rows; 47 + int n_columns; 48 + int i; 49 + char *errMsg = NULL; 50 + char *col_name; 51 + int type; 52 + bool ok_from_column = false; 53 + bool ok_to_column = false; 54 + bool ok_cost_column = false; 55 + bool ok_geom_column = false; 56 + bool ok_oneway_tofrom = false; 57 + bool ok_oneway_fromto = false; 58 + bool from_null = false; 59 + bool from_int = false; 60 + bool from_double = false; 61 + bool from_text = false; 62 + bool from_blob = false; 63 + bool to_null = false; 64 + bool to_int = false; 65 + bool to_double = false; 66 + bool to_text = false; 67 + bool to_blob = false; 68 + bool cost_null = false; 69 + bool cost_int = false; 70 + bool cost_double = false; 71 + bool cost_text = false; 72 + bool cost_blob = false; 73 + bool tofrom_null = false; 74 + bool tofrom_int = false; 75 + bool tofrom_double = false; 76 + bool tofrom_text = false; 77 + bool tofrom_blob = false; 78 + bool fromto_null = false; 79 + bool fromto_int = false; 80 + bool fromto_double = false; 81 + bool fromto_text = false; 82 + bool fromto_blob = false; 83 + bool geom_null = false; 84 + bool geom_not_linestring = false; 85 + int col_n; 86 + int cost_n; 87 + int fromto_n = 0; 88 + int tofrom_n = 0; 89 + int rowid; 90 + int id_from = -1; 91 + int id_to = -1; 92 + char code_from[1024]; 93 + char code_to[1024]; 94 + double node_from_x; 95 + double node_from_y; 96 + double node_to_x; 97 + double node_to_y; 98 + double cost_val; 99 + int fromto; 100 + int tofrom; 101 + wxString endMsg; 102 + wxString msg; 103 + bool wr; 104 + ::wxBeginBusyCursor(); 105 +// checking for table existence 106 + sql = wxT("SELECT tbl_name FROM sqlite_master WHERE tbl_name LIKE '"); 107 + sql += table; 108 + sql += wxT("' AND type = 'table'"); 109 + strcpy(xsql, sql.ToUTF8()); 110 + ret = 111 + sqlite3_get_table(SqliteHandle, xsql, &results, &n_rows, &n_columns, 112 + &errMsg); 113 + if (ret != SQLITE_OK) 114 + { 115 +// some error occurred 116 + wxMessageBox(wxT("SQLite SQL error: ") + wxString::FromUTF8(errMsg), 117 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 118 + sqlite3_free(errMsg); 119 + goto abort; 120 + } 121 + if (n_rows == 0) 122 + { 123 + // required table does not exists 124 + wxMessageBox(wxT("ERROR: table \"") + table + wxT("\" does not exists"), 125 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 126 + goto abort; 127 + } else 128 + sqlite3_free_table(results); 129 +// checking for columns existence 130 + sql = wxT("PRAGMA table_info(\""); 131 + sql += table; 132 + sql += wxT("\")"); 133 + strcpy(xsql, sql.ToUTF8()); 134 + ret = 135 + sqlite3_get_table(SqliteHandle, xsql, &results, &n_rows, &n_columns, 136 + &errMsg); 137 + if (ret != SQLITE_OK) 138 + { 139 +// some error occurred 140 + wxMessageBox(wxT("SQLite SQL error: ") + wxString::FromUTF8(errMsg), 141 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 142 + sqlite3_free(errMsg); 143 + goto abort; 144 + } 145 + if (n_rows > 1) 146 + { 147 + for (i = 1; i <= n_rows; i++) 148 + { 149 + char xcol[256]; 150 + col_name = results[(i * n_columns) + 1]; 151 + strcpy(xcol, from.ToUTF8()); 152 + if (strcasecmp(xcol, col_name) == 0) 153 + ok_from_column = true; 154 + strcpy(xcol, to.ToUTF8()); 155 + if (strcasecmp(xcol, col_name) == 0) 156 + ok_to_column = true; 157 + if (cost_length == false) 158 + { 159 + strcpy(xcol, cost.ToUTF8()); 160 + if (strcasecmp(xcol, col_name) == 0) 161 + ok_cost_column = true; 162 + } 163 + strcpy(xcol, geometry.ToUTF8()); 164 + if (strcasecmp(xcol, col_name) == 0) 165 + ok_geom_column = true; 166 + if (one_way == true) 167 + { 168 + strcpy(xcol, one_way_from_to.ToUTF8()); 169 + if (strcasecmp(xcol, col_name) == 0) 170 + ok_oneway_tofrom = true; 171 + } 172 + if (one_way == true) 173 + { 174 + strcpy(xcol, one_way_to_from.ToUTF8()); 175 + if (strcasecmp(xcol, col_name) == 0) 176 + ok_oneway_fromto = true; 177 + } 178 + } 179 + sqlite3_free_table(results); 180 + } 181 + if (ok_from_column == true && ok_to_column == true && ok_geom_column == true) 182 + ; 183 + else 184 + goto abort; 185 + if (cost_length == false && ok_cost_column == false) 186 + goto abort; 187 + if (one_way == true && ok_oneway_tofrom == false) 188 + goto abort; 189 + if (one_way == true && ok_oneway_fromto == false) 190 + goto abort; 191 +// checking column types 192 + p_graph = new Network(); 193 + sql = 194 + wxT("SELECT \"") + from + wxT("\", \"") + to + wxT("\", GeometryType(\"") + 195 + geometry + wxT("\")"); 196 + col_n = 3; 197 + if (cost_length == false) 198 + { 199 + sql += wxT(", \"") + cost + wxT("\""); 200 + cost_n = col_n; 201 + col_n++; 202 + } 203 + if (one_way == true) 204 + { 205 + sql += wxT(", \"") + one_way_to_from + wxT("\""); 206 + tofrom_n = col_n; 207 + col_n++; 208 + sql += wxT(", \"") + one_way_from_to + wxT("\""); 209 + fromto_n = col_n; 210 + col_n++; 211 + } 212 + sql += wxT(" FROM \"") + table; 213 + sql += wxT("\""); 214 + strcpy(xsql, sql.ToUTF8()); 215 + ret = sqlite3_prepare_v2(SqliteHandle, xsql, strlen(xsql), &stmt, NULL); 216 + if (ret != SQLITE_OK) 217 + { 218 + wxString err = wxString::FromUTF8(sqlite3_errmsg(SqliteHandle)); 219 + wxMessageBox(wxT("SQL error: ") + err, wxT("spatialite-gui"), 220 + wxOK | wxICON_ERROR, this); 221 + goto abort; 222 + } 223 + n_columns = sqlite3_column_count(stmt); 224 + while (1) 225 + { 226 + ret = sqlite3_step(stmt); 227 + if (ret == SQLITE_DONE) 228 + break; 229 + if (ret == SQLITE_ROW) 230 + { 231 + // the NodeFrom type 232 + type = sqlite3_column_type(stmt, 0); 233 + if (type == SQLITE_NULL) 234 + from_null = true; 235 + if (type == SQLITE_INTEGER) 236 + { 237 + from_int = true; 238 + id_from = sqlite3_column_int(stmt, 0); 239 + p_graph->InsertNode(id_from); 240 + } 241 + if (type == SQLITE_FLOAT) 242 + from_double = true; 243 + if (type == SQLITE_TEXT) 244 + { 245 + from_text = true; 246 + strcpy(code_from, (char *) sqlite3_column_text(stmt, 0)); 247 + p_graph->InsertNode(code_from); 248 + } 249 + if (type == SQLITE_BLOB) 250 + from_blob = true; 251 + // the NodeTo type 252 + type = sqlite3_column_type(stmt, 1); 253 + if (type == SQLITE_NULL) 254 + to_null = true; 255 + if (type == SQLITE_INTEGER) 256 + { 257 + to_int = true; 258 + id_to = sqlite3_column_int(stmt, 1); 259 + p_graph->InsertNode(id_to); 260 + } 261 + if (type == SQLITE_FLOAT) 262 + to_double = true; 263 + if (type == SQLITE_TEXT) 264 + { 265 + to_text = true; 266 + strcpy(code_to, (char *) sqlite3_column_text(stmt, 1)); 267 + p_graph->InsertNode(code_to); 268 + } 269 + if (type == SQLITE_BLOB) 270 + to_blob = true; 271 + // the Geometry type 272 + type = sqlite3_column_type(stmt, 2); 273 + if (type == SQLITE_NULL) 274 + geom_null = true; 275 + else if (strcmp("LINESTRING", (char *) sqlite3_column_text(stmt, 2)) 276 + != 0) 277 + geom_not_linestring = true; 278 + if (cost_length == false) 279 + { 280 + // the Cost type 281 + type = sqlite3_column_type(stmt, 3); 282 + if (type == SQLITE_NULL) 283 + cost_null = true; 284 + if (type == SQLITE_INTEGER) 285 + cost_int = true; 286 + if (type == SQLITE_FLOAT) 287 + cost_double = true; 288 + if (type == SQLITE_TEXT) 289 + cost_text = true; 290 + if (type == SQLITE_BLOB) 291 + cost_blob = true; 292 + } 293 + if (one_way == true) 294 + { 295 + // the FromTo type 296 + type = sqlite3_column_type(stmt, 4); 297 + if (type == SQLITE_NULL) 298 + fromto_null = true; 299 + if (type == SQLITE_INTEGER) 300 + fromto_int = true; 301 + if (type == SQLITE_FLOAT) 302 + fromto_double = true; 303 + if (type == SQLITE_TEXT) 304 + fromto_text = true; 305 + if (type == SQLITE_BLOB) 306 + fromto_blob = true; 307 + // the ToFrom type 308 + type = sqlite3_column_type(stmt, 5); 309 + if (type == SQLITE_NULL) 310 + tofrom_null = true; 311 + if (type == SQLITE_INTEGER) 312 + tofrom_int = true; 313 + if (type == SQLITE_FLOAT) 314 + tofrom_double = true; 315 + if (type == SQLITE_TEXT) 316 + tofrom_text = true; 317 + if (type == SQLITE_BLOB) 318 + tofrom_blob = true; 319 + } 320 + } else 321 + { 322 + wxString err = wxString::FromUTF8(sqlite3_errmsg(SqliteHandle)); 323 + wxMessageBox(wxT("sqlite3_step error: ") + err, wxT("spatialite-gui"), 324 + wxOK | wxICON_ERROR, this); 325 + sqlite3_finalize(stmt); 326 + goto abort; 327 + } 328 + } 329 + sqlite3_finalize(stmt); 330 + ret = 1; 331 + if (from_null == true) 332 + ret = 0; 333 + if (from_blob == true) 334 + ret = 0; 335 + if (from_double == true) 336 + ret = 0; 337 + if (to_null == true) 338 + ret = 0; 339 + if (to_blob == true) 340 + ret = 0; 341 + if (to_double == true) 342 + ret = 0; 343 + if (geom_null == true) 344 + ret = 0; 345 + if (geom_not_linestring == true) 346 + ret = 0; 347 + if (cost_length == false) 348 + { 349 + if (cost_null == true) 350 + ret = 0; 351 + if (cost_blob == true) 352 + ret = 0; 353 + if (cost_text == true) 354 + ret = 0; 355 + } 356 + if (one_way == true) 357 + { 358 + if (fromto_null == true) 359 + ret = 0; 360 + if (fromto_blob == true) 361 + ret = 0; 362 + if (fromto_text == true) 363 + ret = 0; 364 + if (fromto_double == true) 365 + ret = 0; 366 + if (tofrom_null == true) 367 + ret = 0; 368 + if (tofrom_blob == true) 369 + ret = 0; 370 + if (tofrom_text == true) 371 + ret = 0; 372 + if (tofrom_double == true) 373 + ret = 0; 374 + } 375 + if (!ret) 376 + goto abort; 377 + if (from_int == true && to_int == true) 378 + { 379 + // each node is identified by an INTEGER id 380 + p_graph->SetNodeCode(false); 381 + } else if (from_text == true && to_text == true) 382 + { 383 + // each node is identified by a TEXT code 384 + p_graph->SetNodeCode(true); 385 + } else 386 + goto abort; 387 + p_graph->InitNodes(); 388 +// checking topologic consistency 389 + sql = wxT("SELECT ROWID, \"") + from + wxT("\", \"") + to + wxT("\", "); 390 + sql += 391 + wxT("X(StartPoint(\"") + geometry + wxT("\")), Y(StartPoint(\"") + 392 + geometry + wxT("\")), "); 393 + sql += 394 + wxT("X(EndPoint(\"") + geometry + wxT("\")), Y(EndPoint(\"") + geometry + 395 + wxT("\"))"); 396 + if (cost_length == false) 397 + sql += wxT(", ") + cost; 398 + else 399 + sql += wxT(", GLength(\"") + geometry + wxT("\")"); 400 + col_n = 8; 401 + if (one_way == true) 402 + { 403 + sql += wxT(", \"") + one_way_to_from + wxT("\""); 404 + tofrom_n = col_n; 405 + col_n++; 406 + sql += wxT(", \"") + one_way_from_to + wxT("\""); 407 + fromto_n = col_n; 408 + col_n++; 409 + } 410 + sql += wxT(" FROM \"") + table + wxT("\""); 411 + strcpy(xsql, sql.ToUTF8()); 412 + ret = sqlite3_prepare_v2(SqliteHandle, xsql, strlen(xsql), &stmt, NULL); 413 + if (ret != SQLITE_OK) 414 + { 415 + wxString err = wxString::FromUTF8(sqlite3_errmsg(SqliteHandle)); 416 + wxMessageBox(wxT("SQL error: ") + err, wxT("spatialite-gui"), 417 + wxOK | wxICON_ERROR, this); 418 + goto abort; 419 + } 420 + n_columns = sqlite3_column_count(stmt); 421 + while (1) 422 + { 423 + ret = sqlite3_step(stmt); 424 + if (ret == SQLITE_DONE) 425 + break; 426 + if (ret == SQLITE_ROW) 427 + { 428 + fromto = true; 429 + tofrom = true; 430 + if (p_graph->IsNodeCode() == true) 431 + { 432 + id_from = -1; 433 + id_to = -1; 434 + } else 435 + { 436 + *code_from = '\0'; 437 + *code_to = '\0'; 438 + } 439 + // fetching the ROWID 440 + rowid = sqlite3_column_int(stmt, 0); 441 + // fetching the NodeFrom value 442 + if (p_graph->IsNodeCode() == true) 443 + strcpy(code_from, (char *) sqlite3_column_text(stmt, 1)); 444 + else 445 + id_from = sqlite3_column_int(stmt, 1); 446 + // fetching the NodeTo value 447 + if (p_graph->IsNodeCode() == true) 448 + strcpy(code_to, (char *) sqlite3_column_text(stmt, 2)); 449 + else 450 + id_to = sqlite3_column_int(stmt, 2); 451 + // fetching the NodeFromX value 452 + node_from_x = sqlite3_column_double(stmt, 3); 453 + // fetching the NodeFromY value 454 + node_from_y = sqlite3_column_double(stmt, 4); 455 + // fetching the NodeFromX value 456 + node_to_x = sqlite3_column_double(stmt, 5); 457 + // fetching the NodeFromY value 458 + node_to_y = sqlite3_column_double(stmt, 6); 459 + // fetching the Cost value 460 + cost_val = sqlite3_column_double(stmt, 7); 461 + if (one_way == true) 462 + { 463 + // fetching the OneWay-FromTo value 464 + fromto = sqlite3_column_int(stmt, fromto_n); 465 + // fetching the OneWay-ToFrom value 466 + tofrom = sqlite3_column_int(stmt, tofrom_n); 467 + } 468 + if (cost_val <= 0.0) 469 + p_graph->SetError(); 470 + if (bidirectional == true) 471 + { 472 + if (fromto) 473 + { 474 + if (p_graph->IsNodeCode() == true) 475 + p_graph->AddArc(rowid, code_from, code_to, node_from_x, 476 + node_from_y, node_to_x, node_to_y, 477 + cost_val); 478 + else 479 + p_graph->AddArc(rowid, id_from, id_to, node_from_x, 480 + node_from_y, node_to_x, node_to_y, 481 + cost_val); 482 + } 483 + if (tofrom) 484 + { 485 + if (p_graph->IsNodeCode() == true) 486 + p_graph->AddArc(rowid, code_to, code_from, node_to_x, 487 + node_to_y, node_from_x, node_from_y, 488 + cost_val); 489 + else 490 + p_graph->AddArc(rowid, id_to, id_from, node_to_x, node_to_y, 491 + node_from_x, node_from_y, cost_val); 492 + } 493 + } else 494 + { 495 + if (p_graph->IsNodeCode() == true) 496 + p_graph->AddArc(rowid, code_from, code_to, node_from_x, 497 + node_from_y, node_to_x, node_to_y, cost_val); 498 + else 499 + p_graph->AddArc(rowid, id_from, id_to, node_from_x, node_from_y, 500 + node_to_x, node_to_y, cost_val); 501 + } 502 + if (p_graph->IsError() == true) 503 + { 504 + sqlite3_finalize(stmt); 505 + goto abort; 506 + } 507 + } else 508 + { 509 + wxString err = wxString::FromUTF8(sqlite3_errmsg(SqliteHandle)); 510 + wxMessageBox(wxT("sqlite3_step error: ") + err, wxT("spatialite-gui"), 511 + wxOK | wxICON_ERROR, this); 512 + sqlite3_finalize(stmt); 513 + goto abort; 514 + } 515 + } 516 + sqlite3_finalize(stmt); 517 + ::wxEndBusyCursor(); 518 + wr = CreateNetwork(p_graph, table, from, to, geometry); 519 + if (wr == true) 520 + { 521 + endMsg = 522 + wxT("OK: VirtualNetwork table '") + table + 523 + wxT("_net' successfully created"); 524 + wxMessageBox(endMsg, wxT("spatialite-gui"), wxOK | wxICON_INFORMATION, 525 + this); 526 + } else 527 + { 528 + endMsg = 529 + wxT("DB ERROR: VirtualNetwork table '") + table + 530 + wxT("_net' was not created"); 531 + wxMessageBox(endMsg, wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 532 + } 533 + if (p_graph) 534 + delete p_graph; 535 + InitTableTree(); 536 + return; 537 +abort: 538 + ::wxEndBusyCursor(); 539 + msg = 540 + wxT 541 + ("It's impossible to build a Network using the given configuration;\nsome fatal error occurred\n\n"); 542 + msg += wxT("please note: using the 'spatialite_network' command-line tool\n"); 543 + msg += 544 + wxT 545 + ("you can obtain a full detailed report explaining causes for this failure"); 546 + wxMessageBox(msg, wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 547 + if (p_graph) 548 + delete p_graph; 549 +} 550 + 551 +void 552 + MyFrame::OutputNetNode(unsigned char *auxbuf, int *size, int ind, 553 + bool node_code, int max_node_length, NetNode * pN, 554 + int endian_arch) 555 +{ 556 +// 557 +// exporting a Node into NETWORK-DATA 558 +// 559 + int n_star; 560 + int i; 561 + NetArc **arc_array; 562 + NetArc *pA; 563 + unsigned char *out = auxbuf; 564 + *out++ = GAIA_NET_NODE; 565 + gaiaExport32(out, ind, 1, endian_arch); // the Node internal index 566 + out += 4; 567 + if (node_code) 568 + { 569 + // Nodes are identified by a TEXT Code 570 + memset(out, '\0', max_node_length); 571 + strcpy((char *) out, pN->GetCode().ToUTF8()); 572 + out += max_node_length; 573 + } else 574 + { 575 + // Nodes are identified by an INTEGER Id 576 + gaiaExport32(out, pN->GetId(), 1, endian_arch); // the Node ID 577 + out += 4; 578 + } 579 + arc_array = pN->PrepareOutcomings(&n_star); 580 + gaiaExport16(out, n_star, 1, endian_arch); // # of outcoming arcs 581 + out += 2; 582 + for (i = 0; i < n_star; i++) 583 + { 584 + // exporting the outcoming arcs 585 + pA = *(arc_array + i); 586 + *out++ = GAIA_NET_ARC; 587 + gaiaExport32(out, pA->GetRowId(), 1, endian_arch); // the Arc rowid 588 + out += 4; 589 + gaiaExport32(out, pA->GetTo()->GetInternalIndex(), 1, endian_arch); // the ToNode internal index 590 + out += 4; 591 + gaiaExport64(out, pA->GetCost(), 1, endian_arch); // the Arc Cost 592 + out += 8; 593 + *out++ = GAIA_NET_END; 594 + } 595 + if (arc_array) 596 + delete[]arc_array; 597 + *out++ = GAIA_NET_END; 598 + *size = out - auxbuf; 599 +} 600 + 601 +bool MyFrame::CreateNetwork(Network * p_graph, wxString & table, 602 + wxString & from, wxString & to, wxString & geometry) 603 +{ 604 +// 605 +// creates the NETWORK-DATA table 606 +// 607 + int ret; 608 + wxString sql; 609 + char xsql[1024]; 610 + char *errMsg = NULL; 611 + unsigned char *auxbuf = new unsigned char[MAX_BLOCK]; 612 + unsigned char *buf = new unsigned char[MAX_BLOCK]; 613 + unsigned char *out; 614 + sqlite3_stmt *stmt; 615 + int i; 616 + int size; 617 + int endian_arch = gaiaEndianArch(); 618 + NetNode *pN; 619 + int pk = 0; 620 + int nodes_cnt = 0; 621 + int len; 622 + bool net_data_exists = false; 623 + bool net_exists = false; 624 + bool delete_existing = false; 625 + wxString data_table = table + wxT("_net_data"); 626 + wxString net_table = table + wxT("_net"); 627 + net_data_exists = TableAlreadyExists(data_table); 628 + net_exists = TableAlreadyExists(net_table); 629 + if (net_data_exists == true || net_exists == true) 630 + { 631 + // asking permission to overwrite existing tables 632 + wxString msg; 633 + if (net_data_exists == true) 634 + msg += wxT("A table named '") + data_table + wxT("' already exists\n"); 635 + if (net_exists == true) 636 + msg += wxT("A table named '") + net_table + wxT("' already exists\n"); 637 + msg += wxT("\nDo you allow DROPping existing table(s) ?"); 638 + wxMessageDialog confirm(this, msg, wxT("Confirm overwrite"), 639 + wxYES_NO | wxICON_QUESTION); 640 + ret = confirm.ShowModal(); 641 + if (ret == wxID_YES) 642 + delete_existing = true; 643 + } 644 + ::wxBeginBusyCursor(); 645 + for (i = 0; i < p_graph->GetNumNodes(); i++) 646 + { 647 + // setting the internal index to each Node 648 + pN = p_graph->GetSortedNode(i); 649 + pN->SetInternalIndex(i); 650 + } 651 +// starts a transaction 652 + ret = sqlite3_exec(SqliteHandle, "BEGIN", NULL, NULL, &errMsg); 653 + if (ret != SQLITE_OK) 654 + { 655 + wxMessageBox(wxT("BEGIN error: ") + wxString::FromUTF8(errMsg), 656 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 657 + sqlite3_free(errMsg); 658 + goto abort; 659 + } 660 + if (delete_existing == true) 661 + { 662 + sql = wxT("DROP TABLE IF EXISTS \"") + net_table + wxT("\""); 663 + strcpy(xsql, sql.ToUTF8()); 664 + ret = sqlite3_exec(SqliteHandle, xsql, NULL, NULL, &errMsg); 665 + if (ret != SQLITE_OK) 666 + { 667 + wxMessageBox(wxT("DROP TABLE error: ") + wxString::FromUTF8(errMsg), 668 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 669 + sqlite3_free(errMsg); 670 + goto abort; 671 + } 672 + sql = wxT("DROP TABLE IF EXISTS \"") + data_table + wxT("\""); 673 + strcpy(xsql, sql.ToUTF8()); 674 + ret = sqlite3_exec(SqliteHandle, xsql, NULL, NULL, &errMsg); 675 + if (ret != SQLITE_OK) 676 + { 677 + wxMessageBox(wxT("DROP TABLE error: ") + wxString::FromUTF8(errMsg), 678 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 679 + sqlite3_free(errMsg); 680 + goto abort; 681 + } 682 + } 683 +// creating the NETWORK-DATA table 684 + sql = wxT("CREATE TABLE \"") + data_table; 685 + sql += wxT("\" (\"Id\" INTEGER PRIMARY KEY, \"NetworkData\" BLOB NOT NULL)"); 686 + strcpy(xsql, sql.ToUTF8()); 687 + ret = sqlite3_exec(SqliteHandle, xsql, NULL, NULL, &errMsg); 688 + if (ret != SQLITE_OK) 689 + { 690 + wxMessageBox(wxT("CREATE TABLE error: ") + wxString::FromUTF8(errMsg), 691 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 692 + sqlite3_free(errMsg); 693 + goto abort; 694 + } 695 +// preparing the SQL statement 696 + sql = 697 + wxT("INSERT INTO \"") + data_table + 698 + wxT("\" (\"Id\", \"NetworkData\") VALUES (?, ?)"); 699 + strcpy(xsql, sql.ToUTF8()); 700 + ret = sqlite3_prepare_v2(SqliteHandle, xsql, strlen(xsql), &stmt, NULL); 701 + if (ret != SQLITE_OK) 702 + { 703 + wxString err = wxString::FromUTF8(sqlite3_errmsg(SqliteHandle)); 704 + wxMessageBox(wxT("INSERT error: ") + err, wxT("spatialite-gui"), 705 + wxOK | wxICON_ERROR, this); 706 + goto abort; 707 + } 708 + if (pk == 0) 709 + { 710 + // preparing the HEADER block 711 + out = buf; 712 + *out++ = GAIA_NET_START; 713 + *out++ = GAIA_NET_HEADER; 714 + gaiaExport32(out, p_graph->GetNumNodes(), 1, endian_arch); // how many Nodes are there 715 + out += 4; 716 + if (p_graph->IsNodeCode() == true) 717 + *out++ = GAIA_NET_CODE; // Nodes are identified by a TEXT code 718 + else 719 + *out++ = GAIA_NET_ID; // Nodes are identified by an INTEGER id 720 + if (p_graph->IsNodeCode() == true) 721 + *out++ = p_graph->GetMaxCodeLength(); // max TEXT code length 722 + else 723 + *out++ = 0x00; 724 + // inserting the main Table name 725 + *out++ = GAIA_NET_TABLE; 726 + len = table.Len() + 1; 727 + gaiaExport16(out, len, 1, endian_arch); // the Table Name length, including last '\0' 728 + out += 2; 729 + memset(out, '\0', len); 730 + strcpy((char *) out, table.ToUTF8()); 731 + out += len; 732 + // inserting the NodeFrom column name 733 + *out++ = GAIA_NET_FROM; 734 + len = from.Len() + 1; 735 + gaiaExport16(out, len, 1, endian_arch); // the NodeFrom column Name length, including last '\0' 736 + out += 2; 737 + memset(out, '\0', len); 738 + strcpy((char *) out, from.ToUTF8()); 739 + out += len; 740 + // inserting the NodeTo column name 741 + *out++ = GAIA_NET_TO; 742 + len = to.Len() + 1; 743 + gaiaExport16(out, len, 1, endian_arch); // the NodeTo column Name length, including last '\0' 744 + out += 2; 745 + memset(out, '\0', len); 746 + strcpy((char *) out, to.ToUTF8()); 747 + out += len; 748 + // inserting the Geometry column name 749 + *out++ = GAIA_NET_GEOM; 750 + len = geometry.Len() + 1; 751 + gaiaExport16(out, len, 1, endian_arch); // the Geometry column Name length, including last '\0' 752 + out += 2; 753 + memset(out, '\0', len); 754 + strcpy((char *) out, geometry.ToUTF8()); 755 + out += len; 756 + *out++ = GAIA_NET_END; 757 + // INSERTing the Header block 758 + sqlite3_reset(stmt); 759 + sqlite3_clear_bindings(stmt); 760 + sqlite3_bind_int64(stmt, 1, pk); 761 + sqlite3_bind_blob(stmt, 2, buf, out - buf, SQLITE_STATIC); 762 + ret = sqlite3_step(stmt); 763 + if (ret == SQLITE_DONE || ret == SQLITE_ROW) 764 + ; 765 + else 766 + { 767 + wxString err = wxString::FromUTF8(sqlite3_errmsg(SqliteHandle)); 768 + wxMessageBox(wxT("sqlite3_step error: ") + err, wxT("spatialite-gui"), 769 + wxOK | wxICON_ERROR, this); 770 + sqlite3_finalize(stmt); 771 + goto abort; 772 + } 773 + pk++; 774 + // preparing a new block 775 + out = buf; 776 + *out++ = GAIA_NET_BLOCK; 777 + gaiaExport16(out, 0, 1, endian_arch); // how many Nodes are into this block 778 + out += 2; 779 + nodes_cnt = 0; 780 + } 781 + for (i = 0; i < p_graph->GetNumNodes(); i++) 782 + { 783 + // looping on each Node 784 + pN = p_graph->GetSortedNode(i); 785 + OutputNetNode(auxbuf, &size, i, p_graph->IsNodeCode(), 786 + p_graph->GetMaxCodeLength(), pN, endian_arch); 787 + if (size >= (MAX_BLOCK - (out - buf))) 788 + { 789 + // inserting the last block 790 + gaiaExport16(buf + 1, nodes_cnt, 1, endian_arch); // how many Nodes are into this block 791 + sqlite3_reset(stmt); 792 + sqlite3_clear_bindings(stmt); 793 + sqlite3_bind_int64(stmt, 1, pk); 794 + sqlite3_bind_blob(stmt, 2, buf, out - buf, SQLITE_STATIC); 795 + ret = sqlite3_step(stmt); 796 + if (ret == SQLITE_DONE || ret == SQLITE_ROW) 797 + ; 798 + else 799 + { 800 + wxString err = wxString::FromUTF8(sqlite3_errmsg(SqliteHandle)); 801 + wxMessageBox(wxT("sqlite3_step error: ") + err, 802 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 803 + sqlite3_finalize(stmt); 804 + goto abort; 805 + } 806 + pk++; 807 + // preparing a new block 808 + out = buf; 809 + *out++ = GAIA_NET_BLOCK; 810 + gaiaExport16(out, 0, 1, endian_arch); // how many Nodes are into this block 811 + out += 2; 812 + nodes_cnt = 0; 813 + } 814 + // inserting the current Node into the block 815 + nodes_cnt++; 816 + memcpy(out, auxbuf, size); 817 + out += size; 818 + } 819 + if (nodes_cnt) 820 + { 821 + // inserting the last block 822 + gaiaExport16(buf + 1, nodes_cnt, 1, endian_arch); // how many Nodes are into this block 823 + sqlite3_reset(stmt); 824 + sqlite3_clear_bindings(stmt); 825 + sqlite3_bind_int64(stmt, 1, pk); 826 + sqlite3_bind_blob(stmt, 2, buf, out - buf, SQLITE_STATIC); 827 + ret = sqlite3_step(stmt); 828 + if (ret == SQLITE_DONE || ret == SQLITE_ROW) 829 + ; 830 + else 831 + { 832 + wxString err = wxString::FromUTF8(sqlite3_errmsg(SqliteHandle)); 833 + wxMessageBox(wxT("sqlite3_step error: ") + err, wxT("spatialite-gui"), 834 + wxOK | wxICON_ERROR, this); 835 + sqlite3_finalize(stmt); 836 + goto abort; 837 + } 838 + } 839 + sqlite3_finalize(stmt); 840 +// creating the VirtualNetwork NET-table 841 + sql = wxT("CREATE VIRTUAL TABLE \"") + net_table; 842 + sql += wxT("\" USING VirtualNetwork("); 843 + sql += data_table + wxT(")"); 844 + strcpy(xsql, sql.ToUTF8()); 845 + ret = sqlite3_exec(SqliteHandle, xsql, NULL, NULL, &errMsg); 846 + if (ret != SQLITE_OK) 847 + { 848 + wxMessageBox(wxT("CREATE VIRTUAL TABLE error: ") + 849 + wxString::FromUTF8(errMsg), wxT("spatialite-gui"), 850 + wxOK | wxICON_ERROR, this); 851 + sqlite3_free(errMsg); 852 + goto abort; 853 + } 854 +// commits the transaction 855 + ret = sqlite3_exec(SqliteHandle, "COMMIT", NULL, NULL, &errMsg); 856 + if (ret != SQLITE_OK) 857 + { 858 + wxMessageBox(wxT("COMMIT error: ") + wxString::FromUTF8(errMsg), 859 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 860 + sqlite3_free(errMsg); 861 + goto abort; 862 + } 863 + if (buf) 864 + delete[]buf; 865 + if (auxbuf) 866 + delete[]auxbuf; 867 + ::wxEndBusyCursor(); 868 + return true; 869 +abort: 870 + ::wxEndBusyCursor(); 871 + if (buf) 872 + delete[]buf; 873 + if (auxbuf) 874 + delete[]auxbuf; 875 + return true; 876 + return false; 877 +} 878 + 879 +int cmp_prenodes_code(const void *p1, const void *p2) 880 +{ 881 +// 882 +// compares two preliminary nodes by CODE [for QSORT] 883 +// 884 + NetNodePre *pP1 = *((NetNodePre **) p1); 885 + NetNodePre *pP2 = *((NetNodePre **) p2); 886 + return pP1->GetCode().Cmp(pP2->GetCode()); 887 +} 888 + 889 +int cmp_prenodes_id(const void *p1, const void *p2) 890 +{ 891 +// 892 +// compares two preliminary nodes by ID [for QSORT] 893 +// 894 + NetNodePre *pP1 = *((NetNodePre **) p1); 895 + NetNodePre *pP2 = *((NetNodePre **) p2); 896 + return pP1->GetId() - pP2->GetId(); 897 +} 898 + 899 +int cmp_nodes2_code(const void *p1, const void *p2) 900 +{ 901 +// 902 +// compares two nodes by CODE [for BSEARCH] 903 +// 904 + NetNode *pN1 = (NetNode *) p1; 905 + NetNode *pN2 = *((NetNode **) p2); 906 + return pN1->GetCode().Cmp(pN2->GetCode()); 907 +} 908 + 909 +int cmp_nodes2_id(const void *p1, const void *p2) 910 +{ 911 +// 912 +// compares two nodes by ID [for BSEARCH] 913 +// 914 + NetNode *pN1 = (NetNode *) p1; 915 + NetNode *pN2 = *((NetNode **) p2); 916 + return pN1->GetId() - pN2->GetId(); 917 +} 918 + 919 +int cmp_nodes1_code(const void *p1, const void *p2) 920 +{ 921 +// 922 +// compares two nodes by CODE [for QSORT] 923 +// 924 + NetNode *pN1 = *((NetNode **) p1); 925 + NetNode *pN2 = *((NetNode **) p2); 926 + return pN1->GetCode().Cmp(pN2->GetCode()); 927 +} 928 + 929 +int cmp_nodes1_id(const void *p1, const void *p2) 930 +{ 931 +// 932 +// compares two nodes by ID [for QSORT ] 933 +// 934 + NetNode *pN1 = *((NetNode **) p1); 935 + NetNode *pN2 = *((NetNode **) p2); 936 + return pN1->GetId() - pN2->GetId(); 937 +} 938 + 939 +NetNodePre::NetNodePre(int id) 940 +{ 941 +// 942 +// Network Node [preliminary] constructor 943 +// 944 + Id = id; 945 + Code = wxT(""); 946 + Next = NULL; 947 +} 948 + 949 +NetNodePre::NetNodePre(const char *code) 950 +{ 951 +// 952 +// Network Node [preliminary] constructor 953 +// 954 + Id = -1; 955 + Code = wxString::FromUTF8(code); 956 + Code.Truncate(30); 957 + Next = NULL; 958 +} 959 + 960 +NetNode::NetNode(int id) 961 +{ 962 +// 963 +// Network Node [final] constructor 964 +// 965 + InternalIndex = -1; 966 + Id = id; 967 + Code = wxT(""); 968 + X = DBL_MAX; 969 + Y = DBL_MAX; 970 + First = NULL; 971 + Last = NULL; 972 + Next = NULL; 973 +} 974 + 975 +NetNode::NetNode(wxString & code) 976 +{ 977 +// 978 +// Network Node [final] constructor 979 +// 980 + InternalIndex = -1; 981 + Id = -1; 982 + Code = code; 983 + X = DBL_MAX; 984 + Y = DBL_MAX; 985 + First = NULL; 986 + Last = NULL; 987 + Next = NULL; 988 +} 989 + 990 +NetNode::~NetNode() 991 +{ 992 +// Network Node [final] destructor 993 + NetArcRef *pAR; 994 + NetArcRef *pARn; 995 + pAR = First; 996 + while (pAR) 997 + { 998 + pARn = pAR->GetNext(); 999 + delete pAR; 1000 + pAR = pARn; 1001 + } 1002 +} 1003 + 1004 +void NetNode::AddOutcoming(NetArc * pA) 1005 +{ 1006 +// 1007 +// adds an outcoming Arc to a Node 1008 +// 1009 + NetArcRef *pAR = new NetArcRef(pA); 1010 + if (!First) 1011 + First = pAR; 1012 + if (Last) 1013 + Last->SetNext(pAR); 1014 + Last = pAR; 1015 +} 1016 + 1017 +NetArc **NetNode::PrepareOutcomings(int *count) 1018 +{ 1019 +// 1020 +// preparing the outcoming arc array 1021 +// 1022 + NetArc **arc_array; 1023 + int n = 0; 1024 + int i; 1025 + bool ok; 1026 + NetArcRef *pAR; 1027 + NetArc *pA0; 1028 + NetArc *pA1; 1029 + pAR = First; 1030 + while (pAR) 1031 + { 1032 + // counting how many outcoming arcs are there 1033 + n++; 1034 + pAR = pAR->GetNext(); 1035 + } 1036 + if (!n) 1037 + { 1038 + *count = 0; 1039 + return NULL; 1040 + } 1041 + arc_array = new NetArc *[n]; 1042 + i = 0; 1043 + pAR = First; 1044 + while (pAR) 1045 + { 1046 + // populating the arcs array 1047 + *(arc_array + i++) = pAR->GetReference(); 1048 + pAR = pAR->GetNext(); 1049 + } 1050 + ok = true; 1051 + while (ok == true) 1052 + { 1053 + // bubble sorting the arcs by Cost 1054 + ok = false; 1055 + for (i = 1; i < n; i++) 1056 + { 1057 + pA0 = *(arc_array + i - 1); 1058 + pA1 = *(arc_array + i); 1059 + if (pA0->GetCost() > pA1->GetCost()) 1060 + { 1061 + // swapping the arcs 1062 + *(arc_array + i - 1) = pA1; 1063 + *(arc_array + i) = pA0; 1064 + ok = true; 1065 + } 1066 + } 1067 + } 1068 + *count = n; 1069 + return arc_array; 1070 +} 1071 + 1072 +NetArc::NetArc(int rowid, NetNode * from, NetNode * to, double cost) 1073 +{ 1074 +// 1075 +// Network Arc constructor 1076 +// 1077 + RowId = rowid; 1078 + From = from; 1079 + To = to; 1080 + Cost = cost; 1081 + Next = NULL; 1082 +} 1083 + 1084 +Network::Network() 1085 +{ 1086 +// 1087 +// Network constructor 1088 +// 1089 + FirstPre = NULL; 1090 + LastPre = NULL; 1091 + NumPreNodes = 0; 1092 + SortedPreNodes = NULL; 1093 + NumPreNodes = 0; 1094 + SortedPreNodes = NULL; 1095 + FirstArc = NULL; 1096 + LastArc = NULL; 1097 + FirstNode = NULL; 1098 + LastNode = NULL; 1099 + NumNodes = 0; 1100 + SortedNodes = NULL; 1101 + Error = false; 1102 + NodeCode = false; 1103 + MaxCodeLength = 0; 1104 +} 1105 + 1106 +Network::~Network() 1107 +{ 1108 +// 1109 +// Network destructor 1110 +// 1111 + NetArc *pA; 1112 + NetArc *pAn; 1113 + NetNode *pN; 1114 + NetNode *pNn; 1115 + CleanPreNodes(); 1116 + pA = FirstArc; 1117 + while (pA) 1118 + { 1119 + pAn = pA->GetNext(); 1120 + delete pA; 1121 + pA = pAn; 1122 + } 1123 + pN = FirstNode; 1124 + while (pN) 1125 + { 1126 + pNn = pN->GetNext(); 1127 + delete pN; 1128 + pN = pNn; 1129 + } 1130 + if (SortedNodes) 1131 + delete[]SortedNodes; 1132 +} 1133 + 1134 +void Network::CleanPreNodes() 1135 +{ 1136 +// 1137 +// cleaning up the preliminary Nodes list 1138 +// 1139 + NetNodePre *pP; 1140 + NetNodePre *pPn; 1141 + pP = FirstPre; 1142 + while (pP) 1143 + { 1144 + pPn = pP->GetNext(); 1145 + delete pP; 1146 + pP = pPn; 1147 + } 1148 + FirstPre = NULL; 1149 + LastPre = NULL; 1150 + NumPreNodes = 0; 1151 + if (SortedPreNodes) 1152 + delete[]SortedPreNodes; 1153 + SortedPreNodes = NULL; 1154 +} 1155 + 1156 +void Network::InsertNode(int id) 1157 +{ 1158 +// 1159 +// inserts a Node into the preliminary list 1160 +// 1161 + NetNodePre *pP = new NetNodePre(id); 1162 + if (!FirstPre) 1163 + FirstPre = pP; 1164 + if (LastPre) 1165 + LastPre->SetNext(pP); 1166 + LastPre = pP; 1167 +} 1168 + 1169 +void Network::InsertNode(const char *code) 1170 +{ 1171 +// 1172 +// inserts a Node into the preliminary list 1173 +// 1174 + NetNodePre *pP = new NetNodePre(code); 1175 + if (!FirstPre) 1176 + FirstPre = pP; 1177 + if (LastPre) 1178 + LastPre->SetNext(pP); 1179 + LastPre = pP; 1180 +} 1181 + 1182 +void Network::AddNode(int id) 1183 +{ 1184 +// 1185 +// inserts a Node into the final list 1186 +// 1187 + NetNode *pN = new NetNode(id); 1188 + if (!FirstNode) 1189 + FirstNode = pN; 1190 + if (LastNode) 1191 + LastNode->SetNext(pN); 1192 + LastNode = pN; 1193 +} 1194 + 1195 +void Network::AddNode(wxString & code) 1196 +{ 1197 +// 1198 +// inserts a Node into the final list 1199 +// 1200 + int len; 1201 + NetNode *pN = new NetNode(code); 1202 + len = pN->GetCode().Len() + 1; 1203 + if (len > MaxCodeLength) 1204 + MaxCodeLength = len; 1205 + if (!FirstNode) 1206 + FirstNode = pN; 1207 + if (LastNode) 1208 + LastNode->SetNext(pN); 1209 + LastNode = pN; 1210 +} 1211 + 1212 +NetNode *Network::ProcessNode(int id, double x, double y, NetNode ** pOther) 1213 +{ 1214 +// 1215 +// inserts a new node or retrieves an already defined one 1216 +// 1217 + NetNode *pN = Find(id); 1218 + *pOther = NULL; 1219 + if (pN) 1220 + { 1221 + // this Node already exists into the sorted list 1222 + if (pN->GetX() == DBL_MAX && pN->GetY() == DBL_MAX) 1223 + ; 1224 + else 1225 + { 1226 + if (pN->GetX() == x && pN->GetY() == y) 1227 + ; 1228 + else 1229 + *pOther = pN; 1230 + } 1231 + return pN; 1232 + } 1233 +// unexpected error; undefined Node 1234 + return NULL; 1235 +} 1236 + 1237 +NetNode *Network::ProcessNode(wxString & code, double x, double y, 1238 + NetNode ** pOther) 1239 +{ 1240 +// 1241 +// inserts a new node or retrieves an already defined one 1242 +// 1243 + NetNode *pN = Find(code); 1244 + *pOther = NULL; 1245 + if (pN) 1246 + { 1247 + // this Node already exists into the sorted list 1248 + if (pN->GetX() == DBL_MAX && pN->GetY() == DBL_MAX) 1249 + ; 1250 + else 1251 + { 1252 + if (pN->GetX() == x && pN->GetY() == y) 1253 + ; 1254 + else 1255 + *pOther = pN; 1256 + } 1257 + return pN; 1258 + } 1259 +// unexpected error; undefined Node 1260 + return NULL; 1261 +} 1262 + 1263 +void 1264 + Network::AddArc(int rowid, int id_from, int id_to, double node_from_x, 1265 + double node_from_y, double node_to_x, double node_to_y, 1266 + double cost) 1267 +{ 1268 +// 1269 +// inserting an arc into the memory structures 1270 +// 1271 + NetNode *pFrom; 1272 + NetNode *pTo; 1273 + NetNode *pN2; 1274 + NetArc *pA; 1275 + pFrom = ProcessNode(id_from, node_from_x, node_from_y, &pN2); 1276 + if (pN2) 1277 + Error = true; 1278 + pTo = ProcessNode(id_to, node_to_x, node_to_y, &pN2); 1279 + if (pN2) 1280 + Error = true; 1281 + if (!pFrom) 1282 + Error = true; 1283 + if (!pTo) 1284 + Error = true; 1285 + if (pFrom == pTo) 1286 + Error = true; 1287 + if (Error == true) 1288 + return; 1289 + pA = new NetArc(rowid, pFrom, pTo, cost); 1290 + if (!FirstArc) 1291 + FirstArc = pA; 1292 + if (LastArc) 1293 + LastArc->SetNext(pA); 1294 + LastArc = pA; 1295 +// updating Node connections 1296 + pFrom->AddOutcoming(pA); 1297 +} 1298 + 1299 +void 1300 + Network::AddArc(int rowid, const char *code_from, const char *code_to, 1301 + double node_from_x, double node_from_y, double node_to_x, 1302 + double node_to_y, double cost) 1303 +{ 1304 +// 1305 +// inserting an arc into the memory structures 1306 +// 1307 + NetNode *pFrom; 1308 + NetNode *pTo; 1309 + NetNode *pN2; 1310 + NetArc *pA; 1311 + wxString stCode = wxString::FromUTF8(code_from); 1312 + pFrom = ProcessNode(stCode, node_from_x, node_from_y, &pN2); 1313 + if (pN2) 1314 + Error = true; 1315 + stCode = wxString::FromUTF8(code_to); 1316 + pTo = ProcessNode(stCode, node_to_x, node_to_y, &pN2); 1317 + if (pN2) 1318 + Error = true; 1319 + if (!pFrom) 1320 + Error = true; 1321 + if (!pTo) 1322 + Error = true; 1323 + if (pFrom == pTo) 1324 + Error = true; 1325 + if (Error == true) 1326 + return; 1327 + pA = new NetArc(rowid, pFrom, pTo, cost); 1328 + if (!FirstArc) 1329 + FirstArc = pA; 1330 + if (LastArc) 1331 + LastArc->SetNext(pA); 1332 + LastArc = pA; 1333 +// updating Node connections 1334 + pFrom->AddOutcoming(pA); 1335 +} 1336 + 1337 +void Network::Sort() 1338 +{ 1339 +// 1340 +// updating the Nodes sorted list 1341 +// 1342 + int i; 1343 + NetNode *pN; 1344 + NumNodes = 0; 1345 + if (SortedNodes) 1346 + { 1347 + // we must free the already existent sorted list 1348 + delete[]SortedNodes; 1349 + } 1350 + SortedNodes = NULL; 1351 + pN = FirstNode; 1352 + while (pN) 1353 + { 1354 + NumNodes++; 1355 + pN = pN->GetNext(); 1356 + } 1357 + if (!NumNodes) 1358 + return; 1359 + SortedNodes = new NetNode *[NumNodes]; 1360 + i = 0; 1361 + pN = FirstNode; 1362 + while (pN) 1363 + { 1364 + *(SortedNodes + i++) = pN; 1365 + pN = pN->GetNext(); 1366 + } 1367 + if (NodeCode == true) 1368 + { 1369 + // Nodes are identified by a TEXT code 1370 + qsort(SortedNodes, NumNodes, sizeof(NetNode *), cmp_nodes1_code); 1371 + } else 1372 + { 1373 + // Nodes are identified by an INTEGER id 1374 + qsort(SortedNodes, NumNodes, sizeof(NetNode *), cmp_nodes1_id); 1375 + } 1376 +} 1377 + 1378 +NetNode *Network::GetSortedNode(int x) 1379 +{ 1380 +// 1381 +// return a sorted Node [by position] 1382 +// 1383 + if (x >= 0 && x < NumNodes) 1384 + return *(SortedNodes + x); 1385 + return NULL; 1386 +} 1387 + 1388 +NetNode *Network::Find(int id) 1389 +{ 1390 +// 1391 +// searching a Node into the sorted list 1392 +// 1393 + NetNode **ret; 1394 + NetNode pN(id); 1395 + if (!SortedNodes) 1396 + return NULL; 1397 +// Nodes are identified by an INTEGER id 1398 + ret = 1399 + (NetNode **) bsearch(&pN, SortedNodes, NumNodes, sizeof(NetNode *), 1400 + cmp_nodes2_id); 1401 + if (!ret) 1402 + return NULL; 1403 + return *ret; 1404 +} 1405 + 1406 +NetNode *Network::Find(wxString & code) 1407 +{ 1408 +// 1409 +// searching a Node into the sorted list 1410 +// 1411 + NetNode **ret; 1412 + NetNode pN(code); 1413 + if (!SortedNodes) 1414 + return NULL; 1415 +// Nodes are identified by a TEXT code 1416 + ret = 1417 + (NetNode **) bsearch(&pN, SortedNodes, NumNodes, sizeof(NetNode *), 1418 + cmp_nodes2_code); 1419 + if (!ret) 1420 + return NULL; 1421 + return *ret; 1422 +} 1423 + 1424 +void Network::InitNodes() 1425 +{ 1426 +// 1427 +// prepares the final Nodes list 1428 +// 1429 + int last_id; 1430 + wxString last_code; 1431 + int i; 1432 + NetNodePre *pP; 1433 + NumPreNodes = 0; 1434 +// sorting preliminary nodes 1435 + if (SortedPreNodes) 1436 + { 1437 + // we must free the already existent sorted list 1438 + delete[]SortedPreNodes; 1439 + } 1440 + SortedPreNodes = NULL; 1441 + pP = FirstPre; 1442 + while (pP) 1443 + { 1444 + NumPreNodes++; 1445 + pP = pP->GetNext(); 1446 + } 1447 + if (!NumPreNodes) 1448 + return; 1449 + SortedPreNodes = new NetNodePre *[NumPreNodes]; 1450 + i = 0; 1451 + pP = FirstPre; 1452 + while (pP) 1453 + { 1454 + *(SortedPreNodes + i++) = pP; 1455 + pP = pP->GetNext(); 1456 + } 1457 + if (NodeCode == true) 1458 + { 1459 + // Nodes are identified by a TEXT code 1460 + qsort(SortedPreNodes, NumPreNodes, sizeof(NetNodePre *), 1461 + cmp_prenodes_code); 1462 + } else 1463 + { 1464 + // Nodes are identified by an INTEGER id 1465 + qsort(SortedPreNodes, NumPreNodes, sizeof(NetNodePre *), cmp_prenodes_id); 1466 + } 1467 +// creating the final Nodes linked list 1468 + last_id = -1; 1469 + last_code = wxT(""); 1470 + for (i = 0; i < NumPreNodes; i++) 1471 + { 1472 + pP = *(SortedPreNodes + i); 1473 + if (NodeCode == true) 1474 + { 1475 + // Nodes are identified by a TEXT code 1476 + if (pP->GetCode().Cmp(last_code) != 0) 1477 + AddNode(pP->GetCode()); 1478 + } else 1479 + { 1480 + // Nodes are identified by an INTEGER id 1481 + if (pP->GetId() != last_id) 1482 + AddNode(pP->GetId()); 1483 + } 1484 + last_id = pP->GetId(); 1485 + last_code = pP->GetCode(); 1486 + } 1487 +// sorting the final Nodes list 1488 + Sort(); 1489 +// cleaning up the preliminary Nodes structs 1490 + CleanPreNodes(); 1491 +}
Changes to Objects.cpp.
1 1 /* 2 2 / Objects.cpp 3 3 / miscellaneous ancillary classes implementation 4 4 / 5 -/ version 1.1, 2008 September 13 5 +/ version 1.2, 2008 October 9 6 6 / 7 7 / Author: Sandro Furieri a-furieri@lqt.it 8 8 / 9 9 / Copyright (C) 2008 Alessandro Furieri 10 10 / 11 11 / This program is free software: you can redistribute it and/or modify 12 12 / it under the terms of the GNU General Public License as published by ................................................................................ 21 21 / You should have received a copy of the GNU General Public License 22 22 / along with this program. If not, see <http://www.gnu.org/licenses/>. 23 23 / 24 24 */ 25 25 26 26 #include "Classdef.h" 27 27 28 -MyObject::MyObject (int type, wxString & name) 28 +MyObject::MyObject(int type, wxString & name) 29 29 { 30 30 // 31 31 // constructor - TreeItemData 32 32 // 33 - Type = type; 34 - Name = name; 35 - Column = wxT (""); 33 + Type = type; 34 + Name = name; 35 + Column = wxT(""); 36 36 } 37 37 38 -MyObject::MyObject (int type, wxString & name, wxString & column) 38 +MyObject::MyObject(int type, wxString & name, wxString & column) 39 39 { 40 40 // 41 41 // constructor - TreeItemData 42 42 // 43 - Type = type; 44 - Name = name; 45 - Column = column; 43 + Type = type; 44 + Name = name; 45 + Column = column; 46 46 } 47 47 48 -void 49 -MyVariant::Copy (MyVariant * other) 48 +void MyVariant::Copy(MyVariant * other) 50 49 { 51 50 // 52 51 // transfers a BLOB value 53 52 // 54 - if (other->Type != MY_BLOB_VARIANT) 55 - return; 56 - if (!(other->Blob)) 57 - return; 58 - if (Blob) 59 - delete[]Blob; 60 - Type = MY_BLOB_VARIANT; 61 - BlobSize = other->BlobSize; 62 - Blob = other->Blob; 63 - other->Type = MY_NULL_VARIANT; 64 - other->Blob = NULL; 65 - other->BlobSize = 0; 53 + if (other->Type != MY_BLOB_VARIANT) 54 + return; 55 + if (!(other->Blob)) 56 + return; 57 + if (Blob) 58 + delete[]Blob; 59 + Type = MY_BLOB_VARIANT; 60 + BlobSize = other->BlobSize; 61 + Blob = other->Blob; 62 + other->Type = MY_NULL_VARIANT; 63 + other->Blob = NULL; 64 + other->BlobSize = 0; 66 65 } 67 66 68 -void 69 -MyVariant::Set (const unsigned char *text) 67 +void MyVariant::Set(const unsigned char *text) 70 68 { 71 69 // 72 70 // sets a String value for this Variant value 73 71 // 74 - Type = MY_TXT_VARIANT; 75 - TxtValue = wxString::FromUTF8 ((const char *) text); 72 + Type = MY_TXT_VARIANT; 73 + TxtValue = wxString::FromUTF8((const char *) text); 76 74 } 77 75 78 -void 79 -MyVariant::Set (const void *blob, int size) 76 +void MyVariant::Set(const void *blob, int size) 80 77 { 81 78 // 82 79 // sets a BLOB value for this Variant value 83 80 // 84 - if (size <= 0) 85 - return; 86 - Type = MY_BLOB_VARIANT; 87 - BlobSize = size; 88 - Blob = new unsigned char[size]; 89 - memcpy (Blob, blob, size); 81 + if (size <= 0) 82 + return; 83 + Type = MY_BLOB_VARIANT; 84 + BlobSize = size; 85 + Blob = new unsigned char[size]; 86 + memcpy(Blob, blob, size); 90 87 } 91 88 92 -void 93 -MyRowVariant::Create (int cols) 89 +void MyRowVariant::Create(int cols) 94 90 { 95 91 // 96 92 // creating the row variant 97 93 // 98 - if (ColumnArray) 99 - delete[]ColumnArray; 100 - NumCols = cols; 101 - ColumnArray = new MyVariant[NumCols]; 94 + if (ColumnArray) 95 + delete[]ColumnArray; 96 + NumCols = cols; 97 + ColumnArray = new MyVariant[NumCols]; 102 98 } 103 99 104 -void 105 -MyRowVariant::Set (int col, int value) 100 +void MyRowVariant::Set(int col, sqlite3_int64 value) 106 101 { 107 102 // 108 103 // setting an Integer value for the Nth column 109 104 // 110 - MyVariant *var; 111 - if (col < 0 || col >= NumCols) 112 - return; 113 - var = ColumnArray + col; 114 - var->Set (value); 105 + MyVariant *var; 106 + if (col < 0 || col >= NumCols) 107 + return; 108 + var = ColumnArray + col; 109 + var->Set(value); 115 110 } 116 111 117 -void 118 -MyRowVariant::Set (int col, double value) 112 +void MyRowVariant::Set(int col, double value) 119 113 { 120 114 // 121 115 // setting a Double value for the Nth column 122 116 // 123 - MyVariant *var; 124 - if (col < 0 || col >= NumCols) 125 - return; 126 - var = ColumnArray + col; 127 - var->Set (value); 117 + MyVariant *var; 118 + if (col < 0 || col >= NumCols) 119 + return; 120 + var = ColumnArray + col; 121 + var->Set(value); 128 122 } 129 123 130 -void 131 -MyRowVariant::Set (int col, const unsigned char *value) 124 +void MyRowVariant::Set(int col, const unsigned char *value) 132 125 { 133 126 // 134 127 // setting a String value for the Nth column 135 128 // 136 - MyVariant *var; 137 - if (col < 0 || col >= NumCols) 138 - return; 139 - var = ColumnArray + col; 140 - var->Set (value); 129 + MyVariant *var; 130 + if (col < 0 || col >= NumCols) 131 + return; 132 + var = ColumnArray + col; 133 + var->Set(value); 141 134 } 142 135 143 -void 144 -MyRowVariant::Set (int col, const void *blob, int size) 136 +void MyRowVariant::Set(int col, const void *blob, int size) 145 137 { 146 138 // 147 139 // setting a BLOB value for the Nth column 148 140 // 149 - MyVariant *var; 150 - if (col < 0 || col >= NumCols) 151 - return; 152 - var = ColumnArray + col; 153 - var->Set (blob, size); 141 + MyVariant *var; 142 + if (col < 0 || col >= NumCols) 143 + return; 144 + var = ColumnArray + col; 145 + var->Set(blob, size); 154 146 } 155 147 156 -MyVariant * 157 -MyRowVariant::GetColumn (int col) 148 +MyVariant *MyRowVariant::GetColumn(int col) 158 149 { 159 150 // 160 151 // returns a Column Variant Value 161 152 // 162 - MyVariant *var; 163 - if (col < 0 || col >= NumCols) 164 - return NULL; 165 - var = ColumnArray + col; 166 - return var; 153 + MyVariant *var; 154 + if (col < 0 || col >= NumCols) 155 + return NULL; 156 + var = ColumnArray + col; 157 + return var; 167 158 } 168 159 169 -MyVariantList::MyVariantList () 160 +MyVariantList::MyVariantList() 170 161 { 171 162 // 172 163 // constructor - result set container 173 164 // 174 - NumCols = 0; 175 - ColumnName = NULL; 176 - First = NULL; 177 - Last = NULL; 165 + NumCols = 0; 166 + ColumnName = NULL; 167 + First = NULL; 168 + Last = NULL; 178 169 } 179 170 180 -MyVariantList::~MyVariantList () 171 +MyVariantList::~MyVariantList() 181 172 { 182 173 // 183 174 // destructor - result set container 184 175 // 185 - MyRowVariant *el; 186 - MyRowVariant *elN; 187 - if (ColumnName) 188 - delete[]ColumnName; 189 - el = First; 190 - while (el) 191 - { 192 - elN = el->GetNext (); 193 - delete el; 194 - el = elN; 195 - } 176 + MyRowVariant *el; 177 + MyRowVariant *elN; 178 + if (ColumnName) 179 + delete[]ColumnName; 180 + el = First; 181 + while (el) 182 + { 183 + elN = el->GetNext(); 184 + delete el; 185 + el = elN; 186 + } 196 187 } 197 188 198 -int 199 -MyVariantList::GetRows () 189 +int MyVariantList::GetRows() 200 190 { 201 191 // 202 192 // counting how many rows are there 203 193 // 204 - int cnt = 0; 205 - MyRowVariant *el = First; 206 - while (el) 207 - { 208 - cnt++; 209 - el = el->GetNext (); 210 - } 211 - return cnt; 194 + int cnt = 0; 195 + MyRowVariant *el = First; 196 + while (el) 197 + { 198 + cnt++; 199 + el = el->GetNext(); 200 + } 201 + return cnt; 212 202 } 213 203 214 -MyRowVariant * 215 -MyVariantList::Add (int columns) 204 +MyRowVariant *MyVariantList::Add(int columns) 216 205 { 217 206 // 218 207 // adds a row into the result set 219 208 // 220 - if (!NumCols) 221 - { 222 - NumCols = columns; 223 - ColumnName = new wxString[NumCols]; 224 - } 225 - MyRowVariant *el = new MyRowVariant (columns); 226 - if (!First) 227 - First = el; 228 - if (Last) 229 - Last->SetNext (el); 230 - Last = el; 231 - return el; 209 + if (!NumCols) 210 + { 211 + NumCols = columns; 212 + ColumnName = new wxString[NumCols]; 213 + } 214 + MyRowVariant *el = new MyRowVariant(columns); 215 + if (!First) 216 + First = el; 217 + if (Last) 218 + Last->SetNext(el); 219 + Last = el; 220 + return el; 232 221 } 233 222 234 -void 235 -MyVariantList::SetColumnName (int col, const char *name) 223 +void MyVariantList::SetColumnName(int col, const char *name) 236 224 { 237 225 // 238 226 // storing a column name 239 227 // 240 - if (col < 0 || col >= NumCols) 241 - return; 242 - ColumnName[col] = wxString::FromUTF8 (name); 228 + if (col < 0 || col >= NumCols) 229 + return; 230 + ColumnName[col] = wxString::FromUTF8(name); 243 231 } 244 232 245 -wxString & MyVariantList::GetColumnName (int col) 233 +wxString & MyVariantList::GetColumnName(int col) 246 234 { 247 235 // 248 236 // retrieving a column name 249 237 // 250 - return ColumnName[col]; 238 + return ColumnName[col]; 251 239 } 252 240 253 -MyBlobs::MyBlobs (int rows, int cols) 241 +MyBlobs::MyBlobs(int rows, int cols) 254 242 { 255 243 // 256 244 // constructor - a BLOB matrix 257 245 // 258 - int r; 259 - MyRowVariant *rowVar; 260 - NumRows = 0; 261 - NumCols = 0; 262 - Rows = NULL; 263 - if (rows < 1 || cols < 1) 264 - return; 265 - NumRows = rows; 266 - NumCols = cols; 267 - Rows = new MyRowVariant[rows]; 268 - for (r = 0; r < rows; r++) 269 - { 270 - rowVar = Rows + r; 271 - rowVar->Create (cols); 272 - } 246 + int r; 247 + MyRowVariant *rowVar; 248 + NumRows = 0; 249 + NumCols = 0; 250 + Rows = NULL; 251 + if (rows < 1 || cols < 1) 252 + return; 253 + NumRows = rows; 254 + NumCols = cols; 255 + Rows = new MyRowVariant[rows]; 256 + for (r = 0; r < rows; r++) 257 + { 258 + rowVar = Rows + r; 259 + rowVar->Create(cols); 260 + } 273 261 } 274 262 275 -MyBlobs::~MyBlobs () 263 +MyBlobs::~MyBlobs() 276 264 { 277 265 // 278 266 // destructor - a BLOB matrix 279 267 // 280 - if (Rows) 281 - delete[]Rows; 268 + if (Rows) 269 + delete[]Rows; 282 270 } 283 271 284 -void 285 -MyBlobs::SetBlob (int row, int col, MyVariant * org) 272 +void MyBlobs::SetBlob(int row, int col, MyVariant * org) 286 273 { 287 274 // 288 275 // setting a BLOB value 289 276 // 290 - MyRowVariant *rowVar; 291 - MyVariant *dest; 292 - if (row < 0 || row >= NumRows) 293 - return; 294 - if (col < 0 || col >= NumCols) 295 - return; 296 - rowVar = Rows + row; 297 - if (!rowVar) 298 - return; 299 - dest = rowVar->GetColumn (col); 300 - if (!dest) 301 - return; 302 - dest->Copy (org); 277 + MyRowVariant *rowVar; 278 + MyVariant *dest; 279 + if (row < 0 || row >= NumRows) 280 + return; 281 + if (col < 0 || col >= NumCols) 282 + return; 283 + rowVar = Rows + row; 284 + if (!rowVar) 285 + return; 286 + dest = rowVar->GetColumn(col); 287 + if (!dest) 288 + return; 289 + dest->Copy(org); 303 290 } 304 291 305 -MyVariant * 306 -MyBlobs::GetBlob (int row, int col) 292 +MyVariant *MyBlobs::GetBlob(int row, int col) 307 293 { 308 294 // 309 295 // return a BLOB value 310 296 // 311 - MyRowVariant *rowVar; 312 - MyVariant *dest; 313 - if (row < 0 || row >= NumRows) 314 - return NULL; 315 - if (col < 0 || col >= NumCols) 316 - return NULL; 317 - rowVar = Rows + row; 318 - if (!rowVar) 319 - return NULL; 320 - dest = rowVar->GetColumn (col); 321 - if (!dest) 322 - return NULL; 323 - if (dest->GetType () != MY_BLOB_VARIANT) 324 - return NULL; 325 - return dest; 297 + MyRowVariant *rowVar; 298 + MyVariant *dest; 299 + if (row < 0 || row >= NumRows) 300 + return NULL; 301 + if (col < 0 || col >= NumCols) 302 + return NULL; 303 + rowVar = Rows + row; 304 + if (!rowVar) 305 + return NULL; 306 + dest = rowVar->GetColumn(col); 307 + if (!dest) 308 + return NULL; 309 + if (dest->GetType() != MY_BLOB_VARIANT) 310 + return NULL; 311 + return dest; 326 312 } 327 313 328 -MyValues::MyValues (int rows, int cols) 314 +MyValues::MyValues(int rows, int cols) 329 315 { 330 316 // 331 317 // constructor - a generic values matrix 332 318 // 333 - int r; 334 - MyRowVariant *rowVar; 335 - NumRows = 0; 336 - NumCols = 0; 337 - Rows = NULL; 338 - if (rows < 1 || cols < 1) 339 - return; 340 - NumRows = rows; 341 - NumCols = cols; 342 - Rows = new MyRowVariant[rows]; 343 - for (r = 0; r < rows; r++) 344 - { 345 - rowVar = Rows + r; 346 - rowVar->Create (cols); 347 - } 319 + int r; 320 + MyRowVariant *rowVar; 321 + NumRows = 0; 322 + NumCols = 0; 323 + Rows = NULL; 324 + if (rows < 1 || cols < 1) 325 + return; 326 + NumRows = rows; 327 + NumCols = cols; 328 + Rows = new MyRowVariant[rows]; 329 + for (r = 0; r < rows; r++) 330 + { 331 + rowVar = Rows + r; 332 + rowVar->Create(cols); 333 + } 348 334 } 349 335 350 -MyValues::~MyValues () 336 +MyValues::~MyValues() 351 337 { 352 338 // 353 339 // destructor - a generic values matrix 354 340 // 355 - if (Rows) 356 - delete[]Rows; 341 + if (Rows) 342 + delete[]Rows; 357 343 } 358 344 359 -void 360 -MyValues::SetValue (int row, int col, int value) 345 +void MyValues::SetValue(int row, int col, sqlite3_int64 value) 361 346 { 362 347 // 363 348 // setting an integer value 364 349 // 365 - MyRowVariant *rowVar; 366 - MyVariant *dest; 367 - if (row < 0 || row >= NumRows) 368 - return; 369 - if (col < 0 || col >= NumCols) 370 - return; 371 - rowVar = Rows + row; 372 - if (!rowVar) 373 - return; 374 - dest = rowVar->GetColumn (col); 375 - if (!dest) 376 - return; 377 - dest->Set (value); 350 + MyRowVariant *rowVar; 351 + MyVariant *dest; 352 + if (row < 0 || row >= NumRows) 353 + return; 354 + if (col < 0 || col >= NumCols) 355 + return; 356 + rowVar = Rows + row; 357 + if (!rowVar) 358 + return; 359 + dest = rowVar->GetColumn(col); 360 + if (!dest) 361 + return; 362 + dest->Set(value); 378 363 } 379 364 380 -void 381 -MyValues::SetValue (int row, int col, double value) 365 +void MyValues::SetValue(int row, int col, double value) 382 366 { 383 367 // 384 368 // setting a double value 385 369 // 386 - MyRowVariant *rowVar; 387 - MyVariant *dest; 388 - if (row < 0 || row >= NumRows) 389 - return; 390 - if (col < 0 || col >= NumCols) 391 - return; 392 - rowVar = Rows + row; 393 - if (!rowVar) 394 - return; 395 - dest = rowVar->GetColumn (col); 396 - if (!dest) 397 - return; 398 - dest->Set (value); 370 + MyRowVariant *rowVar; 371 + MyVariant *dest; 372 + if (row < 0 || row >= NumRows) 373 + return; 374 + if (col < 0 || col >= NumCols) 375 + return; 376 + rowVar = Rows + row; 377 + if (!rowVar) 378 + return; 379 + dest = rowVar->GetColumn(col); 380 + if (!dest) 381 + return; 382 + dest->Set(value); 399 383 } 400 384 401 -void 402 -MyValues::SetValue (int row, int col, wxString & value) 385 +void MyValues::SetValue(int row, int col, wxString & value) 403 386 { 404 387 // 405 388 // setting a string value 406 389 // 407 - MyRowVariant *rowVar; 408 - MyVariant *dest; 409 - if (row < 0 || row >= NumRows) 410 - return; 411 - if (col < 0 || col >= NumCols) 412 - return; 413 - rowVar = Rows + row; 414 - if (!rowVar) 415 - return; 416 - dest = rowVar->GetColumn (col); 417 - if (!dest) 418 - return; 419 - dest->Set (value); 390 + MyRowVariant *rowVar; 391 + MyVariant *dest; 392 + if (row < 0 || row >= NumRows) 393 + return; 394 + if (col < 0 || col >= NumCols) 395 + return; 396 + rowVar = Rows + row; 397 + if (!rowVar) 398 + return; 399 + dest = rowVar->GetColumn(col); 400 + if (!dest) 401 + return; 402 + dest->Set(value); 420 403 } 421 404 422 -MyVariant * 423 -MyValues::GetValue (int row, int col) 405 +MyVariant *MyValues::GetValue(int row, int col) 424 406 { 425 407 // 426 408 // return a generic value 427 409 // 428 - MyRowVariant *rowVar; 429 - MyVariant *dest; 430 - if (row < 0 || row >= NumRows) 431 - return NULL; 432 - if (col < 0 || col >= NumCols) 433 - return NULL; 434 - rowVar = Rows + row; 435 - if (!rowVar) 436 - return NULL; 437 - dest = rowVar->GetColumn (col); 438 - if (!dest) 439 - return NULL; 440 - return dest; 410 + MyRowVariant *rowVar; 411 + MyVariant *dest; 412 + if (row < 0 || row >= NumRows) 413 + return NULL; 414 + if (col < 0 || col >= NumCols) 415 + return NULL; 416 + rowVar = Rows + row; 417 + if (!rowVar) 418 + return NULL; 419 + dest = rowVar->GetColumn(col); 420 + if (!dest) 421 + return NULL; 422 + return dest; 441 423 } 442 424 443 -MyRowVariant * 444 -MyValues::GetRow (int row) 425 +MyRowVariant *MyValues::GetRow(int row) 445 426 { 446 427 // 447 428 // return a row of generic values 448 429 // 449 - MyRowVariant *rowVar; 450 - if (row < 0 || row >= NumRows) 451 - return NULL; 452 - rowVar = Rows + row; 453 - return rowVar; 430 + MyRowVariant *rowVar; 431 + if (row < 0 || row >= NumRows) 432 + return NULL; 433 + rowVar = Rows + row; 434 + return rowVar; 454 435 } 455 436 456 -MyColumnInfo::MyColumnInfo (wxString & name, bool pkey) 437 +MyColumnInfo::MyColumnInfo(wxString & name, bool pkey) 457 438 { 458 439 // 459 440 // constructor - a table column object 460 441 // 461 - Name = name; 462 - PrimaryKey = pkey; 463 - Geometry = false; 464 - GeometryIndex = false; 465 - Next = NULL; 442 + Name = name; 443 + PrimaryKey = pkey; 444 + Geometry = false; 445 + GeometryIndex = false; 446 + MbrCache = false; 447 + Next = NULL; 466 448 } 467 449 468 -MyIndexInfo::MyIndexInfo (wxString & name) 450 +MyIndexInfo::MyIndexInfo(wxString & name) 469 451 { 470 452 // 471 453 // constructor - a table index object 472 454 // 473 - Name = name; 474 - Next = NULL; 455 + Name = name; 456 + Next = NULL; 475 457 } 476 458 477 -MyTriggerInfo::MyTriggerInfo (wxString & name) 459 +MyTriggerInfo::MyTriggerInfo(wxString & name) 478 460 { 479 461 // 480 462 // constructor - a table trigger object 481 463 // 482 - Name = name; 483 - Next = NULL; 464 + Name = name; 465 + Next = NULL; 484 466 } 485 467 486 -MyTableInfo::~MyTableInfo () 468 +MyTableInfo::~MyTableInfo() 487 469 { 488 470 // 489 471 // destructor - a table columns collection 490 472 // 491 - MyColumnInfo *elc; 492 - MyColumnInfo *elcN; 493 - MyIndexInfo *eli; 494 - MyIndexInfo *eliN; 495 - MyTriggerInfo *elt; 496 - MyTriggerInfo *eltN; 497 - elc = FirstColumn; 498 - while (elc) 499 - { 500 - elcN = elc->GetNext (); 501 - delete elc; 502 - elc = elcN; 503 - } 504 - eli = FirstIndex; 505 - while (eli) 506 - { 507 - eliN = eli->GetNext (); 508 - delete eli; 509 - eli = eliN; 510 - } 511 - elt = FirstTrigger; 512 - while (elt) 513 - { 514 - eltN = elt->GetNext (); 515 - delete elt; 516 - elt = eltN; 517 - } 518 -} 519 - 520 -void 521 -MyTableInfo::AddColumn (wxString & name, bool pkey) 473 + MyColumnInfo *elc; 474 + MyColumnInfo *elcN; 475 + MyIndexInfo *eli; 476 + MyIndexInfo *eliN; 477 + MyTriggerInfo *elt; 478 + MyTriggerInfo *eltN; 479 + elc = FirstColumn; 480 + while (elc) 481 + { 482 + elcN = elc->GetNext(); 483 + delete elc; 484 + elc = elcN; 485 + } 486 + eli = FirstIndex; 487 + while (eli) 488 + { 489 + eliN = eli->GetNext(); 490 + delete eli; 491 + eli = eliN; 492 + } 493 + elt = FirstTrigger; 494 + while (elt) 495 + { 496 + eltN = elt->GetNext(); 497 + delete elt; 498 + elt = eltN; 499 + } 500 +} 501 + 502 +void MyTableInfo::AddColumn(wxString & name, bool pkey) 522 503 { 523 504 // 524 505 // inserting a column def into a table 525 506 // 526 - MyColumnInfo *el = new MyColumnInfo (name, pkey); 527 - if (!FirstColumn) 528 - FirstColumn = el; 529 - if (LastColumn) 530 - LastColumn->SetNext (el); 531 - LastColumn = el; 507 + MyColumnInfo *el = new MyColumnInfo(name, pkey); 508 + if (!FirstColumn) 509 + FirstColumn = el; 510 + if (LastColumn) 511 + LastColumn->SetNext(el); 512 + LastColumn = el; 532 513 } 533 514 534 -void 535 -MyTableInfo::SetGeometry (wxString & name, bool index, bool cached) 515 +void MyTableInfo::SetGeometry(wxString & name, bool index, bool cached) 536 516 { 537 517 // 538 518 //setting a geometry column 539 519 // 540 - MyColumnInfo *elc; 541 - elc = FirstColumn; 542 - while (elc) 543 - { 544 - if (name == elc->GetName ()) 545 - { 546 - elc->SetGeometry (); 547 - if (index == true) 548 - elc->SetGeometryIndex (); 549 - if (cached == true) 550 - elc->SetMbrCache (); 551 - } 552 - elc = elc->GetNext (); 553 - } 520 + MyColumnInfo *elc; 521 + elc = FirstColumn; 522 + while (elc) 523 + { 524 + if (name == elc->GetName()) 525 + { 526 + elc->SetGeometry(); 527 + if (index == true) 528 + elc->SetGeometryIndex(); 529 + if (cached == true) 530 + elc->SetMbrCache(); 531 + } 532 + elc = elc->GetNext(); 533 + } 554 534 } 555 535 556 -void 557 -MyTableInfo::AddIndex (wxString & name) 536 +void MyTableInfo::AddIndex(wxString & name) 558 537 { 559 538 // 560 539 // inserting an index def into a table 561 540 // 562 - MyIndexInfo *el = new MyIndexInfo (name); 563 - if (!FirstIndex) 564 - FirstIndex = el; 565 - if (LastIndex) 566 - LastIndex->SetNext (el); 567 - LastIndex = el; 541 + MyIndexInfo *el = new MyIndexInfo(name); 542 + if (!FirstIndex) 543 + FirstIndex = el; 544 + if (LastIndex) 545 + LastIndex->SetNext(el); 546 + LastIndex = el; 568 547 } 569 548 570 -void 571 -MyTableInfo::AddTrigger (wxString & name) 549 +void MyTableInfo::AddTrigger(wxString & name) 572 550 { 573 551 // 574 552 // inserting a trigger def into a table 575 553 // 576 - MyTriggerInfo *el = new MyTriggerInfo (name); 577 - if (!FirstTrigger) 578 - FirstTrigger = el; 579 - if (LastTrigger) 580 - LastTrigger->SetNext (el); 581 - LastTrigger = el; 554 + MyTriggerInfo *el = new MyTriggerInfo(name); 555 + if (!FirstTrigger) 556 + FirstTrigger = el; 557 + if (LastTrigger) 558 + LastTrigger->SetNext(el); 559 + LastTrigger = el; 582 560 } 583 561 584 -MyViewInfo::~MyViewInfo () 562 +MyViewInfo::~MyViewInfo() 585 563 { 586 564 // 587 565 // destructor - a view columns collection 588 566 // 589 - MyColumnInfo *elc; 590 - MyColumnInfo *elcN; 591 - elc = First; 592 - while (elc) 593 - { 594 - elcN = elc->GetNext (); 595 - delete elc; 596 - elc = elcN; 597 - } 567 + MyColumnInfo *elc; 568 + MyColumnInfo *elcN; 569 + elc = First; 570 + while (elc) 571 + { 572 + elcN = elc->GetNext(); 573 + delete elc; 574 + elc = elcN; 575 + } 598 576 } 599 577 600 -void 601 -MyViewInfo::AddColumn (wxString & name) 578 +void MyViewInfo::AddColumn(wxString & name) 602 579 { 603 580 // 604 581 // inserting a column def into a view 605 582 // 606 - MyColumnInfo *el = new MyColumnInfo (name, false); 607 - if (!First) 608 - First = el; 609 - if (Last) 610 - Last->SetNext (el); 611 - Last = el; 583 + MyColumnInfo *el = new MyColumnInfo(name, false); 584 + if (!First) 585 + First = el; 586 + if (Last) 587 + Last->SetNext(el); 588 + Last = el; 612 589 } 613 590 614 -MySqlHistory::~MySqlHistory () 591 +MySqlHistory::~MySqlHistory() 615 592 { 616 593 // 617 594 // destructor - the SQL queries history 618 595 // 619 - MySqlQuery *elq; 620 - MySqlQuery *elqN; 621 - elq = First; 622 - while (elq) 623 - { 624 - elqN = elq->GetNext (); 625 - delete elq; 626 - elq = elqN; 627 - } 596 + MySqlQuery *elq; 597 + MySqlQuery *elqN; 598 + elq = First; 599 + while (elq) 600 + { 601 + elqN = elq->GetNext(); 602 + delete elq; 603 + elq = elqN; 604 + } 628 605 } 629 606 630 -void 631 -MySqlHistory::Add (wxString & sql) 607 +void MySqlHistory::Add(wxString & sql) 632 608 { 633 609 // 634 610 // inserting an SQL query into the history 635 611 // 636 - if (Last) 637 - { 638 - // avoiding stupid duplicates 639 - if (Last->GetSql () == sql) 640 - return; 641 - } 642 - MySqlQuery *el = new MySqlQuery (sql); 643 - if (!First) 644 - First = el; 645 - el->SetPrev (Last); 646 - if (Last) 647 - Last->SetNext (el); 648 - Last = el; 649 - Current = el; 612 + if (Last) 613 + { 614 + // avoiding stupid duplicates 615 + if (Last->GetSql() == sql) 616 + return; 617 + } 618 + MySqlQuery *el = new MySqlQuery(sql); 619 + if (!First) 620 + First = el; 621 + el->SetPrev(Last); 622 + if (Last) 623 + Last->SetNext(el); 624 + Last = el; 625 + Current = el; 650 626 } 651 627 652 -MySqlQuery * 653 -MySqlHistory::GetNext () 628 +MySqlQuery *MySqlHistory::GetNext() 654 629 { 655 630 // 656 631 // return the next SQL query 657 632 // 658 - if (Current) 659 - { 660 - if (Current->GetNext ()) 661 - { 662 - Current = Current->GetNext (); 663 - return Current; 664 - } 665 - else 666 - return NULL; 667 - } 668 - return NULL; 633 + if (Current) 634 + { 635 + if (Current->GetNext()) 636 + { 637 + Current = Current->GetNext(); 638 + return Current; 639 + } else 640 + return NULL; 641 + } 642 + return NULL; 669 643 } 670 644 671 -MySqlQuery * 672 -MySqlHistory::GetPrev () 645 +MySqlQuery *MySqlHistory::GetPrev() 673 646 { 674 647 // 675 648 // return the previous SQL query 676 649 // 677 - if (Current) 678 - { 679 - if (Current->GetPrev ()) 680 - { 681 - Current = Current->GetPrev (); 682 - return Current; 683 - } 684 - else 685 - return NULL; 686 - } 687 - return NULL; 650 + if (Current) 651 + { 652 + if (Current->GetPrev()) 653 + { 654 + Current = Current->GetPrev(); 655 + return Current; 656 + } else 657 + return NULL; 658 + } 659 + return NULL; 688 660 } 689 661 690 -bool 691 -MySqlHistory::TestNext () 662 +bool MySqlHistory::TestNext() 692 663 { 693 664 // 694 665 // tests if the next SQL query exists 695 666 // 696 - if (Current) 697 - { 698 - if (Current->GetNext ()) 699 - return true; 700 - else 701 - return false; 702 - } 703 - return false; 667 + if (Current) 668 + { 669 + if (Current->GetNext()) 670 + return true; 671 + else 672 + return false; 673 + } 674 + return false; 704 675 } 705 676 706 -bool 707 -MySqlHistory::TestPrev () 677 +bool MySqlHistory::TestPrev() 708 678 { 709 679 // 710 680 // tests if the previous SQL query exists 711 681 // 712 - if (Current) 713 - { 714 - if (Current->GetPrev ()) 715 - return true; 716 - else 717 - return false; 718 - } 719 - return false; 682 + if (Current) 683 + { 684 + if (Current->GetPrev()) 685 + return true; 686 + else 687 + return false; 688 + } 689 + return false; 690 +} 691 + 692 +AutoFDOTables::~AutoFDOTables() 693 +{ 694 +// 695 +// destructor - auto FDO-OGR wrapper linked list 696 +// 697 + AutoFDOTable *el; 698 + AutoFDOTable *elN; 699 + el = First; 700 + while (el) 701 + { 702 + elN = el->GetNext(); 703 + delete el; 704 + el = elN; 705 + } 706 +} 707 + 708 +void AutoFDOTables::Add(const char *name, const int len) 709 +{ 710 +// 711 +// adding a table name to the auto FDO-OGR wrapper linked list 712 +// 713 + AutoFDOTable *el = new AutoFDOTable(name, len); 714 + if (!First) 715 + First = el; 716 + if (Last) 717 + Last->SetNext(el); 718 + Last = el; 720 719 }
Changes to QueryView.cpp.
1 1 /* 2 2 / QueryView.cpp 3 -/ a panel to set and show SQL queries 3 +/ a panel to set SQL queries 4 4 / 5 -/ version 1.1, 2008 September 13 5 +/ version 1.2, 2008 October 9 6 6 / 7 7 / Author: Sandro Furieri a-furieri@lqt.it 8 8 / 9 9 / Copyright (C) 2008 Alessandro Furieri 10 10 / 11 11 / This program is free software: you can redistribute it and/or modify 12 12 / it under the terms of the GNU General Public License as published by ................................................................................ 32 32 // ICONs in XPM format [universally portable] 33 33 // 34 34 #include "icons/sql_go.xpm" 35 35 #include "icons/hs_back.xpm" 36 36 #include "icons/hs_back_no.xpm" 37 37 #include "icons/hs_forward.xpm" 38 38 #include "icons/hs_forward_no.xpm" 39 -#include "icons/rs_first.xpm" 40 -#include "icons/rs_last.xpm" 41 -#include "icons/rs_next.xpm" 42 -#include "icons/rs_previous.xpm" 43 -#include "icons/refresh.xpm" 44 39 45 -MyQueryView::MyQueryView (MyFrame * parent, wxWindowID id): 46 -wxPanel (parent, id, wxDefaultPosition, wxSize (440, 480), wxBORDER_SUNKEN) 40 +MyQueryView::MyQueryView(MyFrame * parent, wxWindowID id): 41 +wxPanel(parent, id, wxDefaultPosition, wxSize(440, 76), wxBORDER_SUNKEN) 47 42 { 48 43 // 49 44 // constructor: a frame for SQL Queries 50 45 // 51 - RsBlock = 500; // the ResultSet block size 52 - RowIds = new int[RsBlock]; 53 - ReadOnly = true; 54 - InsertRow = NULL; 55 - MainFrame = parent; 46 + MainFrame = parent; 47 + BracketStart = -1; 48 + BracketEnd = -1; 49 + IgnoreEvent = false; 56 50 // SQL statement 57 - SqlCtrl = 58 - new wxTextCtrl (this, ID_SQL, wxT (""), wxPoint (40, 5), 59 - wxSize (200, 20), 60 - wxTE_MULTILINE | wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB | 61 - wxHSCROLL); 62 - BtnSqlGo = 63 - new wxBitmapButton (this, ID_SQL_GO, wxBitmap (sql_go_xpm), 64 - wxPoint (340, 30), wxSize (32, 48)); 65 - BtnSqlGo->SetToolTip (wxT ("Execute SQL statement")); 66 - BtnHistoryBack = 67 - new wxBitmapButton (this, ID_HISTORY_BACK, wxBitmap (hs_back_xpm), 68 - wxPoint (5, 5), wxSize (32, 48)); 69 - BtnHistoryBack->SetBitmapDisabled (wxBitmap (hs_back_no_xpm)); 70 - BtnHistoryBack->SetToolTip (wxT ("History: previous SQL statement")); 71 - BtnHistoryForward = 72 - new wxBitmapButton (this, ID_HISTORY_FORWARD, wxBitmap (hs_forward_xpm), 73 - wxPoint (5, 55), wxSize (32, 48)); 74 - BtnHistoryForward->SetBitmapDisabled (wxBitmap (hs_forward_no_xpm)); 75 - BtnHistoryForward->SetToolTip (wxT ("History: next SQL statement")); 76 - BtnRsFirst = 77 - new wxBitmapButton (this, ID_RS_FIRST, wxBitmap (rs_first_xpm), 78 - wxPoint (5, 400), wxSize (32, 32)); 79 - BtnRsFirst->SetToolTip (wxT ("ResultSet: go to first row")); 80 - BtnRsPrevious = 81 - new wxBitmapButton (this, ID_RS_PREVIOUS, wxBitmap (rs_previous_xpm), 82 - wxPoint (55, 400), wxSize (32, 32)); 83 - BtnRsPrevious->SetToolTip (wxT ("ResultSet: go to previous block")); 84 - BtnRefresh = 85 - new wxBitmapButton (this, ID_REFRESH, wxBitmap (refresh_xpm), 86 - wxPoint (55, 400), wxSize (32, 32)); 87 - BtnRefresh->SetToolTip (wxT ("ResultSet: refresh")); 88 - BtnRsNext = 89 - new wxBitmapButton (this, ID_RS_NEXT, wxBitmap (rs_next_xpm), 90 - wxPoint (105, 400), wxSize (32, 32)); 91 - BtnRsNext->SetToolTip (wxT ("ResultSet: go to next block")); 92 - BtnRsLast = 93 - new wxBitmapButton (this, ID_RS_LAST, wxBitmap (rs_last_xpm), 94 - wxPoint (155, 400), wxSize (32, 32)); 95 - BtnRsLast->SetToolTip (wxT ("ResultSet: go to last row")); 96 - RsCurrentBlock = 97 - new wxStaticText (this, ID_RS_BLOCK, wxT (""), wxPoint (210, 400), 98 - wxSize (200, 18)); 99 - TableView = NULL; 100 - TableBlobs = NULL; 101 - TableValues = NULL; 102 - CurrentBlob = NULL; 103 - SetHistoryStates (); 51 + SqlCtrl = 52 + new MySqlControl(this, ID_SQL, wxT(""), wxPoint(40, 5), 53 + wxSize(20, 20), 54 + wxTE_MULTILINE | wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB | 55 + wxHSCROLL | wxTE_RICH); 56 + BtnSqlGo = 57 + new wxBitmapButton(this, ID_SQL_GO, wxBitmap(sql_go_xpm), wxPoint(340, 5), 58 + wxSize(32, 69)); 59 + BtnSqlGo->SetToolTip(wxT("Execute SQL statement")); 60 + BtnHistoryBack = 61 + new wxBitmapButton(this, ID_HISTORY_BACK, wxBitmap(hs_back_xpm), 62 + wxPoint(5, 5), wxSize(32, 32)); 63 + BtnHistoryBack->SetBitmapDisabled(wxBitmap(hs_back_no_xpm)); 64 + BtnHistoryBack->SetToolTip(wxT("History: previous SQL statement")); 65 + BtnHistoryForward = 66 + new wxBitmapButton(this, ID_HISTORY_FORWARD, wxBitmap(hs_forward_xpm), 67 + wxPoint(5, 40), wxSize(32, 32)); 68 + BtnHistoryForward->SetBitmapDisabled(wxBitmap(hs_forward_no_xpm)); 69 + BtnHistoryForward->SetToolTip(wxT("History: next SQL statement")); 70 + SetHistoryStates(); 104 71 // setting up event handlers 105 - Connect (ID_SQL_GO, wxEVT_COMMAND_BUTTON_CLICKED, 106 - (wxObjectEventFunction) & MyQueryView::OnSqlGo); 107 - Connect (ID_HISTORY_BACK, wxEVT_COMMAND_BUTTON_CLICKED, 108 - (wxObjectEventFunction) & MyQueryView::OnHistoryBack); 109 - Connect (ID_HISTORY_FORWARD, wxEVT_COMMAND_BUTTON_CLICKED, 110 - (wxObjectEventFunction) & MyQueryView::OnHistoryForward); 111 - Connect (ID_RS_FIRST, wxEVT_COMMAND_BUTTON_CLICKED, 112 - (wxObjectEventFunction) & MyQueryView::OnRsFirst); 113 - Connect (ID_RS_PREVIOUS, wxEVT_COMMAND_BUTTON_CLICKED, 114 - (wxObjectEventFunction) & MyQueryView::OnRsPrevious); 115 - Connect (ID_RS_NEXT, wxEVT_COMMAND_BUTTON_CLICKED, 116 - (wxObjectEventFunction) & MyQueryView::OnRsNext); 117 - Connect (ID_RS_LAST, wxEVT_COMMAND_BUTTON_CLICKED, 118 - (wxObjectEventFunction) & MyQueryView::OnRsLast); 119 - Connect (ID_REFRESH, wxEVT_COMMAND_BUTTON_CLICKED, 120 - (wxObjectEventFunction) & MyQueryView::OnRefresh); 121 - Connect (wxID_ANY, wxEVT_SIZE, 122 - (wxObjectEventFunction) & MyQueryView::OnSize); 123 - Connect (wxID_ANY, wxEVT_GRID_SELECT_CELL, 124 - (wxObjectEventFunction) & MyQueryView::OnCellSelected); 125 - Connect (wxID_ANY, wxEVT_GRID_CELL_RIGHT_CLICK, 126 - (wxObjectEventFunction) & MyQueryView::OnRightClick); 127 - Connect (wxID_ANY, wxEVT_GRID_CELL_CHANGE, 128 - (wxObjectEventFunction) & MyQueryView::OnCellChanged); 129 - Connect (Grid_Delete, wxEVT_COMMAND_MENU_SELECTED, 130 - (wxObjectEventFunction) & MyQueryView::OnCmdDelete); 131 - Connect (Grid_Insert, wxEVT_COMMAND_MENU_SELECTED, 132 - (wxObjectEventFunction) & MyQueryView::OnCmdInsert); 133 - Connect (Grid_Abort, wxEVT_COMMAND_MENU_SELECTED, 134 - (wxObjectEventFunction) & MyQueryView::OnCmdAbort); 135 - Connect (Grid_Clear, wxEVT_COMMAND_MENU_SELECTED, 136 - (wxObjectEventFunction) & MyQueryView::OnCmdClearSelection); 137 - Connect (Grid_All, wxEVT_COMMAND_MENU_SELECTED, 138 - (wxObjectEventFunction) & MyQueryView::OnCmdSelectAll); 139 - Connect (Grid_Row, wxEVT_COMMAND_MENU_SELECTED, 140 - (wxObjectEventFunction) & MyQueryView::OnCmdSelectRow); 141 - Connect (Grid_Column, wxEVT_COMMAND_MENU_SELECTED, 142 - (wxObjectEventFunction) & MyQueryView::OnCmdSelectColumn); 143 - Connect (Grid_Copy, wxEVT_COMMAND_MENU_SELECTED, 144 - (wxObjectEventFunction) & MyQueryView::OnCmdCopy); 145 - Connect (Grid_Blob, wxEVT_COMMAND_MENU_SELECTED, 146 - (wxObjectEventFunction) & MyQueryView::OnCmdBlob); 147 - Connect (Grid_BlobIn, wxEVT_COMMAND_MENU_SELECTED, 148 - (wxObjectEventFunction) & MyQueryView::OnCmdBlobIn); 149 - Connect (Grid_BlobOut, wxEVT_COMMAND_MENU_SELECTED, 150 - (wxObjectEventFunction) & MyQueryView::OnCmdBlobOut); 151 - Connect (Grid_BlobNull, wxEVT_COMMAND_MENU_SELECTED, 152 - (wxObjectEventFunction) & MyQueryView::OnCmdBlobNull); 153 -} 154 - 155 -void 156 -MyQueryView::ShowSqlControls () 72 + Connect(ID_SQL_GO, wxEVT_COMMAND_BUTTON_CLICKED, 73 + (wxObjectEventFunction) & MyQueryView::OnSqlGo); 74 + Connect(ID_HISTORY_BACK, wxEVT_COMMAND_BUTTON_CLICKED, 75 + (wxObjectEventFunction) & MyQueryView::OnHistoryBack); 76 + Connect(ID_HISTORY_FORWARD, wxEVT_COMMAND_BUTTON_CLICKED, 77 + (wxObjectEventFunction) & MyQueryView::OnHistoryForward); 78 + Connect(wxID_ANY, wxEVT_SIZE, (wxObjectEventFunction) & MyQueryView::OnSize); 79 + Connect(wxID_ANY, wxEVT_COMMAND_TEXT_UPDATED, 80 + (wxObjectEventFunction) & MyQueryView::OnSqlSyntaxColor); 81 +} 82 + 83 +void MyQueryView::ShowControls() 157 84 { 158 85 // 159 86 // making all SQL controls to be visible 160 87 // 161 - SqlCtrl->Show (true); 162 - BtnSqlGo->Show (true); 163 - BtnHistoryBack->Show (true); 164 - BtnHistoryForward->Show (true); 165 - SetHistoryStates (); 88 + SqlCtrl->Show(true); 89 + BtnSqlGo->Show(true); 90 + BtnHistoryBack->Show(true); 91 + BtnHistoryForward->Show(true); 92 + SetHistoryStates(); 166 93 } 167 94 168 -void 169 -MyQueryView::ShowRsControls () 170 -{ 171 -// 172 -// making all ResultSet controls to be visible 173 -// 174 - BtnRsFirst->Show (true); 175 - BtnRsPrevious->Show (true); 176 - BtnRsNext->Show (true); 177 - BtnRsLast->Show (true); 178 - BtnRefresh->Show (true); 179 - RsCurrentBlock->Show (true); 180 - if (TableView) 181 - TableView->Show (true); 182 -} 183 - 184 -void 185 -MyQueryView::HideControls () 95 +void MyQueryView::HideControls() 186 96 { 187 97 // 188 98 // making all controls to be invisible 189 99 // 190 - SqlCtrl->Show (false); 191 - BtnSqlGo->Show (false); 192 - BtnHistoryBack->Show (false); 193 - BtnHistoryForward->Show (false); 194 - BtnRsFirst->Show (false); 195 - BtnRsPrevious->Show (false); 196 - BtnRsNext->Show (false); 197 - BtnRsLast->Show (false); 198 - BtnRefresh->Show (false); 199 - RsCurrentBlock->Show (false); 200 - if (TableView) 201 - TableView->Show (false); 202 -} 203 - 204 -void 205 -MyQueryView::HideRsControls () 206 -{ 207 -// 208 -// making all ResultSet controls to be invisible 209 -// 210 - BtnRsFirst->Show (false); 211 - BtnRsPrevious->Show (false); 212 - BtnRsNext->Show (false); 213 - BtnRsLast->Show (false); 214 - BtnRefresh->Show (false); 215 - RsCurrentBlock->Show (false); 216 - if (TableView) 217 - TableView->Show (false); 218 -} 219 - 220 -void 221 -MyQueryView::SetHistoryStates () 100 + SqlCtrl->Show(false); 101 + BtnSqlGo->Show(false); 102 + BtnHistoryBack->Show(false); 103 + BtnHistoryForward->Show(false); 104 + 105 +} 106 + 107 +void MyQueryView::AddToHistory(wxString & sql) 108 +{ 109 +// 110 +// adds an SQL statement to history 111 +// 112 + History.Add(sql); 113 + SetHistoryStates(); 114 +} 115 + 116 +void MyQueryView::SetHistoryStates() 222 117 { 223 118 // 224 119 // updates the history buttons state 225 120 // 226 - BtnHistoryForward->Enable (History.TestNext ()); 227 - BtnHistoryBack->Enable (History.TestPrev ()); 121 + BtnHistoryForward->Enable(History.TestNext()); 122 + BtnHistoryBack->Enable(History.TestPrev()); 228 123 } 229 124 230 -void 231 -MyQueryView::EditTable (wxString & sql, int *primaryKeys, int *blobCols, 232 - wxString & table) 233 -{ 234 -// 235 -// starting the edit table sequence 236 -// 237 - int i; 238 - for (i = 0; i < 1024; i++) 239 - { 240 - PrimaryKeys[i] = *(primaryKeys + i); 241 - BlobColumns[i] = *(blobCols + i); 242 - } 243 - ReadOnly = false; 244 - TableName = table; 245 - SqlCtrl->SetValue (sql); 246 - if (ExecuteSql (sql, 0) == false) 247 - wxMessageBox (SqlErrorMsg, wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 248 - MainFrame); 249 -} 250 - 251 -void 252 -MyQueryView::SetSql (wxString & sql, bool execute) 125 +void MyQueryView::SetSql(wxString & sql, bool execute) 253 126 { 254 127 // 255 128 // sets an SQL statement [and maybe executes it] 256 129 // 257 - ReadOnly = true; 258 - SqlCtrl->SetValue (sql); 259 - if (execute == true) 260 - { 261 - if (ExecuteSql (sql, 0) == false) 262 - wxMessageBox (SqlErrorMsg, wxT ("spatialite-gui"), 263 - wxOK | wxICON_ERROR, MainFrame); 264 - } 265 -} 266 - 267 -bool 268 -MyQueryView::ExecuteSql (wxString & sql, int from) 269 -{ 270 -// 271 -// executing some SQL statement 272 -// 273 - char *xSql = NULL; 274 - char err_msg[2048]; 275 - int columns; 276 - int i_col; 277 - int i_row; 278 - int end_row = 0; 279 - wxString blobType; 280 - MyVariantList list; 281 - MyRowVariant *row; 282 - MyVariant *value; 283 - wxString cellValue; 284 - wxString currentBlock; 285 - sqlite3_stmt *stmt; 286 - sqlite3 *sqlite = MainFrame->GetSqlite (); 287 - SqlErrorMsg = wxT (""); 288 - if (TableView) 289 - TableView->Destroy (); 290 - TableView = NULL; 291 - if (TableBlobs) 292 - delete TableBlobs; 293 - if (TableValues) 294 - delete TableValues; 295 - TableBlobs = NULL; 296 - TableValues = NULL; 297 - CurrentBlob = NULL; 298 - HideRsControls (); 299 - RsBeginRow = 0; 300 - RsEndRow = 0; 301 - RsMaxRow = 0; 302 - for (i_row = 0; i_row < RsBlock; i_row++) 303 - RowIds[i_row] = -1; 304 - i_row = 0; 305 - xSql = new char[65536]; 306 - strcpy (xSql, sql.ToUTF8 ()); 307 - ::wxBeginBusyCursor (); 308 - int ret = sqlite3_prepare_v2 (sqlite, xSql, strlen (xSql), &stmt, NULL); 309 - if (ret != SQLITE_OK) 310 - { 311 - sprintf (err_msg, "SQL error: \"%s\"", sqlite3_errmsg (sqlite)); 312 - SqlErrorMsg = wxString::FromUTF8 (err_msg); 313 - ::wxEndBusyCursor (); 314 - delete[]xSql; 315 - return false; 316 - } 317 - RsCurrentBlock->Show (true); 318 - while (1) 319 - { 320 - // 321 - // fetching the result set rows 322 - // 323 - ret = sqlite3_step (stmt); 324 - if (ret == SQLITE_DONE) 325 - break; // end of result set 326 - if (ret == SQLITE_ROW) 327 - { 328 - // 329 - // fetching a row 330 - // 331 - if ((i_row % 100) == 0) 332 - { 333 - currentBlock.Printf (wxT 334 - ("fetching the result set: %d rows"), 335 - i_row); 336 - RsCurrentBlock->SetLabel (currentBlock); 337 - } 338 - if (i_row < from) 339 - { 340 - i_row++; 341 - continue; 342 - } 343 - if ((i_row - from) >= RsBlock) 344 - { 345 - i_row++; 346 - continue; 347 - } 348 - end_row = i_row; 349 - columns = sqlite3_column_count (stmt); 350 - MyRowVariant *rowVariant = list.Add (columns); 351 - for (i_col = 0; i_col < columns; i_col++) 352 - { 353 - int int_value; 354 - double dbl_value; 355 - const unsigned char *txt_value; 356 - const void *blob_value; 357 - int blobSize; 358 - list.SetColumnName (i_col, 359 - sqlite3_column_name (stmt, i_col)); 360 - switch (sqlite3_column_type (stmt, i_col)) 361 - { 362 - case SQLITE_INTEGER: 363 - int_value = sqlite3_column_int (stmt, i_col); 364 - rowVariant->Set (i_col, int_value); 365 - break; 366 - case SQLITE_FLOAT: 367 - dbl_value = sqlite3_column_double (stmt, i_col); 368 - rowVariant->Set (i_col, dbl_value); 369 - break; 370 - case SQLITE_TEXT: 371 - txt_value = sqlite3_column_text (stmt, i_col); 372 - rowVariant->Set (i_col, txt_value); 373 - break; 374 - case SQLITE_BLOB: 375 - blob_value = sqlite3_column_blob (stmt, i_col); 376 - blobSize = sqlite3_column_bytes (stmt, i_col); 377 - rowVariant->Set (i_col, blob_value, blobSize); 378 - break; 379 - case SQLITE_NULL: 380 - default: 381 - break; 382 - }; 383 - } 384 - i_row++; 385 - } 386 - else 387 - { 388 - sprintf (err_msg, "SQL error: \"%s\"", sqlite3_errmsg (sqlite)); 389 - SqlErrorMsg = wxString::FromUTF8 (err_msg); 390 - goto error; 391 - } 392 - } 393 - sqlite3_finalize (stmt); 394 - RsBeginRow = from; 395 - RsEndRow = end_row; 396 - RsMaxRow = i_row; 397 - if (list.GetRows () == 0) 398 - { 399 - // 400 - // this one is an EMPTY Result Set 401 - // 402 - if (ReadOnly == false) 403 - { 404 - // preparing the insert row 405 - int numCols = 0; 406 - wxString *colNames = 407 - MainFrame->GetColumnNames (TableName, &numCols); 408 - CreateGrid (0, numCols + 1); 409 - TableView->SetColLabelValue (0, wxT ("ROWID")); 410 - for (i_col = 0; i_col < numCols; i_col++) 411 - TableView->SetColLabelValue (i_col + 1, 412 - *(colNames + i_col)); 413 - TableView->EnableEditing (true); 414 - delete[]colNames; 415 - } 416 - else 417 - { 418 - // simply showing a warning message 419 - CreateGrid (1, 1); 420 - TableView->SetColLabelValue (0, wxT ("Message")); 421 - TableView->SetRowLabelValue (0, wxT ("Message")); 422 - TableView->SetCellValue (0, 0, 423 - wxT 424 - ("SQL query returned an empty ResultSet\n\nThis is not an error")); 425 - } 426 - } 427 - else 428 - { 429 - // 430 - // preparing the Grid to show the result set 431 - // 432 - CreateGrid (list.GetRows (), list.GetColumns ()); 433 - if (ReadOnly == true) 434 - TableView->EnableEditing (false); 435 - else 436 - TableView->EnableEditing (true); 437 - for (i_col = 0; i_col < list.GetColumns (); i_col++) 438 - TableView->SetColLabelValue (i_col, list.GetColumnName (i_col)); 439 - if (ReadOnly == false) 440 - TableView->SetColLabelValue (0, wxT ("ROWID")); 441 - i_row = 0; 442 - row = list.GetFirst (); 443 - while (row) 444 - { 445 - cellValue.Printf (wxT ("%d"), i_row + RsBeginRow + 1); 446 - TableView->SetRowLabelValue (i_row, cellValue); 447 - if (ReadOnly == false) 448 - { 449 - // storing the ROWID value into the RowIds array 450 - value = row->GetColumn (0); 451 - if (value->GetType () == MY_INT_VARIANT) 452 - RowIds[i_row] = value->GetIntValue (); 453 - } 454 - for (i_col = 0; i_col < row->GetNumCols (); i_col++) 455 - { 456 - value = row->GetColumn (i_col); 457 - if (value) 458 - { 459 - switch (value->GetType ()) 460 - { 461 - case MY_INT_VARIANT: 462 - cellValue.Printf (wxT ("%d"), 463 - value->GetIntValue ()); 464 - TableView->SetCellValue (i_row, i_col, 465 - cellValue); 466 - if (ReadOnly == false) 467 - TableValues->SetValue (i_row, i_col, 468 - value->GetIntValue 469 - ()); 470 - break; 471 - case MY_DBL_VARIANT: 472 - cellValue.Printf (wxT ("%1.4lf"), 473 - value->GetDblValue ()); 474 - TableView->SetCellValue (i_row, i_col, 475 - cellValue); 476 - if (ReadOnly == false) 477 - TableValues->SetValue (i_row, i_col, 478 - value->GetDblValue 479 - ()); 480 - break; 481 - case MY_TXT_VARIANT: 482 - TableView->SetCellValue (i_row, i_col, 483 - value->GetTxtValue 484 - ()); 485 - if (ReadOnly == false) 486 - TableValues->SetValue (i_row, i_col, 487 - value->GetTxtValue 488 - ()); 489 - break; 490 - case MY_BLOB_VARIANT: 491 - blobType = wxT ("UNKNOWN type"); 492 - switch (MainFrame->GuessBlobType 493 - (value->GetBlobSize (), 494 - value->GetBlob ())) 495 - { 496 - case MyFrame::BLOB_GEOMETRY: 497 - blobType = wxT ("GEOMETRY"); 498 - break; 499 - case MyFrame::BLOB_EXIF: 500 - case MyFrame::BLOB_JFIF: 501 - case MyFrame::BLOB_JPEG: 502 - blobType = wxT ("JPEG image"); 503 - break; 504 - case MyFrame::BLOB_PNG: 505 - blobType = wxT ("PNG image"); 506 - break; 507 - case MyFrame::BLOB_GIF: 508 - blobType = wxT ("GIF image"); 509 - break; 510 - case MyFrame::BLOB_PDF: 511 - blobType = wxT ("PDF document"); 512 - break; 513 - case MyFrame::BLOB_ZIP: 514 - blobType = wxT ("ZIP archive"); 515 - break; 516 - }; 517 - cellValue.Printf (wxT ("BLOB sz=%d "), 518 - value->GetBlobSize ()); 519 - cellValue += blobType; 520 - TableView->SetCellValue (i_row, i_col, 521 - cellValue); 522 - TableView->SetReadOnly (i_row, i_col); 523 - TableBlobs->SetBlob (i_row, i_col, value); 524 - break; 525 - case MY_NULL_VARIANT: 526 - default: 527 - TableView->SetCellValue (i_row, i_col, 528 - wxT ("NULL")); 529 - break; 530 - }; 531 - } 532 - else 533 - TableView->SetCellValue (i_row, i_col, wxT ("NULL")); 534 - if (ReadOnly == false) 535 - { 536 - if (IsPrimaryKey (i_col) == true) 537 - TableView->SetReadOnly (i_row, i_col); 538 - if (IsBlobColumn (i_col) == true) 539 - TableView->SetReadOnly (i_row, i_col); 540 - } 541 - } 542 - i_row++; 543 - row = row->GetNext (); 544 - } 545 - } 546 - if (ReadOnly == false) 547 - { 548 - // prepearing the insert row 549 - TableView->SetRowLabelValue (TableView->GetNumberRows () - 1, 550 - wxT ("Insert row")); 551 - InsertPending = false; 552 - for (i_col = 0; i_col < TableView->GetNumberCols (); i_col++) 553 - { 554 - TableView->SetCellValue (TableView->GetNumberRows () - 1, i_col, 555 - wxT ("")); 556 - TableView->SetCellBackgroundColour (TableView-> 557 - GetNumberRows () - 1, i_col, 558 - wxColour (0, 0, 0)); 559 - TableView->SetReadOnly (TableView->GetNumberRows () - 1, i_col); 560 - } 561 - } 562 - TableView->AutoSize (); 563 - ResizeTableView (); 564 - currentBlock.Printf (wxT ("current block: %d / %d [%d rows]"), 565 - RsBeginRow + 1, RsEndRow + 1, RsMaxRow); 566 - RsCurrentBlock->SetLabel (currentBlock); 567 - ShowRsControls (); 568 - History.Add (sql); 569 - SetHistoryStates (); 570 - ::wxEndBusyCursor (); 571 - if (xSql) 572 - delete[]xSql; 573 - return true; 574 - error: 575 - ::wxEndBusyCursor (); 576 - sqlite3_finalize (stmt); 577 - if (xSql) 578 - delete[]xSql; 579 - return false; 580 -} 581 - 582 -bool 583 -MyQueryView::IsPrimaryKey (int column) 584 -{ 585 -// 586 -// checks if this column is a Primary Key one 587 -// 588 - int i; 589 - for (i = 0; i < 1024; i++) 590 - { 591 - if (PrimaryKeys[i] == column) 592 - return true; 593 - } 594 - return false; 595 -} 596 - 597 -bool 598 -MyQueryView::IsBlobColumn (int column) 599 -{ 600 -// 601 -// checks if this column is a BLOB-type column 602 -// 603 - int i; 604 - for (i = 0; i < 1024; i++) 605 - { 606 - if (BlobColumns[i] == column) 607 - return true; 608 - } 609 - return false; 610 -} 611 - 612 -void 613 -MyQueryView::CreateGrid (int rows, int cols) 614 -{ 615 -// 616 -// creating a new Grid to show the result set 617 -// 618 - int extra = 0; 619 - if (ReadOnly == false) 620 - extra = 1; 621 - wxSize sz = GetClientSize (); 622 - TableView = 623 - new wxGrid (this, wxID_ANY, wxPoint (5, 120), wxSize (200, 200)); 624 - TableView->Show (false); 625 - TableView->CreateGrid (rows + extra, cols); 626 - TableBlobs = new MyBlobs (rows, cols); 627 - if (ReadOnly == false) 628 - TableValues = new MyValues (rows, cols); 629 -} 630 - 631 -void 632 -MyQueryView::ResizeTableView () 633 -{ 634 -// 635 -// resizing the Grid to show the result set 636 -// 637 - wxSize sz = GetClientSize (); 638 - if (TableView) 639 - { 640 - TableView->SetSize (sz.GetWidth () - 10, sz.GetHeight () - 160); 641 - TableView->Show (true); 642 - } 643 -} 644 - 645 -void 646 -MyQueryView::OnSize (wxSizeEvent & event) 130 + SqlCtrl->SetValue(sql); 131 + if (execute == true) 132 + { 133 + if (MainFrame->GetRsView()->ExecuteSql(sql, 0, true) == false) 134 + wxMessageBox(MainFrame->GetRsView()->GetSqlErrorMsg(), 135 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, MainFrame); 136 + } 137 +} 138 + 139 +void MyQueryView::OnSize(wxSizeEvent & event) 647 140 { 648 141 // 649 142 // this window has changed its size 650 143 // 651 - wxSize sz = GetClientSize (); 652 - SqlCtrl->SetSize (sz.GetWidth () - 80, 100); 653 - BtnSqlGo->Move (sz.GetWidth () - 35, 30); 654 - if (TableView) 655 - TableView->SetSize (sz.GetWidth () - 10, sz.GetHeight () - 160); 656 - BtnRsFirst->Move (5, sz.GetHeight () - 35); 657 - BtnRsPrevious->Move (40, sz.GetHeight () - 35); 658 - BtnRefresh->Move (75, sz.GetHeight () - 35); 659 - BtnRsNext->Move (110, sz.GetHeight () - 35); 660 - BtnRsLast->Move (145, sz.GetHeight () - 35); 661 - RsCurrentBlock->Move (180, sz.GetHeight () - 25); 662 -} 663 - 664 -void 665 -MyQueryView::OnSqlGo (wxCommandEvent & WXUNUSED (event)) 144 + int vert; 145 + int vertBack; 146 + wxSize sz = GetClientSize(); 147 +// setting the SQL statement pane size 148 + SqlCtrl->SetSize(sz.GetWidth() - 80, sz.GetHeight() - 10); 149 +// setting the SQL GO button position 150 + vert = (sz.GetHeight() - 69) / 2; 151 + if (vert < 5) 152 + vert = 5; 153 + BtnSqlGo->Move(sz.GetWidth() - 35, 5); 154 +// setting the SQL GO button size 155 + vert = sz.GetHeight() - 10; 156 + if (vert < 66) 157 + vert = 66; 158 + BtnSqlGo->SetSize(32, vert); 159 +// setting the HISTORY BACK button position 160 + BtnHistoryBack->Move(5, 5); 161 +// setting the HISTORY BACK button size 162 + vert = (sz.GetHeight() - 15) / 2; 163 + if (vert < 32) 164 + vert = 32; 165 + BtnHistoryBack->SetSize(32, vert); 166 + vertBack = 10 + vert; 167 +// setting the HISTORY FORWARD button position 168 + BtnHistoryForward->Move(5, vertBack); 169 +// setting the HISTORY FORWARD button size 170 + BtnHistoryForward->SetSize(32, vert); 171 +} 172 + 173 +void MyQueryView::OnSqlGo(wxCommandEvent & WXUNUSED(event)) 666 174 { 667 175 // 668 176 // executing an SQL statement 669 177 // 670 - ReadOnly = true; 671 - wxString sql = SqlCtrl->GetValue (); 672 - if (ExecuteSql (sql, 0) == false) 673 - wxMessageBox (SqlErrorMsg, wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 674 - MainFrame); 178 + wxString sql = SqlCtrl->GetValue(); 179 + if (MainFrame->GetRsView()->ExecuteSql(sql, 0, true) == false) 180 + wxMessageBox(MainFrame->GetRsView()->GetSqlErrorMsg(), 181 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, MainFrame); 675 182 } 676 183 677 -void 678 -MyQueryView::OnHistoryBack (wxCommandEvent & WXUNUSED (event)) 184 +void MyQueryView::OnHistoryBack(wxCommandEvent & WXUNUSED(event)) 679 185 { 680 186 // 681 187 // going backward into the SQL Queries History 682 188 // 683 - MySqlQuery *sql = History.GetPrev (); 684 - if (sql) 685 - { 686 - SetSql (sql->GetSql (), false); 687 - SetHistoryStates (); 688 - } 189 + MySqlQuery *sql = History.GetPrev(); 190 + if (sql) 191 + { 192 + SetSql(sql->GetSql(), false); 193 + SetHistoryStates(); 194 + } 689 195 } 690 196 691 -void 692 -MyQueryView::OnHistoryForward (wxCommandEvent & WXUNUSED (event)) 197 +void MyQueryView::OnHistoryForward(wxCommandEvent & WXUNUSED(event)) 693 198 { 694 199 // 695 200 // going forward into the SQL Queries History 696 201 // 697 - MySqlQuery *sql = History.GetNext (); 698 - if (sql) 699 - { 700 - SetSql (sql->GetSql (), false); 701 - SetHistoryStates (); 702 - } 202 + MySqlQuery *sql = History.GetNext(); 203 + if (sql) 204 + { 205 + SetSql(sql->GetSql(), false); 206 + SetHistoryStates(); 207 + } 208 +} 209 + 210 +bool MyQueryView::IsSqlString(wxString & str) 211 +{ 212 +// checks if this one is an SQL string constant 213 + char word[4096]; 214 + strcpy(word, str.ToUTF8()); 215 + int len = strlen(word); 216 + if (len < 2) 217 + return false; 218 + if (word[0] == '\'' && word[len - 1] == '\'') 219 + return true; 220 + if (word[0] == '"' && word[len - 1] == '"') 221 + return true; 222 + return false; 223 +} 224 + 225 +bool MyQueryView::IsSqlNumber(wxString & str) 226 +{ 227 +// checks if this one is an SQL numeric constant 228 + double dbl; 229 + return str.ToDouble(&dbl); 230 +} 231 + 232 +bool MyQueryView::IsSqliteExtra(wxString & str) 233 +{ 234 +// checks if this one is an extra SQLite keyword 235 + if (str.CmpNoCase(wxT("asc")) == 0) 236 + return true; 237 + if (str.CmpNoCase(wxT("desc")) == 0) 238 + return true; 239 + if (str.CmpNoCase(wxT("null")) == 0) 240 + return true; 241 + if (str.CmpNoCase(wxT("trigger")) == 0) 242 + return true; 243 + if (str.CmpNoCase(wxT("for")) == 0) 244 + return true; 245 + if (str.CmpNoCase(wxT("each")) == 0) 246 + return true; 247 + if (str.CmpNoCase(wxT("row")) == 0) 248 + return true; 249 + if (str.CmpNoCase(wxT("begin")) == 0) 250 + return true; 251 + if (str.CmpNoCase(wxT("end")) == 0) 252 + return true; 253 + if (str.CmpNoCase(wxT("before")) == 0) 254 + return true; 255 + if (str.CmpNoCase(wxT("after")) == 0) 256 + return true; 257 + if (str.CmpNoCase(wxT("virtual")) == 0) 258 + return true; 259 + return false; 260 +} 261 + 262 +bool MyQueryView::IsSqlFunction(wxString & str, char next_c) 263 +{ 264 +// checks if this one is an SQL function 265 + if (next_c != '(') 266 + return false; 267 + if (str.CmpNoCase(wxT("raise")) == 0) 268 + return true; 269 + if (str.CmpNoCase(wxT("avg")) == 0) 270 + return true; 271 + if (str.CmpNoCase(wxT("count")) == 0) 272 + return true; 273 + if (str.CmpNoCase(wxT("group_concat")) == 0) 274 + return true; 275 + if (str.CmpNoCase(wxT("max")) == 0) 276 + return true; 277 + if (str.CmpNoCase(wxT("min")) == 0) 278 + return true; 279 + if (str.CmpNoCase(wxT("sum")) == 0) 280 + return true; 281 + if (str.CmpNoCase(wxT("total")) == 0) 282 + return true; 283 + if (str.CmpNoCase(wxT("abs")) == 0) 284 + return true; 285 + if (str.CmpNoCase(wxT("coalesce")) == 0) 286 + return true; 287 + if (str.CmpNoCase(wxT("glob")) == 0) 288 + return true; 289 + if (str.CmpNoCase(wxT("ifnull")) == 0) 290 + return true; 291 + if (str.CmpNoCase(wxT("hex")) == 0) 292 + return true; 293 + if (str.CmpNoCase(wxT("last_insert_rowid")) == 0) 294 + return true; 295 + if (str.CmpNoCase(wxT("length")) == 0) 296 + return true; 297 + if (str.CmpNoCase(wxT("load_extension")) == 0) 298 + return true; 299 + if (str.CmpNoCase(wxT("lower")) == 0) 300 + return true; 301 + if (str.CmpNoCase(wxT("ltrim")) == 0) 302 + return true; 303 + if (str.CmpNoCase(wxT("nullif")) == 0) 304 + return true; 305 + if (str.CmpNoCase(wxT("quote")) == 0) 306 + return true; 307 + if (str.CmpNoCase(wxT("random")) == 0) 308 + return true; 309 + if (str.CmpNoCase(wxT("randomblob")) == 0) 310 + return true; 311 + if (str.CmpNoCase(wxT("replace")) == 0) 312 + return true; 313 + if (str.CmpNoCase(wxT("round")) == 0) 314 + return true; 315 + if (str.CmpNoCase(wxT("rtrim")) == 0) 316 + return true; 317 + if (str.CmpNoCase(wxT("soundex")) == 0) 318 + return true; 319 + if (str.CmpNoCase(wxT("sqlite_version")) == 0) 320 + return true; 321 + if (str.CmpNoCase(wxT("substr")) == 0) 322 + return true; 323 + if (str.CmpNoCase(wxT("trim")) == 0) 324 + return true; 325 + if (str.CmpNoCase(wxT("typeof")) == 0) 326 + return true; 327 + if (str.CmpNoCase(wxT("upper")) == 0) 328 + return true; 329 + if (str.CmpNoCase(wxT("zeroblob")) == 0) 330 + return true; 331 + return false; 332 +} 333 + 334 +bool MyQueryView::IsSqlGeoFunction(wxString & str, char next_c) 335 +{ 336 +// checks if this one is an SQL geo-function 337 + if (next_c != '(') 338 + return false; 339 + if (str.CmpNoCase(wxT("MakePoint")) == 0) 340 + return true; 341 + if (str.CmpNoCase(wxT("BuildMbr")) == 0) 342 + return true; 343 + if (str.CmpNoCase(wxT("BuildCircleMbr")) == 0) 344 + return true; 345 + if (str.CmpNoCase(wxT("MbrMinX")) == 0) 346 + return true; 347 + if (str.CmpNoCase(wxT("MbrMinY")) == 0) 348 + return true; 349 + if (str.CmpNoCase(wxT("MbrMaxX")) == 0) 350 + return true; 351 + if (str.CmpNoCase(wxT("MbrMaxY")) == 0) 352 + return true; 353 + if (str.CmpNoCase(wxT("GeomFromText")) == 0) 354 + return true; 355 + if (str.CmpNoCase(wxT("PointFromText")) == 0) 356 + return true; 357 + if (str.CmpNoCase(wxT("LineFromText")) == 0) 358 + return true; 359 + if (str.CmpNoCase(wxT("LineStringFromText")) == 0) 360 + return true; 361 + if (str.CmpNoCase(wxT("PolyFromText")) == 0) 362 + return true; 363 + if (str.CmpNoCase(wxT("PolygonFromText")) == 0) 364 + return true; 365 + if (str.CmpNoCase(wxT("MPointFromText")) == 0) 366 + return true; 367 + if (str.CmpNoCase(wxT("MultiPointFromText")) == 0) 368 + return true; 369 + if (str.CmpNoCase(wxT("MLineFromText")) == 0) 370 + return true; 371 + if (str.CmpNoCase(wxT("MultiLineStringFromText")) == 0) 372 + return true; 373 + if (str.CmpNoCase(wxT("MPolyFromText")) == 0) 374 + return true; 375 + if (str.CmpNoCase(wxT("MultiPolygonFromText")) == 0) 376 + return true; 377 + if (str.CmpNoCase(wxT("GeomCollFromText")) == 0) 378 + return true; 379 + if (str.CmpNoCase(wxT("GeometryCollectionFromText")) == 0) 380 + return true; 381 + if (str.CmpNoCase(wxT("GeomFromWKB")) == 0) 382 + return true; 383 + if (str.CmpNoCase(wxT("PointFromWKB")) == 0) 384 + return true; 385 + if (str.CmpNoCase(wxT("LineFromWKB")) == 0) 386 + return true; 387 + if (str.CmpNoCase(wxT("LineStringFromWKB")) == 0) 388 + return true; 389 + if (str.CmpNoCase(wxT("PolyFromWKB")) == 0) 390 + return true; 391 + if (str.CmpNoCase(wxT("PolygonFromWKB")) == 0) 392 + return true; 393 + if (str.CmpNoCase(wxT("MPointFromWKB")) == 0) 394 + return true; 395 + if (str.CmpNoCase(wxT("MultiPointFromWKB")) == 0) 396 + return true; 397 + if (str.CmpNoCase(wxT("MLineFromWKB")) == 0) 398 + return true; 399 + if (str.CmpNoCase(wxT("MultiLineStringFromWKB")) == 0) 400 + return true; 401 + if (str.CmpNoCase(wxT("MPolyFromWKB")) == 0) 402 + return true; 403 + if (str.CmpNoCase(wxT("MultiPolygonFromWKB")) == 0) 404 + return true; 405 + if (str.CmpNoCase(wxT("GeomCollFromWKB")) == 0) 406 + return true; 407 + if (str.CmpNoCase(wxT("GeometryCollectionFromWKB")) == 0) 408 + return true; 409 + if (str.CmpNoCase(wxT("AsText")) == 0) 410 + return true; 411 + if (str.CmpNoCase(wxT("AsBinary")) == 0) 412 + return true; 413 + if (str.CmpNoCase(wxT("Dimension")) == 0) 414 + return true; 415 + if (str.CmpNoCase(wxT("GeometryType")) == 0) 416 + return true; 417 + if (str.CmpNoCase(wxT("SRID")) == 0) 418 + return true; 419 + if (str.CmpNoCase(wxT("SetSRID")) == 0) 420 + return true; 421 + if (str.CmpNoCase(wxT("IsEmpty")) == 0) 422 + return true; 423 + if (str.CmpNoCase(wxT("IsSimple")) == 0) 424 + return true; 425 + if (str.CmpNoCase(wxT("IsValid")) == 0) 426 + return true; 427 + if (str.CmpNoCase(wxT("Boundary")) == 0) 428 + return true; 429 + if (str.CmpNoCase(wxT("Envelope")) == 0) 430 + return true; 431 + if (str.CmpNoCase(wxT("X")) == 0) 432 + return true; 433 + if (str.CmpNoCase(wxT("Y")) == 0) 434 + return true; 435 + if (str.CmpNoCase(wxT("StartPoint")) == 0) 436 + return true; 437 + if (str.CmpNoCase(wxT("EndPoint")) == 0) 438 + return true; 439 + if (str.CmpNoCase(wxT("GLength")) == 0) 440 + return true; 441 + if (str.CmpNoCase(wxT("IsClosed")) == 0) 442 + return true; 443 + if (str.CmpNoCase(wxT("IsRing")) == 0) 444 + return true; 445 + if (str.CmpNoCase(wxT("Simplify")) == 0) 446 + return true; 447 + if (str.CmpNoCase(wxT("SimplifyPreserveTopology")) == 0) 448 + return true; 449 + if (str.CmpNoCase(wxT("NumPoints")) == 0) 450 + return true; 451 + if (str.CmpNoCase(wxT("PointN")) == 0) 452 + return true; 453 + if (str.CmpNoCase(wxT("Centroid")) == 0) 454 + return true; 455 + if (str.CmpNoCase(wxT("PointOnSurface")) == 0) 456 + return true; 457 + if (str.CmpNoCase(wxT("Area")) == 0) 458 + return true; 459 + if (str.CmpNoCase(wxT("ExteriorRing")) == 0) 460 + return true; 461 + if (str.CmpNoCase(wxT("NumInteriorRing")) == 0) 462 + return true; 463 + if (str.CmpNoCase(wxT("NumInteriorRings")) == 0) 464 + return true; 465 + if (str.CmpNoCase(wxT("InteriorRingN")) == 0) 466 + return true; 467 + if (str.CmpNoCase(wxT("NumGeometries")) == 0) 468 + return true; 469 + if (str.CmpNoCase(wxT("GeometryN")) == 0) 470 + return true; 471 + if (str.CmpNoCase(wxT("MbrEqual")) == 0) 472 + return true; 473 + if (str.CmpNoCase(wxT("MbrDisjoint")) == 0) 474 + return true; 475 + if (str.CmpNoCase(wxT("MbrTouches")) == 0) 476 + return true; 477 + if (str.CmpNoCase(wxT("MbrWithin")) == 0) 478 + return true; 479 + if (str.CmpNoCase(wxT("MbrOverlaps")) == 0) 480 + return true; 481 + if (str.CmpNoCase(wxT("MbrIntersects")) == 0) 482 + return true; 483 + if (str.CmpNoCase(wxT("MbrContains")) == 0) 484 + return true; 485 + if (str.CmpNoCase(wxT("Equals")) == 0) 486 + return true; 487 + if (str.CmpNoCase(wxT("Disjoint")) == 0) 488 + return true; 489 + if (str.CmpNoCase(wxT("Touches")) == 0) 490 + return true; 491 + if (str.CmpNoCase(wxT("Within")) == 0) 492 + return true; 493 + if (str.CmpNoCase(wxT("Overlaps")) == 0) 494 + return true; 495 + if (str.CmpNoCase(wxT("Crosses")) == 0) 496 + return true; 497 + if (str.CmpNoCase(wxT("Intersects")) == 0) 498 + return true; 499 + if (str.CmpNoCase(wxT("Contains")) == 0) 500 + return true; 501 + if (str.CmpNoCase(wxT("Relate")) == 0) 502 + return true; 503 + if (str.CmpNoCase(wxT("Distance")) == 0) 504 + return true; 505 + if (str.CmpNoCase(wxT("Intersection")) == 0) 506 + return true; 507 + if (str.CmpNoCase(wxT("Difference")) == 0) 508 + return true; 509 + if (str.CmpNoCase(wxT("GUnion")) == 0) 510 + return true; 511 + if (str.CmpNoCase(wxT("SymDifference")) == 0) 512 + return true; 513 + if (str.CmpNoCase(wxT("Buffer")) == 0) 514 + return true; 515 + if (str.CmpNoCase(wxT("ConvexHull")) == 0) 516 + return true; 517 + if (str.CmpNoCase(wxT("Transform")) == 0) 518 + return true; 519 + if (str.CmpNoCase(wxT("ShiftCoords")) == 0) 520 + return true; 521 + if (str.CmpNoCase(wxT("ShiftCoordinates")) == 0) 522 + return true; 523 + if (str.CmpNoCase(wxT("ScaleCoords")) == 0) 524 + return true; 525 + if (str.CmpNoCase(wxT("ScaleCoordinates")) == 0) 526 + return true; 527 + if (str.CmpNoCase(wxT("RotateCoords")) == 0) 528 + return true; 529 + if (str.CmpNoCase(wxT("RotateCoordinates")) == 0) 530 + return true; 531 + if (str.CmpNoCase(wxT("ReflectCoords")) == 0) 532 + return true; 533 + if (str.CmpNoCase(wxT("ReflectCoordinates")) == 0) 534 + return true; 535 + if (str.CmpNoCase(wxT("SwapCoords")) == 0) 536 + return true; 537 + if (str.CmpNoCase(wxT("SwapCoordinates")) == 0) 538 + return true; 539 + if (str.CmpNoCase(wxT("InitSpatialMetaData")) == 0) 540 + return true; 541 + if (str.CmpNoCase(wxT("AddGeometryColumn")) == 0) 542 + return true; 543 + if (str.CmpNoCase(wxT("RecoverGeometryColumn")) == 0) 544 + return true; 545 + if (str.CmpNoCase(wxT("DiscardGeometryColumn")) == 0) 546 + return true; 547 + if (str.CmpNoCase(wxT("CreateSpatialIndex")) == 0) 548 + return true; 549 + if (str.CmpNoCase(wxT("CreateMbrCache")) == 0) 550 + return true; 551 + if (str.CmpNoCase(wxT("DisableSpatialIndex")) == 0) 552 + return true; 553 + if (str.CmpNoCase(wxT("FilterMbrWithin")) == 0) 554 + return true; 555 + if (str.CmpNoCase(wxT("FilterMbrContains")) == 0) 556 + return true; 557 + if (str.CmpNoCase(wxT("FilterMbrIntersects")) == 0) 558 + return true; 559 + if (str.CmpNoCase(wxT("BuildMbrFilter")) == 0) 560 + return true; 561 + return false; 562 +} 563 + 564 +void MyQueryView::DoSqlSyntaxColor() 565 +{ 566 +// 567 +// evidencing a nice colored SQL syntax 568 +// 569 + IgnoreEvent = true; 570 + SqlCtrl->Hide(); 571 + wxTextAttr normal_style(wxColour(128, 128, 128), wxColour(255, 255, 255), 572 + wxFont(10, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, 573 + wxFONTWEIGHT_NORMAL)); 574 + wxTextAttr sql_style(wxColour(0, 0, 255), wxColour(255, 255, 255), 575 + wxFont(10, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, 576 + wxFONTWEIGHT_BOLD)); 577 + wxTextAttr const_style(wxColour(255, 0, 255), wxColour(255, 255, 255), 578 + wxFont(10, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, 579 + wxFONTWEIGHT_NORMAL)); 580 + wxTextAttr fnct_style(wxColour(192, 128, 0), wxColour(255, 255, 255), 581 + wxFont(10, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, 582 + wxFONTWEIGHT_BOLD)); 583 + wxTextAttr bracket_style(wxColour(255, 0, 0), wxColour(192, 192, 192), 584 + wxFont(12, wxFONTFAMILY_ROMAN, wxFONTSTYLE_NORMAL, 585 + wxFONTWEIGHT_BOLD)); 586 + wxString sql = SqlCtrl->GetValue(); 587 +// setting the base style 588 + SqlCtrl->SetStyle(0, sql.Len(), normal_style); 589 + wxString right = sql; 590 + int from; 591 + int to = 0; 592 + int i; 593 + char c; 594 + char next_c; 595 + SqlTokenizer tokenizer(sql); 596 + while (tokenizer.HasMoreTokens()) 597 + { 598 + wxString token = tokenizer.GetNextToken(); 599 + from = to + right.Find(token); 600 + to = from + token.Len(); 601 + // extracting the unparsed portion of the SQL string 602 + right = sql.Mid(to); 603 + next_c = '\0'; 604 + for (i = 0; i < (int) right.Len(); i++) 605 + { 606 + c = right.GetChar(i); 607 + if (c == ' ' || c == '\t' || c == '\r' || c == '\n') 608 + continue; 609 + next_c = c; 610 + break; 611 + } 612 + char word[4096]; 613 + strcpy(word, token.ToUTF8()); 614 + if (gaiaIsReservedSqliteName(word)) 615 + { 616 + // setting the SQL keyword style 617 + SqlCtrl->SetStyle(from, to, sql_style); 618 + } else if (IsSqliteExtra(token)) 619 + { 620 + // setting the SQL keyword style 621 + SqlCtrl->SetStyle(from, to, sql_style); 622 + } else if (IsSqlString(token) == true) 623 + { 624 + // setting the SQL string constant style 625 + SqlCtrl->SetStyle(from, to, const_style); 626 + } else if (IsSqlNumber(token) == true) 627 + { 628 + // setting the SQL numeric constant style 629 + SqlCtrl->SetStyle(from, to, const_style); 630 + } else if (IsSqlFunction(token, next_c) == true) 631 + { 632 + // setting the SQL function style 633 + SqlCtrl->SetStyle(from, to, fnct_style); 634 + } else if (IsSqlGeoFunction(token, next_c) == true) 635 + { 636 + // setting the SQL geo-function style 637 + SqlCtrl->SetStyle(from, to, fnct_style); 638 + } 639 + } 640 + if (BracketStart >= 0) 641 + { 642 + // evidencing an opening bracket 643 + SqlCtrl->SetStyle(BracketStart, BracketStart + 1, bracket_style); 644 + } 645 + if (BracketEnd >= 0) 646 + { 647 + // evidencing a closing bracket 648 + SqlCtrl->SetStyle(BracketEnd, BracketEnd + 1, bracket_style); 649 + } 650 + SqlCtrl->Show(); 651 + SqlCtrl->SetFocus(); 652 + IgnoreEvent = false; 653 +} 654 + 655 +void MyQueryView::OnSqlSyntaxColor(wxCommandEvent & event) 656 +{ 657 +// 658 +// EVENT: updating the SQL syntax 659 +// 660 + if (IgnoreEvent == true) 661 + { 662 + // processing is still in progress; ignoring any internally generated call 663 + return; 664 + } 665 + event.Skip(); 666 + EventBrackets(); 667 +} 668 + 669 +void MyQueryView::EvidBrackets(int on, int off) 670 +{ 671 +// evidencing corresponding brackets [open/close] 672 + BracketStart = -1; 673 + BracketEnd = -1; 674 + if (on >= 0) 675 + BracketStart = on; 676 + if (off >= 0) 677 + BracketEnd = off; 678 + DoSqlSyntaxColor(); 679 +} 680 + 681 +void MyQueryView::EventBrackets() 682 +{ 683 +// 684 +// evidencing brackets [balancing open-close pairs] 685 +// 686 + if (IgnoreEvent == true) 687 + { 688 + // processing is still in progress; ignoring any internally generated call 689 + return; 690 + } 691 + int pos = SqlCtrl->GetInsertionPoint(); 692 + int on; 693 + int off; 694 + wxString sql = SqlCtrl->GetValue(); 695 + char pre = '\0'; 696 + char post = '\0'; 697 + if (pos > 0) 698 + pre = sql.GetChar(pos - 1); 699 + if (pos < (int) sql.Len()) 700 + post = sql.GetChar(pos); 701 + if (post == '(') 702 + { 703 + // positioned before an opening bracket 704 + if (CheckBrackets(pos, false, &on, &off) == true) 705 + EvidBrackets(on, off); 706 + else 707 + EvidBrackets(pos, -1); 708 + return; 709 + } 710 + if (pre == ')') 711 + { 712 + // positioned after a closing bracket 713 + if (CheckBrackets(pos - 1, true, &on, &off) == true) 714 + EvidBrackets(on, off); 715 + else 716 + EvidBrackets(-1, pos - 1); 717 + return; 718 + } 719 + EvidBrackets(-1, -1); 720 +} 721 + 722 +bool MyQueryView::CheckBrackets(int pos, bool reverse_direction, int *on, 723 + int *off) 724 +{ 725 +// trying to balance a brackets pair [opening/closing] 726 + int i; 727 + int len; 728 + int level = 0; 729 + char c; 730 + int single_quoted = 0; 731 + int double_quoted = 0; 732 + wxString sql = SqlCtrl->GetValue(); 733 + if (reverse_direction == true) 734 + { 735 + // going backward from CLOSE to OPEN 736 + for (i = pos - 1; i >= 0; i--) 737 + { 738 + c = sql.GetChar(i); 739 + if (c == '\'' && !double_quoted) 740 + { 741 + // single quoting start-stop 742 + if (single_quoted) 743 + single_quoted = 0; 744 + else 745 + single_quoted = 1; 746 + } 747 + if (c == '"' && !single_quoted) 748 + { 749 + // double quoting start-stop 750 + if (double_quoted) 751 + double_quoted = 0; 752 + else 753 + double_quoted = 1; 754 + } 755 + if (single_quoted || double_quoted) 756 + continue; 757 + if (c == ')') 758 + level++; 759 + if (c == '(') 760 + { 761 + if (level == 0) 762 + { 763 + *on = i; 764 + *off = pos; 765 + return true; 766 + } 767 + level--; 768 + } 769 + } 770 + } else 771 + { 772 + // going forward from OPEN to CLOSE 773 + len = sql.Len(); 774 + for (i = pos + 1; i < len; i++) 775 + { 776 + c = sql.GetChar(i); 777 + if (c == '\'' && !double_quoted) 778 + { 779 + // single quoting start-stop 780 + if (single_quoted) 781 + single_quoted = 0; 782 + else 783 + single_quoted = 1; 784 + } 785 + if (c == '"' && !single_quoted) 786 + { 787 + // double quoting start-stop 788 + if (double_quoted) 789 + double_quoted = 0; 790 + else 791 + double_quoted = 1; 792 + } 793 + if (single_quoted || double_quoted) 794 + continue; 795 + if (c == '(') 796 + level++; 797 + if (c == ')') 798 + { 799 + if (level == 0) 800 + { 801 + *on = pos; 802 + *off = i; 803 + return true; 804 + } 805 + level--; 806 + } 807 + } 808 + } 809 + return false; 810 +} 811 + 812 +MySqlControl::MySqlControl(MyQueryView * parent, wxWindowID id, const wxString & value, const wxPoint & pos, const wxSize & size, long style): 813 +wxTextCtrl(parent, id, value, pos, size, style) 814 +{ 815 +// 816 +// constructor: SQL text control 817 +// 818 + Parent = parent; 819 + Connect(wxID_ANY, wxEVT_LEFT_DOWN, 820 + (wxObjectEventFunction) & MySqlControl::OnSqlMousePosition); 821 + Connect(wxID_ANY, wxEVT_KEY_UP, 822 + (wxObjectEventFunction) & MySqlControl::OnSqlArrowPosition); 703 823 } 704 824 705 -void 706 -MyQueryView::OnRsFirst (wxCommandEvent & WXUNUSED (event)) 825 +void MySqlControl::OnSqlMousePosition(wxMouseEvent & event) 707 826 { 708 827 // 709 -// scrolling to the result set beginning 828 +// intercepting mouse clicks 710 829 // 711 - wxString sql = SqlCtrl->GetValue (); 712 - if (ExecuteSql (sql, 0) == false) 713 - wxMessageBox (SqlErrorMsg, wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 714 - MainFrame); 830 + if (Parent->IsIgnoreEvent() == true) 831 + return; 832 + event.Skip(); 833 + Parent->EventBrackets(); 715 834 } 716 835 717 -void 718 -MyQueryView::OnRsPrevious (wxCommandEvent & WXUNUSED (event)) 836 +void MySqlControl::OnSqlArrowPosition(wxKeyEvent & event) 719 837 { 720 838 // 721 -// scrolling to the result set previous block 839 +// intercepting arrow keys 722 840 // 723 - wxString sql = SqlCtrl->GetValue (); 724 - int start = RsBeginRow - RsBlock; 725 - if (start < 0) 726 - start = 0; 727 - if (ExecuteSql (sql, start) == false) 728 - wxMessageBox (SqlErrorMsg, wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 729 - MainFrame); 841 + if (Parent->IsIgnoreEvent() == true) 842 + return; 843 + event.Skip(); 844 + int key_code = event.GetKeyCode(); 845 + switch (key_code) 846 + { 847 + case WXK_DELETE: 848 + case WXK_HOME: 849 + case WXK_LEFT: 850 + case WXK_UP: 851 + case WXK_RIGHT: 852 + case WXK_DOWN: 853 + case WXK_PAGEUP: 854 + case WXK_PAGEDOWN: 855 + case WXK_NUMPAD_DELETE: 856 + case WXK_NUMPAD_HOME: 857 + case WXK_NUMPAD_LEFT: 858 + case WXK_NUMPAD_UP: 859 + case WXK_NUMPAD_RIGHT: 860 + case WXK_NUMPAD_DOWN: 861 + case WXK_NUMPAD_PAGEUP: 862 + case WXK_NUMPAD_PAGEDOWN: 863 + Parent->EventBrackets(); 864 + break; 865 + default: 866 + break; 867 + }; 730 868 } 731 869 732 -void 733 -MyQueryView::OnRsNext (wxCommandEvent & WXUNUSED (event)) 870 +SqlTokenizer::SqlTokenizer(wxString & sql) 734 871 { 735 -// 736 -// scrolling to the result set next block 737 -// 738 - wxString sql = SqlCtrl->GetValue (); 739 - int start = RsEndRow + 1; 740 - if (ExecuteSql (sql, start) == false) 741 - wxMessageBox (SqlErrorMsg, wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 742 - MainFrame); 872 +// breaking tokens from an SQL expression 873 + Block = 1024; 874 + Max = Block; 875 + int i; 876 + char c; 877 + int single_quoted = 0; 878 + int double_quoted = 0; 879 + int white_space = 0; 880 + int start = -1; 881 + int len; 882 +// initial allocation for the token list 883 + TokenList = new wxString *[Max]; 884 + for (i = 0; i < Max; i++) 885 + TokenList[i] = NULL; 886 + Index = 0; 887 + for (i = 0; i < (int) sql.Len(); i++) 888 + { 889 + // scanning the SQL statement 890 + c = sql.GetChar(i); 891 + if (c == '\'' && !double_quoted) 892 + { 893 + if (single_quoted) 894 + { 895 + single_quoted = 0; 896 + len = i - start; 897 + len++; 898 + wxString *token = new wxString(sql.Mid(start, len)); 899 + Insert(token); 900 + start = -1; 901 + } else 902 + { 903 + single_quoted = 1; 904 + start = i; 905 + } 906 + continue; 907 + } 908 + if (c == '"' && !single_quoted) 909 + { 910 + if (double_quoted) 911 + { 912 + double_quoted = 0; 913 + len = i - start; 914 + len++; 915 + wxString *token = new wxString(sql.Mid(start, len)); 916 + Insert(token); 917 + start = -1; 918 + } else 919 + { 920 + double_quoted = 1; 921 + start = i; 922 + } 923 + continue; 924 + } 925 + if (single_quoted || double_quoted) 926 + continue; 927 + if (c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '(' 928 + || c == ')' || c == ';' || c == ',') 929 + { 930 + if (white_space) 931 + continue; 932 + if (start >= 0) 933 + { 934 + // ok, we have a valid SQL token 935 + len = i - start; 936 + wxString *token = new wxString(sql.Mid(start, len)); 937 + Insert(token); 938 + } 939 + start = -1; 940 + white_space = 1; 941 + continue; 942 + } 943 + white_space = 0; 944 + if (start < 0) 945 + start = i; 946 + } 947 + if (start >= 0) 948 + { 949 + // fetching the last token 950 + i = sql.Len(); 951 + len = i - start; 952 + wxString *token = new wxString(sql.Mid(start, len)); 953 + Insert(token); 954 + } 955 + Index = 0; 743 956 } 744 957 745 -void 746 -MyQueryView::OnRsLast (wxCommandEvent & WXUNUSED (event)) 958 +SqlTokenizer::~SqlTokenizer() 747 959 { 748 -// 749 -// scrolling to the result set ending 750 -// 751 - wxString sql = SqlCtrl->GetValue (); 752 - int start = RsMaxRow - RsBlock; 753 - if (start < 0) 754 - start = 0; 755 - if (ExecuteSql (sql, start) == false) 756 - wxMessageBox (SqlErrorMsg, wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 757 - MainFrame); 758 -} 759 - 760 -void 761 -MyQueryView::OnRefresh (wxCommandEvent & WXUNUSED (event)) 762 -{ 763 -// 764 -// refreshing the result set 765 -// 766 - wxString sql = SqlCtrl->GetValue (); 767 - int start = RsBeginRow; 768 - if (ExecuteSql (sql, start) == false) 769 - wxMessageBox (SqlErrorMsg, wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 770 - MainFrame); 960 +// destructor 961 + wxString *token; 962 + Index = 0; 963 + while (1) 964 + { 965 + token = TokenList[Index]; 966 + if (token == NULL) 967 + break; 968 + delete token; 969 + Index++; 970 + } 971 + delete[]TokenList; 771 972 } 772 973 773 -void 774 -MyQueryView::OnRightClick (wxGridEvent & event) 974 +void SqlTokenizer::Expand() 775 975 { 776 -// 777 -// right click on some cell [mouse action] 778 -// 779 - MyVariant *blobVar; 780 - wxMenu menu; 781 - wxMenuItem *menuItem; 782 - wxPoint pt = event.GetPosition (); 783 - if (ReadOnly == false && event.GetRow () == TableView->GetNumberRows () - 1) 784 - { 785 - // this is the INSERT ROW 786 - if (InsertPending == true) 787 - { 788 - menuItem = 789 - new wxMenuItem (&menu, Grid_Insert, 790 - wxT ("&Confirm insertion")); 791 - menu.Append (menuItem); 792 - menuItem = 793 - new wxMenuItem (&menu, Grid_Abort, 794 - wxT ("&Abort insertion")); 795 - menu.Append (menuItem); 796 - } 797 - else 798 - { 799 - menuItem = 800 - new wxMenuItem (&menu, Grid_Insert, 801 - wxT ("&Insert new row")); 802 - menu.Append (menuItem); 803 - } 804 - TableView->PopupMenu (&menu, pt); 805 - return; 806 - } 807 - CurrentEvtRow = event.GetRow (); 808 - CurrentEvtColumn = event.GetCol (); 809 - blobVar = TableBlobs->GetBlob (CurrentEvtRow, CurrentEvtColumn); 810 - if (blobVar) 811 - { 812 - // this one is a BLOB cell 813 - if (ReadOnly == false) 814 - { 815 - MyRowVariant *varRow = TableValues->GetRow (CurrentEvtRow); 816 - if (varRow->IsDeleted () == false) 817 - { 818 - menuItem = 819 - new wxMenuItem (&menu, Grid_Delete, 820 - wxT ("&Delete row")); 821 - menu.Append (menuItem); 822 - menuItem = 823 - new wxMenuItem (&menu, Grid_Insert, 824 - wxT ("&Insert new row")); 825 - menu.Append (menuItem); 826 - menu.AppendSeparator (); 827 - } 828 - } 829 - menuItem = new wxMenuItem (&menu, Grid_Blob, wxT ("BLOB &explore")); 830 - menu.Append (menuItem); 831 - if (MainFrame->GuessBlobType (blobVar->GetBlobSize (), 832 - blobVar->GetBlob ()) == 833 - MyFrame::BLOB_GEOMETRY) 834 - ; 835 - else 836 - { 837 - menu.AppendSeparator (); 838 - menuItem = 839 - new wxMenuItem (&menu, Grid_BlobIn, wxT ("BLOB &import")); 840 - menu.Append (menuItem); 841 - menuItem = 842 - new wxMenuItem (&menu, Grid_BlobOut, wxT ("BLOB &export")); 843 - menu.Append (menuItem); 844 - menuItem = 845 - new wxMenuItem (&menu, Grid_BlobNull, 846 - wxT ("Set BLOB as &NULL")); 847 - menu.Append (menuItem); 848 - } 849 - CurrentBlob = blobVar; 850 - } 851 - else 852 - { 853 - // this one is an ordinary cell 854 - CurrentBlob = NULL; 855 - if (ReadOnly == false) 856 - { 857 - MyRowVariant *varRow = TableValues->GetRow (CurrentEvtRow); 858 - if (varRow->IsDeleted () == false) 859 - { 860 - menuItem = 861 - new wxMenuItem (&menu, Grid_Delete, 862 - wxT ("&Delete row")); 863 - menu.Append (menuItem); 864 - menuItem = 865 - new wxMenuItem (&menu, Grid_Insert, 866 - wxT ("&Insert new row")); 867 - menu.Append (menuItem); 868 - if (IsBlobColumn (CurrentEvtColumn) == true) 869 - { 870 - menu.AppendSeparator (); 871 - menuItem = 872 - new wxMenuItem (&menu, Grid_BlobIn, 873 - wxT ("BLOB &import")); 874 - menu.Append (menuItem); 875 - } 876 - menu.AppendSeparator (); 877 - } 878 - } 879 - menuItem = 880 - new wxMenuItem (&menu, Grid_Clear, wxT ("&Clear selection")); 881 - menu.Append (menuItem); 882 - menuItem = new wxMenuItem (&menu, Grid_All, wxT ("Select &all")); 883 - menu.Append (menuItem); 884 - menuItem = new wxMenuItem (&menu, Grid_Row, wxT ("Select &row")); 885 - menu.Append (menuItem); 886 - menuItem = 887 - new wxMenuItem (&menu, Grid_Column, wxT ("&Select column")); 888 - menu.Append (menuItem); 889 - menu.AppendSeparator (); 890 - menuItem = new wxMenuItem (&menu, Grid_Copy, wxT ("&Copy")); 891 - menu.Append (menuItem); 892 - if (TableView->IsSelection () == false) 893 - menuItem->Enable (false); 894 - } 895 - TableView->PopupMenu (&menu, pt); 976 +// expanding the token list 977 + int newSize = Max + Block; 978 + int i; 979 + wxString **newList = new wxString *[newSize]; 980 + for (i = 0; i < newSize; i++) 981 + newList[i] = NULL; 982 + for (i = 0; i < Max; i++) 983 + newList[i] = TokenList[i]; 984 + delete[]TokenList; 985 + TokenList = newList; 986 + Max = newSize; 896 987 } 897 988 898 -void 899 -MyQueryView::OnCellSelected (wxGridEvent & event) 989 +void SqlTokenizer::Insert(wxString * token) 900 990 { 901 -// 902 -// cell selection changed 903 -// 904 - if (InsertPending == true) 905 - { 906 - // an INSERT row is still pending 907 - if (event.GetRow () != TableView->GetNumberRows () - 1) 908 - DoInsert (false); 909 - } 910 - event.Skip (); 911 -} 912 - 913 -void 914 -MyQueryView::OnCellChanged (wxGridEvent & event) 915 -{ 916 -// 917 -// user changed value in some cell 918 -// 919 - MyVariant *oldValue; 920 - MyVariant *insValue; 921 - wxString value; 922 - wxString numValue; 923 - wxString newValue = wxT ("NULL"); 924 - wxString sql; 925 - wxString rowid; 926 - char *errMsg = NULL; 927 - bool error = false; 928 - long int_value; 929 - bool okIntValue = false; 930 - double dbl_value; 931 - bool okDblValue = false; 932 - int ret; 933 - int row = event.GetRow (); 934 - int column = event.GetCol (); 935 - value = TableView->GetCellValue (row, column); 936 - if (InsertPending == true) 937 - { 938 - // an INSERT row is still pending 939 - insValue = InsertRow->GetColumn (column); 940 - numValue = value; 941 - numValue.Replace (wxT (","), wxT (".")); 942 - okIntValue = numValue.ToLong (&int_value); 943 - okDblValue = numValue.ToDouble (&dbl_value); 944 - if (okIntValue == true) 945 - insValue->Set ((int) int_value); 946 - else if (okDblValue == true) 947 - insValue->Set (dbl_value); 948 - else 949 - insValue->Set (value); 950 - if (row != TableView->GetNumberRows () - 1) 951 - DoInsert (false); 952 - return; 953 - } 954 - if (value.Len () > 0) 955 - { 956 - numValue = value; 957 - numValue.Replace (wxT (","), wxT (".")); 958 - okIntValue = numValue.ToLong (&int_value); 959 - okDblValue = numValue.ToDouble (&dbl_value); 960 - if (okIntValue == true) 961 - newValue.Printf (wxT ("%d"), int_value); 962 - else if (okDblValue == true) 963 - newValue.Printf (wxT ("%1.6lf"), dbl_value); 964 - else 965 - { 966 - value.Replace (wxT ("'"), wxT ("''")); 967 - newValue = wxT ("'") + value + wxT ("'"); 968 - } 969 - } 970 - oldValue = TableValues->GetValue (row, 0); 971 - rowid.Printf (wxT ("%d"), oldValue->GetIntValue ()); 972 - sql = 973 - wxT ("UPDATE ") + TableName + wxT (" SET ") + 974 - TableView->GetColLabelValue (column) + wxT (" = ") + newValue + 975 - wxT (" WHERE ROWID = ") + rowid; 976 - ret = 977 - sqlite3_exec (MainFrame->GetSqlite (), sql.ToUTF8 (), NULL, NULL, 978 - &errMsg); 979 - if (ret != SQLITE_OK) 980 - { 981 - wxMessageBox (wxT ("SQLite SQL error: ") + 982 - wxString::FromUTF8 (errMsg), wxT ("spatialite-gui"), 983 - wxOK | wxICON_ERROR, this); 984 - sqlite3_free (errMsg); 985 - error = true; 986 - } 987 - oldValue = TableValues->GetValue (row, column); 988 - if (error == true) 989 - { 990 - // update failed; restorig old cell value 991 - value = wxT ("NULL"); 992 - if (oldValue) 993 - { 994 - if (oldValue->GetType () == MY_INT_VARIANT) 995 - value.Printf (wxT ("%d"), oldValue->GetIntValue ()); 996 - if (oldValue->GetType () == MY_DBL_VARIANT) 997 - value.Printf (wxT ("%1.6lf"), oldValue->GetDblValue ()); 998 - if (oldValue->GetType () == MY_TXT_VARIANT) 999 - value = oldValue->GetTxtValue (); 1000 - } 1001 - TableView->SetCellValue (row, column, value); 1002 - TableView->ForceRefresh (); 1003 - } 1004 - else 1005 - { 1006 - // marking cell as modified 1007 - TableView->SetCellTextColour (row, column, wxColour (0, 0, 192)); 1008 - TableView->SetCellBackgroundColour (row, column, 1009 - wxColour (255, 255, 204)); 1010 - TableView->ForceRefresh (); 1011 - } 991 +// inserting a new token 992 + if (Index == (Max - 1)) 993 + Expand(); 994 + TokenList[Index++] = token; 1012 995 } 1013 996 1014 -void 1015 -MyQueryView::DoInsert (bool confirmed) 997 +bool SqlTokenizer::HasMoreTokens() 1016 998 { 1017 -// 1018 -// performing actual row INSERT 1019 -// 1020 - int i; 1021 - int ret; 1022 - MyVariant *var; 1023 - wxString value; 1024 - wxString strValue; 1025 - wxString sql; 1026 - char *errMsg = NULL; 1027 - if (confirmed == false) 1028 - { 1029 - ret = 1030 - wxMessageBox (wxT 1031 - ("A new row is ready for insertion\n\nConfirm ?"), 1032 - wxT ("spatialite-gui"), wxYES_NO | wxICON_QUESTION, 1033 - this); 1034 - if (ret != wxYES) 1035 - goto close_insert; 1036 - } 1037 - sql = wxT ("INSERT INTO ") + TableName + wxT (" ("); 1038 - for (i = 1; i < TableView->GetNumberCols (); i++) 1039 - { 1040 - if (i > 1) 1041 - sql += wxT (", "); 1042 - sql += TableView->GetColLabelValue (i); 1043 - } 1044 - sql += wxT (") VALUES ("); 1045 - for (i = 1; i < InsertRow->GetNumCols (); i++) 1046 - { 1047 - if (i > 1) 1048 - sql += wxT (", "); 1049 - var = InsertRow->GetColumn (i); 1050 - value = wxT ("NULL"); 1051 - if (var->GetType () == MY_INT_VARIANT) 1052 - value.Printf (wxT ("%d"), var->GetIntValue ()); 1053 - if (var->GetType () == MY_DBL_VARIANT) 1054 - value.Printf (wxT ("%d"), var->GetDblValue ()); 1055 - if (var->GetType () == MY_TXT_VARIANT) 1056 - { 1057 - strValue = var->GetTxtValue (); 1058 - strValue.Replace (wxT ("'"), wxT ("''")); 1059 - value = wxT ("'") + strValue + wxT ("'"); 1060 - } 1061 - sql += value; 1062 - } 1063 - sql += wxT (")"); 1064 - ret = 1065 - sqlite3_exec (MainFrame->GetSqlite (), sql.ToUTF8 (), NULL, NULL, 1066 - &errMsg); 1067 - if (ret != SQLITE_OK) 1068 - { 1069 - wxMessageBox (wxT ("SQLite SQL error: ") + 1070 - wxString::FromUTF8 (errMsg), wxT ("spatialite-gui"), 1071 - wxOK | wxICON_ERROR, this); 1072 - sqlite3_free (errMsg); 1073 - } 1074 - close_insert: 1075 -// 1076 -// closing insert row 1077 -// 1078 - InsertPending = false; 1079 - delete InsertRow; 1080 - InsertRow = NULL; 1081 - for (i = 0; i < TableView->GetNumberCols (); i++) 1082 - { 1083 - TableView->SetCellValue (TableView->GetNumberRows () - 1, i, 1084 - wxT ("")); 1085 - TableView->SetCellBackgroundColour (TableView->GetNumberRows () - 1, 1086 - i, wxColour (0, 0, 0)); 1087 - TableView->SetReadOnly (TableView->GetNumberRows () - 1, i); 1088 - } 1089 -} 1090 - 1091 -void 1092 -MyQueryView::OnCmdDelete (wxCommandEvent & event) 1093 -{ 1094 -// 1095 -// user required row deletion 1096 -// 1097 - char *errMsg = NULL; 1098 - bool error = false; 1099 - int ret; 1100 - int i; 1101 - wxString sql; 1102 - wxString rowid; 1103 - MyVariant *value; 1104 - MyRowVariant *varRow = TableValues->GetRow (CurrentEvtRow); 1105 - if (varRow->IsDeleted () == true) 1106 - return; 1107 - value = TableValues->GetValue (CurrentEvtRow, 0); 1108 - rowid.Printf (wxT ("%d"), value->GetIntValue ()); 1109 - ret = 1110 - wxMessageBox (wxT ("Requested deletion for row identified by RowId = ") 1111 - + rowid + wxT ("\n\nConfirm ?"), wxT ("spatialite-gui"), 1112 - wxYES_NO | wxICON_QUESTION, this); 1113 - if (ret != wxYES) 1114 - return; 1115 - sql = wxT ("DELETE FROM ") + TableName + wxT (" WHERE ROWID = ") + rowid; 1116 - ret = 1117 - sqlite3_exec (MainFrame->GetSqlite (), sql.ToUTF8 (), NULL, NULL, 1118 - &errMsg); 1119 - if (ret != SQLITE_OK) 1120 - { 1121 - wxMessageBox (wxT ("SQLite SQL error: ") + 1122 - wxString::FromUTF8 (errMsg), wxT ("spatialite-gui"), 1123 - wxOK | wxICON_ERROR, this); 1124 - sqlite3_free (errMsg); 1125 - error = true; 1126 - } 1127 - if (error == false) 1128 - { 1129 - // marking row as deleted 1130 - varRow->SetDeleted (); 1131 - for (i = 0; i < TableView->GetNumberCols (); i++) 1132 - { 1133 - TableView->SetCellTextColour (CurrentEvtRow, i, 1134 - wxColour (0, 0, 0)); 1135 - TableView->SetCellBackgroundColour (CurrentEvtRow, i, 1136 - wxColour (128, 128, 128)); 1137 - TableView->SetReadOnly (CurrentEvtRow, i); 1138 - } 1139 - TableView->ForceRefresh (); 1140 - } 1141 -} 1142 - 1143 -void 1144 -MyQueryView::OnCmdInsert (wxCommandEvent & event) 1145 -{ 1146 -// 1147 -// user required row insertion 1148 -// 1149 - int i; 1150 - if (ReadOnly == true) 1151 - return; 1152 - if (InsertPending == true) 1153 - { 1154 - // an INSERT is still pending, and the user required actual insertion 1155 - DoInsert (true); 1156 - return; 1157 - } 1158 - InsertRow = new MyRowVariant (TableView->GetNumberCols ()); 1159 - TableView->MakeCellVisible (TableView->GetNumberRows () - 1, 1); 1160 - InsertPending = true; 1161 - for (i = 1; i < TableView->GetNumberCols (); i++) 1162 - { 1163 - TableView->SetCellValue (TableView->GetNumberRows () - 1, i, 1164 - wxT ("")); 1165 - TableView->SetCellBackgroundColour (TableView->GetNumberRows () - 1, 1166 - i, wxColour (255, 255, 255)); 1167 - TableView->SetReadOnly (TableView->GetNumberRows () - 1, i, false); 1168 - } 999 + wxString *token = TokenList[Index]; 1000 + if (token == NULL) 1001 + return false; 1002 + return true; 1169 1003 } 1170 1004 1171 -void 1172 -MyQueryView::OnCmdAbort (wxCommandEvent & event) 1005 +wxString & SqlTokenizer::GetNextToken() 1173 1006 { 1174 -// 1175 -// user cancelled current row insertion 1176 -// 1177 - int i; 1178 - if (InsertPending) 1179 - { 1180 - InsertPending = false; 1181 - delete InsertRow; 1182 - InsertRow = NULL; 1183 - for (i = 0; i < TableView->GetNumberCols (); i++) 1184 - { 1185 - TableView->SetCellValue (TableView->GetNumberRows () - 1, i, 1186 - wxT ("")); 1187 - TableView->SetCellBackgroundColour (TableView-> 1188 - GetNumberRows () - 1, i, 1189 - wxColour (0, 0, 0)); 1190 - TableView->SetReadOnly (TableView->GetNumberRows () - 1, i); 1191 - } 1192 - } 1193 -} 1194 - 1195 -void 1196 -MyQueryView::OnCmdClearSelection (wxCommandEvent & event) 1197 -{ 1198 -// 1199 -// clearing current selection 1200 -// 1201 - TableView->ClearSelection (); 1202 -} 1203 - 1204 -void 1205 -MyQueryView::OnCmdSelectAll (wxCommandEvent & event) 1206 -{ 1207 -// 1208 -// selecting all 1209 -// 1210 - TableView->SelectAll (); 1211 -} 1212 - 1213 -void 1214 -MyQueryView::OnCmdSelectRow (wxCommandEvent & event) 1215 -{ 1216 -// 1217 -// selecting the current row 1218 -// 1219 - TableView->SelectRow (CurrentEvtRow); 1220 -} 1221 - 1222 -void 1223 -MyQueryView::OnCmdSelectColumn (wxCommandEvent & event) 1224 -{ 1225 -// 1226 -// selecting column 1227 -// 1228 - TableView->SelectCol (CurrentEvtColumn); 1229 -} 1230 - 1231 -void 1232 -MyQueryView::OnCmdCopy (wxCommandEvent & event) 1233 -{ 1234 -// 1235 -// copying the selection into the clipboard 1236 -// 1237 - wxString copyData; 1238 - int row; 1239 - int col; 1240 - bool newRow; 1241 - bool firstRow = true; 1242 - for (row = 0; row < TableView->GetNumberRows (); row++) 1243 - { 1244 - newRow = true; 1245 - for (col = 0; col < TableView->GetNumberCols (); col++) 1246 - { 1247 - if (TableView->IsInSelection (row, col) == true) 1248 - { 1249 - // ok, this cell is included into the selection to copy 1250 - if (firstRow == true) 1251 - { 1252 - newRow = false; 1253 - firstRow = false; 1254 - } 1255 - else if (newRow == true) 1256 - { 1257 - newRow = false; 1258 - copyData += wxT ("\n"); 1259 - } 1260 - else 1261 - copyData += wxT ("\t"); 1262 - copyData += TableView->GetCellValue (row, col); 1263 - } 1264 - } 1265 - } 1266 - if (wxTheClipboard->Open ()) 1267 - { 1268 - wxTheClipboard->SetData (new wxTextDataObject (copyData)); 1269 - wxTheClipboard->Close (); 1270 - } 1271 -} 1272 - 1273 -void 1274 -MyQueryView::OnCmdBlob (wxCommandEvent & event) 1275 -{ 1276 -// 1277 -// exploring some BLOB value 1278 -// 1279 - if (!CurrentBlob) 1280 - return; 1281 - BlobExplorerDialog dlg; 1282 - dlg.Create (MainFrame, CurrentBlob->GetBlobSize (), 1283 - CurrentBlob->GetBlob ()); 1284 - dlg.ShowModal (); 1285 -} 1286 - 1287 -void 1288 -MyQueryView::OnCmdBlobIn (wxCommandEvent & event) 1289 -{ 1290 -// importing an external file into a BLOB-value 1291 - FILE *in = NULL; 1292 - char path[2048]; 1293 - int rd; 1294 - int maxSize = 1024 * 1024; // limit BLOB size to 1MB 1295 - wxString fileList; 1296 - wxString rowid; 1297 - wxString sql; 1298 - wxString blobValue; 1299 - wxString hex; 1300 - MyVariant *value; 1301 - bool error = false; 1302 - unsigned char *buffer = NULL; 1303 - int ret; 1304 - char *errMsg = NULL; 1305 - wxString lastDir; 1306 - fileList = 1307 - wxT 1308 - ("BLOB Document (*.jpg;*.jpeg;*.png;*.gif;*.pdf;*.zip)|*.jpg;*.jpeg;*.png;*.gif;*.pdf;*.zip|"); 1309 - fileList += 1310 - wxT ("Image (*.jpg;*.jpeg;*.png;*.gif)|*.jpg;*.jpeg;*.png;*.gif|"); 1311 - fileList += 1312 - wxT 1313 - ("JPEG Image (*.jpg;*.jpeg)|*.jpg;*.jpeg|PNG Image (*.png)|*.png|GIF Image (*.gif)|*.gif"); 1314 - fileList += 1315 - wxT 1316 - ("PDF Document (*.pdf)|*.pdf|ZIP Archive|(*.zip)|All files (*.*)|*.*"); 1317 - wxFileDialog *fileDialog = 1318 - new wxFileDialog (this, wxT ("loading a BLOB value"), 1319 - wxT (""), wxT (""), fileList, 1320 - wxFD_OPEN | wxFD_FILE_MUST_EXIST, wxDefaultPosition, 1321 - wxDefaultSize, wxT ("filedlg")); 1322 - lastDir = MainFrame->GetLastDirectory (); 1323 - if (lastDir.Len () >= 1) 1324 - fileDialog->SetDirectory (lastDir); 1325 - ret = fileDialog->ShowModal (); 1326 - if (ret == wxID_OK) 1327 - { 1328 - strcpy (path, fileDialog->GetPath ().ToUTF8 ()); 1329 - in = fopen (path, "rb"); 1330 - if (!in) 1331 - { 1332 - wxMessageBox (wxT ("Cannot open '") + fileDialog->GetPath () + 1333 - wxT ("' for reading"), wxT ("spatialite-gui"), 1334 - wxOK | wxICON_ERROR, this); 1335 - return; 1336 - } 1337 - wxFileName file (fileDialog->GetPath ()); 1338 - lastDir = file.GetPath (); 1339 - MainFrame->SetLastDirectory (lastDir); 1340 - ::wxBeginBusyCursor (); 1341 - buffer = new unsigned char[maxSize]; 1342 - rd = fread (buffer, 1, maxSize, in); 1343 - if (rd == maxSize && !(feof (in))) 1344 - { 1345 - // exceding 1MB; it's too big for a BLOB 1346 - wxMessageBox (wxT 1347 - ("Selected file excedes 1MB; cowardly refusing to load it as a BLOB value ..."), 1348 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 1349 - this); 1350 - goto end; 1351 - } 1352 - if (ferror (in)) 1353 - { 1354 - // I/O error 1355 - wxMessageBox (wxT ("an I/O error occurred"), 1356 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 1357 - this); 1358 - goto end; 1359 - } 1360 - // 1361 - // preparing theSQL UPDATE statement 1362 - // 1363 - value = TableValues->GetValue (CurrentEvtRow, 0); 1364 - rowid.Printf (wxT ("%d"), value->GetIntValue ()); 1365 - HexBlobValue (buffer, rd, hex); 1366 - sql = 1367 - wxT ("UPDATE ") + TableName + wxT (" SET ") + 1368 - TableView->GetColLabelValue (CurrentEvtColumn); 1369 - sql += wxT (" = ") + hex + wxT (" WHERE ROWID = ") + rowid; 1370 - ret = 1371 - sqlite3_exec (MainFrame->GetSqlite (), sql.ToUTF8 (), NULL, NULL, 1372 - &errMsg); 1373 - if (ret != SQLITE_OK) 1374 - { 1375 - wxMessageBox (wxT ("SQLite SQL error: ") + 1376 - wxString::FromUTF8 (errMsg), 1377 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 1378 - this); 1379 - sqlite3_free (errMsg); 1380 - error = true; 1381 - } 1382 - ::wxEndBusyCursor (); 1383 - value = TableValues->GetValue (CurrentEvtRow, CurrentEvtColumn); 1384 - if (error == false) 1385 - { 1386 - // updating the Grid cell 1387 - blobValue.Printf (wxT ("BLOB sz=%d "), rd); 1388 - switch (MainFrame->GuessBlobType (rd, buffer)) 1389 - { 1390 - case MyFrame::BLOB_EXIF: 1391 - case MyFrame::BLOB_JFIF: 1392 - case MyFrame::BLOB_JPEG: 1393 - blobValue += wxT ("JPEG image"); 1394 - break; 1395 - case MyFrame::BLOB_PNG: 1396 - blobValue += wxT ("PNG image"); 1397 - break; 1398 - case MyFrame::BLOB_GIF: 1399 - blobValue += wxT ("GIF image"); 1400 - break; 1401 - case MyFrame::BLOB_PDF: 1402 - blobValue += wxT ("PDF document"); 1403 - break; 1404 - case MyFrame::BLOB_ZIP: 1405 - blobValue += wxT ("ZIP archive"); 1406 - break; 1407 - default: 1408 - blobValue += wxT ("UNKNOWN type"); 1409 - }; 1410 - TableView->SetCellValue (CurrentEvtRow, CurrentEvtColumn, 1411 - blobValue); 1412 - TableView->SetCellTextColour (CurrentEvtRow, CurrentEvtColumn, 1413 - wxColour (0, 0, 192)); 1414 - TableView->SetCellBackgroundColour (CurrentEvtRow, 1415 - CurrentEvtColumn, 1416 - wxColour (255, 255, 204)); 1417 - TableView->ForceRefresh (); 1418 - } 1419 - } 1420 - end: 1421 -// clean-up 1422 - if (in) 1423 - fclose (in); 1424 - if (buffer) 1425 - delete[]buffer; 1426 -} 1427 - 1428 -void 1429 -MyQueryView::HexBlobValue (unsigned char *blob, int size, wxString & hex) 1430 -{ 1431 -// 1432 -// builds the HEX BLOB as X'01234567890abcdef' 1433 -// 1434 - int i; 1435 - wxString digit; 1436 - hex = wxT ("X'"); 1437 - for (i = 0; i < size; i++) 1438 - { 1439 - digit.Printf (wxT ("%02x"), *(blob + i)); 1440 - hex += digit; 1441 - } 1442 - hex += wxT ("'"); 1443 -} 1444 - 1445 -void 1446 -MyQueryView::OnCmdBlobOut (wxCommandEvent & event) 1447 -{ 1448 -// exporting to external file a BLOB-value 1449 - int blobType; 1450 - wxString fileName; 1451 - wxString fileType; 1452 - int ret; 1453 - wxString path; 1454 - FILE *out = NULL; 1455 - char xpath[2048]; 1456 - int wr; 1457 - wxString lastDir; 1458 - if (!CurrentBlob) 1459 - return; 1460 - blobType = 1461 - MainFrame->GuessBlobType (CurrentBlob->GetBlobSize (), 1462 - CurrentBlob->GetBlob ()); 1463 - switch (blobType) 1464 - { 1465 - case MyFrame::BLOB_EXIF: 1466 - case MyFrame::BLOB_JFIF: 1467 - case MyFrame::BLOB_JPEG: 1468 - fileName = wxT ("image.jpg"); 1469 - fileType = wxT ("File JPEG (*.jpg;*.jpeg)|*.jpg"); 1470 - break; 1471 - case MyFrame::BLOB_PNG: 1472 - fileName = wxT ("image.png"); 1473 - fileType = wxT ("File PNG (*.png)|*.png"); 1474 - break; 1475 - case MyFrame::BLOB_GIF: 1476 - fileName = wxT ("image.gif"); 1477 - fileType = wxT ("File GIF (*.gif)|*.gif"); 1478 - break; 1479 - case MyFrame::BLOB_PDF: 1480 - fileName = wxT ("document.pdf"); 1481 - fileType = wxT ("PDF document (*.jpg;*.jpeg)|*.jpg"); 1482 - break; 1483 - case MyFrame::BLOB_ZIP: 1484 - fileName = wxT ("archive.zip"); 1485 - fileType = wxT ("ZIP Archive (*.zip)|*.zip"); 1486 - break; 1487 - default: 1488 - fileName = wxT ("file"); 1489 - }; 1490 - fileType += wxT ("|All files (*.*)|*.*"); 1491 - wxFileDialog *fileDialog = 1492 - new wxFileDialog (this, wxT ("exporting a BLOB value to file"), 1493 - wxT (""), fileName, fileType, 1494 - wxFD_SAVE | wxFD_OVERWRITE_PROMPT, wxDefaultPosition, 1495 - wxDefaultSize, wxT ("filedlg")); 1496 - lastDir = MainFrame->GetLastDirectory (); 1497 - if (lastDir.Len () >= 1) 1498 - fileDialog->SetDirectory (lastDir); 1499 - ret = fileDialog->ShowModal (); 1500 - if (ret == wxID_OK) 1501 - { 1502 - wxFileName file (fileDialog->GetPath ()); 1503 - path = file.GetPath (); 1504 - path += file.GetPathSeparator (); 1505 - path += file.GetName (); 1506 - switch (blobType) 1507 - { 1508 - case MyFrame::BLOB_EXIF: 1509 - case MyFrame::BLOB_JFIF: 1510 - case MyFrame::BLOB_JPEG: 1511 - path += wxT (".jpg"); 1512 - break; 1513 - case MyFrame::BLOB_PNG: 1514 - path += wxT (".png"); 1515 - break; 1516 - case MyFrame::BLOB_GIF: 1517 - path += wxT (".gif"); 1518 - break; 1519 - case MyFrame::BLOB_PDF: 1520 - path += wxT (".pdf"); 1521 - break; 1522 - case MyFrame::BLOB_ZIP: 1523 - path += wxT (".zip"); 1524 - break; 1525 - default: 1526 - path += file.GetExt (); 1527 - }; 1528 - strcpy (xpath, path.ToUTF8 ()); 1529 - out = fopen (xpath, "wb"); 1530 - if (!out) 1531 - { 1532 - wxMessageBox (wxT ("Cannot open '") + path + 1533 - wxT ("' for writing"), wxT ("spatialite-gui"), 1534 - wxOK | wxICON_ERROR, this); 1535 - return; 1536 - } 1537 - lastDir = file.GetPath (); 1538 - MainFrame->SetLastDirectory (lastDir); 1539 - ::wxBeginBusyCursor (); 1540 - wr = fwrite (CurrentBlob->GetBlob (), 1, CurrentBlob->GetBlobSize (), 1541 - out); 1542 - if (wr != CurrentBlob->GetBlobSize ()) 1543 - { 1544 - wxMessageBox (wxT ("an I/O error occurred"), 1545 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 1546 - this); 1547 - } 1548 - fclose (out); 1549 - ::wxEndBusyCursor (); 1550 - } 1551 -} 1552 - 1553 -void 1554 -MyQueryView::OnCmdBlobNull (wxCommandEvent & event) 1555 -{ 1556 -// setting to NULL a BLOB-value 1557 - wxString rowid; 1558 - wxString sql; 1559 - int ret; 1560 - char *errMsg = NULL; 1561 - bool error = false; 1562 - MyVariant *value; 1563 - value = TableValues->GetValue (CurrentEvtRow, 0); 1564 - rowid.Printf (wxT ("%d"), value->GetIntValue ()); 1565 - sql = 1566 - wxT ("UPDATE ") + TableName + wxT (" SET ") + 1567 - TableView->GetColLabelValue (CurrentEvtColumn); 1568 - sql += wxT (" = NULL WHERE ROWID = ") + rowid; 1569 - ret = 1570 - sqlite3_exec (MainFrame->GetSqlite (), sql.ToUTF8 (), NULL, NULL, 1571 - &errMsg); 1572 - if (ret != SQLITE_OK) 1573 - { 1574 - wxMessageBox (wxT ("SQLite SQL error: ") + 1575 - wxString::FromUTF8 (errMsg), wxT ("spatialite-gui"), 1576 - wxOK | wxICON_ERROR, this); 1577 - sqlite3_free (errMsg); 1578 - error = true; 1579 - } 1580 - if (error == false) 1581 - { 1582 - // updating the Grid cell 1583 - TableView->SetCellValue (CurrentEvtRow, CurrentEvtColumn, 1584 - wxT ("NULL")); 1585 - TableView->SetCellTextColour (CurrentEvtRow, CurrentEvtColumn, 1586 - wxColour (0, 0, 192)); 1587 - TableView->SetCellBackgroundColour (CurrentEvtRow, CurrentEvtColumn, 1588 - wxColour (255, 255, 204)); 1589 - TableView->ForceRefresh (); 1590 - } 1007 +// return the next token 1008 + wxString *token = TokenList[Index]; 1009 + Index++; 1010 + CurrentToken = *token; 1011 + return CurrentToken; 1591 1012 }
Added ResultSetView.cpp.
1 +/* 2 +/ ResultSetView.cpp 3 +/ a panel to show SQL query results 4 +/ 5 +/ version 1.2, 2008 October 9 6 +/ 7 +/ Author: Sandro Furieri a-furieri@lqt.it 8 +/ 9 +/ Copyright (C) 2008 Alessandro Furieri 10 +/ 11 +/ This program is free software: you can redistribute it and/or modify 12 +/ it under the terms of the GNU General Public License as published by 13 +/ the Free Software Foundation, either version 3 of the License, or 14 +/ (at your option) any later version. 15 +/ 16 +/ This program is distributed in the hope that it will be useful, 17 +/ but WITHOUT ANY WARRANTY; without even the implied warranty of 18 +/ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 +/ GNU General Public License for more details. 20 +/ 21 +/ You should have received a copy of the GNU General Public License 22 +/ along with this program. If not, see <http://www.gnu.org/licenses/>. 23 +/ 24 +*/ 25 + 26 +#include "Classdef.h" 27 + 28 +#include "wx/clipbrd.h" 29 +#include "wx/filename.h" 30 + 31 +// 32 +// ICONs in XPM format [universally portable] 33 +// 34 +#include "icons/rs_first.xpm" 35 +#include "icons/rs_last.xpm" 36 +#include "icons/rs_next.xpm" 37 +#include "icons/rs_previous.xpm" 38 +#include "icons/refresh.xpm" 39 + 40 +#if defined(_WIN32) || defined (__MINGW32__) 41 +#define FORMAT_64 "%I64d" 42 +#else 43 +#define FORMAT_64 "%lld" 44 +#endif 45 + 46 +MyResultSetView::MyResultSetView(MyFrame * parent, wxWindowID id): 47 +wxPanel(parent, id, wxDefaultPosition, wxSize(440, 480), wxBORDER_SUNKEN) 48 +{ 49 +// 50 +// constructor: a frame for SQL Result Sets 51 +// 52 + RsBlock = 500; // the ResultSet block size 53 + RowIds = new sqlite3_int64[RsBlock]; 54 + ReadOnly = true; 55 + InsertRow = NULL; 56 + MainFrame = parent; 57 + BtnRsFirst = 58 + new wxBitmapButton(this, ID_RS_FIRST, wxBitmap(rs_first_xpm), 59 + wxPoint(5, 400), wxSize(32, 32)); 60 + BtnRsFirst->SetToolTip(wxT("ResultSet: go to first row")); 61 + BtnRsPrevious = 62 + new wxBitmapButton(this, ID_RS_PREVIOUS, wxBitmap(rs_previous_xpm), 63 + wxPoint(55, 400), wxSize(32, 32)); 64 + BtnRsPrevious->SetToolTip(wxT("ResultSet: go to previous block")); 65 + BtnRefresh = 66 + new wxBitmapButton(this, ID_REFRESH, wxBitmap(refresh_xpm), 67 + wxPoint(55, 400), wxSize(32, 32)); 68 + BtnRefresh->SetToolTip(wxT("ResultSet: refresh")); 69 + BtnRsNext = 70 + new wxBitmapButton(this, ID_RS_NEXT, wxBitmap(rs_next_xpm), 71 + wxPoint(105, 400), wxSize(32, 32)); 72 + BtnRsNext->SetToolTip(wxT("ResultSet: go to next block")); 73 + BtnRsLast = 74 + new wxBitmapButton(this, ID_RS_LAST, wxBitmap(rs_last_xpm), 75 + wxPoint(155, 400), wxSize(32, 32)); 76 + BtnRsLast->SetToolTip(wxT("ResultSet: go to last row")); 77 + RsCurrentBlock = 78 + new wxStaticText(this, ID_RS_BLOCK, wxT(""), wxPoint(210, 400), 79 + wxSize(200, 18)); 80 + TableView = NULL; 81 + TableBlobs = NULL; 82 + TableValues = NULL; 83 + CurrentBlob = NULL; 84 +// setting up event handlers 85 + Connect(ID_RS_FIRST, wxEVT_COMMAND_BUTTON_CLICKED, 86 + (wxObjectEventFunction) & MyResultSetView::OnRsFirst); 87 + Connect(ID_RS_PREVIOUS, wxEVT_COMMAND_BUTTON_CLICKED, 88 + (wxObjectEventFunction) & MyResultSetView::OnRsPrevious); 89 + Connect(ID_RS_NEXT, wxEVT_COMMAND_BUTTON_CLICKED, 90 + (wxObjectEventFunction) & MyResultSetView::OnRsNext); 91 + Connect(ID_RS_LAST, wxEVT_COMMAND_BUTTON_CLICKED, 92 + (wxObjectEventFunction) & MyResultSetView::OnRsLast); 93 + Connect(ID_REFRESH, wxEVT_COMMAND_BUTTON_CLICKED, 94 + (wxObjectEventFunction) & MyResultSetView::OnRefresh); 95 + Connect(wxID_ANY, wxEVT_SIZE, 96 + (wxObjectEventFunction) & MyResultSetView::OnSize); 97 + Connect(wxID_ANY, wxEVT_GRID_SELECT_CELL, 98 + (wxObjectEventFunction) & MyResultSetView::OnCellSelected); 99 + Connect(wxID_ANY, wxEVT_GRID_CELL_RIGHT_CLICK, 100 + (wxObjectEventFunction) & MyResultSetView::OnRightClick); 101 + Connect(wxID_ANY, wxEVT_GRID_CELL_CHANGE, 102 + (wxObjectEventFunction) & MyResultSetView::OnCellChanged); 103 + Connect(Grid_Delete, wxEVT_COMMAND_MENU_SELECTED, 104 + (wxObjectEventFunction) & MyResultSetView::OnCmdDelete); 105 + Connect(Grid_Insert, wxEVT_COMMAND_MENU_SELECTED, 106 + (wxObjectEventFunction) & MyResultSetView::OnCmdInsert); 107 + Connect(Grid_Abort, wxEVT_COMMAND_MENU_SELECTED, 108 + (wxObjectEventFunction) & MyResultSetView::OnCmdAbort); 109 + Connect(Grid_Clear, wxEVT_COMMAND_MENU_SELECTED, 110 + (wxObjectEventFunction) & MyResultSetView::OnCmdClearSelection); 111 + Connect(Grid_All, wxEVT_COMMAND_MENU_SELECTED, 112 + (wxObjectEventFunction) & MyResultSetView::OnCmdSelectAll); 113 + Connect(Grid_Row, wxEVT_COMMAND_MENU_SELECTED, 114 + (wxObjectEventFunction) & MyResultSetView::OnCmdSelectRow); 115 + Connect(Grid_Column, wxEVT_COMMAND_MENU_SELECTED, 116 + (wxObjectEventFunction) & MyResultSetView::OnCmdSelectColumn); 117 + Connect(Grid_Copy, wxEVT_COMMAND_MENU_SELECTED, 118 + (wxObjectEventFunction) & MyResultSetView::OnCmdCopy); 119 + Connect(Grid_Blob, wxEVT_COMMAND_MENU_SELECTED, 120 + (wxObjectEventFunction) & MyResultSetView::OnCmdBlob); 121 + Connect(Grid_BlobIn, wxEVT_COMMAND_MENU_SELECTED, 122 + (wxObjectEventFunction) & MyResultSetView::OnCmdBlobIn); 123 + Connect(Grid_BlobOut, wxEVT_COMMAND_MENU_SELECTED, 124 + (wxObjectEventFunction) & MyResultSetView::OnCmdBlobOut); 125 + Connect(Grid_BlobNull, wxEVT_COMMAND_MENU_SELECTED, 126 + (wxObjectEventFunction) & MyResultSetView::OnCmdBlobNull); 127 +} 128 + 129 +MyResultSetView::~MyResultSetView() 130 +{ 131 +// destructor 132 + if (RowIds) 133 + delete[]RowIds; 134 + if (InsertRow) 135 + delete InsertRow; 136 + if (TableBlobs) 137 + delete TableBlobs; 138 + if (TableValues) 139 + delete TableValues; 140 +} 141 + 142 +void MyResultSetView::ShowControls() 143 +{ 144 +// 145 +// making all ResultSet controls to be visible 146 +// 147 + BtnRsFirst->Show(true); 148 + BtnRsPrevious->Show(true); 149 + BtnRsNext->Show(true); 150 + BtnRsLast->Show(true); 151 + BtnRefresh->Show(true); 152 + RsCurrentBlock->Show(true); 153 + if (TableView) 154 + TableView->Show(true); 155 +} 156 + 157 +void MyResultSetView::HideControls() 158 +{ 159 +// 160 +// making all controls to be invisible 161 +// 162 + BtnRsFirst->Show(false); 163 + BtnRsPrevious->Show(false); 164 + BtnRsNext->Show(false); 165 + BtnRsLast->Show(false); 166 + BtnRefresh->Show(false); 167 + RsCurrentBlock->Show(false); 168 + if (TableView) 169 + TableView->Show(false); 170 +} 171 + 172 +void MyResultSetView::EditTable(wxString & sql, int *primaryKeys, int *blobCols, 173 + wxString & table) 174 +{ 175 +// 176 +// starting the edit table sequence 177 +// 178 + int i; 179 + for (i = 0; i < 1024; i++) 180 + { 181 + PrimaryKeys[i] = *(primaryKeys + i); 182 + BlobColumns[i] = *(blobCols + i); 183 + } 184 + ReadOnly = false; 185 + TableName = table; 186 + MainFrame->GetQueryView()->GetSqlCtrl()->SetValue(sql); 187 + if (ExecuteSql(sql, 0, ReadOnly) == false) 188 + wxMessageBox(SqlErrorMsg, wxT("spatialite-gui"), wxOK | wxICON_ERROR, 189 + MainFrame); 190 +} 191 + 192 +bool MyResultSetView::ExecuteSql(wxString & sql, int from, bool read_only) 193 +{ 194 +// 195 +// executing some SQL statement 196 +// 197 + ReadOnly = read_only; 198 + char *xSql = NULL; 199 + char err_msg[2048]; 200 + char dummy[1024]; 201 + int columns; 202 + int i_col; 203 + int i_row; 204 + int end_row = 0; 205 + wxString blobType; 206 + MyVariantList list; 207 + MyRowVariant *row; 208 + MyVariant *value; 209 + wxString cellValue; 210 + wxString currentBlock; 211 + sqlite3_stmt *stmt; 212 + sqlite3 *sqlite = MainFrame->GetSqlite(); 213 + SqlErrorMsg = wxT(""); 214 + if (TableView) 215 + TableView->Destroy(); 216 + TableView = NULL; 217 + if (TableBlobs) 218 + delete TableBlobs; 219 + if (TableValues) 220 + delete TableValues; 221 + TableBlobs = NULL; 222 + TableValues = NULL; 223 + CurrentBlob = NULL; 224 + HideControls(); 225 + RsBeginRow = 0; 226 + RsEndRow = 0; 227 + RsMaxRow = 0; 228 + for (i_row = 0; i_row < RsBlock; i_row++) 229 + RowIds[i_row] = -1; 230 + i_row = 0; 231 + xSql = new char[65536]; 232 + strcpy(xSql, sql.ToUTF8()); 233 + ::wxBeginBusyCursor(); 234 + int ret = sqlite3_prepare_v2(sqlite, xSql, strlen(xSql), &stmt, NULL); 235 + if (ret != SQLITE_OK) 236 + { 237 + sprintf(err_msg, "SQL error: \"%s\"", sqlite3_errmsg(sqlite)); 238 + SqlErrorMsg = wxString::FromUTF8(err_msg); 239 + ::wxEndBusyCursor(); 240 + delete[]xSql; 241 + return false; 242 + } 243 + RsCurrentBlock->Show(true); 244 + while (1) 245 + { 246 + // 247 + // fetching the result set rows 248 + // 249 + ret = sqlite3_step(stmt); 250 + if (ret == SQLITE_DONE) 251 + break; // end of result set 252 + if (ret == SQLITE_ROW) 253 + { 254 + // 255 + // fetching a row 256 + // 257 + if ((i_row % 100) == 0) 258 + { 259 + sprintf(dummy, "fetching the result set: %d rows", i_row); 260 + currentBlock = wxString::FromUTF8(dummy); 261 + RsCurrentBlock->SetLabel(currentBlock); 262 + } 263 + if (i_row < from) 264 + { 265 + i_row++; 266 + continue; 267 + } 268 + if ((i_row - from) >= RsBlock) 269 + { 270 + i_row++; 271 + continue; 272 + } 273 + end_row = i_row; 274 + columns = sqlite3_column_count(stmt); 275 + MyRowVariant *rowVariant = list.Add(columns); 276 + for (i_col = 0; i_col < columns; i_col++) 277 + { 278 + sqlite3_int64 int_value; 279 + double dbl_value; 280 + const unsigned char *txt_value; 281 + const void *blob_value; 282 + int blobSize; 283 + list.SetColumnName(i_col, sqlite3_column_name(stmt, i_col)); 284 + switch (sqlite3_column_type(stmt, i_col)) 285 + { 286 + case SQLITE_INTEGER: 287 + int_value = sqlite3_column_int64(stmt, i_col); 288 + rowVariant->Set(i_col, int_value); 289 + break; 290 + case SQLITE_FLOAT: 291 + dbl_value = sqlite3_column_double(stmt, i_col); 292 + rowVariant->Set(i_col, dbl_value); 293 + break; 294 + case SQLITE_TEXT: 295 + txt_value = sqlite3_column_text(stmt, i_col); 296 + rowVariant->Set(i_col, txt_value); 297 + break; 298 + case SQLITE_BLOB: 299 + blob_value = sqlite3_column_blob(stmt, i_col); 300 + blobSize = sqlite3_column_bytes(stmt, i_col); 301 + rowVariant->Set(i_col, blob_value, blobSize); 302 + break; 303 + case SQLITE_NULL: 304 + default: 305 + break; 306 + }; 307 + } 308 + i_row++; 309 + } else 310 + { 311 + sprintf(err_msg, "SQL error: \"%s\"", sqlite3_errmsg(sqlite)); 312 + SqlErrorMsg = wxString::FromUTF8(err_msg); 313 + goto error; 314 + } 315 + } 316 + sqlite3_finalize(stmt); 317 + RsBeginRow = from; 318 + RsEndRow = end_row; 319 + RsMaxRow = i_row; 320 + if (list.GetRows() == 0) 321 + { 322 + // 323 + // this one is an EMPTY Result Set 324 + // 325 + if (ReadOnly == false) 326 + { 327 + // preparing the insert row 328 + int numCols = 0; 329 + wxString *colNames = MainFrame->GetColumnNames(TableName, &numCols); 330 + CreateGrid(0, numCols + 1); 331 + TableView->SetColLabelValue(0, wxT("ROWID")); 332 + for (i_col = 0; i_col < numCols; i_col++) 333 + TableView->SetColLabelValue(i_col + 1, *(colNames + i_col)); 334 + TableView->EnableEditing(true); 335 + delete[]colNames; 336 + } else 337 + { 338 + // simply showing a warning message 339 + CreateGrid(1, 1); 340 + TableView->SetColLabelValue(0, wxT("Message")); 341 + TableView->SetRowLabelValue(0, wxT("Message")); 342 + TableView->SetCellValue(0, 0, 343 + wxT 344 + ("SQL query returned an empty ResultSet\n\nThis is not an error")); 345 + } 346 + } else 347 + { 348 + // 349 + // preparing the Grid to show the result set 350 + // 351 + CreateGrid(list.GetRows(), list.GetColumns()); 352 + if (ReadOnly == true) 353 + TableView->EnableEditing(false); 354 + else 355 + TableView->EnableEditing(true); 356 + for (i_col = 0; i_col < list.GetColumns(); i_col++) 357 + TableView->SetColLabelValue(i_col, list.GetColumnName(i_col)); 358 + if (ReadOnly == false) 359 + TableView->SetColLabelValue(0, wxT("ROWID")); 360 + i_row = 0; 361 + row = list.GetFirst(); 362 + while (row) 363 + { 364 + sprintf(dummy, "%d", i_row + RsBeginRow + 1); 365 + cellValue = wxString::FromUTF8(dummy); 366 + TableView->SetRowLabelValue(i_row, cellValue); 367 + if (ReadOnly == false) 368 + { 369 + // storing the ROWID value into the RowIds array 370 + value = row->GetColumn(0); 371 + if (value->GetType() == MY_INT_VARIANT) 372 + RowIds[i_row] = value->GetIntValue(); 373 + } 374 + for (i_col = 0; i_col < row->GetNumCols(); i_col++) 375 + { 376 + value = row->GetColumn(i_col); 377 + if (value) 378 + { 379 + switch (value->GetType()) 380 + { 381 + case MY_INT_VARIANT: 382 + sprintf(dummy, FORMAT_64, value->GetIntValue()); 383 + cellValue = wxString::FromUTF8(dummy); 384 + TableView->SetCellValue(i_row, i_col, cellValue); 385 + if (ReadOnly == false) 386 + TableValues->SetValue(i_row, i_col, 387 + value->GetIntValue()); 388 + break; 389 + case MY_DBL_VARIANT: 390 + sprintf(dummy, "%1.6lf", value->GetDblValue()); 391 + cellValue = wxString::FromUTF8(dummy); 392 + TableView->SetCellValue(i_row, i_col, cellValue); 393 + if (ReadOnly == false) 394 + TableValues->SetValue(i_row, i_col, 395 + value->GetDblValue()); 396 + break; 397 + case MY_TXT_VARIANT: 398 + TableView->SetCellValue(i_row, i_col, 399 + value->GetTxtValue()); 400 + if (ReadOnly == false) 401 + TableValues->SetValue(i_row, i_col, 402 + value->GetTxtValue()); 403 + break; 404 + case MY_BLOB_VARIANT: 405 + blobType = wxT("UNKNOWN type"); 406 + switch (gaiaGuessBlobType 407 + (value->GetBlob(), value->GetBlobSize())) 408 + { 409 + case GAIA_GEOMETRY_BLOB: 410 + blobType = wxT("GEOMETRY"); 411 + break; 412 + case GAIA_JPEG_BLOB: 413 + blobType = wxT("JPEG image"); 414 + break; 415 + case GAIA_EXIF_BLOB: 416 + blobType = wxT("JPEG-EXIF image"); 417 + break; 418 + case GAIA_EXIF_GPS_BLOB: 419 + blobType = wxT("JPEG-EXIF-GPS image"); 420 + break; 421 + case GAIA_PNG_BLOB: 422 + blobType = wxT("PNG image"); 423 + break; 424 + case GAIA_GIF_BLOB: 425 + blobType = wxT("GIF image"); 426 + break; 427 + case GAIA_PDF_BLOB: 428 + blobType = wxT("PDF document"); 429 + break; 430 + case GAIA_ZIP_BLOB: 431 + blobType = wxT("ZIP archive"); 432 + break; 433 + }; 434 + sprintf(dummy, "BLOB sz=%d ", value->GetBlobSize()); 435 + cellValue = wxString::FromUTF8(dummy); 436 + cellValue += blobType; 437 + TableView->SetCellValue(i_row, i_col, cellValue); 438 + TableView->SetReadOnly(i_row, i_col); 439 + TableBlobs->SetBlob(i_row, i_col, value); 440 + break; 441 + case MY_NULL_VARIANT: 442 + default: 443 + TableView->SetCellValue(i_row, i_col, wxT("NULL")); 444 + break; 445 + }; 446 + } else 447 + TableView->SetCellValue(i_row, i_col, wxT("NULL")); 448 + if (ReadOnly == false) 449 + { 450 + if (IsPrimaryKey(i_col) == true) 451 + TableView->SetReadOnly(i_row, i_col); 452 + if (IsBlobColumn(i_col) == true) 453 + TableView->SetReadOnly(i_row, i_col); 454 + } 455 + } 456 + i_row++; 457 + row = row->GetNext(); 458 + } 459 + } 460 + if (ReadOnly == false) 461 + { 462 + // prepearing the insert row 463 + TableView->SetRowLabelValue(TableView->GetNumberRows() - 1, 464 + wxT("Insert row")); 465 + InsertPending = false; 466 + for (i_col = 0; i_col < TableView->GetNumberCols(); i_col++) 467 + { 468 + TableView->SetCellValue(TableView->GetNumberRows() - 1, i_col, 469 + wxT("")); 470 + TableView->SetCellBackgroundColour(TableView->GetNumberRows() - 1, 471 + i_col, wxColour(0, 0, 0)); 472 + TableView->SetReadOnly(TableView->GetNumberRows() - 1, i_col); 473 + } 474 + } 475 + TableView->SetRowLabelSize(wxGRID_AUTOSIZE); 476 + TableView->AutoSize(); 477 + ResizeView(); 478 + sprintf(dummy, "current block: %d / %d [%d rows]", RsBeginRow + 1, 479 + RsEndRow + 1, RsMaxRow); 480 + currentBlock = wxString::FromUTF8(dummy); 481 + RsCurrentBlock->SetLabel(currentBlock); 482 + ShowControls(); 483 + MainFrame->GetQueryView()->AddToHistory(sql); 484 + ::wxEndBusyCursor(); 485 + if (xSql) 486 + delete[]xSql; 487 + return true; 488 +error: 489 + ::wxEndBusyCursor(); 490 + sqlite3_finalize(stmt); 491 + if (xSql) 492 + delete[]xSql; 493 + return false; 494 +} 495 + 496 +bool MyResultSetView::IsPrimaryKey(int column) 497 +{ 498 +// 499 +// checks if this column is a Primary Key one 500 +// 501 + int i; 502 + for (i = 0; i < 1024; i++) 503 + { 504 + if (PrimaryKeys[i] == column) 505 + return true; 506 + } 507 + return false; 508 +} 509 + 510 +bool MyResultSetView::IsBlobColumn(int column) 511 +{ 512 +// 513 +// checks if this column is a BLOB-type column 514 +// 515 + int i; 516 + for (i = 0; i < 1024; i++) 517 + { 518 + if (BlobColumns[i] == column) 519 + return true; 520 + } 521 + return false; 522 +} 523 + 524 +void MyResultSetView::CreateGrid(int rows, int cols) 525 +{ 526 +// 527 +// creating a new Grid to show the result set 528 +// 529 + int extra = 0; 530 + if (ReadOnly == false) 531 + extra = 1; 532 + wxSize sz = GetClientSize(); 533 + TableView = new wxGrid(this, wxID_ANY, wxPoint(5, 5), wxSize(200, 200)); 534 + TableView->Show(false); 535 + TableView->CreateGrid(rows + extra, cols); 536 + TableBlobs = new MyBlobs(rows, cols); 537 + if (ReadOnly == false) 538 + TableValues = new MyValues(rows, cols); 539 +} 540 + 541 +void MyResultSetView::ResizeView() 542 +{ 543 +// 544 +// resizing the Grid to show the result set 545 +// 546 + wxSize sz = GetClientSize(); 547 + if (TableView) 548 + { 549 + TableView->SetSize(sz.GetWidth() - 10, sz.GetHeight() - 45); 550 + TableView->Show(true); 551 + } 552 +} 553 + 554 +void MyResultSetView::OnSize(wxSizeEvent & event) 555 +{ 556 +// 557 +// this window has changed its size 558 +// 559 + wxSize sz = GetClientSize(); 560 + if (TableView) 561 + TableView->SetSize(sz.GetWidth() - 10, sz.GetHeight() - 45); 562 + BtnRsFirst->Move(5, sz.GetHeight() - 35); 563 + BtnRsPrevious->Move(40, sz.GetHeight() - 35); 564 + BtnRefresh->Move(75, sz.GetHeight() - 35); 565 + BtnRsNext->Move(110, sz.GetHeight() - 35); 566 + BtnRsLast->Move(145, sz.GetHeight() - 35); 567 + RsCurrentBlock->Move(180, sz.GetHeight() - 25); 568 +} 569 + 570 +void MyResultSetView::OnRsFirst(wxCommandEvent & WXUNUSED(event)) 571 +{ 572 +// 573 +// scrolling to the result set beginning 574 +// 575 + wxString sql = MainFrame->GetQueryView()->GetSqlCtrl()->GetValue(); 576 + if (ExecuteSql(sql, 0, ReadOnly) == false) 577 + wxMessageBox(SqlErrorMsg, wxT("spatialite-gui"), wxOK | wxICON_ERROR, 578 + MainFrame); 579 +} 580 + 581 +void MyResultSetView::OnRsPrevious(wxCommandEvent & WXUNUSED(event)) 582 +{ 583 +// 584 +// scrolling to the result set previous block 585 +// 586 + wxString sql = MainFrame->GetQueryView()->GetSqlCtrl()->GetValue(); 587 + int start = RsBeginRow - RsBlock; 588 + if (start < 0) 589 + start = 0; 590 + if (ExecuteSql(sql, start, ReadOnly) == false) 591 + wxMessageBox(SqlErrorMsg, wxT("spatialite-gui"), wxOK | wxICON_ERROR, 592 + MainFrame); 593 +} 594 + 595 +void MyResultSetView::OnRsNext(wxCommandEvent & WXUNUSED(event)) 596 +{ 597 +// 598 +// scrolling to the result set next block 599 +// 600 + wxString sql = MainFrame->GetQueryView()->GetSqlCtrl()->GetValue(); 601 + int start = RsEndRow + 1; 602 + if (ExecuteSql(sql, start, ReadOnly) == false) 603 + wxMessageBox(SqlErrorMsg, wxT("spatialite-gui"), wxOK | wxICON_ERROR, 604 + MainFrame); 605 +} 606 + 607 +void MyResultSetView::OnRsLast(wxCommandEvent & WXUNUSED(event)) 608 +{ 609 +// 610 +// scrolling to the result set ending 611 +// 612 + wxString sql = MainFrame->GetQueryView()->GetSqlCtrl()->GetValue(); 613 + int start = RsMaxRow - RsBlock; 614 + if (start < 0) 615 + start = 0; 616 + if (ExecuteSql(sql, start, ReadOnly) == false) 617 + wxMessageBox(SqlErrorMsg, wxT("spatialite-gui"), wxOK | wxICON_ERROR, 618 + MainFrame); 619 +} 620 + 621 +void MyResultSetView::OnRefresh(wxCommandEvent & WXUNUSED(event)) 622 +{ 623 +// 624 +// refreshing the result set 625 +// 626 + wxString sql = MainFrame->GetQueryView()->GetSqlCtrl()->GetValue(); 627 + int start = RsBeginRow; 628 + if (ExecuteSql(sql, start, ReadOnly) == false) 629 + wxMessageBox(SqlErrorMsg, wxT("spatialite-gui"), wxOK | wxICON_ERROR, 630 + MainFrame); 631 +} 632 + 633 +void MyResultSetView::OnRightClick(wxGridEvent & event) 634 +{ 635 +// 636 +// right click on some cell [mouse action] 637 +// 638 + MyVariant *blobVar; 639 + wxMenu *menu = new wxMenu(); 640 + wxMenuItem *menuItem; 641 + wxPoint pt = event.GetPosition(); 642 + if (ReadOnly == false && event.GetRow() == TableView->GetNumberRows() - 1) 643 + { 644 + // this is the INSERT ROW 645 + if (InsertPending == true) 646 + { 647 + menuItem = 648 + new wxMenuItem(menu, Grid_Insert, wxT("&Confirm insertion")); 649 + menu->Append(menuItem); 650 + menuItem = new wxMenuItem(menu, Grid_Abort, wxT("&Abort insertion")); 651 + menu->Append(menuItem); 652 + } else 653 + { 654 + menuItem = new wxMenuItem(menu, Grid_Insert, wxT("&Insert new row")); 655 + menu->Append(menuItem); 656 + } 657 + TableView->PopupMenu(menu, pt); 658 + return; 659 + } 660 + CurrentEvtRow = event.GetRow(); 661 + CurrentEvtColumn = event.GetCol(); 662 + blobVar = TableBlobs->GetBlob(CurrentEvtRow, CurrentEvtColumn); 663 + if (blobVar) 664 + { 665 + // this one is a BLOB cell 666 + if (ReadOnly == false) 667 + { 668 + MyRowVariant *varRow = TableValues->GetRow(CurrentEvtRow); 669 + if (varRow->IsDeleted() == false) 670 + { 671 + menuItem = new wxMenuItem(menu, Grid_Delete, wxT("&Delete row")); 672 + menu->Append(menuItem); 673 + menuItem = 674 + new wxMenuItem(menu, Grid_Insert, wxT("&Insert new row")); 675 + menu->Append(menuItem); 676 + menu->AppendSeparator(); 677 + } 678 + } 679 + menuItem = new wxMenuItem(menu, Grid_Blob, wxT("BLOB &explore")); 680 + menu->Append(menuItem); 681 + if (gaiaGuessBlobType(blobVar->GetBlob(), blobVar->GetBlobSize()) == 682 + GAIA_GEOMETRY_BLOB) 683 + ; 684 + else 685 + { 686 + menu->AppendSeparator(); 687 + menuItem = new wxMenuItem(menu, Grid_BlobIn, wxT("BLOB &import")); 688 + menu->Append(menuItem); 689 + menuItem = new wxMenuItem(menu, Grid_BlobOut, wxT("BLOB &export")); 690 + menu->Append(menuItem); 691 + menuItem = 692 + new wxMenuItem(menu, Grid_BlobNull, wxT("Set BLOB as &NULL")); 693 + menu->Append(menuItem); 694 + } 695 + CurrentBlob = blobVar; 696 + } else 697 + { 698 + // this one is an ordinary cell 699 + CurrentBlob = NULL; 700 + if (ReadOnly == false) 701 + { 702 + MyRowVariant *varRow = TableValues->GetRow(CurrentEvtRow); 703 + if (varRow->IsDeleted() == false) 704 + { 705 + menuItem = new wxMenuItem(menu, Grid_Delete, wxT("&Delete row")); 706 + menu->Append(menuItem); 707 + menuItem = 708 + new wxMenuItem(menu, Grid_Insert, wxT("&Insert new row")); 709 + menu->Append(menuItem); 710 + if (IsBlobColumn(CurrentEvtColumn) == true) 711 + { 712 + menu->AppendSeparator(); 713 + menuItem = 714 + new wxMenuItem(menu, Grid_BlobIn, wxT("BLOB &import")); 715 + menu->Append(menuItem); 716 + } 717 + menu->AppendSeparator(); 718 + } 719 + } 720 + menuItem = new wxMenuItem(menu, Grid_Clear, wxT("&Clear selection")); 721 + menu->Append(menuItem); 722 + menuItem = new wxMenuItem(menu, Grid_All, wxT("Select &all")); 723 + menu->Append(menuItem); 724 + menuItem = new wxMenuItem(menu, Grid_Row, wxT("Select &row")); 725 + menu->Append(menuItem); 726 + menuItem = new wxMenuItem(menu, Grid_Column, wxT("&Select column")); 727 + menu->Append(menuItem); 728 + menu->AppendSeparator(); 729 + menuItem = new wxMenuItem(menu, Grid_Copy, wxT("&Copy")); 730 + menu->Append(menuItem); 731 + if (TableView->IsSelection() == false) 732 + menuItem->Enable(false); 733 + } 734 + TableView->PopupMenu(menu, pt); 735 +} 736 + 737 +void MyResultSetView::OnCellSelected(wxGridEvent & event) 738 +{ 739 +// 740 +// cell selection changed 741 +// 742 + if (InsertPending == true) 743 + { 744 + // an INSERT row is still pending 745 + if (event.GetRow() != TableView->GetNumberRows() - 1) 746 + DoInsert(false); 747 + } 748 + event.Skip(); 749 +} 750 + 751 +void MyResultSetView::OnCellChanged(wxGridEvent & event) 752 +{ 753 +// 754 +// user changed value in some cell 755 +// 756 + MyVariant *oldValue; 757 + MyVariant *insValue; 758 + wxString value; 759 + wxString numValue; 760 + wxString newValue = wxT("NULL"); 761 + wxString sql; 762 + wxString rowid; 763 + char *errMsg = NULL; 764 + bool error = false; 765 + sqlite3_int64 int64_value; 766 + long long_value; 767 + bool okIntValue = false; 768 + double dbl_value; 769 + bool okDblValue = false; 770 + int ret; 771 + char dummy[256]; 772 + int row = event.GetRow(); 773 + int column = event.GetCol(); 774 + value = TableView->GetCellValue(row, column); 775 + if (InsertPending == true) 776 + { 777 + // an INSERT row is still pending 778 + insValue = InsertRow->GetColumn(column); 779 + numValue = value; 780 + numValue.Replace(wxT(","), wxT(".")); 781 + okIntValue = numValue.ToLong(&long_value); 782 + okDblValue = numValue.ToDouble(&dbl_value); 783 + if (okIntValue == true) 784 + { 785 + int64_value = long_value; 786 + insValue->Set(int64_value); 787 + } else if (okDblValue == true) 788 + insValue->Set(dbl_value); 789 + else 790 + insValue->Set(value); 791 + if (row != TableView->GetNumberRows() - 1) 792 + DoInsert(false); 793 + return; 794 + } 795 + if (value.Len() > 0) 796 + { 797 + numValue = value; 798 + numValue.Replace(wxT(","), wxT(".")); 799 + okIntValue = numValue.ToLong(&long_value); 800 + okDblValue = numValue.ToDouble(&dbl_value); 801 + if (okIntValue == true) 802 + { 803 + int64_value = long_value; 804 + sprintf(dummy, FORMAT_64, int64_value); 805 + newValue = wxString::FromUTF8(dummy); 806 + } else if (okDblValue == true) 807 + { 808 + sprintf(dummy, "%1.6lf", dbl_value); 809 + newValue = wxString::FromUTF8(dummy); 810 + } else 811 + { 812 + value.Replace(wxT("'"), wxT("''")); 813 + newValue = wxT("'") + value + wxT("'"); 814 + } 815 + } 816 + oldValue = TableValues->GetValue(row, 0); 817 + sprintf(dummy, FORMAT_64, oldValue->GetIntValue()); 818 + rowid = wxString::FromUTF8(dummy); 819 + sql = 820 + wxT("UPDATE \"") + TableName + wxT("\" SET \"") + 821 + TableView->GetColLabelValue(column) + wxT("\" = ") + newValue + 822 + wxT(" WHERE ROWID = ") + rowid; 823 + ret = sqlite3_exec(MainFrame->GetSqlite(), sql.ToUTF8(), NULL, NULL, &errMsg); 824 + if (ret != SQLITE_OK) 825 + { 826 + wxMessageBox(wxT("SQLite SQL error: ") + wxString::FromUTF8(errMsg), 827 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 828 + sqlite3_free(errMsg); 829 + error = true; 830 + } 831 + oldValue = TableValues->GetValue(row, column); 832 + if (error == true) 833 + { 834 + // update failed; restorig old cell value 835 + value = wxT("NULL"); 836 + if (oldValue) 837 + { 838 + if (oldValue->GetType() == MY_INT_VARIANT) 839 + { 840 + sprintf(dummy, FORMAT_64, oldValue->GetIntValue()); 841 + value = wxString::FromUTF8(dummy); 842 + } 843 + if (oldValue->GetType() == MY_DBL_VARIANT) 844 + { 845 + sprintf(dummy, "%1.6lf", oldValue->GetDblValue()); 846 + value = wxString::FromUTF8(dummy); 847 + } 848 + if (oldValue->GetType() == MY_TXT_VARIANT) 849 + value = oldValue->GetTxtValue(); 850 + } 851 + TableView->SetCellValue(row, column, value); 852 + TableView->ForceRefresh(); 853 + } else 854 + { 855 + // marking cell as modified 856 + TableView->SetCellTextColour(row, column, wxColour(0, 0, 192)); 857 + TableView->SetCellBackgroundColour(row, column, wxColour(255, 255, 204)); 858 + TableView->ForceRefresh(); 859 + } 860 +} 861 + 862 +void MyResultSetView::DoInsert(bool confirmed) 863 +{ 864 +// 865 +// performing actual row INSERT 866 +// 867 + int i; 868 + int ret; 869 + MyVariant *var; 870 + wxString value; 871 + wxString strValue; 872 + wxString sql; 873 + char dummy[256]; 874 + char *errMsg = NULL; 875 + if (confirmed == false) 876 + { 877 + ret = 878 + wxMessageBox(wxT("A new row is ready for insertion\n\nConfirm ?"), 879 + wxT("spatialite-gui"), wxYES_NO | wxICON_QUESTION, this); 880 + if (ret != wxYES) 881 + goto close_insert; 882 + } 883 + sql = wxT("INSERT INTO \"") + TableName + wxT("\" ("); 884 + for (i = 1; i < TableView->GetNumberCols(); i++) 885 + { 886 + if (i > 1) 887 + sql += wxT(", "); 888 + sql += wxT("\"") + TableView->GetColLabelValue(i) + wxT("\""); 889 + } 890 + sql += wxT(") VALUES ("); 891 + for (i = 1; i < InsertRow->GetNumCols(); i++) 892 + { 893 + if (i > 1) 894 + sql += wxT(", "); 895 + var = InsertRow->GetColumn(i); 896 + value = wxT("NULL"); 897 + if (var->GetType() == MY_INT_VARIANT) 898 + { 899 + sprintf(dummy, FORMAT_64, var->GetIntValue()); 900 + value = wxString::FromUTF8(dummy); 901 + } 902 + if (var->GetType() == MY_DBL_VARIANT) 903 + { 904 + sprintf(dummy, "%1.6lf", var->GetDblValue()); 905 + value = wxString::FromUTF8(dummy); 906 + } 907 + if (var->GetType() == MY_TXT_VARIANT) 908 + { 909 + strValue = var->GetTxtValue(); 910 + strValue.Replace(wxT("'"), wxT("''")); 911 + value = wxT("'") + strValue + wxT("'"); 912 + } 913 + sql += value; 914 + } 915 + sql += wxT(")"); 916 + ret = sqlite3_exec(MainFrame->GetSqlite(), sql.ToUTF8(), NULL, NULL, &errMsg); 917 + if (ret != SQLITE_OK) 918 + { 919 + wxMessageBox(wxT("SQLite SQL error: ") + wxString::FromUTF8(errMsg), 920 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 921 + sqlite3_free(errMsg); 922 + } 923 +close_insert: 924 +// 925 +// closing insert row 926 +// 927 + InsertPending = false; 928 + delete InsertRow; 929 + InsertRow = NULL; 930 + for (i = 0; i < TableView->GetNumberCols(); i++) 931 + { 932 + TableView->SetCellValue(TableView->GetNumberRows() - 1, i, wxT("")); 933 + TableView->SetCellBackgroundColour(TableView->GetNumberRows() - 1, i, 934 + wxColour(0, 0, 0)); 935 + TableView->SetReadOnly(TableView->GetNumberRows() - 1, i); 936 + } 937 +} 938 + 939 +void MyResultSetView::OnCmdDelete(wxCommandEvent & event) 940 +{ 941 +// 942 +// user required row deletion 943 +// 944 + char *errMsg = NULL; 945 + bool error = false; 946 + int ret; 947 + int i; 948 + wxString sql; 949 + wxString rowid; 950 + MyVariant *value; 951 + char dummy[256]; 952 + MyRowVariant *varRow = TableValues->GetRow(CurrentEvtRow); 953 + if (varRow->IsDeleted() == true) 954 + return; 955 + value = TableValues->GetValue(CurrentEvtRow, 0); 956 + sprintf(dummy, FORMAT_64, value->GetIntValue()); 957 + rowid = wxString::FromUTF8(dummy); 958 + ret = 959 + wxMessageBox(wxT("Requested deletion for row identified by RowId = ") 960 + + rowid + wxT("\n\nConfirm ?"), wxT("spatialite-gui"), 961 + wxYES_NO | wxICON_QUESTION, this); 962 + if (ret != wxYES) 963 + return; 964 + sql = wxT("DELETE FROM \"") + TableName + wxT("\" WHERE ROWID = ") + rowid; 965 + ret = sqlite3_exec(MainFrame->GetSqlite(), sql.ToUTF8(), NULL, NULL, &errMsg); 966 + if (ret != SQLITE_OK) 967 + { 968 + wxMessageBox(wxT("SQLite SQL error: ") + wxString::FromUTF8(errMsg), 969 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 970 + sqlite3_free(errMsg); 971 + error = true; 972 + } 973 + if (error == false) 974 + { 975 + // marking row as deleted 976 + varRow->SetDeleted(); 977 + for (i = 0; i < TableView->GetNumberCols(); i++) 978 + { 979 + TableView->SetCellTextColour(CurrentEvtRow, i, wxColour(0, 0, 0)); 980 + TableView->SetCellBackgroundColour(CurrentEvtRow, i, 981 + wxColour(128, 128, 128)); 982 + TableView->SetReadOnly(CurrentEvtRow, i); 983 + } 984 + TableView->ForceRefresh(); 985 + } 986 +} 987 + 988 +void MyResultSetView::OnCmdInsert(wxCommandEvent & event) 989 +{ 990 +// 991 +// user required row insertion 992 +// 993 + int i; 994 + if (ReadOnly == true) 995 + return; 996 + if (InsertPending == true) 997 + { 998 + // an INSERT is still pending, and the user required actual insertion 999 + DoInsert(true); 1000 + return; 1001 + } 1002 + InsertRow = new MyRowVariant(TableView->GetNumberCols()); 1003 + TableView->MakeCellVisible(TableView->GetNumberRows() - 1, 1); 1004 + InsertPending = true; 1005 + for (i = 1; i < TableView->GetNumberCols(); i++) 1006 + { 1007 + TableView->SetCellValue(TableView->GetNumberRows() - 1, i, wxT("")); 1008 + TableView->SetCellBackgroundColour(TableView->GetNumberRows() - 1, i, 1009 + wxColour(255, 255, 255)); 1010 + TableView->SetReadOnly(TableView->GetNumberRows() - 1, i, false); 1011 + } 1012 +} 1013 + 1014 +void MyResultSetView::OnCmdAbort(wxCommandEvent & event) 1015 +{ 1016 +// 1017 +// user cancelled current row insertion 1018 +// 1019 + int i; 1020 + if (InsertPending) 1021 + { 1022 + InsertPending = false; 1023 + delete InsertRow; 1024 + InsertRow = NULL; 1025 + for (i = 0; i < TableView->GetNumberCols(); i++) 1026 + { 1027 + TableView->SetCellValue(TableView->GetNumberRows() - 1, i, wxT("")); 1028 + TableView->SetCellBackgroundColour(TableView->GetNumberRows() - 1, i, 1029 + wxColour(0, 0, 0)); 1030 + TableView->SetReadOnly(TableView->GetNumberRows() - 1, i); 1031 + } 1032 + } 1033 +} 1034 + 1035 +void MyResultSetView::OnCmdClearSelection(wxCommandEvent & event) 1036 +{ 1037 +// 1038 +// clearing current selection 1039 +// 1040 + TableView->ClearSelection(); 1041 +} 1042 + 1043 +void MyResultSetView::OnCmdSelectAll(wxCommandEvent & event) 1044 +{ 1045 +// 1046 +// selecting all 1047 +// 1048 + TableView->SelectAll(); 1049 +} 1050 + 1051 +void MyResultSetView::OnCmdSelectRow(wxCommandEvent & event) 1052 +{ 1053 +// 1054 +// selecting the current row 1055 +// 1056 + TableView->SelectRow(CurrentEvtRow); 1057 +} 1058 + 1059 +void MyResultSetView::OnCmdSelectColumn(wxCommandEvent & event) 1060 +{ 1061 +// 1062 +// selecting column 1063 +// 1064 + TableView->SelectCol(CurrentEvtColumn); 1065 +} 1066 + 1067 +void MyResultSetView::OnCmdCopy(wxCommandEvent & event) 1068 +{ 1069 +// 1070 +// copying the selection into the clipboard 1071 +// 1072 + wxString copyData; 1073 + int row; 1074 + int col; 1075 + bool newRow; 1076 + bool firstRow = true; 1077 + for (row = 0; row < TableView->GetNumberRows(); row++) 1078 + { 1079 + newRow = true; 1080 + for (col = 0; col < TableView->GetNumberCols(); col++) 1081 + { 1082 + if (TableView->IsInSelection(row, col) == true) 1083 + { 1084 + // ok, this cell is included into the selection to copy 1085 + if (firstRow == true) 1086 + { 1087 + newRow = false; 1088 + firstRow = false; 1089 + } else if (newRow == true) 1090 + { 1091 + newRow = false; 1092 + copyData += wxT("\n"); 1093 + } else 1094 + copyData += wxT("\t"); 1095 + copyData += TableView->GetCellValue(row, col); 1096 + } 1097 + } 1098 + } 1099 + if (wxTheClipboard->Open()) 1100 + { 1101 + wxTheClipboard->SetData(new wxTextDataObject(copyData)); 1102 + wxTheClipboard->Close(); 1103 + } 1104 +} 1105 + 1106 +void MyResultSetView::OnCmdBlob(wxCommandEvent & event) 1107 +{ 1108 +// 1109 +// exploring some BLOB value 1110 +// 1111 + if (!CurrentBlob) 1112 + return; 1113 + BlobExplorerDialog dlg; 1114 + dlg.Create(MainFrame, CurrentBlob->GetBlobSize(), CurrentBlob->GetBlob()); 1115 + dlg.ShowModal(); 1116 +} 1117 + 1118 +void MyResultSetView::OnCmdBlobIn(wxCommandEvent & event) 1119 +{ 1120 +// importing an external file into a BLOB-value 1121 + FILE *in = NULL; 1122 + char path[2048]; 1123 + int rd; 1124 + int maxSize = 1024 * 1024; // limit BLOB size to 1MB 1125 + wxString fileList; 1126 + wxString rowid; 1127 + wxString sql; 1128 + wxString blobValue; 1129 + wxString hex; 1130 + MyVariant *value; 1131 + char dummy[1024]; 1132 + bool error = false; 1133 + unsigned char *buffer = NULL; 1134 + int ret; 1135 + char *errMsg = NULL; 1136 + wxString lastDir; 1137 + fileList = 1138 + wxT 1139 + ("BLOB Document (*.jpg;*.jpeg;*.png;*.gif;*.pdf;*.zip)|*.jpg;*.jpeg;*.png;*.gif;*.pdf;*.zip|"); 1140 + fileList += wxT("Image (*.jpg;*.jpeg;*.png;*.gif)|*.jpg;*.jpeg;*.png;*.gif|"); 1141 + fileList += 1142 + wxT 1143 + ("JPEG Image (*.jpg;*.jpeg)|*.jpg;*.jpeg|PNG Image (*.png)|*.png|GIF Image (*.gif)|*.gif"); 1144 + fileList += 1145 + wxT("PDF Document (*.pdf)|*.pdf|ZIP Archive|(*.zip)|All files (*.*)|*.*"); 1146 + wxFileDialog *fileDialog = new wxFileDialog(this, wxT("loading a BLOB value"), 1147 + wxT(""), wxT(""), fileList, 1148 + wxFD_OPEN | wxFD_FILE_MUST_EXIST, 1149 + wxDefaultPosition, 1150 + wxDefaultSize, wxT("filedlg")); 1151 + lastDir = MainFrame->GetLastDirectory(); 1152 + if (lastDir.Len() >= 1) 1153 + fileDialog->SetDirectory(lastDir); 1154 + ret = fileDialog->ShowModal(); 1155 + if (ret == wxID_OK) 1156 + { 1157 + strcpy(path, fileDialog->GetPath().ToUTF8()); 1158 + in = fopen(path, "rb"); 1159 + if (!in) 1160 + { 1161 + wxMessageBox(wxT("Cannot open '") + fileDialog->GetPath() + 1162 + wxT("' for reading"), wxT("spatialite-gui"), 1163 + wxOK | wxICON_ERROR, this); 1164 + return; 1165 + } 1166 + wxFileName file(fileDialog->GetPath()); 1167 + lastDir = file.GetPath(); 1168 + MainFrame->SetLastDirectory(lastDir); 1169 + ::wxBeginBusyCursor(); 1170 + buffer = new unsigned char[maxSize]; 1171 + rd = fread(buffer, 1, maxSize, in); 1172 + if (rd == maxSize && !(feof(in))) 1173 + { 1174 + // exceding 1MB; it's too big for a BLOB 1175 + wxMessageBox(wxT 1176 + ("Selected file excedes 1MB; cowardly refusing to load it as a BLOB value ..."), 1177 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 1178 + goto end; 1179 + } 1180 + if (ferror(in)) 1181 + { 1182 + // I/O error 1183 + wxMessageBox(wxT("an I/O error occurred"), wxT("spatialite-gui"), 1184 + wxOK | wxICON_ERROR, this); 1185 + goto end; 1186 + } 1187 + // 1188 + // preparing theSQL UPDATE statement 1189 + // 1190 + value = TableValues->GetValue(CurrentEvtRow, 0); 1191 + sprintf(dummy, FORMAT_64, value->GetIntValue()); 1192 + rowid = wxString::FromUTF8(dummy); 1193 + HexBlobValue(buffer, rd, hex); 1194 + sql = 1195 + wxT("UPDATE \"") + TableName + wxT("\" SET \"") + 1196 + TableView->GetColLabelValue(CurrentEvtColumn); 1197 + sql += wxT("\" = ") + hex + wxT(" WHERE ROWID = ") + rowid; 1198 + ret = 1199 + sqlite3_exec(MainFrame->GetSqlite(), sql.ToUTF8(), NULL, NULL, &errMsg); 1200 + if (ret != SQLITE_OK) 1201 + { 1202 + wxMessageBox(wxT("SQLite SQL error: ") + wxString::FromUTF8(errMsg), 1203 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 1204 + sqlite3_free(errMsg); 1205 + error = true; 1206 + } 1207 + ::wxEndBusyCursor(); 1208 + value = TableValues->GetValue(CurrentEvtRow, CurrentEvtColumn); 1209 + if (error == false) 1210 + { 1211 + // updating the Grid cell 1212 + sprintf(dummy, "BLOB sz=%d ", rd); 1213 + blobValue = wxString::FromUTF8(dummy); 1214 + switch (gaiaGuessBlobType(buffer, rd)) 1215 + { 1216 + case GAIA_JPEG_BLOB: 1217 + blobValue += wxT("JPEG image"); 1218 + break; 1219 + case GAIA_EXIF_BLOB: 1220 + blobValue += wxT("JPEG-EXIF image"); 1221 + break; 1222 + case GAIA_EXIF_GPS_BLOB: 1223 + blobValue += wxT("JPEG-EXIF-GPS image"); 1224 + break; 1225 + case GAIA_PNG_BLOB: 1226 + blobValue += wxT("PNG image"); 1227 + break; 1228 + case GAIA_GIF_BLOB: 1229 + blobValue += wxT("GIF image"); 1230 + break; 1231 + case GAIA_PDF_BLOB: 1232 + blobValue += wxT("PDF document"); 1233 + break; 1234 + case GAIA_ZIP_BLOB: 1235 + blobValue += wxT("ZIP archive"); 1236 + break; 1237 + default: 1238 + blobValue += wxT("UNKNOWN type"); 1239 + }; 1240 + TableView->SetCellValue(CurrentEvtRow, CurrentEvtColumn, blobValue); 1241 + TableView->SetCellTextColour(CurrentEvtRow, CurrentEvtColumn, 1242 + wxColour(0, 0, 192)); 1243 + TableView->SetCellBackgroundColour(CurrentEvtRow, CurrentEvtColumn, 1244 + wxColour(255, 255, 204)); 1245 + TableView->ForceRefresh(); 1246 + } 1247 + } 1248 +end: 1249 +// clean-up 1250 + if (in) 1251 + fclose(in); 1252 + if (buffer) 1253 + delete[]buffer; 1254 +} 1255 + 1256 +void MyResultSetView::HexBlobValue(unsigned char *blob, int size, 1257 + wxString & hex) 1258 +{ 1259 +// 1260 +// builds the HEX BLOB as X'01234567890abcdef' 1261 +// 1262 + int i; 1263 + char digit[16]; 1264 + hex = wxT("X'"); 1265 + for (i = 0; i < size; i++) 1266 + { 1267 + sprintf(digit, "%02x", *(blob + i)); 1268 + hex += wxString::FromUTF8(digit); 1269 + } 1270 + hex += wxT("'"); 1271 +} 1272 + 1273 +void MyResultSetView::OnCmdBlobOut(wxCommandEvent & event) 1274 +{ 1275 +// exporting to external file a BLOB-value 1276 + int blobType; 1277 + wxString fileName; 1278 + wxString fileType; 1279 + int ret; 1280 + wxString path; 1281 + FILE *out = NULL; 1282 + char xpath[2048]; 1283 + int wr; 1284 + wxString lastDir; 1285 + if (!CurrentBlob) 1286 + return; 1287 + blobType = 1288 + gaiaGuessBlobType(CurrentBlob->GetBlob(), CurrentBlob->GetBlobSize()); 1289 + switch (blobType) 1290 + { 1291 + case GAIA_JPEG_BLOB: 1292 + case GAIA_EXIF_BLOB: 1293 + case GAIA_EXIF_GPS_BLOB: 1294 + fileName = wxT("image.jpg"); 1295 + fileType = wxT("File JPEG (*.jpg;*.jpeg)|*.jpg"); 1296 + break; 1297 + case GAIA_PNG_BLOB: 1298 + fileName = wxT("image.png"); 1299 + fileType = wxT("File PNG (*.png)|*.png"); 1300 + break; 1301 + case GAIA_GIF_BLOB: 1302 + fileName = wxT("image.gif"); 1303 + fileType = wxT("File GIF (*.gif)|*.gif"); 1304 + break; 1305 + case GAIA_PDF_BLOB: 1306 + fileName = wxT("document.pdf"); 1307 + fileType = wxT("PDF document (*.jpg;*.jpeg)|*.jpg"); 1308 + break; 1309 + case GAIA_ZIP_BLOB: 1310 + fileName = wxT("archive.zip"); 1311 + fileType = wxT("ZIP Archive (*.zip)|*.zip"); 1312 + break; 1313 + default: 1314 + fileName = wxT("file"); 1315 + }; 1316 + fileType += wxT("|All files (*.*)|*.*"); 1317 + wxFileDialog *fileDialog = 1318 + new wxFileDialog(this, wxT("exporting a BLOB value to file"), 1319 + wxT(""), fileName, fileType, 1320 + wxFD_SAVE | wxFD_OVERWRITE_PROMPT, wxDefaultPosition, 1321 + wxDefaultSize, wxT("filedlg")); 1322 + lastDir = MainFrame->GetLastDirectory(); 1323 + if (lastDir.Len() >= 1) 1324 + fileDialog->SetDirectory(lastDir); 1325 + ret = fileDialog->ShowModal(); 1326 + if (ret == wxID_OK) 1327 + { 1328 + wxFileName file(fileDialog->GetPath()); 1329 + path = file.GetPath(); 1330 + path += file.GetPathSeparator(); 1331 + path += file.GetName(); 1332 + switch (blobType) 1333 + { 1334 + case GAIA_JPEG_BLOB: 1335 + case GAIA_EXIF_BLOB: 1336 + case GAIA_EXIF_GPS_BLOB: 1337 + path += wxT(".jpg"); 1338 + break; 1339 + case GAIA_PNG_BLOB: 1340 + path += wxT(".png"); 1341 + break; 1342 + case GAIA_GIF_BLOB: 1343 + path += wxT(".gif"); 1344 + break; 1345 + case GAIA_PDF_BLOB: 1346 + path += wxT(".pdf"); 1347 + break; 1348 + case GAIA_ZIP_BLOB: 1349 + path += wxT(".zip"); 1350 + break; 1351 + default: 1352 + path += file.GetExt(); 1353 + }; 1354 + strcpy(xpath, path.ToUTF8()); 1355 + out = fopen(xpath, "wb"); 1356 + if (!out) 1357 + { 1358 + wxMessageBox(wxT("Cannot open '") + path + wxT("' for writing"), 1359 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 1360 + return; 1361 + } 1362 + lastDir = file.GetPath(); 1363 + MainFrame->SetLastDirectory(lastDir); 1364 + ::wxBeginBusyCursor(); 1365 + wr = fwrite(CurrentBlob->GetBlob(), 1, CurrentBlob->GetBlobSize(), out); 1366 + if (wr != CurrentBlob->GetBlobSize()) 1367 + { 1368 + wxMessageBox(wxT("an I/O error occurred"), wxT("spatialite-gui"), 1369 + wxOK | wxICON_ERROR, this); 1370 + } 1371 + fclose(out); 1372 + ::wxEndBusyCursor(); 1373 + } 1374 +} 1375 + 1376 +void MyResultSetView::OnCmdBlobNull(wxCommandEvent & event) 1377 +{ 1378 +// setting to NULL a BLOB-value 1379 + wxString rowid; 1380 + wxString sql; 1381 + int ret; 1382 + char *errMsg = NULL; 1383 + bool error = false; 1384 + MyVariant *value; 1385 + char dummy[256]; 1386 + value = TableValues->GetValue(CurrentEvtRow, 0); 1387 + sprintf(dummy, FORMAT_64, value->GetIntValue()); 1388 + rowid = wxString::FromUTF8(dummy); 1389 + sql = 1390 + wxT("UPDATE \"") + TableName + wxT("\" SET \"") + 1391 + TableView->GetColLabelValue(CurrentEvtColumn); 1392 + sql += wxT("\" = NULL WHERE ROWID = ") + rowid; 1393 + ret = sqlite3_exec(MainFrame->GetSqlite(), sql.ToUTF8(), NULL, NULL, &errMsg); 1394 + if (ret != SQLITE_OK) 1395 + { 1396 + wxMessageBox(wxT("SQLite SQL error: ") + wxString::FromUTF8(errMsg), 1397 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 1398 + sqlite3_free(errMsg); 1399 + error = true; 1400 + } 1401 + if (error == false) 1402 + { 1403 + // updating the Grid cell 1404 + TableView->SetCellValue(CurrentEvtRow, CurrentEvtColumn, wxT("NULL")); 1405 + TableView->SetCellTextColour(CurrentEvtRow, CurrentEvtColumn, 1406 + wxColour(0, 0, 192)); 1407 + TableView->SetCellBackgroundColour(CurrentEvtRow, CurrentEvtColumn, 1408 + wxColour(255, 255, 204)); 1409 + TableView->ForceRefresh(); 1410 + } 1411 +}
Changes to Shapefiles.cpp.
1 1 /* 2 2 / Shapefiles.cpp 3 3 / methods related to Shapefile loading and saving 4 4 / 5 -/ version 1.1, 2008 September 13 5 +/ version 1.2, 2008 October 9 6 6 / 7 7 / Author: Sandro Furieri a-furieri@lqt.it 8 8 / 9 9 / Copyright (C) 2008 Alessandro Furieri 10 10 / 11 11 / This program is free software: you can redistribute it and/or modify 12 12 / it under the terms of the GNU General Public License as published by ................................................................................ 21 21 / You should have received a copy of the GNU General Public License 22 22 / along with this program. If not, see <http://www.gnu.org/licenses/>. 23 23 / 24 24 */ 25 25 26 26 #include "Classdef.h" 27 27 28 -void 29 -MyFrame::CleanTxtTab (char *buf) 28 +void MyFrame::CleanTxtTab(char *buf) 30 29 { 31 30 // well-formatting a string to be used as a Txt/Tab string 32 - char tmp[65536]; 33 - char *in = tmp; 34 - char *out = buf; 35 - strcpy (tmp, buf); 36 - while (*in != '\0') 37 - { 38 - if (*in == '\t' || *in == '\r' || *in == '\n') 39 - { 40 - in++; 41 - *out++ = ' '; 42 - } 43 - else 44 - *out++ = *in++; 45 - } 46 - *out = '\0'; 31 + char tmp[65536]; 32 + char *in = tmp; 33 + char *out = buf; 34 + strcpy(tmp, buf); 35 + while (*in != '\0') 36 + { 37 + if (*in == '\t' || *in == '\r' || *in == '\n') 38 + { 39 + in++; 40 + *out++ = ' '; 41 + } else 42 + *out++ = *in++; 43 + } 44 + *out = '\0'; 47 45 } 48 46 49 -void 50 -MyFrame::CleanCsv (char *buf) 47 +void MyFrame::CleanCsv(char *buf) 51 48 { 52 49 // well-formatting a string to be used as a Csv string 53 - char tmp[65536]; 54 - char *in = tmp; 55 - char *out = buf; 56 - bool special = false; 57 - strcpy (tmp, buf); 58 - while (*in != '\0') 59 - { 60 - if (*in == ',' || *in == '\r' || *in == '\n') 61 - special = true; 62 - if (*in == '"') 63 - *out++ = '"'; 64 - *out++ = *in++; 65 - } 66 - *out = '\0'; 67 - if (special == true) 68 - { 69 - sprintf (tmp, "\"%s\"", buf); 70 - strcpy (buf, tmp); 71 - } 50 + char tmp[65536]; 51 + char *in = tmp; 52 + char *out = buf; 53 + bool special = false; 54 + strcpy(tmp, buf); 55 + while (*in != '\0') 56 + { 57 + if (*in == ',' || *in == '\r' || *in == '\n') 58 + special = true; 59 + if (*in == '"') 60 + *out++ = '"'; 61 + *out++ = *in++; 62 + } 63 + *out = '\0'; 64 + if (special == true) 65 + { 66 + sprintf(tmp, "\"%s\"", buf); 67 + strcpy(buf, tmp); 68 + } 72 69 } 73 70 74 -void 75 -MyFrame::CleanHtml (char *buf) 71 +void MyFrame::CleanHtml(char *buf) 76 72 { 77 73 // well-formatting a string to be used as an Html string 78 - char tmp[65536]; 79 - char *in = tmp; 80 - char *out = buf; 81 - strcpy (tmp, buf); 82 - while (*in != '\0') 83 - { 84 - if (*in == '<') 85 - { 86 - *out++ = '&'; 87 - *out++ = 'l'; 88 - *out++ = 't'; 89 - *out++ = ';'; 90 - in++; 91 - continue; 92 - } 93 - if (*in == '>') 94 - { 95 - *out++ = '&'; 96 - *out++ = 'g'; 97 - *out++ = 't'; 98 - *out++ = ';'; 99 - in++; 100 - continue; 101 - } 102 - if (*in == ' ') 103 - { 104 - *out++ = '&'; 105 - *out++ = 'n'; 106 - *out++ = 'b'; 107 - *out++ = 's'; 108 - *out++ = 'p'; 109 - *out++ = ';'; 110 - in++; 111 - continue; 112 - } 113 - if (*in == '"') 114 - { 115 - *out++ = '&'; 116 - *out++ = 'q'; 117 - *out++ = 'u'; 118 - *out++ = 'o'; 119 - *out++ = 't'; 120 - *out++ = ';'; 121 - in++; 122 - continue; 123 - } 124 - if (*in == '&') 125 - { 126 - *out++ = '&'; 127 - *out++ = 'a'; 128 - *out++ = 'm'; 129 - *out++ = 'p'; 130 - *out++ = ';'; 131 - in++; 132 - continue; 133 - } 134 - *out++ = *in++; 135 - } 136 - *out = '\0'; 74 + char tmp[65536]; 75 + char *in = tmp; 76 + char *out = buf; 77 + strcpy(tmp, buf); 78 + while (*in != '\0') 79 + { 80 + if (*in == '<') 81 + { 82 + *out++ = '&'; 83 + *out++ = 'l'; 84 + *out++ = 't'; 85 + *out++ = ';'; 86 + in++; 87 + continue; 88 + } 89 + if (*in == '>') 90 + { 91 + *out++ = '&'; 92 + *out++ = 'g'; 93 + *out++ = 't'; 94 + *out++ = ';'; 95 + in++; 96 + continue; 97 + } 98 + if (*in == ' ') 99 + { 100 + *out++ = '&'; 101 + *out++ = 'n'; 102 + *out++ = 'b'; 103 + *out++ = 's'; 104 + *out++ = 'p'; 105 + *out++ = ';'; 106 + in++; 107 + continue; 108 + } 109 + if (*in == '"') 110 + { 111 + *out++ = '&'; 112 + *out++ = 'q'; 113 + *out++ = 'u'; 114 + *out++ = 'o'; 115 + *out++ = 't'; 116 + *out++ = ';'; 117 + in++; 118 + continue; 119 + } 120 + if (*in == '&') 121 + { 122 + *out++ = '&'; 123 + *out++ = 'a'; 124 + *out++ = 'm'; 125 + *out++ = 'p'; 126 + *out++ = ';'; 127 + in++; 128 + continue; 129 + } 130 + *out++ = *in++; 131 + } 132 + *out = '\0'; 137 133 } 138 134 139 -bool MyFrame::TableAlreadyExists (wxString & name) 135 +bool MyFrame::TableAlreadyExists(wxString & name) 140 136 { 141 137 // 142 138 // checks if a table of this name already exists 143 139 // 144 - char ** 145 - results; 146 - int 147 - rows; 148 - int 149 - columns; 150 - int 151 - i; 152 - char * 153 - errMsg = NULL; 154 - bool 155 - already_exists = false; 156 - wxString 157 - sql = 158 - wxT 159 - ("SELECT name FROM sqlite_master WHERE type = 'table' AND name = '"); 160 - sql += name; 161 - sql += wxT ("'"); 162 - int 163 - ret = sqlite3_get_table (SqliteHandle, sql.ToUTF8 (), &results, 164 - &rows, &columns, &errMsg); 165 - if (ret != SQLITE_OK) 166 - { 167 - wxMessageBox (wxT ("SQLite SQL error: ") + 168 - wxString::FromUTF8 (errMsg), wxT ("spatialite-gui"), 169 - wxOK | wxICON_ERROR, this); 170 - sqlite3_free (errMsg); 171 - return false; 172 - } 173 - if (rows < 1) 174 - ; 175 - else 176 - { 177 - for (i = 1; i <= rows; i++) 178 - already_exists = true; 179 - } 180 - sqlite3_free_table (results); 181 - return already_exists; 140 + char **results; 141 + int rows; 142 + int columns; 143 + int i; 144 + char *errMsg = NULL; 145 + bool already_exists = false; 146 + wxString sql = 147 + wxT("SELECT name FROM sqlite_master WHERE type = 'table' AND name LIKE '"); 148 + sql += name; 149 + sql += wxT("'"); 150 + int ret = sqlite3_get_table(SqliteHandle, sql.ToUTF8(), &results, 151 + &rows, &columns, &errMsg); 152 + if (ret != SQLITE_OK) 153 + { 154 + wxMessageBox(wxT("SQLite SQL error: ") + wxString::FromUTF8(errMsg), 155 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 156 + sqlite3_free(errMsg); 157 + return false; 158 + } 159 + if (rows < 1) 160 + ; 161 + else 162 + { 163 + for (i = 1; i <= rows; i++) 164 + already_exists = true; 165 + } 166 + sqlite3_free_table(results); 167 + return already_exists; 182 168 } 183 169 184 -bool MyFrame::SridNotExists (int srid) 170 +bool MyFrame::SridNotExists(int srid) 185 171 { 186 172 // 187 173 // checks if a SRID value is a valid one 188 174 // 189 - char ** 190 - results; 191 - int 192 - rows; 193 - int 194 - columns; 195 - int 196 - i; 197 - char * 198 - errMsg = NULL; 199 - bool 200 - constrained = false; 201 - bool 202 - not_exists = true; 203 - wxString 204 - RefSysName; 205 - wxString 206 - sql = 207 - wxT 208 - ("SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'spatial_ref_sys'"); 209 - int 210 - ret = sqlite3_get_table (SqliteHandle, sql.ToUTF8 (), &results, 211 - &rows, &columns, &errMsg); 212 - if (ret != SQLITE_OK) 213 - { 214 - wxMessageBox (wxT ("SQLite SQL error: ") + 215 - wxString::FromUTF8 (errMsg), wxT ("spatialite-gui"), 216 - wxOK | wxICON_ERROR, this); 217 - sqlite3_free (errMsg); 218 - return false; 219 - } 220 - if (rows < 1) 221 - ; 222 - else 223 - { 224 - for (i = 1; i <= rows; i++) 225 - constrained = true; 226 - } 227 - sqlite3_free_table (results); 228 - if (constrained == false) 229 - return false; 230 - sql.Printf (wxT 231 - ("SELECT ref_sys_name FROM spatial_ref_sys WHERE srid = %d"), 232 - srid); 233 - ret = 234 - sqlite3_get_table (SqliteHandle, sql.ToUTF8 (), &results, &rows, 235 - &columns, &errMsg); 236 - if (ret != SQLITE_OK) 237 - { 238 - wxMessageBox (wxT ("SQLite SQL error: ") + 239 - wxString::FromUTF8 (errMsg), wxT ("spatialite-gui"), 240 - wxOK | wxICON_ERROR, this); 241 - sqlite3_free (errMsg); 242 - return false; 243 - } 244 - if (rows < 1) 245 - ; 246 - else 247 - { 248 - for (i = 1; i <= rows; i++) 249 - not_exists = false; 250 - } 251 - sqlite3_free_table (results); 252 - return not_exists; 175 + char **results; 176 + int rows; 177 + int columns; 178 + int i; 179 + char *errMsg = NULL; 180 + bool constrained = false; 181 + bool not_exists = true; 182 + wxString RefSysName; 183 + char xsql[128]; 184 + wxString sql = 185 + wxT 186 + ("SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'spatial_ref_sys'"); 187 + int ret = sqlite3_get_table(SqliteHandle, sql.ToUTF8(), &results, 188 + &rows, &columns, &errMsg); 189 + if (ret != SQLITE_OK) 190 + { 191 + wxMessageBox(wxT("SQLite SQL error: ") + wxString::FromUTF8(errMsg), 192 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 193 + sqlite3_free(errMsg); 194 + return false; 195 + } 196 + if (rows < 1) 197 + ; 198 + else 199 + { 200 + for (i = 1; i <= rows; i++) 201 + constrained = true; 202 + } 203 + sqlite3_free_table(results); 204 + if (constrained == false) 205 + return false; 206 + sprintf(xsql, "SELECT ref_sys_name FROM spatial_ref_sys WHERE srid = %d", 207 + srid); 208 + ret = 209 + sqlite3_get_table(SqliteHandle, xsql, &results, &rows, &columns, &errMsg); 210 + if (ret != SQLITE_OK) 211 + { 212 + wxMessageBox(wxT("SQLite SQL error: ") + wxString::FromUTF8(errMsg), 213 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 214 + sqlite3_free(errMsg); 215 + return false; 216 + } 217 + if (rows < 1) 218 + ; 219 + else 220 + { 221 + for (i = 1; i <= rows; i++) 222 + not_exists = false; 223 + } 224 + sqlite3_free_table(results); 225 + return not_exists; 253 226 } 254 227 255 -bool MyFrame::CheckMetadata () 228 +bool MyFrame::CheckMetadata() 256 229 { 257 230 // 258 231 // checking if METADATA tables are defined 259 232 // 260 - char ** 261 - results; 262 - int 263 - rows; 264 - int 265 - columns; 266 - int 267 - i; 268 - char * 269 - errMsg = NULL; 270 - bool 271 - constrained = false; 272 - wxString 273 - sql = 274 - wxT 275 - ("SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'geometry_columns'"); 276 - int 277 - ret = sqlite3_get_table (SqliteHandle, sql.ToUTF8 (), &results, 278 - &rows, &columns, &errMsg); 279 - if (ret != SQLITE_OK) 280 - { 281 - wxMessageBox (wxT ("SQLite SQL error: ") + 282 - wxString::FromUTF8 (errMsg), wxT ("spatialite-gui"), 283 - wxOK | wxICON_ERROR, this); 284 - sqlite3_free (errMsg); 285 - return false; 286 - } 287 - if (rows < 1) 288 - ; 289 - else 290 - { 291 - for (i = 1; i <= rows; i++) 292 - constrained = true; 293 - } 294 - sqlite3_free_table (results); 295 - return constrained; 233 + char **results; 234 + int rows; 235 + int columns; 236 + int i; 237 + char *errMsg = NULL; 238 + bool constrained = false; 239 + if (SpatiaLiteMetadata == false) 240 + return false; 241 + wxString sql = 242 + wxT 243 + ("SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'geometry_columns'"); 244 + int ret = sqlite3_get_table(SqliteHandle, sql.ToUTF8(), &results, 245 + &rows, &columns, &errMsg); 246 + if (ret != SQLITE_OK) 247 + { 248 + wxMessageBox(wxT("SQLite SQL error: ") + wxString::FromUTF8(errMsg), 249 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 250 + sqlite3_free(errMsg); 251 + return false; 252 + } 253 + if (rows < 1) 254 + ; 255 + else 256 + { 257 + for (i = 1; i <= rows; i++) 258 + constrained = true; 259 + } 260 + sqlite3_free_table(results); 261 + return constrained; 296 262 } 297 263 298 -void 299 -MyFrame::CleanSqlString (char *value) 264 +void MyFrame::CleanSqlString(char *value) 300 265 { 301 266 // 302 267 // returns a well formatted TEXT value for SQL 303 268 // 1] strips trailing spaces 304 269 // 2] masks any ' inside the string, appending another ' 305 270 // 306 - char new_value[1024]; 307 - char *p; 308 - int len; 309 - int i; 310 - len = strlen (value); 311 - for (i = (len - 1); i >= 0; i--) 312 - { 313 - // stripping trailing spaces 314 - if (value[i] == ' ') 315 - value[i] = '\0'; 316 - else 317 - break; 318 - } 319 - p = new_value; 320 - for (i = 0; i < len; i++) 321 - { 322 - if (value[i] == '\'') 323 - *(p++) = '\''; 324 - *(p++) = value[i]; 325 - } 326 - *p = '\0'; 327 - strcpy (value, new_value); 271 + char new_value[1024]; 272 + char *p; 273 + int len; 274 + int i; 275 + len = strlen(value); 276 + for (i = (len - 1); i >= 0; i--) 277 + { 278 + // stripping trailing spaces 279 + if (value[i] == ' ') 280 + value[i] = '\0'; 281 + else 282 + break; 283 + } 284 + p = new_value; 285 + for (i = 0; i < len; i++) 286 + { 287 + if (value[i] == '\'') 288 + *(p++) = '\''; 289 + *(p++) = value[i]; 290 + } 291 + *p = '\0'; 292 + strcpy(value, new_value); 328 293 } 329 294 330 -void 331 -MyFrame::LoadShapefile (wxString & path, wxString & table, int srid, 332 - wxString & column, wxString & charset) 295 +void MyFrame::LoadShapefile(wxString & path, wxString & table, int srid, 296 + wxString & column, wxString & charset) 333 297 { 334 298 // 335 299 // loading a Shapefile as a new DB table 336 300 // 337 - int cnt; 338 - int col_cnt; 339 - int seed; 340 - int len; 341 - int dup; 342 - int idup; 343 - int current_row; 344 - int ret; 345 - int rows = 0; 346 - char *errMsg = NULL; 347 - char xtable[1024]; 348 - char xcolumn[1024]; 349 - char dummy[65536]; 350 - char dummyName[4096]; 351 - char sql[65536]; 352 - char **col_name = NULL; 353 - const char *geom_type = "UNKNOWN"; 354 - char *hexWKB = NULL; 355 - int szSQL; 356 - char *bufSQL = NULL; 357 - wxString dummyStr; 358 - wxString msg; 359 - gaiaShapefilePtr shp = NULL; 360 - gaiaDbfFieldPtr dbf_field; 361 - bool metadata = CheckMetadata (); 362 - bool sqlError = false; 301 + sqlite3_stmt *stmt; 302 + int cnt; 303 + int col_cnt; 304 + int seed; 305 + int len; 306 + int dup; 307 + int idup; 308 + int current_row; 309 + int ret; 310 + int rows = 0; 311 + char *errMsg = NULL; 312 + char xtable[1024]; 313 + char xcolumn[1024]; 314 + char dummyName[4096]; 315 + char sql[65536]; 316 + char **col_name = NULL; 317 + unsigned char *blob; 318 + int blob_size; 319 + const char *geom_type = "UNKNOWN"; 320 + wxString dummyStr; 321 + wxString msg; 322 + gaiaShapefilePtr shp = NULL; 323 + gaiaDbfFieldPtr dbf_field; 324 + bool metadata = CheckMetadata(); 325 + bool sqlError = false; 363 326 // 364 327 // performing some checks before starting 365 328 // 366 - if (TableAlreadyExists (table) == true) 367 - { 368 - wxMessageBox (wxT ("a table name '") + table + 369 - wxT ("' already exists"), wxT ("spatialite-gui"), 370 - wxOK | wxICON_ERROR, this); 371 - return; 372 - } 373 - if (gaiaIllegalSqlName (table.ToUTF8 ()) == 1 374 - || gaiaIsReservedSqlName (table.ToUTF8 ()) == 1 375 - || gaiaIsReservedSqliteName (table.ToUTF8 ()) == 1) 376 - { 377 - wxMessageBox (wxT ("'") + table + 378 - wxT 379 - ("' is an invalid TABLE NAME\n\nsame as SQL reserved keyword"), 380 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, this); 381 - return; 382 - } 383 - if (gaiaIllegalSqlName (column.ToUTF8 ()) == 1 384 - || gaiaIsReservedSqlName (column.ToUTF8 ()) == 1 385 - || gaiaIsReservedSqliteName (column.ToUTF8 ()) == 1) 386 - { 387 - wxMessageBox (wxT ("'") + column + 388 - wxT 389 - ("' is an invalid COLUMN NAME\n\nsame as SQL reserved keyword"), 390 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, this); 391 - return; 392 - } 393 - if (metadata == true) 394 - { 395 - if (SridNotExists (srid) == true) 396 - { 397 - wxMessageBox (wxT ("invalid SRID value"), 398 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 399 - this); 400 - return; 401 - } 402 - } 329 + if (TableAlreadyExists(table) == true) 330 + { 331 + wxMessageBox(wxT("a table name '") + table + wxT("' already exists"), 332 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 333 + return; 334 + } 335 + if (metadata == true) 336 + { 337 + if (SridNotExists(srid) == true) 338 + { 339 + wxMessageBox(wxT("invalid SRID value"), wxT("spatialite-gui"), 340 + wxOK | wxICON_ERROR, this); 341 + return; 342 + } 343 + } 403 344 // 404 345 // initalizing the SHP struct 405 346 // 406 - shp = gaiaAllocShapefile (); 407 - gaiaOpenShpRead (shp, path.ToUTF8 (), charset.ToUTF8 (), "UTF-8"); 408 - if (!(shp->Valid)) 409 - { 410 - gaiaFreeShapefile (shp); 411 - return; 412 - } 413 - ::wxBeginBusyCursor (); 347 + shp = gaiaAllocShapefile(); 348 + gaiaOpenShpRead(shp, path.ToUTF8(), charset.ToUTF8(), "UTF-8"); 349 + if (!(shp->Valid)) 350 + { 351 + wxString error = wxT("ERROR: invalid Shapefile\n\n"); 352 + if (shp->LastError) 353 + error += wxString::FromUTF8(shp->LastError); 354 + gaiaFreeShapefile(shp); 355 + wxMessageBox(error, wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 356 + return; 357 + } 358 + ::wxBeginBusyCursor(); 414 359 // 415 360 // checking for duplicate / illegal column names and antialising them 416 361 // 417 - col_cnt = 0; 418 - dbf_field = shp->Dbf->First; 419 - while (dbf_field) 420 - { 421 - // counting DBF fields 422 - col_cnt++; 423 - dbf_field = dbf_field->Next; 424 - } 425 - col_name = (char **) malloc (sizeof (char *) * col_cnt); 426 - cnt = 0; 427 - seed = 0; 428 - dbf_field = shp->Dbf->First; 429 - while (dbf_field) 430 - { 431 - // preparing column names 432 - if (gaiaIllegalSqlName (dbf_field->Name) 433 - || gaiaIsReservedSqlName (dbf_field->Name) 434 - || gaiaIsReservedSqliteName (dbf_field->Name)) 435 - sprintf (dummyName, "COL_%d", seed++); 436 - else 437 - strcpy (dummyName, dbf_field->Name); 438 - dup = 0; 439 - for (idup = 0; idup < cnt; idup++) 440 - { 441 - if (strcasecmp (dummyName, *(col_name + idup)) == 0) 442 - dup = 1; 443 - } 444 - if (strcasecmp (dummyName, "PK_UID") == 0) 445 - dup = 1; 446 - if (strcasecmp (dummyName, column.ToUTF8 ()) == 0) 447 - dup = 1; 448 - if (dup) 449 - sprintf (dummyName, "COL_%d", seed++); 450 - len = strlen (dummyName); 451 - *(col_name + cnt) = (char *) malloc (len + 1); 452 - strcpy (*(col_name + cnt), dummyName); 453 - cnt++; 454 - dbf_field = dbf_field->Next; 455 - } 362 + col_cnt = 0; 363 + dbf_field = shp->Dbf->First; 364 + while (dbf_field) 365 + { 366 + // counting DBF fields 367 + col_cnt++; 368 + dbf_field = dbf_field->Next; 369 + } 370 + col_name = (char **) malloc(sizeof(char *) * col_cnt); 371 + cnt = 0; 372 + seed = 0; 373 + dbf_field = shp->Dbf->First; 374 + while (dbf_field) 375 + { 376 + // preparing column names 377 + strcpy(dummyName, dbf_field->Name); 378 + dup = 0; 379 + for (idup = 0; idup < cnt; idup++) 380 + { 381 + if (strcasecmp(dummyName, *(col_name + idup)) == 0) 382 + dup = 1; 383 + } 384 + if (strcasecmp(dummyName, "PK_UID") == 0) 385 + dup = 1; 386 + if (strcasecmp(dummyName, column.ToUTF8()) == 0) 387 + dup = 1; 388 + if (dup) 389 + sprintf(dummyName, "COL_%d", seed++); 390 + len = strlen(dummyName); 391 + *(col_name + cnt) = (char *) malloc(len + 1); 392 + strcpy(*(col_name + cnt), dummyName); 393 + cnt++; 394 + dbf_field = dbf_field->Next; 395 + } 456 396 // 457 397 // starting a transaction 458 398 // 459 - ret = sqlite3_exec (SqliteHandle, "BEGIN", NULL, 0, &errMsg); 460 - if (ret != SQLITE_OK) 461 - { 462 - wxMessageBox (wxT ("load shapefile error:") + 463 - wxString::FromUTF8 (errMsg), wxT ("spatialite-gui"), 464 - wxOK | wxICON_ERROR, this); 465 - sqlite3_free (errMsg); 466 - sqlError = true; 467 - goto clean_up; 468 - } 399 + ret = sqlite3_exec(SqliteHandle, "BEGIN", NULL, 0, &errMsg); 400 + if (ret != SQLITE_OK) 401 + { 402 + wxMessageBox(wxT("load shapefile error:") + wxString::FromUTF8(errMsg), 403 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 404 + sqlite3_free(errMsg); 405 + sqlError = true; 406 + goto clean_up; 407 + } 469 408 // 470 409 // creating the Table 471 410 // 472 - strcpy (xtable, table.ToUTF8 ()); 473 - strcpy (xcolumn, column.ToUTF8 ()); 474 - sprintf (sql, "CREATE TABLE %s", xtable); 475 - strcat (sql, " (\nPK_UID INTEGER PRIMARY KEY AUTOINCREMENT"); 476 - cnt = 0; 477 - dbf_field = shp->Dbf->First; 478 - while (dbf_field) 479 - { 480 - strcat (sql, ",\n"); 481 - strcat (sql, *(col_name + cnt)); 482 - cnt++; 483 - switch (dbf_field->Type) 484 - { 485 - case 'C': 486 - strcat (sql, " TEXT"); 487 - break; 488 - case 'N': 489 - if (dbf_field->Decimals) 490 - strcat (sql, " DOUBLE"); 491 - else 492 - { 493 - if (dbf_field->Length <= 9) 494 - strcat (sql, " INTEGER"); 495 - else 496 - strcat (sql, " DOUBLE"); 497 - } 498 - break; 499 - case 'D': 500 - strcat (sql, " TEXT"); 501 - break; 502 - case 'L': 503 - strcat (sql, " INTEGER"); 504 - break; 505 - }; 506 - strcat (sql, " NOT NULL"); 507 - dbf_field = dbf_field->Next; 508 - } 509 - if (metadata == true) 510 - strcat (sql, ")"); 511 - else 512 - { 513 - strcat (sql, ",\n"); 514 - strcat (sql, xcolumn); 515 - strcat (sql, " BLOB NOT NULL)"); 516 - } 517 - ret = sqlite3_exec (SqliteHandle, sql, NULL, 0, &errMsg); 518 - if (ret != SQLITE_OK) 519 - { 520 - wxMessageBox (wxT ("load shapefile error:") + 521 - wxString::FromUTF8 (errMsg), wxT ("spatialite-gui"), 522 - wxOK | wxICON_ERROR, this); 523 - sqlite3_free (errMsg); 524 - sqlError = true; 525 - goto clean_up; 526 - } 527 - if (metadata) 528 - { 529 - // creating Geometry column 530 - switch (shp->Shape) 531 - { 532 - case 1: 533 - case 11: 534 - case 21: 535 - geom_type = "POINT"; 536 - break; 537 - case 8: 538 - geom_type = "MULTIPOINT"; 539 - break; 540 - case 3: 541 - case 13: 542 - case 23: 543 - geom_type = "MULTILINESTRING"; 544 - break; 545 - case 5: 546 - case 15: 547 - case 25: 548 - geom_type = "MULTIPOLYGON"; 549 - break; 550 - }; 551 - sprintf (sql, "SELECT AddGeometryColumn('%s', '%s', %d, '%s', 2)", 552 - xtable, xcolumn, srid, geom_type); 553 - ret = sqlite3_exec (SqliteHandle, sql, NULL, 0, &errMsg); 554 - if (ret != SQLITE_OK) 555 - { 556 - wxMessageBox (wxT ("load shapefile error:") + 557 - wxString::FromUTF8 (errMsg), 558 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 559 - this); 560 - sqlite3_free (errMsg); 561 - sqlError = true; 562 - goto clean_up; 563 - } 564 - } 565 - current_row = 0; 566 - while (1) 567 - { 568 - // 569 - // inserting rows from shapefile 570 - // 571 - ret = gaiaReadShpEntity (shp, current_row, srid); 572 - if (!ret) 573 - { 574 - if (!(shp->LastError)) // normal SHP EOF 575 - break; 576 - wxMessageBox (wxT ("load shapefile error:") + 577 - wxString::FromUTF8 (shp->LastError), 578 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 579 - this); 580 - sqlError = true; 581 - goto clean_up; 582 - } 583 - current_row++; 584 - sprintf (sql, "INSERT INTO %s (\nPK_UID,", xtable); 585 - cnt = 0; 586 - dbf_field = shp->Dbf->First; 587 - while (dbf_field) 588 - { 589 - // columns corresponding to some DBF attribute 590 - strcat (sql, *(col_name + cnt)); 591 - cnt++; 592 - strcat (sql, ","); 593 - dbf_field = dbf_field->Next; 594 - } 595 - strcat (sql, xcolumn); // the GEOMETRY column 596 - strcat (sql, ")\nVALUES ("); 597 - sprintf (dummy, "%d,", current_row); 598 - strcat (sql, dummy); 599 - dbf_field = shp->Dbf->First; 600 - while (dbf_field) 601 - { 602 - // column values 603 - if (!(dbf_field->Value)) 604 - strcat (sql, "NULL"); 605 - else 606 - { 607 - switch (dbf_field->Value->Type) 608 - { 609 - case GAIA_INT_VALUE: 610 - sprintf (dummy, "%d", dbf_field->Value->IntValue); 611 - strcat (sql, dummy); 612 - break; 613 - case GAIA_DOUBLE_VALUE: 614 - sprintf (dummy, "%1.6lf", 615 - dbf_field->Value->DblValue); 616 - strcat (sql, dummy); 617 - break; 618 - case GAIA_TEXT_VALUE: 619 - strcpy (dummy, dbf_field->Value->TxtValue); 620 - CleanSqlString (dummy); 621 - strcat (sql, "'"); 622 - strcat (sql, dummy); 623 - strcat (sql, "'"); 624 - break; 625 - default: 626 - strcat (sql, "NULL"); 627 - break; 628 - }; 629 - } 630 - strcat (sql, ","); 631 - dbf_field = dbf_field->Next; 632 - } 633 - hexWKB = gaiaToHexWkb (shp->Dbf->Geometry); 634 - szSQL = strlen (sql) + strlen (hexWKB) + 1024; 635 - bufSQL = (char *) malloc (szSQL); 636 - strcpy (bufSQL, sql); 637 - strcat (bufSQL, "\n"); 638 - strcat (bufSQL, "GeomFromWkb(X'"); 639 - strcat (bufSQL, hexWKB); 640 - sprintf (dummy, "', %d))", srid); 641 - strcat (bufSQL, dummy); 642 - ret = sqlite3_exec (SqliteHandle, bufSQL, NULL, 0, &errMsg); 643 - if (ret != SQLITE_OK) 644 - { 645 - wxMessageBox (wxT ("load shapefile error:") + 646 - wxString::FromUTF8 (errMsg), 647 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 648 - this); 649 - sqlite3_free (errMsg); 650 - sqlError = true; 651 - goto clean_up; 652 - } 653 - rows++; 654 - free (hexWKB); 655 - hexWKB = NULL; 656 - free (bufSQL); 657 - bufSQL = NULL; 658 - } 659 - clean_up: 660 - if (hexWKB) 661 - free (hexWKB); 662 - if (bufSQL) 663 - free (bufSQL); 664 - gaiaFreeShapefile (shp); 665 - if (col_name) 666 - { 667 - // releasing memory allocation for column names 668 - for (cnt = 0; cnt < col_cnt; cnt++) 669 - free (*(col_name + cnt)); 670 - free (col_name); 671 - } 672 - if (sqlError == true) 673 - { 674 - // some error occurred - ROLLBACK 675 - ret = sqlite3_exec (SqliteHandle, "ROLLBACK", NULL, 0, &errMsg); 676 - if (ret != SQLITE_OK) 677 - { 678 - wxMessageBox (wxT ("load shapefile error:") + 679 - wxString::FromUTF8 (errMsg), 680 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 681 - this); 682 - sqlite3_free (errMsg); 683 - } 684 - ::wxEndBusyCursor (); 685 - msg.Printf (wxT 686 - ("Shapefile not loaded\n\n\na ROLLBACK was automatically performed")); 687 - wxMessageBox (msg, wxT ("spatialite-gui"), wxOK | wxICON_WARNING, 688 - this); 689 - } 690 - else 691 - { 692 - // ok - confirming pending transaction - COMMIT 693 - ret = sqlite3_exec (SqliteHandle, "COMMIT", NULL, 0, &errMsg); 694 - if (ret != SQLITE_OK) 695 - { 696 - wxMessageBox (wxT ("load shapefile error:") + 697 - wxString::FromUTF8 (errMsg), 698 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 699 - this); 700 - sqlite3_free (errMsg); 701 - return; 702 - } 703 - ::wxEndBusyCursor (); 704 - msg.Printf (wxT ("Shapefile loaded\n\n%d inserted rows"), rows); 705 - wxMessageBox (msg, wxT ("spatialite-gui"), 706 - wxOK | wxICON_INFORMATION, this); 707 - ClearTableTree (); 708 - InitTableTree (); 709 - } 411 + strcpy(xtable, table.ToUTF8()); 412 + strcpy(xcolumn, column.ToUTF8()); 413 + sprintf(sql, "CREATE TABLE \"%s\"", xtable); 414 + strcat(sql, " (\n\"PK_UID\" INTEGER PRIMARY KEY AUTOINCREMENT"); 415 + cnt = 0; 416 + dbf_field = shp->Dbf->First; 417 + while (dbf_field) 418 + { 419 + strcat(sql, ",\n\""); 420 + strcat(sql, *(col_name + cnt)); 421 + cnt++; 422 + switch (dbf_field->Type) 423 + { 424 + case 'C': 425 + strcat(sql, "\" TEXT"); 426 + break; 427 + case 'N': 428 + if (dbf_field->Decimals) 429 + strcat(sql, "\" DOUBLE"); 430 + else 431 + { 432 + if (dbf_field->Length <= 18) 433 + strcat(sql, "\" INTEGER"); 434 + else 435 + strcat(sql, "\" DOUBLE"); 436 + } 437 + break; 438 + case 'D': 439 + strcat(sql, "\" DOUBLE"); 440 + break; 441 + case 'L': 442 + strcat(sql, "\" INTEGER"); 443 + break; 444 + }; 445 + dbf_field = dbf_field->Next; 446 + } 447 + if (metadata == true) 448 + strcat(sql, ")"); 449 + else 450 + { 451 + strcat(sql, ",\n"); 452 + strcat(sql, xcolumn); 453 + strcat(sql, " BLOB)"); 454 + } 455 + ret = sqlite3_exec(SqliteHandle, sql, NULL, 0, &errMsg); 456 + if (ret != SQLITE_OK) 457 + { 458 + wxMessageBox(wxT("load shapefile error:") + wxString::FromUTF8(errMsg), 459 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 460 + sqlite3_free(errMsg); 461 + sqlError = true; 462 + goto clean_up; 463 + } 464 + if (metadata) 465 + { 466 + // creating Geometry column 467 + switch (shp->Shape) 468 + { 469 + case 1: 470 + case 11: 471 + case 21: 472 + geom_type = "POINT"; 473 + break; 474 + case 8: 475 + geom_type = "MULTIPOINT"; 476 + break; 477 + case 3: 478 + case 13: 479 + case 23: 480 + gaiaShpAnalyze(shp); 481 + if (shp->EffectiveType == GAIA_LINESTRING) 482 + geom_type = "LINESTRING"; 483 + else 484 + geom_type = "MULTILINESTRING"; 485 + break; 486 + case 5: 487 + case 15: 488 + case 25: 489 + gaiaShpAnalyze(shp); 490 + if (shp->EffectiveType == GAIA_POLYGON) 491 + geom_type = "POLYGON"; 492 + else 493 + geom_type = "MULTIPOLYGON"; 494 + break; 495 + }; 496 + sprintf(sql, "SELECT AddGeometryColumn('%s', '%s', %d, '%s', 2)", xtable, 497 + xcolumn, srid, geom_type); 498 + ret = sqlite3_exec(SqliteHandle, sql, NULL, 0, &errMsg); 499 + if (ret != SQLITE_OK) 500 + { 501 + wxMessageBox(wxT("load shapefile error:") + 502 + wxString::FromUTF8(errMsg), wxT("spatialite-gui"), 503 + wxOK | wxICON_ERROR, this); 504 + sqlite3_free(errMsg); 505 + sqlError = true; 506 + goto clean_up; 507 + } 508 + } else 509 + { 510 + // no Metadata 511 + if (shp->Shape == 3 || shp->Shape == 13 || shp->Shape == 23 512 + || shp->Shape == 5 || shp->Shape == 15 || shp->Shape == 25) 513 + { 514 + // fixing anyway the Geometry type for LINESTRING/MULTILINESTRING or POLYGON/MULTIPOLYGON 515 + gaiaShpAnalyze(shp); 516 + } 517 + } 518 +// preparing the INSERT INTO parameterized statement 519 + sprintf(sql, "INSERT INTO \"%s\" (\"PK_UID\",", xtable); 520 + cnt = 0; 521 + dbf_field = shp->Dbf->First; 522 + while (dbf_field) 523 + { 524 + // columns corresponding to some DBF attribute 525 + strcat(sql, "\""); 526 + strcat(sql, *(col_name + cnt)); 527 + cnt++; 528 + strcat(sql, "\","); 529 + dbf_field = dbf_field->Next; 530 + } 531 + strcat(sql, xcolumn); // the GEOMETRY column 532 + strcat(sql, ")\nVALUES (? "); 533 + dbf_field = shp->Dbf->First; 534 + while (dbf_field) 535 + { 536 + // column values 537 + strcat(sql, ", ?"); 538 + dbf_field = dbf_field->Next; 539 + } 540 + strcat(sql, ", ?)"); // the GEOMETRY column 541 + ret = sqlite3_prepare_v2(SqliteHandle, sql, strlen(sql), &stmt, NULL); 542 + if (ret != SQLITE_OK) 543 + { 544 + wxString err = wxString::FromUTF8(sqlite3_errmsg(SqliteHandle)); 545 + wxMessageBox(wxT("load shapefile error: ") + err, wxT("spatialite-gui"), 546 + wxOK | wxICON_ERROR, this); 547 + sqlError = true; 548 + goto clean_up; 549 + } 550 + current_row = 0; 551 + while (1) 552 + { 553 + // 554 + // inserting rows from shapefile 555 + // 556 + ret = gaiaReadShpEntity(shp, current_row, srid); 557 + if (!ret) 558 + { 559 + if (!(shp->LastError)) // normal SHP EOF 560 + break; 561 + wxMessageBox(wxT("load shapefile error:") + 562 + wxString::FromUTF8(shp->LastError), 563 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 564 + sqlError = true; 565 + goto clean_up; 566 + } 567 + current_row++; 568 + // binding query params 569 + sqlite3_reset(stmt); 570 + sqlite3_clear_bindings(stmt); 571 + sqlite3_bind_int(stmt, 1, current_row); 572 + cnt = 0; 573 + dbf_field = shp->Dbf->First; 574 + while (dbf_field) 575 + { 576 + // column values 577 + if (!(dbf_field->Value)) 578 + sqlite3_bind_null(stmt, cnt + 2); 579 + else 580 + { 581 + switch (dbf_field->Value->Type) 582 + { 583 + case GAIA_INT_VALUE: 584 + sqlite3_bind_int64(stmt, cnt + 2, 585 + dbf_field->Value->IntValue); 586 + break; 587 + case GAIA_DOUBLE_VALUE: 588 + sqlite3_bind_double(stmt, cnt + 2, 589 + dbf_field->Value->DblValue); 590 + break; 591 + case GAIA_TEXT_VALUE: 592 + sqlite3_bind_text(stmt, cnt + 2, 593 + dbf_field->Value->TxtValue, 594 + strlen(dbf_field->Value-> 595 + TxtValue), SQLITE_STATIC); 596 + break; 597 + default: 598 + sqlite3_bind_null(stmt, cnt + 2);; 599 + break; 600 + }; 601 + } 602 + cnt++; 603 + dbf_field = dbf_field->Next; 604 + } 605 + if (shp->Dbf->Geometry) 606 + { 607 + gaiaToSpatiaLiteBlobWkb(shp->Dbf->Geometry, &blob, &blob_size); 608 + sqlite3_bind_blob(stmt, cnt + 2, blob, blob_size, free); 609 + } else 610 + { 611 + /* handling a NULL-Geometry */ 612 + sqlite3_bind_null(stmt, cnt + 2); 613 + } 614 + ret = sqlite3_step(stmt); 615 + if (ret == SQLITE_DONE || ret == SQLITE_ROW) 616 + ; 617 + else 618 + { 619 + wxString err = wxString::FromUTF8(sqlite3_errmsg(SqliteHandle)); 620 + wxMessageBox(wxT("load shapefile error:") + err, 621 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 622 + sqlite3_finalize(stmt); 623 + sqlError = true; 624 + goto clean_up; 625 + } 626 + rows++; 627 + } 628 + sqlite3_finalize(stmt); 629 +clean_up: 630 + gaiaFreeShapefile(shp); 631 + if (col_name) 632 + { 633 + // releasing memory allocation for column names 634 + for (cnt = 0; cnt < col_cnt; cnt++) 635 + free(*(col_name + cnt)); 636 + free(col_name); 637 + } 638 + if (sqlError == true) 639 + { 640 + // some error occurred - ROLLBACK 641 + ret = sqlite3_exec(SqliteHandle, "ROLLBACK", NULL, 0, &errMsg); 642 + if (ret != SQLITE_OK) 643 + { 644 + wxMessageBox(wxT("load shapefile error:") + 645 + wxString::FromUTF8(errMsg), wxT("spatialite-gui"), 646 + wxOK | wxICON_ERROR, this); 647 + sqlite3_free(errMsg); 648 + } 649 + ::wxEndBusyCursor(); 650 + msg = 651 + wxT("Shapefile not loaded\n\n\na ROLLBACK was automatically performed"); 652 + wxMessageBox(msg, wxT("spatialite-gui"), wxOK | wxICON_WARNING, this); 653 + } else 654 + { 655 + // ok - confirming pending transaction - COMMIT 656 + ret = sqlite3_exec(SqliteHandle, "COMMIT", NULL, 0, &errMsg); 657 + if (ret != SQLITE_OK) 658 + { 659 + wxMessageBox(wxT("load shapefile error:") + 660 + wxString::FromUTF8(errMsg), wxT("spatialite-gui"), 661 + wxOK | wxICON_ERROR, this); 662 + sqlite3_free(errMsg); 663 + return; 664 + } 665 + ::wxEndBusyCursor(); 666 + sprintf(dummyName, "Shapefile loaded\n\n%d inserted rows", rows); 667 + msg = wxString::FromUTF8(dummyName); 668 + wxMessageBox(msg, wxT("spatialite-gui"), wxOK | wxICON_INFORMATION, this); 669 + InitTableTree(); 670 + } 710 671 } 711 672 712 -gaiaDbfFieldPtr MyFrame::GetDbfField (gaiaDbfListPtr list, char *name) 673 +gaiaDbfFieldPtr MyFrame::GetDbfField(gaiaDbfListPtr list, char *name) 713 674 { 714 675 // 715 676 // find a DBF attribute by name 716 677 // 717 - gaiaDbfFieldPtr 718 - fld = list->First; 719 - while (fld) 720 - { 721 - if (strcasecmp (fld->Name, name) == 0) 722 - return fld; 723 - fld = fld->Next; 724 - } 725 - return NULL; 678 + gaiaDbfFieldPtr fld = list->First; 679 + while (fld) 680 + { 681 + if (strcasecmp(fld->Name, name) == 0) 682 + return fld; 683 + fld = fld->Next; 684 + } 685 + return NULL; 726 686 } 727 687 728 -void 729 -MyFrame::DumpShapefile (wxString & path, wxString & table, wxString & column, 730 - wxString & charset) 688 +void MyFrame::DumpShapefile(wxString & path, wxString & table, 689 + wxString & column, wxString & charset) 731 690 { 732 691 // 733 692 // dumping a geometry table as Shapefile 734 693 // 735 - char **results; 736 - int rows; 737 - int columns; 738 - int i; 739 - char *errMsg = NULL; 740 - char *gtype; 741 - wxString geometryType; 742 - int shape = -1; 743 - char xtable[1024]; 744 - char xcolumn[1024]; 745 - char xpath[1024]; 746 - char xsql[4096]; 747 - sqlite3_stmt *stmt; 748 - int row1 = 0; 749 - int n_cols = 0; 750 - int offset = 0; 751 - int type; 752 - int multiple_entities = 0; 753 - const unsigned char *char_value; 754 - const void *blob_value; 755 - gaiaShapefilePtr shp = NULL; 756 - gaiaDbfListPtr dbf_export_list = NULL; 757 - gaiaDbfListPtr dbf_list = NULL; 758 - gaiaDbfListPtr dbf_write; 759 - gaiaDbfFieldPtr dbf_field; 760 - gaiaGeomCollPtr geom; 761 - int *max_length = NULL; 762 - int *sql_type = NULL; 763 - char dummy[1024]; 764 - int len; 765 - wxString msg; 766 - wxString sql = 767 - wxT ("SELECT type FROM geometry_columns WHERE f_table_name = '"); 768 - sql += table; 769 - sql += wxT ("' AND f_geometry_column = '"); 770 - sql += column; 771 - sql += wxT ("'"); 772 - int ret = sqlite3_get_table (SqliteHandle, sql.ToUTF8 (), &results, 773 - &rows, &columns, &errMsg); 774 - if (ret != SQLITE_OK) 775 - { 776 - wxMessageBox (wxT ("dump shapefile error:") + 777 - wxString::FromUTF8 (errMsg), wxT ("spatialite-gui"), 778 - wxOK | wxICON_ERROR, this); 779 - sqlite3_free (errMsg); 780 - return; 781 - } 782 - if (rows < 1) 783 - ; 784 - else 785 - { 786 - for (i = 1; i <= rows; i++) 787 - { 788 - gtype = results[(i * columns) + 0]; 789 - geometryType = wxString::FromUTF8 (gtype); 790 - } 791 - } 792 - sqlite3_free_table (results); 793 - if (geometryType == wxT ("POINT")) 794 - shape = GAIA_POINT; 795 - if (geometryType == wxT ("MULTIPOINT")) 796 - shape = GAIA_MULTIPOINT; 797 - if (geometryType == wxT ("LINESTRING") 798 - || geometryType == wxT ("MULTILINESTRING")) 799 - shape = GAIA_LINESTRING; 800 - if (geometryType == wxT ("POLYGON") || geometryType == wxT ("MULTIPOLYGON")) 801 - shape = GAIA_POLYGON; 802 - if (shape < 0) 803 - { 804 - wxMessageBox (wxT ("Unable to detect GeometryType for '") + 805 - table + wxT (".") + column + wxT ("'"), 806 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, this); 807 - return; 808 - } 694 + char **results; 695 + int rows; 696 + int columns; 697 + int i; 698 + char *errMsg = NULL; 699 + char *gtype; 700 + wxString geometryType; 701 + int shape = -1; 702 + char xtable[1024]; 703 + char xcolumn[1024]; 704 + char xpath[1024]; 705 + char xsql[4096]; 706 + sqlite3_stmt *stmt; 707 + int row1 = 0; 708 + int n_cols = 0; 709 + int offset = 0; 710 + int type; 711 + int multiple_entities = 0; 712 + const unsigned char *char_value; 713 + const void *blob_value; 714 + gaiaShapefilePtr shp = NULL; 715 + gaiaDbfListPtr dbf_export_list = NULL; 716 + gaiaDbfListPtr dbf_list = NULL; 717 + gaiaDbfListPtr dbf_write; 718 + gaiaDbfFieldPtr dbf_field; 719 + gaiaGeomCollPtr geom; 720 + int *max_length = NULL; 721 + int *sql_type = NULL; 722 + char dummy[1024]; 723 + int len; 724 + wxString msg; 725 + wxString sql = 726 + wxT("SELECT type FROM geometry_columns WHERE f_table_name = '"); 727 + sql += table; 728 + sql += wxT("' AND f_geometry_column = '"); 729 + sql += column; 730 + sql += wxT("'"); 731 + int ret = sqlite3_get_table(SqliteHandle, sql.ToUTF8(), &results, 732 + &rows, &columns, &errMsg); 733 + if (ret != SQLITE_OK) 734 + { 735 + wxMessageBox(wxT("dump shapefile error:") + wxString::FromUTF8(errMsg), 736 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 737 + sqlite3_free(errMsg); 738 + return; 739 + } 740 + if (rows < 1) 741 + ; 742 + else 743 + { 744 + for (i = 1; i <= rows; i++) 745 + { 746 + gtype = results[(i * columns) + 0]; 747 + geometryType = wxString::FromUTF8(gtype); 748 + } 749 + } 750 + sqlite3_free_table(results); 751 + if (geometryType == wxT("POINT")) 752 + shape = GAIA_POINT; 753 + if (geometryType == wxT("MULTIPOINT")) 754 + shape = GAIA_MULTIPOINT; 755 + if (geometryType == wxT("LINESTRING") 756 + || geometryType == wxT("MULTILINESTRING")) 757 + shape = GAIA_LINESTRING; 758 + if (geometryType == wxT("POLYGON") || geometryType == wxT("MULTIPOLYGON")) 759 + shape = GAIA_POLYGON; 760 + if (shape < 0) 761 + { 762 + wxMessageBox(wxT("Unable to detect GeometryType for '") + 763 + table + wxT(".") + column + wxT("'"), wxT("spatialite-gui"), 764 + wxOK | wxICON_ERROR, this); 765 + return; 766 + } 809 767 // 810 768 // preparing SQL statement 811 769 // 812 - strcpy (xtable, table.ToUTF8 ()); 813 - strcpy (xcolumn, column.ToUTF8 ()); 814 - sprintf (xsql, "SELECT * FROM %s WHERE GeometryType(%s) = ", xtable, 815 - xcolumn); 816 - if (shape == GAIA_LINESTRING) 817 - { 818 - strcat (xsql, "'LINESTRING' OR GeometryType("); 819 - strcat (xsql, xcolumn); 820 - strcat (xsql, ") = 'MULTILINESTRING'"); 821 - } 822 - else if (shape == GAIA_POLYGON) 823 - { 824 - strcat (xsql, "'POLYGON' OR GeometryType("); 825 - strcat (xsql, xcolumn); 826 - strcat (xsql, ") = 'MULTIPOLYGON'"); 827 - } 828 - else if (shape == GAIA_MULTIPOINT) 829 - { 830 - strcat (xsql, "'POINT' OR GeometryType("); 831 - strcat (xsql, xcolumn); 832 - strcat (xsql, ") = 'MULTIPOINT'"); 833 - } 834 - else 835 - strcat (xsql, "'POINT'"); 770 + strcpy(xtable, table.ToUTF8()); 771 + strcpy(xcolumn, column.ToUTF8()); 772 + sprintf(xsql, "SELECT * FROM \"%s\" WHERE GeometryType(\"%s\") = ", xtable, 773 + xcolumn); 774 + if (shape == GAIA_LINESTRING) 775 + { 776 + strcat(xsql, "'LINESTRING' OR GeometryType(\""); 777 + strcat(xsql, xcolumn); 778 + strcat(xsql, "\") = 'MULTILINESTRING'"); 779 + } else if (shape == GAIA_POLYGON) 780 + { 781 + strcat(xsql, "'POLYGON' OR GeometryType(\""); 782 + strcat(xsql, xcolumn); 783 + strcat(xsql, "\") = 'MULTIPOLYGON'"); 784 + } else if (shape == GAIA_MULTIPOINT) 785 + { 786 + strcat(xsql, "'POINT' OR GeometryType(\""); 787 + strcat(xsql, xcolumn); 788 + strcat(xsql, "\") = 'MULTIPOINT'"); 789 + } else 790 + strcat(xsql, "'POINT'"); 791 +// fetching anyway NULL Geometries 792 + strcat(xsql, " OR \""); 793 + strcat(xsql, xcolumn); 794 + strcat(xsql, "\" IS NULL"); 836 795 // 837 796 // compiling SQL prepared statement 838 797 // 839 - ret = sqlite3_prepare_v2 (SqliteHandle, xsql, strlen (xsql), &stmt, NULL); 840 - if (ret != SQLITE_OK) 841 - goto sql_error; 842 - rows = 0; 843 - while (1) 844 - { 845 - // 846 - // Pass I - scrolling the result set to compute real DBF attributes' sizes and types 847 - // 848 - ret = sqlite3_step (stmt); 849 - if (ret == SQLITE_DONE) 850 - break; // end of result set 851 - if (ret == SQLITE_ROW) 852 - { 853 - // processing a result set row 854 - row1++; 855 - if (n_cols == 0) 856 - { 857 - // this one is the first row, so we are going to prepare the DBF Fields list 858 - n_cols = sqlite3_column_count (stmt); 859 - dbf_export_list = gaiaAllocDbfList (); 860 - max_length = (int *) malloc (sizeof (int) * n_cols); 861 - sql_type = (int *) malloc (sizeof (int) * n_cols); 862 - for (i = 0; i < n_cols; i++) 863 - { 864 - // initializes the DBF export fields 865 - strcpy (dummy, sqlite3_column_name (stmt, i)); 866 - gaiaAddDbfField (dbf_export_list, dummy, '\0', 0, 867 - 0, 0); 868 - max_length[i] = 0; 869 - sql_type[i] = SQLITE_NULL; 870 - } 871 - } 872 - for (i = 0; i < n_cols; i++) 873 - { 874 - // update the DBF export fields analyzing fetched data 875 - type = sqlite3_column_type (stmt, i); 876 - if (type == SQLITE_BLOB && strcasecmp ((char *) xcolumn, 877 - (char *) 878 - sqlite3_column_name 879 - (stmt, i)) == 0 880 - && shape == GAIA_POINT) 881 - { 882 - // 883 - // we need to check if there is any MULTIPOINT, 884 - // because shapefile handles simple-points shapes and multi-points shapes 885 - // in a complete differet way 886 - // 887 - blob_value = sqlite3_column_blob (stmt, i); 888 - len = sqlite3_column_bytes (stmt, i); 889 - geom = 890 - gaiaFromSpatiaLiteBlobWkb ((unsigned char *) 891 - blob_value, len); 892 - if (geom) 893 - { 894 - if (geom->FirstPoint != geom->LastPoint) 895 - multiple_entities = 1; 896 - gaiaFreeGeomColl (geom); 897 - } 898 - } 899 - if (type == SQLITE_NULL || type == SQLITE_BLOB) 900 - continue; 901 - if (type == SQLITE_TEXT) 902 - { 903 - char_value = sqlite3_column_text (stmt, i); 904 - len = sqlite3_column_bytes (stmt, i); 905 - sql_type[i] = SQLITE_TEXT; 906 - if (len > max_length[i]) 907 - max_length[i] = len; 908 - } 909 - else if (type == SQLITE_FLOAT 910 - && sql_type[i] != SQLITE_TEXT) 911 - sql_type[i] = SQLITE_FLOAT; // promoting a numeric column to be DOUBLE 912 - else if (type == SQLITE_INTEGER 913 - && (sql_type[i] == SQLITE_NULL 914 - || sql_type[i] == SQLITE_INTEGER)) 915 - sql_type[i] = SQLITE_INTEGER; // promoting a null column to be INTEGER 916 - } 917 - } 918 - else 919 - goto sql_error; 920 - } 921 - if (!row1) 922 - goto empty_result_set; 923 - i = 0; 924 - offset = 0; 925 - dbf_list = gaiaAllocDbfList (); 926 - dbf_field = dbf_export_list->First; 927 - while (dbf_field) 928 - { 929 - // preparing the final DBF attribute list 930 - if (sql_type[i] == SQLITE_NULL) 931 - { 932 - i++; 933 - dbf_field = dbf_field->Next; 934 - continue; 935 - } 936 - if (sql_type[i] == SQLITE_TEXT) 937 - { 938 - gaiaAddDbfField (dbf_list, dbf_field->Name, 'C', offset, 939 - max_length[i], 0); 940 - offset += max_length[i]; 941 - } 942 - if (sql_type[i] == SQLITE_FLOAT) 943 - { 944 - gaiaAddDbfField (dbf_list, dbf_field->Name, 'N', offset, 24, 6); 945 - offset += 24; 946 - } 947 - if (sql_type[i] == SQLITE_INTEGER) 948 - { 949 - gaiaAddDbfField (dbf_list, dbf_field->Name, 'N', offset, 9, 0); 950 - offset += 9; 951 - } 952 - i++; 953 - dbf_field = dbf_field->Next; 954 - } 955 - free (max_length); 956 - free (sql_type); 957 - gaiaFreeDbfList (dbf_export_list); 798 + ret = sqlite3_prepare_v2(SqliteHandle, xsql, strlen(xsql), &stmt, NULL); 799 + if (ret != SQLITE_OK) 800 + goto sql_error; 801 + rows = 0; 802 + while (1) 803 + { 804 + // 805 + // Pass I - scrolling the result set to compute real DBF attributes' sizes and types 806 + // 807 + ret = sqlite3_step(stmt); 808 + if (ret == SQLITE_DONE) 809 + break; // end of result set 810 + if (ret == SQLITE_ROW) 811 + { 812 + // processing a result set row 813 + row1++; 814 + if (n_cols == 0) 815 + { 816 + // this one is the first row, so we are going to prepare the DBF Fields list 817 + n_cols = sqlite3_column_count(stmt); 818 + dbf_export_list = gaiaAllocDbfList(); 819 + max_length = (int *) malloc(sizeof(int) * n_cols); 820 + sql_type = (int *) malloc(sizeof(int) * n_cols); 821 + for (i = 0; i < n_cols; i++) 822 + { 823 + // initializes the DBF export fields 824 + strcpy(dummy, sqlite3_column_name(stmt, i)); 825 + gaiaAddDbfField(dbf_export_list, dummy, '\0', 0, 0, 0); 826 + max_length[i] = 0; 827 + sql_type[i] = SQLITE_NULL; 828 + } 829 + } 830 + for (i = 0; i < n_cols; i++) 831 + { 832 + // update the DBF export fields analyzing fetched data 833 + type = sqlite3_column_type(stmt, i); 834 + if (type == SQLITE_BLOB && strcasecmp((char *) xcolumn, 835 + (char *) 836 + sqlite3_column_name(stmt, 837 + i)) == 0 838 + && shape == GAIA_POINT) 839 + { 840 + // 841 + // we need to check if there is any MULTIPOINT, 842 + // because shapefile handles simple-points shapes and multi-points shapes 843 + // in a complete differet way 844 + // 845 + blob_value = sqlite3_column_blob(stmt, i); 846 + len = sqlite3_column_bytes(stmt, i); 847 + geom = 848 + gaiaFromSpatiaLiteBlobWkb((unsigned char *) blob_value, 849 + len); 850 + if (geom) 851 + { 852 + if (geom->FirstPoint != geom->LastPoint) 853 + multiple_entities = 1; 854 + gaiaFreeGeomColl(geom); 855 + } 856 + } 857 + if (type == SQLITE_NULL || type == SQLITE_BLOB) 858 + continue; 859 + if (type == SQLITE_TEXT) 860 + { 861 + char_value = sqlite3_column_text(stmt, i); 862 + len = sqlite3_column_bytes(stmt, i); 863 + sql_type[i] = SQLITE_TEXT; 864 + if (len > max_length[i]) 865 + max_length[i] = len; 866 + } else if (type == SQLITE_FLOAT && sql_type[i] != SQLITE_TEXT) 867 + sql_type[i] = SQLITE_FLOAT; // promoting a numeric column to be DOUBLE 868 + else if (type == SQLITE_INTEGER 869 + && (sql_type[i] == SQLITE_NULL 870 + || sql_type[i] == SQLITE_INTEGER)) 871 + sql_type[i] = SQLITE_INTEGER; // promoting a null column to be INTEGER 872 + } 873 + } else 874 + goto sql_error; 875 + } 876 + if (!row1) 877 + goto empty_result_set; 878 + i = 0; 879 + offset = 0; 880 + dbf_list = gaiaAllocDbfList(); 881 + dbf_field = dbf_export_list->First; 882 + while (dbf_field) 883 + { 884 + // preparing the final DBF attribute list 885 + if (sql_type[i] == SQLITE_NULL) 886 + { 887 + i++; 888 + dbf_field = dbf_field->Next; 889 + continue; 890 + } 891 + if (sql_type[i] == SQLITE_TEXT) 892 + { 893 + gaiaAddDbfField(dbf_list, dbf_field->Name, 'C', offset, max_length[i], 894 + 0); 895 + offset += max_length[i]; 896 + } 897 + if (sql_type[i] == SQLITE_FLOAT) 898 + { 899 + gaiaAddDbfField(dbf_list, dbf_field->Name, 'N', offset, 24, 6); 900 + offset += 24; 901 + } 902 + if (sql_type[i] == SQLITE_INTEGER) 903 + { 904 + gaiaAddDbfField(dbf_list, dbf_field->Name, 'N', offset, 18, 0); 905 + offset += 18; 906 + } 907 + i++; 908 + dbf_field = dbf_field->Next; 909 + } 910 + free(max_length); 911 + free(sql_type); 912 + gaiaFreeDbfList(dbf_export_list); 958 913 // resetting SQLite query 959 - ret = sqlite3_reset (stmt); 960 - if (ret != SQLITE_OK) 961 - goto sql_error; 914 + ret = sqlite3_reset(stmt); 915 + if (ret != SQLITE_OK) 916 + goto sql_error; 962 917 // trying to open shapefile files 963 - shp = gaiaAllocShapefile (); 964 - strcpy (xpath, path.ToUTF8 ()); 965 - gaiaOpenShpWrite (shp, xpath, shape, dbf_list, "UTF-8", charset.ToUTF8 ()); 966 - if (!(shp->Valid)) 967 - goto no_file; 968 - while (1) 969 - { 970 - // Pass II - scrolling the result set to dump data into shapefile 971 - ret = sqlite3_step (stmt); 972 - if (ret == SQLITE_DONE) 973 - break; // end of result set 974 - if (ret == SQLITE_ROW) 975 - { 976 - rows++; 977 - geom = NULL; 978 - dbf_write = gaiaCloneDbfEntity (dbf_list); 979 - for (i = 0; i < n_cols; i++) 980 - { 981 - if (strcasecmp 982 - ((char *) xcolumn, 983 - (char *) sqlite3_column_name (stmt, i)) == 0) 984 - { 985 - // this one is the internal BLOB encoded GEOMETRY to be exported 986 - blob_value = sqlite3_column_blob (stmt, i); 987 - len = sqlite3_column_bytes (stmt, i); 988 - dbf_write->Geometry = 989 - gaiaFromSpatiaLiteBlobWkb ((unsigned char *) 990 - blob_value, len); 991 - } 992 - strcpy (dummy, sqlite3_column_name (stmt, i)); 993 - dbf_field = GetDbfField (dbf_write, dummy); 994 - if (!dbf_field) 995 - continue; 996 - switch (dbf_field->Type) 997 - { 998 - case 'N': 999 - if (sqlite3_column_type (stmt, i) == SQLITE_INTEGER) 1000 - gaiaSetIntValue (dbf_field, 1001 - sqlite3_column_int (stmt, i)); 1002 - else if (sqlite3_column_type (stmt, i) == 1003 - SQLITE_FLOAT) 1004 - gaiaSetDoubleValue (dbf_field, 1005 - sqlite3_column_double 1006 - (stmt, i)); 1007 - else 1008 - gaiaSetNullValue (dbf_field); 1009 - break; 1010 - case 'C': 1011 - if (sqlite3_column_type (stmt, i) == SQLITE_TEXT) 1012 - { 1013 - strcpy (dummy, 1014 - (char *) sqlite3_column_text (stmt, 1015 - i)); 1016 - gaiaSetStrValue (dbf_field, dummy); 1017 - } 1018 - else 1019 - gaiaSetNullValue (dbf_field); 1020 - break; 1021 - }; 1022 - } 1023 - if (!(dbf_write->Geometry)) 1024 - { 1025 - gaiaFreeDbfList (dbf_write); 1026 - continue; 1027 - } 1028 - if (!gaiaWriteShpEntity (shp, dbf_write)) 1029 - { 1030 - wxMessageBox (wxT ("Shapefile write error"), 1031 - wxT ("spatialite-gui"), 1032 - wxOK | wxICON_INFORMATION, this); 1033 - } 1034 - gaiaFreeDbfList (dbf_write); 1035 - } 1036 - else 1037 - goto sql_error; 1038 - } 1039 - sqlite3_finalize (stmt); 1040 - gaiaFlushShpHeaders (shp); 1041 - gaiaFreeShapefile (shp); 1042 - msg.Printf (wxT ("Exported %d rows into Shapefile"), rows); 1043 - wxMessageBox (msg, wxT ("spatialite-gui"), wxOK | wxICON_INFORMATION, this); 1044 - return; 1045 - sql_error: 918 + shp = gaiaAllocShapefile(); 919 + strcpy(xpath, path.ToUTF8()); 920 + gaiaOpenShpWrite(shp, xpath, shape, dbf_list, "UTF-8", charset.ToUTF8()); 921 + if (!(shp->Valid)) 922 + goto no_file; 923 + while (1) 924 + { 925 + // Pass II - scrolling the result set to dump data into shapefile 926 + ret = sqlite3_step(stmt); 927 + if (ret == SQLITE_DONE) 928 + break; // end of result set 929 + if (ret == SQLITE_ROW) 930 + { 931 + rows++; 932 + geom = NULL; 933 + dbf_write = gaiaCloneDbfEntity(dbf_list); 934 + for (i = 0; i < n_cols; i++) 935 + { 936 + if (strcasecmp 937 + ((char *) xcolumn, 938 + (char *) sqlite3_column_name(stmt, i)) == 0) 939 + { 940 + // this one is the internal BLOB encoded GEOMETRY to be exported 941 + if (sqlite3_column_type(stmt, i) != SQLITE_BLOB) 942 + { 943 + // this one is a NULL Geometry 944 + dbf_write->Geometry = NULL; 945 + } else 946 + { 947 + blob_value = sqlite3_column_blob(stmt, i); 948 + len = sqlite3_column_bytes(stmt, i); 949 + dbf_write->Geometry = 950 + gaiaFromSpatiaLiteBlobWkb((unsigned char *) blob_value, 951 + len); 952 + } 953 + } 954 + strcpy(dummy, sqlite3_column_name(stmt, i)); 955 + dbf_field = GetDbfField(dbf_write, dummy); 956 + if (!dbf_field) 957 + continue; 958 + if (sqlite3_column_type(stmt, i) == SQLITE_NULL) 959 + { 960 + // handling NULL values 961 + gaiaSetNullValue(dbf_field); 962 + } else 963 + { 964 + switch (dbf_field->Type) 965 + { 966 + case 'N': 967 + if (sqlite3_column_type(stmt, i) == SQLITE_INTEGER) 968 + gaiaSetIntValue(dbf_field, 969 + sqlite3_column_int64(stmt, i)); 970 + else if (sqlite3_column_type(stmt, i) == SQLITE_FLOAT) 971 + gaiaSetDoubleValue(dbf_field, 972 + sqlite3_column_double(stmt, i)); 973 + else 974 + gaiaSetNullValue(dbf_field); 975 + break; 976 + case 'C': 977 + if (sqlite3_column_type(stmt, i) == SQLITE_TEXT) 978 + { 979 + strcpy(dummy, 980 + (char *) sqlite3_column_text(stmt, i)); 981 + gaiaSetStrValue(dbf_field, dummy); 982 + } else 983 + gaiaSetNullValue(dbf_field); 984 + break; 985 + }; 986 + } 987 + } 988 + if (!gaiaWriteShpEntity(shp, dbf_write)) 989 + { 990 + wxMessageBox(wxT("Shapefile write error"), wxT("spatialite-gui"), 991 + wxOK | wxICON_INFORMATION, this); 992 + } 993 + gaiaFreeDbfList(dbf_write); 994 + } else 995 + goto sql_error; 996 + } 997 + sqlite3_finalize(stmt); 998 + gaiaFlushShpHeaders(shp); 999 + gaiaFreeShapefile(shp); 1000 + sprintf(dummy, "Exported %d rows into Shapefile", rows); 1001 + msg = wxString::FromUTF8(dummy); 1002 + wxMessageBox(msg, wxT("spatialite-gui"), wxOK | wxICON_INFORMATION, this); 1003 + return; 1004 +sql_error: 1046 1005 // 1047 1006 // some SQL error occurred 1048 1007 // 1049 - sqlite3_finalize (stmt); 1050 - if (dbf_export_list); 1051 - gaiaFreeDbfList (dbf_export_list); 1052 - if (dbf_list); 1053 - gaiaFreeDbfList (dbf_list); 1054 - if (shp) 1055 - gaiaFreeShapefile (shp); 1056 - wxMessageBox (wxT ("dump shapefile error:") + 1057 - wxString::FromUTF8 (sqlite3_errmsg (SqliteHandle)), 1058 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, this); 1059 - return; 1060 - no_file: 1008 + sqlite3_finalize(stmt); 1009 + if (dbf_export_list); 1010 + gaiaFreeDbfList(dbf_export_list); 1011 + if (dbf_list); 1012 + gaiaFreeDbfList(dbf_list); 1013 + if (shp) 1014 + gaiaFreeShapefile(shp); 1015 + wxMessageBox(wxT("dump shapefile error:") + 1016 + wxString::FromUTF8(sqlite3_errmsg(SqliteHandle)), 1017 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 1018 + return; 1019 +no_file: 1061 1020 // 1062 1021 // shapefile can't be created/opened 1063 1022 // 1064 - if (dbf_export_list); 1065 - gaiaFreeDbfList (dbf_export_list); 1066 - if (dbf_list); 1067 - gaiaFreeDbfList (dbf_list); 1068 - if (shp) 1069 - gaiaFreeShapefile (shp); 1070 - wxMessageBox (wxT ("ERROR: unable to open '") + path + 1071 - wxT ("' for writing"), wxT ("spatialite-gui"), 1072 - wxOK | wxICON_ERROR, this); 1073 - return; 1074 - empty_result_set: 1023 + if (dbf_export_list); 1024 + gaiaFreeDbfList(dbf_export_list); 1025 + if (dbf_list); 1026 + gaiaFreeDbfList(dbf_list); 1027 + if (shp) 1028 + gaiaFreeShapefile(shp); 1029 + wxMessageBox(wxT("ERROR: unable to open '") + path + wxT("' for writing"), 1030 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 1031 + return; 1032 +empty_result_set: 1075 1033 // 1076 1034 // the result set is empty - nothing to do 1077 1035 // 1078 - sqlite3_finalize (stmt); 1079 - if (dbf_export_list); 1080 - gaiaFreeDbfList (dbf_export_list); 1081 - if (dbf_list); 1082 - gaiaFreeDbfList (dbf_list); 1083 - if (shp) 1084 - gaiaFreeShapefile (shp); 1085 - wxMessageBox (wxT 1086 - ("The SQL SELECT returned an empty result set\n... there is nothing to export ..."), 1087 - wxT ("spatialite-gui"), wxOK | wxICON_WARNING, this); 1036 + sqlite3_finalize(stmt); 1037 + if (dbf_export_list); 1038 + gaiaFreeDbfList(dbf_export_list); 1039 + if (dbf_list); 1040 + gaiaFreeDbfList(dbf_list); 1041 + if (shp) 1042 + gaiaFreeShapefile(shp); 1043 + wxMessageBox(wxT 1044 + ("The SQL SELECT returned an empty result set\n... there is nothing to export ..."), 1045 + wxT("spatialite-gui"), wxOK | wxICON_WARNING, this); 1088 1046 } 1089 1047 1090 -void 1091 -MyFrame::DumpTxtTab (wxString & path, wxString & table, wxString & charset) 1048 +void MyFrame::DumpTxtTab(wxString & path, wxString & table, wxString & charset) 1092 1049 { 1093 1050 // 1094 1051 // dumping a table as Txt/Tab 1095 1052 // 1096 - wxString sql; 1097 - sqlite3_stmt *stmt; 1098 - int ret; 1099 - int rows = 0; 1100 - int i; 1101 - int n_cols; 1102 - char xpath[1024]; 1103 - char dummy[65536]; 1104 - char outCs[128]; 1105 - char *pDummy; 1106 - wxString msg; 1107 - strcpy (outCs, charset.ToUTF8 ()); 1108 - strcpy (xpath, path.ToUTF8 ()); 1109 - FILE *out = fopen (xpath, "w"); 1110 - if (!out) 1111 - goto no_file; 1053 + wxString sql; 1054 + sqlite3_stmt *stmt; 1055 + int ret; 1056 + int rows = 0; 1057 + int i; 1058 + int n_cols; 1059 + char xpath[1024]; 1060 + char dummy[65536]; 1061 + char outCs[128]; 1062 + char *pDummy; 1063 + wxString msg; 1064 + strcpy(outCs, charset.ToUTF8()); 1065 + strcpy(xpath, path.ToUTF8()); 1066 + FILE *out = fopen(xpath, "w"); 1067 + if (!out) 1068 + goto no_file; 1112 1069 // 1113 1070 // preparing SQL statement 1114 1071 // 1115 - sql = wxT ("SELECT * FROM "); 1116 - sql += table; 1072 + sql = wxT("SELECT * FROM \""); 1073 + sql += table; 1074 + sql += wxT("\""); 1117 1075 // 1118 1076 // compiling SQL prepared statement 1119 1077 // 1120 - ret = 1121 - sqlite3_prepare_v2 (SqliteHandle, sql.ToUTF8 (), sql.Len (), &stmt, 1122 - NULL); 1123 - if (ret != SQLITE_OK) 1124 - goto sql_error; 1125 - rows = 0; 1126 - while (1) 1127 - { 1128 - ret = sqlite3_step (stmt); 1129 - if (ret == SQLITE_DONE) 1130 - break; // end of result set 1131 - if (ret == SQLITE_ROW) 1132 - { 1133 - n_cols = sqlite3_column_count (stmt); 1134 - if (rows == 0) 1135 - { 1136 - // outputting the column titles 1137 - for (i = 0; i < n_cols; i++) 1138 - { 1139 - if (i == 0) 1140 - fprintf (out, "%s", 1141 - sqlite3_column_name (stmt, i)); 1142 - else 1143 - fprintf (out, "\t%s", 1144 - sqlite3_column_name (stmt, i)); 1145 - } 1146 - fprintf (out, "\n"); 1147 - } 1148 - rows++; 1149 - for (i = 0; i < n_cols; i++) 1150 - { 1151 - if (i > 0) 1152 - fprintf (out, "\t"); 1153 - if (sqlite3_column_type (stmt, i) == SQLITE_INTEGER) 1154 - fprintf (out, "%d", sqlite3_column_int (stmt, i)); 1155 - else if (sqlite3_column_type (stmt, i) == SQLITE_FLOAT) 1156 - fprintf (out, "%1.6lf", 1157 - sqlite3_column_double (stmt, i)); 1158 - else if (sqlite3_column_type (stmt, i) == SQLITE_TEXT) 1159 - { 1160 - strcpy (dummy, 1161 - (char *) sqlite3_column_text (stmt, i)); 1162 - CleanTxtTab (dummy); 1163 - pDummy = dummy; 1164 - if (!gaiaConvertCharset (&pDummy, "UTF-8", outCs)) 1165 - goto encoding_error; 1166 - fprintf (out, "%s", dummy); 1167 - } 1168 - } 1169 - fprintf (out, "\n"); 1170 - } 1171 - else 1172 - goto sql_error; 1173 - } 1174 - sqlite3_finalize (stmt); 1175 - fclose (out); 1176 - msg.Printf (wxT ("Exported %d rows into Txt/Tab file"), rows); 1177 - wxMessageBox (msg, wxT ("spatialite-gui"), wxOK | wxICON_INFORMATION, this); 1178 - return; 1179 - sql_error: 1078 + ret = sqlite3_prepare_v2(SqliteHandle, sql.ToUTF8(), sql.Len(), &stmt, NULL); 1079 + if (ret != SQLITE_OK) 1080 + goto sql_error; 1081 + rows = 0; 1082 + while (1) 1083 + { 1084 + ret = sqlite3_step(stmt); 1085 + if (ret == SQLITE_DONE) 1086 + break; // end of result set 1087 + if (ret == SQLITE_ROW) 1088 + { 1089 + n_cols = sqlite3_column_count(stmt); 1090 + if (rows == 0) 1091 + { 1092 + // outputting the column titles 1093 + for (i = 0; i < n_cols; i++) 1094 + { 1095 + if (i == 0) 1096 + fprintf(out, "%s", sqlite3_column_name(stmt, i)); 1097 + else 1098 + fprintf(out, "\t%s", sqlite3_column_name(stmt, i)); 1099 + } 1100 + fprintf(out, "\n"); 1101 + } 1102 + rows++; 1103 + for (i = 0; i < n_cols; i++) 1104 + { 1105 + if (i > 0) 1106 + fprintf(out, "\t"); 1107 + if (sqlite3_column_type(stmt, i) == SQLITE_INTEGER) 1108 + fprintf(out, "%d", sqlite3_column_int(stmt, i)); 1109 + else if (sqlite3_column_type(stmt, i) == SQLITE_FLOAT) 1110 + fprintf(out, "%1.6lf", sqlite3_column_double(stmt, i)); 1111 + else if (sqlite3_column_type(stmt, i) == SQLITE_TEXT) 1112 + { 1113 + strcpy(dummy, (char *) sqlite3_column_text(stmt, i)); 1114 + CleanTxtTab(dummy); 1115 + pDummy = dummy; 1116 + if (!gaiaConvertCharset(&pDummy, "UTF-8", outCs)) 1117 + goto encoding_error; 1118 + fprintf(out, "%s", dummy); 1119 + } 1120 + } 1121 + fprintf(out, "\n"); 1122 + } else 1123 + goto sql_error; 1124 + } 1125 + sqlite3_finalize(stmt); 1126 + fclose(out); 1127 + sprintf(dummy, "Exported %d rows into Txt/Tab file", rows); 1128 + msg = wxString::FromUTF8(dummy); 1129 + wxMessageBox(msg, wxT("spatialite-gui"), wxOK | wxICON_INFORMATION, this); 1130 + return; 1131 +sql_error: 1180 1132 // 1181 1133 // some SQL error occurred 1182 1134 // 1183 - sqlite3_finalize (stmt); 1184 - wxMessageBox (wxT ("dump Txt/Tab error:") + 1185 - wxString::FromUTF8 (sqlite3_errmsg (SqliteHandle)), 1186 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, this); 1187 - if (out) 1188 - fclose (out); 1189 - return; 1190 - encoding_error: 1135 + sqlite3_finalize(stmt); 1136 + wxMessageBox(wxT("dump Txt/Tab error:") + 1137 + wxString::FromUTF8(sqlite3_errmsg(SqliteHandle)), 1138 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 1139 + if (out) 1140 + fclose(out); 1141 + return; 1142 +encoding_error: 1191 1143 // 1192 1144 // some CHARSET converion occurred 1193 1145 // 1194 - sqlite3_finalize (stmt); 1195 - wxMessageBox (wxT ("dump Txt/Tab: charset conversion reported an error"), 1196 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, this); 1197 - if (out) 1198 - fclose (out); 1199 - return; 1200 - no_file: 1146 + sqlite3_finalize(stmt); 1147 + wxMessageBox(wxT("dump Txt/Tab: charset conversion reported an error"), 1148 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 1149 + if (out) 1150 + fclose(out); 1151 + return; 1152 +no_file: 1201 1153 // 1202 1154 // output file can't be created/opened 1203 1155 // 1204 - wxMessageBox (wxT ("ERROR: unable to open '") + path + 1205 - wxT ("' for writing"), wxT ("spatialite-gui"), 1206 - wxOK | wxICON_ERROR, this); 1207 - return; 1156 + wxMessageBox(wxT("ERROR: unable to open '") + path + wxT("' for writing"), 1157 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 1158 + return; 1208 1159 } 1209 1160 1210 -void 1211 -MyFrame::DumpCsv (wxString & path, wxString & table, wxString & charset) 1161 +void MyFrame::DumpCsv(wxString & path, wxString & table, wxString & charset) 1212 1162 { 1213 1163 // 1214 1164 // dumping a table as CSV 1215 1165 // 1216 - wxString sql; 1217 - sqlite3_stmt *stmt; 1218 - int ret; 1219 - int rows = 0; 1220 - int i; 1221 - int n_cols; 1222 - char xpath[1024]; 1223 - char dummy[65536]; 1224 - char outCs[128]; 1225 - char *pDummy; 1226 - wxString msg; 1227 - strcpy (outCs, charset.ToUTF8 ()); 1228 - strcpy (xpath, path.ToUTF8 ()); 1229 - FILE *out = fopen (xpath, "w"); 1230 - if (!out) 1231 - goto no_file; 1166 + wxString sql; 1167 + sqlite3_stmt *stmt; 1168 + int ret; 1169 + int rows = 0; 1170 + int i; 1171 + int n_cols; 1172 + char xpath[1024]; 1173 + char dummy[65536]; 1174 + char outCs[128]; 1175 + char *pDummy; 1176 + wxString msg; 1177 + strcpy(outCs, charset.ToUTF8()); 1178 + strcpy(xpath, path.ToUTF8()); 1179 + FILE *out = fopen(xpath, "w"); 1180 + if (!out) 1181 + goto no_file; 1232 1182 // 1233 1183 // preparing SQL statement 1234 1184 // 1235 - sql = wxT ("SELECT * FROM "); 1236 - sql += table; 1185 + sql = wxT("SELECT * FROM \""); 1186 + sql += table; 1187 + sql += wxT("\""); 1237 1188 // 1238 1189 // compiling SQL prepared statement 1239 1190 // 1240 - ret = 1241 - sqlite3_prepare_v2 (SqliteHandle, sql.ToUTF8 (), sql.Len (), &stmt, 1242 - NULL); 1243 - if (ret != SQLITE_OK) 1244 - goto sql_error; 1245 - rows = 0; 1246 - while (1) 1247 - { 1248 - ret = sqlite3_step (stmt); 1249 - if (ret == SQLITE_DONE) 1250 - break; // end of result set 1251 - if (ret == SQLITE_ROW) 1252 - { 1253 - n_cols = sqlite3_column_count (stmt); 1254 - if (rows == 0) 1255 - { 1256 - // outputting the column titles 1257 - for (i = 0; i < n_cols; i++) 1258 - { 1259 - if (i == 0) 1260 - { 1261 - strcpy (dummy, sqlite3_column_name (stmt, i)); 1262 - CleanCsv (dummy); 1263 - fprintf (out, "%s", dummy); 1264 - } 1265 - else 1266 - { 1267 - strcpy (dummy, sqlite3_column_name (stmt, i)); 1268 - CleanCsv (dummy); 1269 - fprintf (out, ",%s", dummy); 1270 - } 1271 - } 1272 - fprintf (out, "\n"); 1273 - } 1274 - rows++; 1275 - for (i = 0; i < n_cols; i++) 1276 - { 1277 - if (i > 0) 1278 - fprintf (out, ","); 1279 - if (sqlite3_column_type (stmt, i) == SQLITE_INTEGER) 1280 - fprintf (out, "%d", sqlite3_column_int (stmt, i)); 1281 - else if (sqlite3_column_type (stmt, i) == SQLITE_FLOAT) 1282 - fprintf (out, "%1.6lf", 1283 - sqlite3_column_double (stmt, i)); 1284 - else if (sqlite3_column_type (stmt, i) == SQLITE_TEXT) 1285 - { 1286 - strcpy (dummy, 1287 - (char *) sqlite3_column_text (stmt, i)); 1288 - CleanCsv (dummy); 1289 - pDummy = dummy; 1290 - if (!gaiaConvertCharset 1291 - (&pDummy, (const char *) "UTF-8", outCs)) 1292 - goto encoding_error; 1293 - fprintf (out, "%s", dummy); 1294 - } 1295 - } 1296 - fprintf (out, "\n"); 1297 - } 1298 - else 1299 - goto sql_error; 1300 - } 1301 - sqlite3_finalize (stmt); 1302 - fclose (out); 1303 - msg.Printf (wxT ("Exported %d rows into CSV file"), rows); 1304 - wxMessageBox (msg, wxT ("spatialite-gui"), wxOK | wxICON_INFORMATION, this); 1305 - return; 1306 - sql_error: 1191 + ret = sqlite3_prepare_v2(SqliteHandle, sql.ToUTF8(), sql.Len(), &stmt, NULL); 1192 + if (ret != SQLITE_OK) 1193 + goto sql_error; 1194 + rows = 0; 1195 + while (1) 1196 + { 1197 + ret = sqlite3_step(stmt); 1198 + if (ret == SQLITE_DONE) 1199 + break; // end of result set 1200 + if (ret == SQLITE_ROW) 1201 + { 1202 + n_cols = sqlite3_column_count(stmt); 1203 + if (rows == 0) 1204 + { 1205 + // outputting the column titles 1206 + for (i = 0; i < n_cols; i++) 1207 + { 1208 + if (i == 0) 1209 + { 1210 + strcpy(dummy, sqlite3_column_name(stmt, i)); 1211 + CleanCsv(dummy); 1212 + fprintf(out, "%s", dummy); 1213 + } else 1214 + { 1215 + strcpy(dummy, sqlite3_column_name(stmt, i)); 1216 + CleanCsv(dummy); 1217 + fprintf(out, ",%s", dummy); 1218 + } 1219 + } 1220 + fprintf(out, "\n"); 1221 + } 1222 + rows++; 1223 + for (i = 0; i < n_cols; i++) 1224 + { 1225 + if (i > 0) 1226 + fprintf(out, ","); 1227 + if (sqlite3_column_type(stmt, i) == SQLITE_INTEGER) 1228 + fprintf(out, "%d", sqlite3_column_int(stmt, i)); 1229 + else if (sqlite3_column_type(stmt, i) == SQLITE_FLOAT) 1230 + fprintf(out, "%1.6lf", sqlite3_column_double(stmt, i)); 1231 + else if (sqlite3_column_type(stmt, i) == SQLITE_TEXT) 1232 + { 1233 + strcpy(dummy, (char *) sqlite3_column_text(stmt, i)); 1234 + CleanCsv(dummy); 1235 + pDummy = dummy; 1236 + if (!gaiaConvertCharset 1237 + (&pDummy, (const char *) "UTF-8", outCs)) 1238 + goto encoding_error; 1239 + fprintf(out, "%s", dummy); 1240 + } 1241 + } 1242 + fprintf(out, "\n"); 1243 + } else 1244 + goto sql_error; 1245 + } 1246 + sqlite3_finalize(stmt); 1247 + fclose(out); 1248 + sprintf(dummy, "Exported %d rows into CSV file", rows); 1249 + msg = wxString::FromUTF8(dummy); 1250 + wxMessageBox(msg, wxT("spatialite-gui"), wxOK | wxICON_INFORMATION, this); 1251 + return; 1252 +sql_error: 1307 1253 // 1308 1254 // some SQL error occurred 1309 1255 // 1310 - sqlite3_finalize (stmt); 1311 - wxMessageBox (wxT ("dump CSV error:") + 1312 - wxString::FromUTF8 (sqlite3_errmsg (SqliteHandle)), 1313 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, this); 1314 - if (out) 1315 - fclose (out); 1316 - return; 1317 - encoding_error: 1256 + sqlite3_finalize(stmt); 1257 + wxMessageBox(wxT("dump CSV error:") + 1258 + wxString::FromUTF8(sqlite3_errmsg(SqliteHandle)), 1259 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 1260 + if (out) 1261 + fclose(out); 1262 + return; 1263 +encoding_error: 1318 1264 // 1319 1265 // some CHARSET converion occurred 1320 1266 // 1321 - sqlite3_finalize (stmt); 1322 - wxMessageBox (wxT ("dump CSV: charset conversion reported an error"), 1323 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, this); 1324 - if (out) 1325 - fclose (out); 1326 - return; 1327 - no_file: 1267 + sqlite3_finalize(stmt); 1268 + wxMessageBox(wxT("dump CSV: charset conversion reported an error"), 1269 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 1270 + if (out) 1271 + fclose(out); 1272 + return; 1273 +no_file: 1328 1274 // 1329 1275 // output file can't be created/opened 1330 1276 // 1331 - wxMessageBox (wxT ("ERROR: unable to open '") + path + 1332 - wxT ("' for writing"), wxT ("spatialite-gui"), 1333 - wxOK | wxICON_ERROR, this); 1334 - return; 1277 + wxMessageBox(wxT("ERROR: unable to open '") + path + wxT("' for writing"), 1278 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 1279 + return; 1335 1280 } 1336 1281 1337 -void 1338 -MyFrame::DumpHtml (wxString & path, wxString & table, wxString & charset) 1282 +void MyFrame::DumpHtml(wxString & path, wxString & table, wxString & charset) 1339 1283 { 1340 1284 // 1341 1285 // dumping a table as HTML 1342 1286 // 1343 - wxString sql; 1344 - sqlite3_stmt *stmt; 1345 - int ret; 1346 - int rows = 0; 1347 - int i; 1348 - int n_cols; 1349 - char xpath[1024]; 1350 - char xtable[1024]; 1351 - char dummy[65536]; 1352 - char outCs[128]; 1353 - char *pDummy; 1354 - wxString msg; 1355 - strcpy (outCs, charset.ToUTF8 ()); 1356 - strcpy (xpath, path.ToUTF8 ()); 1357 - strcpy (xtable, table.ToUTF8 ()); 1358 - FILE *out = fopen (xpath, "w"); 1359 - if (!out) 1360 - goto no_file; 1361 - fprintf (out, 1362 - "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"); 1363 - fprintf (out, "<html>\n\t<head>\n"); 1364 - fprintf (out, 1365 - "\t\t<meta http-equiv=\"content-type\" content=\"text/html; charset=%s\">\n", 1366 - outCs); 1367 - fprintf (out, "\t\t<title>\nTable '%s': from SQLite/SpatiaLite DB '%s'\n", 1368 - xtable, xpath); 1369 - fprintf (out, "\t\t</title>\n"); 1370 - fprintf (out, "\t\t<style type=\"text/css\">\n"); 1371 - fprintf (out, "table { border: 1px; }\n"); 1372 - fprintf (out, "tr.t0 th { background-color: #c9c9df; }\n"); 1373 - fprintf (out, "tr.d0 td { background-color: #e0efe0; }\n"); 1374 - fprintf (out, "tr.d1 td { background-color: #d0d0df; }\n"); 1375 - fprintf (out, "\t\t</style>\n\t</head>\n\t<body>\n\t\t<table>\n"); 1287 + wxString sql; 1288 + sqlite3_stmt *stmt; 1289 + int ret; 1290 + int rows = 0; 1291 + int i; 1292 + int n_cols; 1293 + char xpath[1024]; 1294 + char xtable[1024]; 1295 + char dummy[65536]; 1296 + char outCs[128]; 1297 + char *pDummy; 1298 + wxString msg; 1299 + strcpy(outCs, charset.ToUTF8()); 1300 + strcpy(xpath, path.ToUTF8()); 1301 + strcpy(xtable, table.ToUTF8()); 1302 + FILE *out = fopen(xpath, "w"); 1303 + if (!out) 1304 + goto no_file; 1305 + fprintf(out, 1306 + "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"); 1307 + fprintf(out, "<html>\n\t<head>\n"); 1308 + fprintf(out, 1309 + "\t\t<meta http-equiv=\"content-type\" content=\"text/html; charset=%s\">\n", 1310 + outCs); 1311 + fprintf(out, "\t\t<title>\nTable '%s': from SQLite/SpatiaLite DB '%s'\n", 1312 + xtable, xpath); 1313 + fprintf(out, "\t\t</title>\n"); 1314 + fprintf(out, "\t\t<style type=\"text/css\">\n"); 1315 + fprintf(out, "table { border: 1px; }\n"); 1316 + fprintf(out, "tr.t0 th { background-color: #c9c9df; }\n"); 1317 + fprintf(out, "tr.d0 td { background-color: #e0efe0; }\n"); 1318 + fprintf(out, "tr.d1 td { background-color: #d0d0df; }\n"); 1319 + fprintf(out, "\t\t</style>\n\t</head>\n\t<body>\n\t\t<table>\n"); 1376 1320 // 1377 1321 // preparing SQL statement 1378 1322 // 1379 - sql = wxT ("SELECT * FROM "); 1380 - sql += table; 1323 + sql = wxT("SELECT * FROM \""); 1324 + sql += table; 1325 + sql += wxT("\""); 1381 1326 // 1382 1327 // compiling SQL prepared statement 1383 1328 // 1384 - ret = 1385 - sqlite3_prepare_v2 (SqliteHandle, sql.ToUTF8 (), sql.Len (), &stmt, 1386 - NULL); 1387 - if (ret != SQLITE_OK) 1388 - goto sql_error; 1389 - rows = 0; 1390 - while (1) 1391 - { 1392 - ret = sqlite3_step (stmt); 1393 - if (ret == SQLITE_DONE) 1394 - break; // end of result set 1395 - if (ret == SQLITE_ROW) 1396 - { 1397 - n_cols = sqlite3_column_count (stmt); 1398 - if (rows == 0) 1399 - { 1400 - // outputting the column titles 1401 - fprintf (out, "\t\t\t<tr class=\"t0\">\n"); 1402 - for (i = 0; i < n_cols; i++) 1403 - { 1404 - strcpy (dummy, sqlite3_column_name (stmt, i)); 1405 - CleanHtml (dummy); 1406 - fprintf (out, "\t\t\t\t<th>%s</th>\n", dummy); 1407 - } 1408 - fprintf (out, "\t\t\t</tr>\n"); 1409 - } 1410 - rows++; 1411 - fprintf (out, "\t\t\t<tr class=\"%s\">\n", 1412 - (rows % 2) ? "d0" : "d1"); 1413 - for (i = 0; i < n_cols; i++) 1414 - { 1415 - if (sqlite3_column_type (stmt, i) == SQLITE_INTEGER) 1416 - fprintf (out, 1417 - "\t\t\t\t<td align=\"right\">%d</td>\n", 1418 - sqlite3_column_int (stmt, i)); 1419 - else if (sqlite3_column_type (stmt, i) == SQLITE_FLOAT) 1420 - fprintf (out, 1421 - "\t\t\t\t<td align=\"right\">%1.6lf</td>\n", 1422 - sqlite3_column_double (stmt, i)); 1423 - else if (sqlite3_column_type (stmt, i) == SQLITE_TEXT) 1424 - { 1425 - strcpy (dummy, 1426 - (char *) sqlite3_column_text (stmt, i)); 1427 - CleanHtml (dummy); 1428 - pDummy = dummy; 1429 - if (!gaiaConvertCharset 1430 - (&pDummy, (const char *) "UTF-8", outCs)) 1431 - goto encoding_error; 1432 - fprintf (out, "\t\t\t\t<td>%s</td>\n", dummy); 1433 - } 1434 - } 1435 - fprintf (out, "\t\t\t</tr>\n"); 1436 - } 1437 - else 1438 - goto sql_error; 1439 - } 1440 - sqlite3_finalize (stmt); 1441 - fprintf (out, "\t\t</table>\n\t</body>\n</html>\n"); 1442 - fclose (out); 1443 - msg.Printf (wxT ("Exported %d rows into HTML file"), rows); 1444 - wxMessageBox (msg, wxT ("spatialite-gui"), wxOK | wxICON_INFORMATION, this); 1445 - return; 1446 - sql_error: 1329 + ret = sqlite3_prepare_v2(SqliteHandle, sql.ToUTF8(), sql.Len(), &stmt, NULL); 1330 + if (ret != SQLITE_OK) 1331 + goto sql_error; 1332 + rows = 0; 1333 + while (1) 1334 + { 1335 + ret = sqlite3_step(stmt); 1336 + if (ret == SQLITE_DONE) 1337 + break; // end of result set 1338 + if (ret == SQLITE_ROW) 1339 + { 1340 + n_cols = sqlite3_column_count(stmt); 1341 + if (rows == 0) 1342 + { 1343 + // outputting the column titles 1344 + fprintf(out, "\t\t\t<tr class=\"t0\">\n"); 1345 + for (i = 0; i < n_cols; i++) 1346 + { 1347 + strcpy(dummy, sqlite3_column_name(stmt, i)); 1348 + CleanHtml(dummy); 1349 + fprintf(out, "\t\t\t\t<th>%s</th>\n", dummy); 1350 + } 1351 + fprintf(out, "\t\t\t</tr>\n"); 1352 + } 1353 + rows++; 1354 + fprintf(out, "\t\t\t<tr class=\"%s\">\n", (rows % 2) ? "d0" : "d1"); 1355 + for (i = 0; i < n_cols; i++) 1356 + { 1357 + if (sqlite3_column_type(stmt, i) == SQLITE_INTEGER) 1358 + fprintf(out, "\t\t\t\t<td align=\"right\">%d</td>\n", 1359 + sqlite3_column_int(stmt, i)); 1360 + else if (sqlite3_column_type(stmt, i) == SQLITE_FLOAT) 1361 + fprintf(out, "\t\t\t\t<td align=\"right\">%1.6lf</td>\n", 1362 + sqlite3_column_double(stmt, i)); 1363 + else if (sqlite3_column_type(stmt, i) == SQLITE_TEXT) 1364 + { 1365 + strcpy(dummy, (char *) sqlite3_column_text(stmt, i)); 1366 + CleanHtml(dummy); 1367 + pDummy = dummy; 1368 + if (!gaiaConvertCharset 1369 + (&pDummy, (const char *) "UTF-8", outCs)) 1370 + goto encoding_error; 1371 + fprintf(out, "\t\t\t\t<td>%s</td>\n", dummy); 1372 + } 1373 + } 1374 + fprintf(out, "\t\t\t</tr>\n"); 1375 + } else 1376 + goto sql_error; 1377 + } 1378 + sqlite3_finalize(stmt); 1379 + fprintf(out, "\t\t</table>\n\t</body>\n</html>\n"); 1380 + fclose(out); 1381 + sprintf(dummy, "Exported %d rows into HTML file", rows); 1382 + msg = wxString::FromUTF8(dummy); 1383 + wxMessageBox(msg, wxT("spatialite-gui"), wxOK | wxICON_INFORMATION, this); 1384 + return; 1385 +sql_error: 1447 1386 // 1448 1387 // some SQL error occurred 1449 1388 // 1450 - sqlite3_finalize (stmt); 1451 - wxMessageBox (wxT ("dump HTML error:") + 1452 - wxString::FromUTF8 (sqlite3_errmsg (SqliteHandle)), 1453 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, this); 1454 - if (out) 1455 - fclose (out); 1456 - return; 1457 - encoding_error: 1389 + sqlite3_finalize(stmt); 1390 + wxMessageBox(wxT("dump HTML error:") + 1391 + wxString::FromUTF8(sqlite3_errmsg(SqliteHandle)), 1392 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 1393 + if (out) 1394 + fclose(out); 1395 + return; 1396 +encoding_error: 1458 1397 // 1459 -// some CHARSET converion occurred 1398 +// some CHARSET convertion occurred 1460 1399 // 1461 - sqlite3_finalize (stmt); 1462 - wxMessageBox (wxT ("dump HTML: charset conversion reported an error"), 1463 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, this); 1464 - if (out) 1465 - fclose (out); 1466 - return; 1467 - no_file: 1400 + sqlite3_finalize(stmt); 1401 + wxMessageBox(wxT("dump HTML: charset conversion reported an error"), 1402 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 1403 + if (out) 1404 + fclose(out); 1405 + return; 1406 +no_file: 1468 1407 // 1469 1408 // output file can't be created/opened 1470 1409 // 1471 - wxMessageBox (wxT ("ERROR: unable to open '") + path + 1472 - wxT ("' for writing"), wxT ("spatialite-gui"), 1473 - wxOK | wxICON_ERROR, this); 1474 - return; 1410 + wxMessageBox(wxT("ERROR: unable to open '") + path + wxT("' for writing"), 1411 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 1412 + return; 1475 1413 }
Changes to TableTree.cpp.
1 1 /* 2 2 / TableTree.cpp 3 3 / tree control to show tables, columns, indices and triggers 4 4 / 5 -/ version 1.1, 2008 September 13 5 +/ version 1.2, 2008 October 9 6 6 / 7 7 / Author: Sandro Furieri a-furieri@lqt.it 8 8 / 9 9 / Copyright (C) 2008 Alessandro Furieri 10 10 / 11 11 / This program is free software: you can redistribute it and/or modify 12 12 / it under the terms of the GNU General Public License as published by ................................................................................ 39 39 #include "icons/pkey.xpm" 40 40 #include "icons/column.xpm" 41 41 #include "icons/index.xpm" 42 42 #include "icons/trigger.xpm" 43 43 #include "icons/geometry.xpm" 44 44 #include "icons/spatialidx.xpm" 45 45 #include "icons/mbrcache.xpm" 46 +#include "icons/kill_spindex.xpm" 47 +#include "icons/dumpshp.xpm" 46 48 47 -MyTableTree::MyTableTree (MyFrame * parent, wxWindowID id):wxTreeCtrl (parent, 48 - id) 49 +MyTableTree::MyTableTree(MyFrame * parent, wxWindowID id):wxTreeCtrl(parent, id) 49 50 { 50 51 // 51 52 // constructor: TREE control to show DB objects 52 53 // 53 - MainFrame = parent; 54 - Root = AddRoot (wxT ("no current DB")); 54 + MainFrame = parent; 55 + Root = AddRoot(wxT("no current DB")); 55 56 // setting up icons 56 - Images = new wxImageList (16, 16, true); 57 - wxIcon icons[12]; 58 - icons[0] = wxIcon (db_xpm); 59 - icons[1] = wxIcon (table_xpm); 60 - icons[2] = wxIcon (pkey_xpm); 61 - icons[3] = wxIcon (column_xpm); 62 - icons[4] = wxIcon (index_xpm); 63 - icons[5] = wxIcon (trigger_xpm); 64 - icons[6] = wxIcon (geometry_xpm); 65 - icons[7] = wxIcon (spatialidx_xpm); 66 - icons[8] = wxIcon (vtable_xpm); 67 - icons[9] = wxIcon (view_xpm); 68 - icons[10] = wxIcon (geotable_xpm); 69 - icons[11] = wxIcon (mbrcache_xpm); 70 - Images->Add (icons[0]); 71 - Images->Add (icons[1]); 72 - Images->Add (icons[2]); 73 - Images->Add (icons[3]); 74 - Images->Add (icons[4]); 75 - Images->Add (icons[5]); 76 - Images->Add (icons[6]); 77 - Images->Add (icons[7]); 78 - Images->Add (icons[8]); 79 - Images->Add (icons[9]); 80 - Images->Add (icons[10]); 81 - Images->Add (icons[11]); 82 - SetImageList (Images); 83 - SetItemImage (Root, 0); 84 -// setting up event handlers 85 - Connect (wxID_ANY, wxEVT_COMMAND_TREE_SEL_CHANGED, 86 - (wxObjectEventFunction) & MyTableTree::OnSelChanged); 87 - Connect (wxID_ANY, wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK, 88 - (wxObjectEventFunction) & MyTableTree::OnRightClick); 89 - Connect (Tree_NewTable, wxEVT_COMMAND_MENU_SELECTED, 90 - (wxObjectEventFunction) & MyTableTree::OnCmdNewTable); 91 - Connect (Tree_NewView, wxEVT_COMMAND_MENU_SELECTED, 92 - (wxObjectEventFunction) & MyTableTree::OnCmdNewView); 93 - Connect (Tree_NewIndex, wxEVT_COMMAND_MENU_SELECTED, 94 - (wxObjectEventFunction) & MyTableTree::OnCmdNewIndex); 95 - Connect (Tree_NewTrigger, wxEVT_COMMAND_MENU_SELECTED, 96 - (wxObjectEventFunction) & MyTableTree::OnCmdNewTrigger); 97 - Connect (Tree_NewColumn, wxEVT_COMMAND_MENU_SELECTED, 98 - (wxObjectEventFunction) & MyTableTree::OnCmdNewColumn); 99 - Connect (Tree_Show, wxEVT_COMMAND_MENU_SELECTED, 100 - (wxObjectEventFunction) & MyTableTree::OnCmdShow); 101 - Connect (Tree_Drop, wxEVT_COMMAND_MENU_SELECTED, 102 - (wxObjectEventFunction) & MyTableTree::OnCmdDrop); 103 - Connect (Tree_Rename, wxEVT_COMMAND_MENU_SELECTED, 104 - (wxObjectEventFunction) & MyTableTree::OnCmdRename); 105 - Connect (Tree_Select, wxEVT_COMMAND_MENU_SELECTED, 106 - (wxObjectEventFunction) & MyTableTree::OnCmdSelect); 107 - Connect (Tree_Refresh, wxEVT_COMMAND_MENU_SELECTED, 108 - (wxObjectEventFunction) & MyTableTree::OnCmdRefresh); 109 - Connect (Tree_Recover, wxEVT_COMMAND_MENU_SELECTED, 110 - (wxObjectEventFunction) & MyTableTree::OnCmdRecover); 111 - Connect (Tree_ShowSql, wxEVT_COMMAND_MENU_SELECTED, 112 - (wxObjectEventFunction) & MyTableTree::OnCmdShowSql); 113 - Connect (Tree_SpatialIndex, wxEVT_COMMAND_MENU_SELECTED, 114 - (wxObjectEventFunction) & MyTableTree::OnCmdSpatialIndex); 115 - Connect (Tree_MbrCache, wxEVT_COMMAND_MENU_SELECTED, 116 - (wxObjectEventFunction) & MyTableTree::OnCmdMbrCache); 117 - Connect (Tree_CheckGeometry, wxEVT_COMMAND_MENU_SELECTED, 118 - (wxObjectEventFunction) & MyTableTree::OnCmdCheckGeometry); 119 - Connect (Tree_SetSrid, wxEVT_COMMAND_MENU_SELECTED, 120 - (wxObjectEventFunction) & MyTableTree::OnCmdSetSrid); 121 - Connect (Tree_DumpShp, wxEVT_COMMAND_MENU_SELECTED, 122 - (wxObjectEventFunction) & MyTableTree::OnCmdDumpShp); 123 - Connect (Tree_DumpTxtTab, wxEVT_COMMAND_MENU_SELECTED, 124 - (wxObjectEventFunction) & MyTableTree::OnCmdDumpTxtTab); 125 - Connect (Tree_DumpCsv, wxEVT_COMMAND_MENU_SELECTED, 126 - (wxObjectEventFunction) & MyTableTree::OnCmdDumpCsv); 127 - Connect (Tree_DumpHtml, wxEVT_COMMAND_MENU_SELECTED, 128 - (wxObjectEventFunction) & MyTableTree::OnCmdDumpHtml); 129 - Connect (Tree_Edit, wxEVT_COMMAND_MENU_SELECTED, 130 - (wxObjectEventFunction) & MyTableTree::OnCmdEdit); 131 -} 132 - 133 -void 134 -MyTableTree::AddTable (wxString & tableName, bool virtualTable) 57 + Images = new wxImageList(16, 16, true); 58 + wxIcon icons[12]; 59 + icons[0] = wxIcon(db_xpm); 60 + icons[1] = wxIcon(table_xpm); 61 + icons[2] = wxIcon(pkey_xpm); 62 + icons[3] = wxIcon(column_xpm); 63 + icons[4] = wxIcon(index_xpm); 64 + icons[5] = wxIcon(trigger_xpm); 65 + icons[6] = wxIcon(geometry_xpm); 66 + icons[7] = wxIcon(spatialidx_xpm); 67 + icons[8] = wxIcon(vtable_xpm); 68 + icons[9] = wxIcon(view_xpm); 69 + icons[10] = wxIcon(geotable_xpm); 70 + icons[11] = wxIcon(mbrcache_xpm); 71 + Images->Add(icons[0]); 72 + Images->Add(icons[1]); 73 + Images->Add(icons[2]); 74 + Images->Add(icons[3]); 75 + Images->Add(icons[4]); 76 + Images->Add(icons[5]); 77 + Images->Add(icons[6]); 78 + Images->Add(icons[7]); 79 + Images->Add(icons[8]); 80 + Images->Add(icons[9]); 81 + Images->Add(icons[10]); 82 + Images->Add(icons[11]); 83 + SetImageList(Images); 84 + SetItemImage(Root, 0); 85 +// setting up event handlers 86 + Connect(wxID_ANY, wxEVT_COMMAND_TREE_SEL_CHANGED, 87 + (wxObjectEventFunction) & MyTableTree::OnSelChanged); 88 + Connect(wxID_ANY, wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK, 89 + (wxObjectEventFunction) & MyTableTree::OnRightClick); 90 + Connect(Tree_NewTable, wxEVT_COMMAND_MENU_SELECTED, 91 + (wxObjectEventFunction) & MyTableTree::OnCmdNewTable); 92 + Connect(Tree_NewView, wxEVT_COMMAND_MENU_SELECTED, 93 + (wxObjectEventFunction) & MyTableTree::OnCmdNewView); 94 + Connect(Tree_NewIndex, wxEVT_COMMAND_MENU_SELECTED, 95 + (wxObjectEventFunction) & MyTableTree::OnCmdNewIndex); 96 + Connect(Tree_NewTrigger, wxEVT_COMMAND_MENU_SELECTED, 97 + (wxObjectEventFunction) & MyTableTree::OnCmdNewTrigger); 98 + Connect(Tree_NewColumn, wxEVT_COMMAND_MENU_SELECTED, 99 + (wxObjectEventFunction) & MyTableTree::OnCmdNewColumn); 100 + Connect(Tree_Show, wxEVT_COMMAND_MENU_SELECTED, 101 + (wxObjectEventFunction) & MyTableTree::OnCmdShow); 102 + Connect(Tree_Drop, wxEVT_COMMAND_MENU_SELECTED, 103 + (wxObjectEventFunction) & MyTableTree::OnCmdDrop); 104 + Connect(Tree_Rename, wxEVT_COMMAND_MENU_SELECTED, 105 + (wxObjectEventFunction) & MyTableTree::OnCmdRename); 106 + Connect(Tree_Select, wxEVT_COMMAND_MENU_SELECTED, 107 + (wxObjectEventFunction) & MyTableTree::OnCmdSelect); 108 + Connect(Tree_Refresh, wxEVT_COMMAND_MENU_SELECTED, 109 + (wxObjectEventFunction) & MyTableTree::OnCmdRefresh); 110 + Connect(Tree_Recover, wxEVT_COMMAND_MENU_SELECTED, 111 + (wxObjectEventFunction) & MyTableTree::OnCmdRecover); 112 + Connect(Tree_ShowSql, wxEVT_COMMAND_MENU_SELECTED, 113 + (wxObjectEventFunction) & MyTableTree::OnCmdShowSql); 114 + Connect(Tree_SpatialIndex, wxEVT_COMMAND_MENU_SELECTED, 115 + (wxObjectEventFunction) & MyTableTree::OnCmdSpatialIndex); 116 + Connect(Tree_MbrCache, wxEVT_COMMAND_MENU_SELECTED, 117 + (wxObjectEventFunction) & MyTableTree::OnCmdMbrCache); 118 + Connect(Tree_RebuildTriggers, wxEVT_COMMAND_MENU_SELECTED, 119 + (wxObjectEventFunction) & MyTableTree::OnCmdRebuildTriggers); 120 + Connect(Tree_CheckGeometry, wxEVT_COMMAND_MENU_SELECTED, 121 + (wxObjectEventFunction) & MyTableTree::OnCmdCheckGeometry); 122 + Connect(Tree_SetSrid, wxEVT_COMMAND_MENU_SELECTED, 123 + (wxObjectEventFunction) & MyTableTree::OnCmdSetSrid); 124 + Connect(Tree_DumpShp, wxEVT_COMMAND_MENU_SELECTED, 125 + (wxObjectEventFunction) & MyTableTree::OnCmdDumpShp); 126 + Connect(Tree_DumpTxtTab, wxEVT_COMMAND_MENU_SELECTED, 127 + (wxObjectEventFunction) & MyTableTree::OnCmdDumpTxtTab); 128 + Connect(Tree_DumpCsv, wxEVT_COMMAND_MENU_SELECTED, 129 + (wxObjectEventFunction) & MyTableTree::OnCmdDumpCsv); 130 + Connect(Tree_DumpHtml, wxEVT_COMMAND_MENU_SELECTED, 131 + (wxObjectEventFunction) & MyTableTree::OnCmdDumpHtml); 132 + Connect(Tree_Edit, wxEVT_COMMAND_MENU_SELECTED, 133 + (wxObjectEventFunction) & MyTableTree::OnCmdEdit); 134 +} 135 + 136 +void MyTableTree::AddTable(wxString & tableName, bool virtualTable) 135 137 { 136 138 // 137 139 // appends a table to the TREE list 138 - MyTableInfo list; 139 - MyColumnInfo *col; 140 - MyIndexInfo *idx; 141 - MyTriggerInfo *trgr; 142 - wxTreeItemId item; 143 - wxTreeItemId item2; 144 - wxString columnInfo; 145 - wxString indexInfo; 146 - wxString triggerInfo; 147 - int icon = 1; 148 - if (virtualTable == true) 149 - icon = 8; 150 - item = AppendItem (Root, tableName, icon); 151 - if (virtualTable == true) 152 - SetItemData (item, 153 - (wxTreeItemData *) (new MyObject (MY_VTABLE, tableName))); 154 - else 155 - SetItemData (item, 156 - (wxTreeItemData *) (new MyObject (MY_TABLE, tableName))); 157 - MainFrame->GetTableColumns (tableName, &list); 158 - MainFrame->GetTableIndices (tableName, &list); 159 - MainFrame->GetTableTriggers (tableName, &list); 160 - col = list.GetFirstColumn (); 161 - while (col) 162 - { 163 - int icon; 164 - if (col->IsPrimaryKey () == true) 165 - icon = 2; 166 - else 167 - { 168 - if (col->IsGeometry () == true) 169 - { 170 - if (virtualTable == false) 171 - SetItemImage (item, 10); 172 - if (col->IsGeometryIndex () == true) 173 - icon = 7; 174 - else if (col->IsMbrCache () == true) 175 - icon = 11; 176 - else 177 - icon = 6; 178 - } 179 - else 180 - icon = 3; 181 - } 182 - columnInfo = col->GetName (); 183 - item2 = AppendItem (item, columnInfo, icon); 184 - if (col->IsGeometry () == true) 185 - { 186 - if (col->IsGeometryIndex () == true) 187 - SetItemData (item2, 188 - (wxTreeItemData *) (new 189 - MyObject 190 - (MY_GEOMETRY_INDEX, 191 - tableName, 192 - col->GetName ()))); 193 - else if (col->IsMbrCache () == true) 194 - SetItemData (item2, 195 - (wxTreeItemData *) (new 196 - MyObject 197 - (MY_GEOMETRY_CACHED, 198 - tableName, 199 - col->GetName ()))); 200 - else 201 - SetItemData (item2, 202 - (wxTreeItemData *) (new 203 - MyObject (MY_GEOMETRY, 204 - tableName, 205 - col->GetName 206 - ()))); 207 - } 208 - else 209 - SetItemData (item2, 210 - (wxTreeItemData *) (new 211 - MyObject (MY_COLUMN, tableName, 212 - col->GetName ()))); 213 - col = col->GetNext (); 214 - } 215 - idx = list.GetFirstIndex (); 216 - while (idx) 217 - { 218 - indexInfo = idx->GetName (); 219 - item2 = AppendItem (item, indexInfo, 4); 220 - SetItemData (item2, 221 - (wxTreeItemData *) (new 222 - MyObject (MY_INDEX, 223 - idx->GetName ()))); 224 - idx = idx->GetNext (); 225 - } 226 - trgr = list.GetFirstTrigger (); 227 - while (trgr) 228 - { 229 - triggerInfo = trgr->GetName (); 230 - item2 = AppendItem (item, triggerInfo, 5); 231 - SetItemData (item2, 232 - (wxTreeItemData *) (new 233 - MyObject (MY_TRIGGER, 234 - trgr->GetName ()))); 235 - trgr = trgr->GetNext (); 236 - } 237 -} 238 - 239 -void 240 -MyTableTree::AddView (wxString & viewName) 140 + MyTableInfo list; 141 + MyColumnInfo *col; 142 + MyIndexInfo *idx; 143 + MyTriggerInfo *trgr; 144 + wxTreeItemId item; 145 + wxTreeItemId item2; 146 + wxString columnInfo; 147 + wxString indexInfo; 148 + wxString triggerInfo; 149 + int icon = 1; 150 + if (virtualTable == true) 151 + icon = 8; 152 + item = AppendItem(Root, tableName, icon); 153 + if (virtualTable == true) 154 + SetItemData(item, (wxTreeItemData *) (new MyObject(MY_VTABLE, tableName))); 155 + else 156 + SetItemData(item, (wxTreeItemData *) (new MyObject(MY_TABLE, tableName))); 157 + MainFrame->GetTableColumns(tableName, &list); 158 + MainFrame->GetTableIndices(tableName, &list); 159 + MainFrame->GetTableTriggers(tableName, &list); 160 + col = list.GetFirstColumn(); 161 + while (col) 162 + { 163 + int icon; 164 + if (col->IsPrimaryKey() == true) 165 + icon = 2; 166 + else 167 + { 168 + if (col->IsGeometry() == true) 169 + { 170 + if (virtualTable == false) 171 + SetItemImage(item, 10); 172 + if (col->IsGeometryIndex() == true) 173 + icon = 7; 174 + else if (col->IsMbrCache() == true) 175 + icon = 11; 176 + else 177 + icon = 6; 178 + } else 179 + icon = 3; 180 + } 181 + columnInfo = col->GetName(); 182 + item2 = AppendItem(item, columnInfo, icon); 183 + if (col->IsGeometry() == true) 184 + { 185 + if (col->IsGeometryIndex() == true) 186 + SetItemData(item2, 187 + (wxTreeItemData *) (new 188 + MyObject(MY_GEOMETRY_INDEX, 189 + tableName, 190 + col->GetName()))); 191 + else if (col->IsMbrCache() == true) 192 + SetItemData(item2, 193 + (wxTreeItemData *) (new 194 + MyObject(MY_GEOMETRY_CACHED, 195 + tableName, 196 + col->GetName()))); 197 + else 198 + SetItemData(item2, 199 + (wxTreeItemData *) (new 200 + MyObject(MY_GEOMETRY, tableName, 201 + col->GetName()))); 202 + } else 203 + SetItemData(item2, 204 + (wxTreeItemData *) (new 205 + MyObject(MY_COLUMN, tableName, 206 + col->GetName()))); 207 + col = col->GetNext(); 208 + } 209 + idx = list.GetFirstIndex(); 210 + while (idx) 211 + { 212 + indexInfo = idx->GetName(); 213 + item2 = AppendItem(item, indexInfo, 4); 214 + SetItemData(item2, 215 + (wxTreeItemData *) (new MyObject(MY_INDEX, idx->GetName()))); 216 + idx = idx->GetNext(); 217 + } 218 + trgr = list.GetFirstTrigger(); 219 + while (trgr) 220 + { 221 + triggerInfo = trgr->GetName(); 222 + item2 = AppendItem(item, triggerInfo, 5); 223 + SetItemData(item2, 224 + (wxTreeItemData *) (new 225 + MyObject(MY_TRIGGER, trgr->GetName()))); 226 + trgr = trgr->GetNext(); 227 + } 228 +} 229 + 230 +void MyTableTree::AddView(wxString & viewName) 241 231 { 242 232 // 243 233 // appends a view to the TREE list 244 - MyViewInfo list; 245 - MyColumnInfo *col; 246 - wxTreeItemId item; 247 - wxTreeItemId item2; 248 - wxString columnInfo; 249 - item = AppendItem (Root, viewName, 9); 250 - SetItemData (item, (wxTreeItemData *) (new MyObject (MY_VIEW, viewName))); 251 - MainFrame->GetViewColumns (viewName, &list); 252 - col = list.GetFirst (); 253 - while (col) 254 - { 255 - columnInfo = col->GetName (); 256 - item2 = AppendItem (item, columnInfo, 3); 257 - SetItemData (item2, 258 - (wxTreeItemData *) (new 259 - MyObject (MY_COLUMN, viewName, 260 - col->GetName ()))); 261 - col = col->GetNext (); 262 - } 263 -} 264 - 265 -void 266 -MyTableTree::OnSelChanged (wxTreeEvent & event) 234 + MyViewInfo list; 235 + MyColumnInfo *col; 236 + wxTreeItemId item; 237 + wxTreeItemId item2; 238 + wxString columnInfo; 239 + item = AppendItem(Root, viewName, 9); 240 + SetItemData(item, (wxTreeItemData *) (new MyObject(MY_VIEW, viewName))); 241 + MainFrame->GetViewColumns(viewName, &list); 242 + col = list.GetFirst(); 243 + while (col) 244 + { 245 + columnInfo = col->GetName(); 246 + item2 = AppendItem(item, columnInfo, 3); 247 + SetItemData(item2, 248 + (wxTreeItemData *) (new 249 + MyObject(MY_COLUMN, viewName, 250 + col->GetName()))); 251 + col = col->GetNext(); 252 + } 253 +} 254 + 255 +void MyTableTree::OnSelChanged(wxTreeEvent & event) 267 256 { 268 257 // 269 258 // selecting some node [mouse action] 270 259 // 271 - wxTreeItemId item = event.GetItem (); 272 - if (item == Root) 273 - return; 274 - MyObject *obj = (MyObject *) GetItemData (item); 275 - if (obj == NULL) 276 - return; 277 - CurrentItem = item; 260 + wxTreeItemId item = event.GetItem(); 261 + if (item == Root) 262 + return; 263 + MyObject *obj = (MyObject *) GetItemData(item); 264 + if (obj == NULL) 265 + return; 266 + CurrentItem = item; 278 267 } 279 268 280 -void 281 -MyTableTree::OnRightClick (wxTreeEvent & event) 269 +void MyTableTree::OnRightClick(wxTreeEvent & event) 282 270 { 283 271 // 284 272 // right click on some node [mouse action] 285 273 // 286 - wxMenu menu; 287 - wxMenuItem *menuItem; 288 - wxString title; 289 - bool table = false; 290 - bool canEdit = false; 291 - bool view = false; 292 - bool column = false; 293 - bool geometry = false; 294 - bool geometry_index = false; 295 - bool geometry_cached = false; 296 - bool index = false; 297 - bool trigger = false; 298 - bool metadata = MainFrame->CheckMetadata (); 299 - if (MainFrame->IsConnected () == false) 300 - return; 301 - wxTreeItemId item = event.GetItem (); 302 - SelectItem (item); 303 - wxPoint pt = event.GetPoint (); 304 - if (item == Root) 305 - { 306 - CurrentItem = NULL; 307 - menuItem = new wxMenuItem (&menu, Tree_Refresh, wxT ("&Refresh")); 308 - menu.Append (menuItem); 309 - menu.AppendSeparator (); 310 - menuItem = 311 - new wxMenuItem (&menu, Tree_NewTable, wxT ("Create New &Table")); 312 - menu.Append (menuItem); 313 - menuItem = 314 - new wxMenuItem (&menu, Tree_NewView, wxT ("Create New &View")); 315 - menu.Append (menuItem); 316 - PopupMenu (&menu, pt); 317 - return; 318 - } 319 - MyObject *obj = (MyObject *) GetItemData (item); 320 - if (obj == NULL) 321 - { 322 - CurrentItem = NULL; 323 - menuItem = new wxMenuItem (&menu, Tree_Refresh, wxT ("&Refresh")); 324 - menu.Append (menuItem); 325 - menu.AppendSeparator (); 326 - menuItem = 327 - new wxMenuItem (&menu, Tree_NewTable, wxT ("Create New &Table")); 328 - menu.Append (menuItem); 329 - menuItem = 330 - new wxMenuItem (&menu, Tree_NewView, wxT ("Create New &View")); 331 - menu.Append (menuItem); 332 - PopupMenu (&menu, pt); 333 - return; 334 - } 335 - switch (obj->GetType ()) 336 - { 274 + wxMenu *menu = new wxMenu(); 275 + wxMenuItem *menuItem; 276 + wxString title; 277 + bool table = false; 278 + bool canEdit = false; 279 + bool view = false; 280 + bool column = false; 281 + bool geometry = false; 282 + bool geometry_index = false; 283 + bool geometry_cached = false; 284 + bool index = false; 285 + bool trigger = false; 286 + bool metadata = MainFrame->CheckMetadata(); 287 + if (MainFrame->IsConnected() == false) 288 + return; 289 + wxTreeItemId item = event.GetItem(); 290 + SelectItem(item); 291 + wxPoint pt = event.GetPoint(); 292 + if (item == Root) 293 + { 294 + CurrentItem = NULL; 295 + menuItem = new wxMenuItem(menu, Tree_Refresh, wxT("&Refresh")); 296 + menu->Append(menuItem); 297 + menu->AppendSeparator(); 298 + menuItem = new wxMenuItem(menu, Tree_NewTable, wxT("Create New &Table")); 299 + menu->Append(menuItem); 300 + menuItem = new wxMenuItem(menu, Tree_NewView, wxT("Create New &View")); 301 + menu->Append(menuItem); 302 + PopupMenu(menu, pt); 303 + return; 304 + } 305 + MyObject *obj = (MyObject *) GetItemData(item); 306 + if (obj == NULL) 307 + { 308 + CurrentItem = NULL; 309 + menuItem = new wxMenuItem(menu, Tree_Refresh, wxT("&Refresh")); 310 + menu->Append(menuItem); 311 + menu->AppendSeparator(); 312 + menuItem = new wxMenuItem(menu, Tree_NewTable, wxT("Create New &Table")); 313 + menu->Append(menuItem); 314 + menuItem = new wxMenuItem(menu, Tree_NewView, wxT("Create New &View")); 315 + menu->Append(menuItem); 316 + PopupMenu(menu, pt); 317 + return; 318 + } 319 + switch (obj->GetType()) 320 + { 337 321 case MY_VTABLE: 338 322 case MY_TABLE: 339 - table = true; 340 - break; 323 + table = true; 324 + break; 341 325 case MY_VIEW: 342 - view = true; 343 - break; 326 + view = true; 327 + break; 344 328 case MY_COLUMN: 345 - column = true; 346 - break; 329 + column = true; 330 + break; 347 331 case MY_GEOMETRY: 348 - geometry = true; 349 - break; 332 + geometry = true; 333 + break; 350 334 case MY_GEOMETRY_INDEX: 351 - geometry_index = true; 352 - break; 335 + geometry_index = true; 336 + break; 353 337 case MY_GEOMETRY_CACHED: 354 - geometry_cached = true; 355 - break; 338 + geometry_cached = true; 339 + break; 356 340 case MY_INDEX: 357 - index = true; 358 - break; 341 + index = true; 342 + break; 359 343 case MY_TRIGGER: 360 - trigger = true; 361 - break; 362 - }; 363 - if (obj->GetType () == MY_TABLE) 364 - canEdit = true; 365 - CurrentItem = item; 366 - menuItem = new wxMenuItem (&menu, Tree_Refresh, wxT ("&Refresh")); 367 - menu.Append (menuItem); 368 - if (table == true) 369 - { 370 - wxString title = wxT ("Table: ") + obj->GetName (); 371 - menu.SetTitle (title); 372 - menu.AppendSeparator (); 373 - menuItem = 374 - new wxMenuItem (&menu, Tree_NewTable, wxT ("Create New &Table")); 375 - menu.Append (menuItem); 376 - menuItem = 377 - new wxMenuItem (&menu, Tree_NewView, wxT ("Create New &View")); 378 - menu.Append (menuItem); 379 - menu.AppendSeparator (); 380 - if (canEdit == true) 381 - { 382 - menuItem = 383 - new wxMenuItem (&menu, Tree_Edit, wxT ("&Edit table rows")); 384 - menu.Append (menuItem); 385 - } 386 - else 387 - { 388 - menuItem = 389 - new wxMenuItem (&menu, Tree_Select, wxT ("&Query table")); 390 - menu.Append (menuItem); 391 - } 392 - menuItem = new wxMenuItem (&menu, Tree_Show, wxT ("&Show columns")); 393 - menu.Append (menuItem); 394 - menuItem = 395 - new wxMenuItem (&menu, Tree_ShowSql, 396 - wxT ("&Show CREATE statement")); 397 - menu.Append (menuItem); 398 - menu.AppendSeparator (); 399 - menuItem = 400 - new wxMenuItem (&menu, Tree_NewColumn, wxT ("Add New &Column")); 401 - menu.Append (menuItem); 402 - menuItem = new wxMenuItem (&menu, Tree_Rename, wxT ("&Rename table")); 403 - menu.Append (menuItem); 404 - menuItem = new wxMenuItem (&menu, Tree_Drop, wxT ("&Drop table")); 405 - menu.Append (menuItem); 406 - menu.AppendSeparator (); 407 - menuItem = 408 - new wxMenuItem (&menu, Tree_NewIndex, wxT ("Create New &Index")); 409 - menu.Append (menuItem); 410 - menuItem = 411 - new wxMenuItem (&menu, Tree_NewTrigger, 412 - wxT ("Create New &Trigger")); 413 - menu.Append (menuItem); 414 - menu.AppendSeparator (); 415 - menuItem = 416 - new wxMenuItem (&menu, Tree_DumpTxtTab, 417 - wxT ("Export as &Txt/Tab")); 418 - menu.Append (menuItem); 419 - menuItem = 420 - new wxMenuItem (&menu, Tree_DumpCsv, wxT ("Export as &CSV")); 421 - menu.Append (menuItem); 422 - menuItem = 423 - new wxMenuItem (&menu, Tree_DumpHtml, wxT ("Export as &HTML")); 424 - menu.Append (menuItem); 425 - } 426 - if (view == true) 427 - { 428 - wxString title = wxT ("View: ") + obj->GetName (); 429 - menu.SetTitle (title); 430 - menu.AppendSeparator (); 431 - menuItem = 432 - new wxMenuItem (&menu, Tree_NewTable, wxT ("Create New &Table")); 433 - menu.Append (menuItem); 434 - menuItem = 435 - new wxMenuItem (&menu, Tree_NewView, wxT ("Create New &View")); 436 - menu.Append (menuItem); 437 - menu.AppendSeparator (); 438 - menuItem = new wxMenuItem (&menu, Tree_Select, wxT ("&Query view")); 439 - menu.Append (menuItem); 440 - menuItem = new wxMenuItem (&menu, Tree_Show, wxT ("&Show columns")); 441 - menu.Append (menuItem); 442 - menuItem = 443 - new wxMenuItem (&menu, Tree_ShowSql, 444 - wxT ("&Show CREATE statement")); 445 - menu.Append (menuItem); 446 - menu.AppendSeparator (); 447 - menuItem = new wxMenuItem (&menu, Tree_Drop, wxT ("&Drop view")); 448 - menu.Append (menuItem); 449 - menu.AppendSeparator (); 450 - menuItem = 451 - new wxMenuItem (&menu, Tree_DumpTxtTab, 452 - wxT ("Export as &Txt/Tab")); 453 - menu.Append (menuItem); 454 - menuItem = 455 - new wxMenuItem (&menu, Tree_DumpCsv, wxT ("Export as &CSV")); 456 - menu.Append (menuItem); 457 - menuItem = 458 - new wxMenuItem (&menu, Tree_DumpHtml, wxT ("Export as &HTML")); 459 - menu.Append (menuItem); 460 - } 461 - if (column == true) 462 - { 463 - wxString title = 464 - wxT ("Column: ") + obj->GetName () + wxT (".") + 465 - obj->GetColumn (); 466 - menu.SetTitle (title); 467 - menuItem = 468 - new wxMenuItem (&menu, Tree_CheckGeometry, 469 - wxT ("&Check geometries")); 470 - menu.Append (menuItem); 471 - menuItem = new wxMenuItem (&menu, Tree_SetSrid, wxT ("&Set SRID")); 472 - menu.Append (menuItem); 473 - if (metadata == true) 474 - { 475 - menu.AppendSeparator (); 476 - menuItem = 477 - new wxMenuItem (&menu, Tree_Recover, 478 - wxT ("&Recover geometry column")); 479 - menu.Append (menuItem); 480 - } 481 - } 482 - if (geometry == true) 483 - { 484 - wxString title = 485 - wxT ("Column: ") + obj->GetName () + wxT (".") + 486 - obj->GetColumn (); 487 - menu.SetTitle (title); 488 - menuItem = 489 - new wxMenuItem (&menu, Tree_Show, wxT ("&Show Spatial Metadata")); 490 - menu.Append (menuItem); 491 - menuItem = 492 - new wxMenuItem (&menu, Tree_CheckGeometry, 493 - wxT ("&Check geometries")); 494 - menu.Append (menuItem); 495 - menu.AppendSeparator (); 496 - menuItem = 497 - new wxMenuItem (&menu, Tree_SpatialIndex, 498 - wxT ("&Build Spatial Index")); 499 - menu.Append (menuItem); 500 - menuItem = 501 - new wxMenuItem (&menu, Tree_MbrCache, wxT ("Build &MBR cache")); 502 - menu.Append (menuItem); 503 - menu.AppendSeparator (); 504 - menuItem = 505 - new wxMenuItem (&menu, Tree_DumpShp, 506 - wxT ("Export as &Shapefile")); 507 - menu.Append (menuItem); 508 - } 509 - if (geometry_index == true) 510 - { 511 - wxString title = 512 - wxT ("Column: ") + obj->GetName () + wxT (".") + 513 - obj->GetColumn (); 514 - menu.SetTitle (title); 515 - menuItem = 516 - new wxMenuItem (&menu, Tree_Show, wxT ("&Show Spatial Metadata")); 517 - menu.Append (menuItem); 518 - menuItem = 519 - new wxMenuItem (&menu, Tree_CheckGeometry, 520 - wxT ("&Check geometries")); 521 - menu.Append (menuItem); 522 - menu.AppendSeparator (); 523 - menuItem = 524 - new wxMenuItem (&menu, Tree_SpatialIndex, 525 - wxT ("&Remove Spatial Index")); 526 - menu.Append (menuItem); 527 - menu.AppendSeparator (); 528 - menuItem = 529 - new wxMenuItem (&menu, Tree_DumpShp, 530 - wxT ("Export as &Shapefile")); 531 - menu.Append (menuItem); 532 - } 533 - if (geometry_cached == true) 534 - { 535 - wxString title = 536 - wxT ("Column: ") + obj->GetName () + wxT (".") + 537 - obj->GetColumn (); 538 - menu.SetTitle (title); 539 - menuItem = 540 - new wxMenuItem (&menu, Tree_Show, wxT ("&Show Spatial Metadata")); 541 - menu.Append (menuItem); 542 - menuItem = 543 - new wxMenuItem (&menu, Tree_CheckGeometry, 544 - wxT ("&Check geometries")); 545 - menu.Append (menuItem); 546 - menu.AppendSeparator (); 547 - menuItem = 548 - new wxMenuItem (&menu, Tree_MbrCache, wxT ("&Remove MBR cache")); 549 - menu.Append (menuItem); 550 - menu.AppendSeparator (); 551 - menuItem = 552 - new wxMenuItem (&menu, Tree_DumpShp, 553 - wxT ("Export as &Shapefile")); 554 - menu.Append (menuItem); 555 - } 556 - if (index == true) 557 - { 558 - wxString title = wxT ("Index: ") + obj->GetName (); 559 - menu.SetTitle (title); 560 - menu.AppendSeparator (); 561 - menuItem = new wxMenuItem (&menu, Tree_Show, wxT ("&Show index")); 562 - menu.Append (menuItem); 563 - menu.AppendSeparator (); 564 - menuItem = new wxMenuItem (&menu, Tree_Drop, wxT ("&Drop index")); 565 - menu.Append (menuItem); 566 - } 567 - if (trigger == true) 568 - { 569 - wxString title = wxT ("Trigger: ") + obj->GetName (); 570 - menu.SetTitle (title); 571 - menu.AppendSeparator (); 572 - menuItem = new wxMenuItem (&menu, Tree_Show, wxT ("&Show trigger")); 573 - menu.Append (menuItem); 574 - menu.AppendSeparator (); 575 - menuItem = new wxMenuItem (&menu, Tree_Drop, wxT ("&Drop trigger")); 576 - menu.Append (menuItem); 577 - } 578 - PopupMenu (&menu, pt); 579 -} 580 - 581 -void 582 -MyTableTree::OnCmdNewTable (wxCommandEvent & event) 344 + trigger = true; 345 + break; 346 + }; 347 + if (obj->GetType() == MY_TABLE) 348 + canEdit = true; 349 + CurrentItem = item; 350 + menuItem = new wxMenuItem(menu, Tree_Refresh, wxT("&Refresh")); 351 + menu->Append(menuItem); 352 + if (table == true) 353 + { 354 + wxString title = wxT("Table: \"") + obj->GetName() + wxT("\""); 355 + menu->SetTitle(title); 356 + menu->AppendSeparator(); 357 + menuItem = new wxMenuItem(menu, Tree_NewTable, wxT("Create New &Table")); 358 + menu->Append(menuItem); 359 + menuItem = new wxMenuItem(menu, Tree_NewView, wxT("Create New &View")); 360 + menu->Append(menuItem); 361 + menu->AppendSeparator(); 362 + if (canEdit == true) 363 + { 364 + menuItem = new wxMenuItem(menu, Tree_Edit, wxT("&Edit table rows")); 365 + menu->Append(menuItem); 366 + } else 367 + { 368 + menuItem = new wxMenuItem(menu, Tree_Select, wxT("&Query table")); 369 + menu->Append(menuItem); 370 + } 371 + menuItem = new wxMenuItem(menu, Tree_Show, wxT("&Show columns")); 372 + menu->Append(menuItem); 373 + menuItem = 374 + new wxMenuItem(menu, Tree_ShowSql, wxT("&Show CREATE statement")); 375 + menu->Append(menuItem); 376 + menu->AppendSeparator(); 377 + menuItem = new wxMenuItem(menu, Tree_NewColumn, wxT("Add New &Column")); 378 + menu->Append(menuItem); 379 + menuItem = new wxMenuItem(menu, Tree_Rename, wxT("&Rename table")); 380 + menu->Append(menuItem); 381 + menuItem = new wxMenuItem(menu, Tree_Drop, wxT("&Drop table")); 382 + menu->Append(menuItem); 383 + menu->AppendSeparator(); 384 + menuItem = new wxMenuItem(menu, Tree_NewIndex, wxT("Create New &Index")); 385 + menu->Append(menuItem); 386 + menuItem = 387 + new wxMenuItem(menu, Tree_NewTrigger, wxT("Create New &Trigger")); 388 + menu->Append(menuItem); 389 + menu->AppendSeparator(); 390 + menuItem = 391 + new wxMenuItem(menu, Tree_DumpTxtTab, wxT("Export as &Txt/Tab")); 392 + menu->Append(menuItem); 393 + menuItem = new wxMenuItem(menu, Tree_DumpCsv, wxT("Export as &CSV")); 394 + menu->Append(menuItem); 395 + menuItem = new wxMenuItem(menu, Tree_DumpHtml, wxT("Export as &HTML")); 396 + menu->Append(menuItem); 397 + } 398 + if (view == true) 399 + { 400 + wxString title = wxT("View: \"") + obj->GetName() + wxT("\""); 401 + menu->SetTitle(title); 402 + menu->AppendSeparator(); 403 + menuItem = new wxMenuItem(menu, Tree_NewTable, wxT("Create New &Table")); 404 + menu->Append(menuItem); 405 + menuItem = new wxMenuItem(menu, Tree_NewView, wxT("Create New &View")); 406 + menu->Append(menuItem); 407 + menu->AppendSeparator(); 408 + menuItem = new wxMenuItem(menu, Tree_Select, wxT("&Query view")); 409 + menu->Append(menuItem); 410 + menuItem = new wxMenuItem(menu, Tree_Show, wxT("&Show columns")); 411 + menu->Append(menuItem); 412 + menuItem = 413 + new wxMenuItem(menu, Tree_ShowSql, wxT("&Show CREATE statement")); 414 + menu->Append(menuItem); 415 + menu->AppendSeparator(); 416 + menuItem = new wxMenuItem(menu, Tree_Drop, wxT("&Drop view")); 417 + menu->Append(menuItem); 418 + menu->AppendSeparator(); 419 + menuItem = 420 + new wxMenuItem(menu, Tree_DumpTxtTab, wxT("Export as &Txt/Tab")); 421 + menu->Append(menuItem); 422 + menuItem = new wxMenuItem(menu, Tree_DumpCsv, wxT("Export as &CSV")); 423 + menu->Append(menuItem); 424 + menuItem = new wxMenuItem(menu, Tree_DumpHtml, wxT("Export as &HTML")); 425 + menu->Append(menuItem); 426 + } 427 + if (column == true) 428 + { 429 + wxString title = 430 + wxT("Column: \"") + obj->GetName() + wxT("\".\"") + obj->GetColumn() + 431 + wxT("\""); 432 + menu->SetTitle(title); 433 + menuItem = 434 + new wxMenuItem(menu, Tree_CheckGeometry, wxT("&Check geometries")); 435 + menu->Append(menuItem); 436 + menuItem = new wxMenuItem(menu, Tree_SetSrid, wxT("&Set SRID")); 437 + menu->Append(menuItem); 438 + if (metadata == true) 439 + { 440 + menu->AppendSeparator(); 441 + menuItem = 442 + new wxMenuItem(menu, Tree_Recover, wxT("&Recover geometry column")); 443 + menu->Append(menuItem); 444 + } 445 + } 446 + if (geometry == true) 447 + { 448 + wxString title = 449 + wxT("Column: \"") + obj->GetName() + wxT("\".\"") + obj->GetColumn() + 450 + wxT("\""); 451 + menu->SetTitle(title); 452 + menuItem = new wxMenuItem(menu, Tree_Show, wxT("&Show Spatial Metadata")); 453 + menu->Append(menuItem); 454 + menuItem = 455 + new wxMenuItem(menu, Tree_CheckGeometry, wxT("&Check geometries")); 456 + menu->Append(menuItem); 457 + menu->AppendSeparator(); 458 + menuItem = 459 + new wxMenuItem(menu, Tree_SpatialIndex, wxT("&Build Spatial Index")); 460 + menuItem->SetBitmap(wxBitmap(spatialidx_xpm)); 461 + menu->Append(menuItem); 462 + menuItem = new wxMenuItem(menu, Tree_MbrCache, wxT("Build &MBR cache")); 463 + menuItem->SetBitmap(wxBitmap(mbrcache_xpm)); 464 + menu->Append(menuItem); 465 + menu->AppendSeparator(); 466 + menuItem = 467 + new wxMenuItem(menu, Tree_RebuildTriggers, 468 + wxT("Rebuild Geometry &Triggers")); 469 + menu->Append(menuItem); 470 + menu->AppendSeparator(); 471 + menuItem = 472 + new wxMenuItem(menu, Tree_DumpShp, wxT("Export as &Shapefile")); 473 + menuItem->SetBitmap(wxBitmap(dumpshp_xpm)); 474 + menu->Append(menuItem); 475 + } 476 + if (geometry_index == true) 477 + { 478 + wxString title = 479 + wxT("Column: \"") + obj->GetName() + wxT("\".\"") + obj->GetColumn() + 480 + wxT("\""); 481 + menu->SetTitle(title); 482 + menuItem = new wxMenuItem(menu, Tree_Show, wxT("&Show Spatial Metadata")); 483 + menu->Append(menuItem); 484 + menuItem = 485 + new wxMenuItem(menu, Tree_CheckGeometry, wxT("&Check geometries")); 486 + menu->Append(menuItem); 487 + menu->AppendSeparator(); 488 + menuItem = 489 + new wxMenuItem(menu, Tree_SpatialIndex, wxT("&Remove Spatial Index")); 490 + menuItem->SetBitmap(wxBitmap(kill_spindex_xpm)); 491 + menu->Append(menuItem); 492 + menu->AppendSeparator(); 493 + menuItem = 494 + new wxMenuItem(menu, Tree_RebuildTriggers, 495 + wxT("Rebuild Geometry &Triggers")); 496 + menu->Append(menuItem); 497 + menu->AppendSeparator(); 498 + menuItem = 499 + new wxMenuItem(menu, Tree_DumpShp, wxT("Export as &Shapefile")); 500 + menuItem->SetBitmap(wxBitmap(dumpshp_xpm)); 501 + menu->Append(menuItem); 502 + } 503 + if (geometry_cached == true) 504 + { 505 + wxString title = 506 + wxT("Column: \"") + obj->GetName() + wxT("\".\"") + obj->GetColumn() + 507 + wxT("\""); 508 + menu->SetTitle(title); 509 + menuItem = new wxMenuItem(menu, Tree_Show, wxT("&Show Spatial Metadata")); 510 + menu->Append(menuItem); 511 + menuItem = 512 + new wxMenuItem(menu, Tree_CheckGeometry, wxT("&Check geometries")); 513 + menu->Append(menuItem); 514 + menu->AppendSeparator(); 515 + menuItem = new wxMenuItem(menu, Tree_MbrCache, wxT("&Remove MBR cache")); 516 + menuItem->SetBitmap(wxBitmap(kill_spindex_xpm)); 517 + menu->Append(menuItem); 518 + menu->AppendSeparator(); 519 + menuItem = 520 + new wxMenuItem(menu, Tree_RebuildTriggers, 521 + wxT("Rebuild Geometry &Triggers")); 522 + menu->Append(menuItem); 523 + menu->AppendSeparator(); 524 + menuItem = 525 + new wxMenuItem(menu, Tree_DumpShp, wxT("Export as &Shapefile")); 526 + menuItem->SetBitmap(wxBitmap(dumpshp_xpm)); 527 + menu->Append(menuItem); 528 + } 529 + if (index == true) 530 + { 531 + wxString title = wxT("Index: \"") + obj->GetName() + wxT("\""); 532 + menu->SetTitle(title); 533 + menu->AppendSeparator(); 534 + menuItem = new wxMenuItem(menu, Tree_Show, wxT("&Show index")); 535 + menu->Append(menuItem); 536 + menu->AppendSeparator(); 537 + menuItem = new wxMenuItem(menu, Tree_Drop, wxT("&Drop index")); 538 + menu->Append(menuItem); 539 + } 540 + if (trigger == true) 541 + { 542 + wxString title = wxT("Trigger: \"") + obj->GetName() + wxT("\""); 543 + menu->SetTitle(title); 544 + menu->AppendSeparator(); 545 + menuItem = new wxMenuItem(menu, Tree_Show, wxT("&Show trigger")); 546 + menu->Append(menuItem); 547 + menu->AppendSeparator(); 548 + menuItem = new wxMenuItem(menu, Tree_Drop, wxT("&Drop trigger")); 549 + menu->Append(menuItem); 550 + } 551 + PopupMenu(menu, pt); 552 +} 553 + 554 +void MyTableTree::OnCmdNewTable(wxCommandEvent & event) 583 555 { 584 556 // 585 557 // menu event - new table creation required 586 558 // 587 - wxString sql; 588 - sql = wxT ("CREATE TABLE ...table-name... (\n"); 589 - sql += wxT ("...column1,\n...column2,\n...columnN)"); 590 - MainFrame->SetSql (sql, false); 559 + wxString sql; 560 + sql = wxT("CREATE TABLE ...table-name... (\n"); 561 + sql += wxT("...column1,\n...column2,\n...columnN)"); 562 + MainFrame->SetSql(sql, false); 591 563 } 592 564 593 -void 594 -MyTableTree::OnCmdNewView (wxCommandEvent & event) 565 +void MyTableTree::OnCmdNewView(wxCommandEvent & event) 595 566 { 596 567 // 597 568 // menu event - new view creation required 598 569 // 599 - wxString sql; 600 - sql = wxT ("CREATE VIEW ...view-name... AS\n"); 601 - sql += wxT ("SELECT ...sql-select-statement..."); 602 - MainFrame->SetSql (sql, false); 570 + wxString sql; 571 + sql = wxT("CREATE VIEW ...view-name... AS\n"); 572 + sql += wxT("SELECT ...sql-select-statement..."); 573 + MainFrame->SetSql(sql, false); 603 574 } 604 575 605 -void 606 -MyTableTree::OnCmdNewIndex (wxCommandEvent & event) 576 +void MyTableTree::OnCmdNewIndex(wxCommandEvent & event) 607 577 { 608 578 // 609 579 // menu event - new index creation required 610 580 // 611 - wxString sql; 612 - MyObject *obj = (MyObject *) GetItemData (CurrentItem); 613 - if (obj == NULL) 614 - return; 615 - if (obj->GetType () == MY_TABLE) 616 - { 617 - sql = wxT ("CREATE [ UNIQUE ] INDEX ...index-name...\nON "); 618 - sql += obj->GetName (); 619 - sql += wxT ("\n(\n...column1, column2, columnN...\n)"); 620 - MainFrame->SetSql (sql, false); 621 - } 581 + wxString sql; 582 + MyObject *obj = (MyObject *) GetItemData(CurrentItem); 583 + if (obj == NULL) 584 + return; 585 + if (obj->GetType() == MY_TABLE) 586 + { 587 + sql = wxT("CREATE [ UNIQUE ] INDEX ...index-name...\nON "); 588 + sql += obj->GetName(); 589 + sql += wxT("\n(\n...column1, column2, columnN...\n)"); 590 + MainFrame->SetSql(sql, false); 591 + } 622 592 } 623 593 624 -void 625 -MyTableTree::OnCmdNewTrigger (wxCommandEvent & event) 594 +void MyTableTree::OnCmdNewTrigger(wxCommandEvent & event) 626 595 { 627 596 // 628 597 // menu event - new trigger creation required 629 598 // 630 - wxString sql; 631 - MyObject *obj = (MyObject *) GetItemData (CurrentItem); 632 - if (obj == NULL) 633 - return; 634 - if (obj->GetType () == MY_TABLE) 635 - { 636 - sql = wxT ("CREATE TRIGGER ...trigger-name...\n[ BEFORE | AFTER ]\n"); 637 - sql += wxT ("[ INSERT | UPDATE | DELETE ]\nON "); 638 - sql += obj->GetName (); 639 - sql += wxT ("\n...sql-statement..."); 640 - MainFrame->SetSql (sql, false); 641 - } 599 + wxString sql; 600 + MyObject *obj = (MyObject *) GetItemData(CurrentItem); 601 + if (obj == NULL) 602 + return; 603 + if (obj->GetType() == MY_TABLE) 604 + { 605 + sql = wxT("CREATE TRIGGER ...trigger-name...\n[ BEFORE | AFTER ]\n"); 606 + sql += wxT("[ INSERT | UPDATE | DELETE ]\nON "); 607 + sql += obj->GetName(); 608 + sql += wxT("\n...sql-statement..."); 609 + MainFrame->SetSql(sql, false); 610 + } 642 611 } 643 612 644 -void 645 -MyTableTree::OnCmdNewColumn (wxCommandEvent & event) 613 +void MyTableTree::OnCmdNewColumn(wxCommandEvent & event) 646 614 { 647 615 // 648 616 // menu event - new column creation required 649 617 // 650 - wxString sql; 651 - MyObject *obj = (MyObject *) GetItemData (CurrentItem); 652 - if (obj == NULL) 653 - return; 654 - if (obj->GetType () == MY_TABLE) 655 - { 656 - sql = wxT ("ALTER TABLE "); 657 - sql += obj->GetName (); 658 - sql += wxT ("\nADD COLUMN ...column-name column-type..."); 659 - MainFrame->SetSql (sql, false); 660 - } 618 + wxString sql; 619 + MyObject *obj = (MyObject *) GetItemData(CurrentItem); 620 + if (obj == NULL) 621 + return; 622 + if (obj->GetType() == MY_TABLE) 623 + { 624 + sql = wxT("ALTER TABLE \""); 625 + sql += obj->GetName(); 626 + sql += wxT("\"\nADD COLUMN ...column-name column-type..."); 627 + MainFrame->SetSql(sql, false); 628 + } 661 629 } 662 630 663 -void 664 -MyTableTree::OnCmdSelect (wxCommandEvent & event) 631 +void MyTableTree::OnCmdSelect(wxCommandEvent & event) 665 632 { 666 633 // 667 634 // menu event - examining table rows required 668 635 // 669 - wxString sql; 670 - MyObject *obj = (MyObject *) GetItemData (CurrentItem); 671 - if (obj == NULL) 672 - return; 673 - sql = wxT ("SELECT * FROM "); 674 - sql += obj->GetName (); 675 - MainFrame->SetSql (sql, true); 636 + wxString sql; 637 + MyObject *obj = (MyObject *) GetItemData(CurrentItem); 638 + if (obj == NULL) 639 + return; 640 + sql = wxT("SELECT * FROM \""); 641 + sql += obj->GetName() + wxT("\""); 642 + MainFrame->SetSql(sql, true); 676 643 } 677 644 678 -void 679 -MyTableTree::OnCmdShow (wxCommandEvent & event) 645 +void MyTableTree::OnCmdShow(wxCommandEvent & event) 680 646 { 681 647 // 682 648 // menu event - examining full infos required 683 649 // 684 - wxString sql; 685 - MyObject *obj = (MyObject *) GetItemData (CurrentItem); 686 - if (obj == NULL) 687 - return; 688 - if (obj->GetType () == MY_TABLE || obj->GetType () == MY_VTABLE 689 - || obj->GetType () == MY_VIEW) 690 - { 691 - sql = wxT ("PRAGMA table_info("); 692 - sql += obj->GetName (); 693 - sql += wxT (")"); 694 - } 695 - if (obj->GetType () == MY_GEOMETRY || obj->GetType () == MY_GEOMETRY_INDEX 696 - || obj->GetType () == MY_GEOMETRY_CACHED) 697 - { 698 - sql = wxT ("SELECT * FROM geom_cols_ref_sys\n"); 699 - sql += wxT ("WHERE f_table_name = '"); 700 - sql += obj->GetName (); 701 - sql += wxT ("'\nAND f_geometry_column = '"); 702 - sql += obj->GetColumn (); 703 - sql += wxT ("'"); 704 - } 705 - if (obj->GetType () == MY_INDEX) 706 - { 707 - sql = wxT ("PRAGMA index_info("); 708 - sql += obj->GetName (); 709 - sql += wxT (")"); 710 - } 711 - if (obj->GetType () == MY_TRIGGER) 712 - { 713 - sql = 714 - wxT 715 - ("SELECT sql FROM sqlite_master\nWHERE type = 'trigger' AND name = '"); 716 - sql += obj->GetName (); 717 - sql += wxT ("'"); 718 - } 719 - if (sql.Len () < 1) 720 - return; 721 - MainFrame->SetSql (sql, true); 722 -} 723 - 724 -void 725 -MyTableTree::OnCmdDrop (wxCommandEvent & event) 650 + wxString sql; 651 + MyObject *obj = (MyObject *) GetItemData(CurrentItem); 652 + if (obj == NULL) 653 + return; 654 + if (obj->GetType() == MY_TABLE || obj->GetType() == MY_VTABLE 655 + || obj->GetType() == MY_VIEW) 656 + { 657 + sql = wxT("PRAGMA table_info(\""); 658 + sql += obj->GetName(); 659 + sql += wxT("\")"); 660 + } 661 + if (obj->GetType() == MY_GEOMETRY || obj->GetType() == MY_GEOMETRY_INDEX 662 + || obj->GetType() == MY_GEOMETRY_CACHED) 663 + { 664 + sql = wxT("SELECT * FROM geom_cols_ref_sys\n"); 665 + sql += wxT("WHERE f_table_name = '"); 666 + sql += obj->GetName(); 667 + sql += wxT("'\nAND f_geometry_column = '"); 668 + sql += obj->GetColumn(); 669 + sql += wxT("'"); 670 + } 671 + if (obj->GetType() == MY_INDEX) 672 + { 673 + sql = wxT("PRAGMA index_info(\""); 674 + sql += obj->GetName(); 675 + sql += wxT("\")"); 676 + } 677 + if (obj->GetType() == MY_TRIGGER) 678 + { 679 + sql = 680 + wxT 681 + ("SELECT sql FROM sqlite_master\nWHERE type = 'trigger' AND name = '"); 682 + sql += obj->GetName(); 683 + sql += wxT("'"); 684 + } 685 + if (sql.Len() < 1) 686 + return; 687 + MainFrame->SetSql(sql, true); 688 +} 689 + 690 +void MyTableTree::OnCmdDrop(wxCommandEvent & event) 726 691 { 727 692 // 728 693 // menu event - dropping some object required 729 694 // 730 - wxString sql; 731 - wxString msg; 732 - char *errMsg = NULL; 733 - int ret; 734 - sqlite3 *sqlite = MainFrame->GetSqlite (); 735 - MyObject *obj = (MyObject *) GetItemData (CurrentItem); 736 - if (obj == NULL) 737 - return; 738 - if (obj->GetType () == MY_TABLE || obj->GetType () == MY_VTABLE) 739 - { 740 - bool metadata = MainFrame->CheckMetadata (); 741 - if (metadata == true) 742 - { 743 - // SpatialMetadata exists; we must check for geometry_columns and SpatialIndices as well 744 - char *errMsg = NULL; 745 - int ret; 746 - int i; 747 - char **results; 748 - int rows; 749 - int columns; 750 - sqlite3 *sqlite = MainFrame->GetSqlite (); 751 - sql = wxT ("SELECT f_geometry_column, spatial_index_enabled "); 752 - sql += wxT ("FROM geometry_columns WHERE f_table_name = '"); 753 - sql += obj->GetName (); 754 - sql += wxT ("'"); 755 - ret = sqlite3_get_table (sqlite, sql.ToUTF8 (), &results, 756 - &rows, &columns, &errMsg); 757 - if (ret != SQLITE_OK) 758 - { 759 - wxMessageBox (wxT ("SQLite SQL error: ") + 760 - wxString::FromUTF8 (errMsg), 761 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 762 - this); 763 - sqlite3_free (errMsg); 764 - return; 765 - } 766 - sql = wxT ("BEGIN; "); 767 - if (rows < 1) 768 - ; 769 - else 770 - { 771 - for (i = 1; i <= rows; i++) 772 - { 773 - if (results[(i * columns) + 0]) 774 - { 775 - const char *column = 776 - results[(i * columns) + 0]; 777 - wxString geo_column = 778 - wxString::FromUTF8 (column); 779 - if (atoi (results[(i * columns) + 1])) 780 - { 781 - // dropping the SpatialIndex 782 - sql += 783 - wxT ("DROP TABLE IF EXISTS idx_"); 784 - sql += obj->GetName (); 785 - sql += wxT ("_"); 786 - sql += geo_column; 787 - sql += wxT ("; "); 788 - // dropping the MBR cache 789 - sql += 790 - wxT ("DROP TABLE IF EXISTS cache_"); 791 - sql += obj->GetName (); 792 - sql += wxT ("_"); 793 - sql += geo_column; 794 - sql += wxT ("; "); 795 - } 796 - // deleting from geometry_columns 797 - sql += 798 - wxT 799 - ("DELETE FROM geometry_columns\n WHERE f_table_name = '"); 800 - sql += obj->GetName (); 801 - sql += 802 - wxT 803 - ("'\n AND f_geometry_column = '"); 804 - sql += geo_column; 805 - sql += wxT ("'; "); 806 - } 807 - } 808 - } 809 - sqlite3_free_table (results); 810 - sql += wxT ("DROP TABLE IF EXISTS "); 811 - sql += obj->GetName (); 812 - sql += wxT ("; COMMIT;"); 813 - } 814 - else 815 - { 816 - // there are no SpatialMetadata at all; we'll simply try to drop the table 817 - sql = wxT ("BEGIN; "); 818 - sql += wxT ("DROP TABLE IF EXISTS "); 819 - sql += obj->GetName (); 820 - sql += wxT ("; COMMIT;"); 821 - } 822 - msg = wxT ("Do you really intend to drop the Table named: '"); 823 - msg += obj->GetName (); 824 - msg += wxT ("'\n[and any other related object] ?"); 825 - } 826 - if (obj->GetType () == MY_VIEW) 827 - { 828 - msg = wxT ("Do you really intend to drop the View named: '"); 829 - msg += obj->GetName (); 830 - msg += wxT ("' ?"); 831 - sql = wxT ("BEGIN; DROP VIEW IF EXISTS "); 832 - sql += obj->GetName (); 833 - sql += wxT ("; COMMIT;"); 834 - } 835 - if (obj->GetType () == MY_INDEX) 836 - { 837 - sql = wxT ("BEGIN; DROP INDEX IF EXISTS "); 838 - sql += obj->GetName (); 839 - sql += wxT ("; COMMIT;"); 840 - } 841 - if (obj->GetType () == MY_TRIGGER) 842 - { 843 - msg = wxT ("Do you really intend to drop the Index named: '"); 844 - msg += obj->GetName (); 845 - msg += wxT ("' ?"); 846 - sql = wxT ("BEGIN; DROP TRIGGER IF EXISTS "); 847 - sql += obj->GetName (); 848 - sql += wxT ("; COMMIT;"); 849 - } 850 - if (sql.Len () < 1) 851 - return; 852 - wxMessageDialog confirm (this, msg, wxT ("Confirming DROP"), 853 - wxOK | wxCANCEL | wxICON_QUESTION); 854 - ret = confirm.ShowModal (); 855 - if (ret != wxID_OK) 856 - return; 857 - ::wxBeginBusyCursor (); 858 - ret = sqlite3_exec (sqlite, sql.ToUTF8 (), NULL, NULL, &errMsg); 859 - if (ret != SQLITE_OK) 860 - { 861 - wxMessageBox (wxT ("SQLite SQL error: ") + 862 - wxString::FromUTF8 (errMsg), 863 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, this); 864 - sqlite3_free (errMsg); 865 - ::wxEndBusyCursor (); 866 - goto rollback; 867 - } 868 - ::wxEndBusyCursor (); 869 - wxMessageBox (wxT ("Selected object '") + obj->GetName () + 870 - wxT ("' was successfully removed"), 871 - wxT ("spatialite-gui"), wxOK | wxICON_INFORMATION, this); 872 - MainFrame->ClearTableTree (); 873 - MainFrame->InitTableTree (); 874 - return; 875 - rollback: 876 - ret = sqlite3_exec (sqlite, "ROLLBACK", NULL, NULL, &errMsg); 877 - if (ret != SQLITE_OK) 878 - { 879 - wxMessageBox (wxT ("SQLite SQL error: ") + 880 - wxString::FromUTF8 (errMsg), wxT ("spatialite-gui"), 881 - wxOK | wxICON_ERROR, this); 882 - sqlite3_free (errMsg); 883 - ::wxEndBusyCursor (); 884 - return; 885 - } 886 - ::wxEndBusyCursor (); 887 - wxMessageBox (wxT 888 - ("An error occurred\n\na ROLLBACK was automatically performed"), 889 - wxT ("spatialite-gui"), wxOK | wxICON_WARNING, this); 890 -} 891 - 892 -void 893 -MyTableTree::OnCmdRename (wxCommandEvent & event) 695 + wxString sql; 696 + wxString msg; 697 + char *errMsg = NULL; 698 + int ret; 699 + sqlite3 *sqlite = MainFrame->GetSqlite(); 700 + MyObject *obj = (MyObject *) GetItemData(CurrentItem); 701 + if (obj == NULL) 702 + return; 703 + if (obj->GetType() == MY_TABLE || obj->GetType() == MY_VTABLE) 704 + { 705 + bool metadata = MainFrame->CheckMetadata(); 706 + if (metadata == true) 707 + { 708 + // SpatialMetadata exists; we must check for geometry_columns and SpatialIndices as well 709 + char *errMsg = NULL; 710 + int ret; 711 + int i; 712 + char **results; 713 + int rows; 714 + int columns; 715 + sqlite3 *sqlite = MainFrame->GetSqlite(); 716 + sql = wxT("SELECT f_geometry_column, spatial_index_enabled "); 717 + sql += wxT("FROM geometry_columns WHERE f_table_name = '"); 718 + sql += obj->GetName(); 719 + sql += wxT("'"); 720 + ret = 721 + sqlite3_get_table(sqlite, sql.ToUTF8(), &results, &rows, &columns, 722 + &errMsg); 723 + if (ret != SQLITE_OK) 724 + { 725 + wxMessageBox(wxT("SQLite SQL error: ") + 726 + wxString::FromUTF8(errMsg), wxT("spatialite-gui"), 727 + wxOK | wxICON_ERROR, this); 728 + sqlite3_free(errMsg); 729 + return; 730 + } 731 + sql = wxT("BEGIN; "); 732 + if (rows < 1) 733 + ; 734 + else 735 + { 736 + for (i = 1; i <= rows; i++) 737 + { 738 + if (results[(i * columns) + 0]) 739 + { 740 + const char *column = results[(i * columns) + 0]; 741 + wxString geo_column = wxString::FromUTF8(column); 742 + if (atoi(results[(i * columns) + 1])) 743 + { 744 + // dropping the SpatialIndex 745 + sql += wxT("DROP TABLE IF EXISTS \"idx_"); 746 + sql += obj->GetName(); 747 + sql += wxT("_"); 748 + sql += geo_column; 749 + sql += wxT("\"; "); 750 + // dropping the MBR cache 751 + sql += wxT("DROP TABLE IF EXISTS \"cache_"); 752 + sql += obj->GetName(); 753 + sql += wxT("_"); 754 + sql += geo_column; 755 + sql += wxT("\"; "); 756 + } 757 + // deleting from geometry_columns 758 + sql += 759 + wxT 760 + ("DELETE FROM geometry_columns\n WHERE f_table_name = '"); 761 + sql += obj->GetName(); 762 + sql += wxT("'\n AND f_geometry_column = '"); 763 + sql += geo_column; 764 + sql += wxT("'; "); 765 + } 766 + } 767 + } 768 + sqlite3_free_table(results); 769 + sql += wxT("DROP TABLE IF EXISTS \""); 770 + sql += obj->GetName(); 771 + sql += wxT("\"; COMMIT;"); 772 + } else 773 + { 774 + // there are no SpatialMetadata at all; we'll simply try to drop the table 775 + sql = wxT("BEGIN; "); 776 + sql += wxT("DROP TABLE IF EXISTS \""); 777 + sql += obj->GetName(); 778 + sql += wxT("\"; COMMIT;"); 779 + } 780 + msg = wxT("Do you really intend to drop the Table named: \""); 781 + msg += obj->GetName(); 782 + msg += wxT("\"\n[and any other related object] ?"); 783 + } 784 + if (obj->GetType() == MY_VIEW) 785 + { 786 + msg = wxT("Do you really intend to drop the View named: \""); 787 + msg += obj->GetName(); 788 + msg += wxT("\" ?"); 789 + sql = wxT("BEGIN; DROP VIEW IF EXISTS \""); 790 + sql += obj->GetName(); 791 + sql += wxT("\"; COMMIT;"); 792 + } 793 + if (obj->GetType() == MY_INDEX) 794 + { 795 + sql = wxT("BEGIN; DROP INDEX IF EXISTS \""); 796 + sql += obj->GetName(); 797 + sql += wxT("\"; COMMIT;"); 798 + } 799 + if (obj->GetType() == MY_TRIGGER) 800 + { 801 + msg = wxT("Do you really intend to drop the Index named: \""); 802 + msg += obj->GetName(); 803 + msg += wxT("\" ?"); 804 + sql = wxT("BEGIN; DROP TRIGGER IF EXISTS \""); 805 + sql += obj->GetName(); 806 + sql += wxT("\"; COMMIT;"); 807 + } 808 + if (sql.Len() < 1) 809 + return; 810 + wxMessageDialog confirm(this, msg, wxT("Confirming DROP"), 811 + wxOK | wxCANCEL | wxICON_QUESTION); 812 + ret = confirm.ShowModal(); 813 + if (ret != wxID_OK) 814 + return; 815 + ::wxBeginBusyCursor(); 816 + ret = sqlite3_exec(sqlite, sql.ToUTF8(), NULL, NULL, &errMsg); 817 + if (ret != SQLITE_OK) 818 + { 819 + wxMessageBox(wxT("SQLite SQL error: ") + wxString::FromUTF8(errMsg), 820 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 821 + sqlite3_free(errMsg); 822 + ::wxEndBusyCursor(); 823 + goto rollback; 824 + } 825 + ::wxEndBusyCursor(); 826 + wxMessageBox(wxT("Selected object '") + obj->GetName() + 827 + wxT("' was successfully removed"), wxT("spatialite-gui"), 828 + wxOK | wxICON_INFORMATION, this); 829 + MainFrame->InitTableTree(); 830 + return; 831 +rollback: 832 + ret = sqlite3_exec(sqlite, "ROLLBACK", NULL, NULL, &errMsg); 833 + if (ret != SQLITE_OK) 834 + { 835 + wxMessageBox(wxT("SQLite SQL error: ") + wxString::FromUTF8(errMsg), 836 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 837 + sqlite3_free(errMsg); 838 + ::wxEndBusyCursor(); 839 + return; 840 + } 841 + ::wxEndBusyCursor(); 842 + wxMessageBox(wxT 843 + ("An error occurred\n\na ROLLBACK was automatically performed"), 844 + wxT("spatialite-gui"), wxOK | wxICON_WARNING, this); 845 +} 846 + 847 +void MyTableTree::OnCmdRename(wxCommandEvent & event) 894 848 { 895 849 // 896 850 // menu event - table renaming required 897 851 // 898 - wxString sql; 899 - MyObject *obj = (MyObject *) GetItemData (CurrentItem); 900 - if (obj == NULL) 901 - return; 902 - if (obj->GetType () == MY_TABLE || obj->GetType () == MY_VTABLE) 903 - { 904 - sql = wxT ("ALTER TABLE "); 905 - sql += obj->GetName (); 906 - sql += wxT ("\nRENAME TO ...new-table-name..."); 907 - MainFrame->SetSql (sql, false); 908 - } 852 + wxString sql; 853 + MyObject *obj = (MyObject *) GetItemData(CurrentItem); 854 + if (obj == NULL) 855 + return; 856 + if (obj->GetType() == MY_TABLE || obj->GetType() == MY_VTABLE) 857 + { 858 + sql = wxT("ALTER TABLE \""); 859 + sql += obj->GetName(); 860 + sql += wxT("\"\nRENAME TO ...new-table-name..."); 861 + MainFrame->SetSql(sql, false); 862 + } 909 863 } 910 864 911 -void 912 -MyTableTree::OnCmdRefresh (wxCommandEvent & event) 865 +void MyTableTree::OnCmdRefresh(wxCommandEvent & event) 913 866 { 914 867 // 915 868 // menu event - refreshing the Tree 916 869 // 917 - MainFrame->ClearTableTree (); 918 - MainFrame->InitTableTree (); 870 + MainFrame->InitTableTree(); 919 871 } 920 872 921 -void 922 -MyTableTree::OnCmdRecover (wxCommandEvent & event) 873 +void MyTableTree::OnCmdRecover(wxCommandEvent & event) 923 874 { 924 875 // 925 876 // menu event - Recover Geometry 926 877 // 927 - char *errMsg = NULL; 928 - int ret; 929 - wxString sql; 930 - int i; 931 - char **results; 932 - int rows; 933 - int columns; 934 - int retval = 0; 935 - int srid = -1; 936 - wxString strSrid; 937 - wxString type; 938 - RecoverDialog dlg; 939 - sqlite3 *sqlite = MainFrame->GetSqlite (); 940 - MyObject *obj = (MyObject *) GetItemData (CurrentItem); 941 - if (obj == NULL) 942 - return; 943 - if (obj->GetType () == MY_COLUMN) 944 - { 945 - // trying to recover a geometry column 946 - if (MainFrame->CheckMetadata () == false) 947 - { 948 - wxMessageBox (wxT 949 - ("Missing Spatial Metadata tables\n\ntry to run the 'init_spatialite.sql' script ..."), 950 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 951 - this); 952 - return; 953 - } 954 - dlg.Create (MainFrame, obj->GetName (), obj->GetColumn ()); 955 - ret = dlg.ShowModal (); 956 - if (ret == wxID_OK) 957 - { 958 - srid = dlg.GetSrid (); 959 - type = dlg.GetType (); 960 - ::wxBeginBusyCursor (); 961 - ret = sqlite3_exec (sqlite, "BEGIN", NULL, NULL, &errMsg); 962 - if (ret != SQLITE_OK) 963 - { 964 - wxMessageBox (wxT ("SQLite SQL error: ") + 965 - wxString::FromUTF8 (errMsg), 966 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 967 - this); 968 - sqlite3_free (errMsg); 969 - ::wxEndBusyCursor (); 970 - return; 971 - } 972 - sql = wxT ("SELECT RecoverGeometryColumn('"); 973 - sql += obj->GetName (); 974 - sql += wxT ("', '"); 975 - sql += obj->GetColumn (); 976 - strSrid.Printf (wxT ("', %d, '"), srid); 977 - sql += strSrid; 978 - sql += type; 979 - sql += wxT ("', 2)"); 980 - ret = sqlite3_get_table (sqlite, sql.ToUTF8 (), &results, 981 - &rows, &columns, &errMsg); 982 - if (ret != SQLITE_OK) 983 - { 984 - wxMessageBox (wxT ("SQLite SQL error: ") + 985 - wxString::FromUTF8 (errMsg), 986 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 987 - this); 988 - sqlite3_free (errMsg); 989 - goto rollback; 990 - } 991 - if (rows < 1) 992 - ; 993 - else 994 - { 995 - for (i = 1; i <= rows; i++) 996 - { 997 - if (results[(i * columns) + 0]) 998 - retval = atoi (results[(i * columns) + 0]); 999 - } 1000 - } 1001 - sqlite3_free_table (results); 1002 - if (!retval) 1003 - goto rollback; 1004 - ret = sqlite3_exec (sqlite, "COMMIT", NULL, NULL, &errMsg); 1005 - if (ret != SQLITE_OK) 1006 - { 1007 - wxMessageBox (wxT ("SQLite SQL error: ") + 1008 - wxString::FromUTF8 (errMsg), 1009 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 1010 - this); 1011 - sqlite3_free (errMsg); 1012 - ::wxEndBusyCursor (); 1013 - return; 1014 - } 1015 - ::wxEndBusyCursor (); 1016 - wxMessageBox (wxT ("Geometry column '") + obj->GetName () + 1017 - wxT (".") + obj->GetColumn () + 1018 - wxT ("' was successfully recovered"), 1019 - wxT ("spatialite-gui"), wxOK | wxICON_INFORMATION, 1020 - this); 1021 - } 1022 - } 1023 - return; 1024 - rollback: 1025 - ret = sqlite3_exec (sqlite, "ROLLBACK", NULL, NULL, &errMsg); 1026 - if (ret != SQLITE_OK) 1027 - { 1028 - wxMessageBox (wxT ("SQLite SQL error: ") + 1029 - wxString::FromUTF8 (errMsg), wxT ("spatialite-gui"), 1030 - wxOK | wxICON_ERROR, this); 1031 - sqlite3_free (errMsg); 1032 - ::wxEndBusyCursor (); 1033 - return; 1034 - } 1035 - ::wxEndBusyCursor (); 1036 - wxMessageBox (wxT 1037 - ("Geometry column doesn't satisfies required constraints\n\na ROLLBACK was automatically performed"), 1038 - wxT ("spatialite-gui"), wxOK | wxICON_WARNING, this); 878 + char *errMsg = NULL; 879 + int ret; 880 + wxString sql; 881 + int i; 882 + char **results; 883 + int rows; 884 + int columns; 885 + int retval = 0; 886 + int srid = -1; 887 + char dummy[128]; 888 + wxString type; 889 + RecoverDialog dlg; 890 + sqlite3 *sqlite = MainFrame->GetSqlite(); 891 + MyObject *obj = (MyObject *) GetItemData(CurrentItem); 892 + if (obj == NULL) 893 + return; 894 + if (obj->GetType() == MY_COLUMN) 895 + { 896 + // trying to recover a geometry column 897 + if (MainFrame->CheckMetadata() == false) 898 + { 899 + wxMessageBox(wxT 900 + ("Missing Spatial Metadata tables\n\ntry to run the 'init_spatialite.sql' script ..."), 901 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 902 + return; 903 + } 904 + dlg.Create(MainFrame, obj->GetName(), obj->GetColumn()); 905 + ret = dlg.ShowModal(); 906 + if (ret == wxID_OK) 907 + { 908 + srid = dlg.GetSrid(); 909 + type = dlg.GetType(); 910 + ::wxBeginBusyCursor(); 911 + ret = sqlite3_exec(sqlite, "BEGIN", NULL, NULL, &errMsg); 912 + if (ret != SQLITE_OK) 913 + { 914 + wxMessageBox(wxT("SQLite SQL error: ") + 915 + wxString::FromUTF8(errMsg), wxT("spatialite-gui"), 916 + wxOK | wxICON_ERROR, this); 917 + sqlite3_free(errMsg); 918 + ::wxEndBusyCursor(); 919 + return; 920 + } 921 + sql = wxT("SELECT RecoverGeometryColumn('"); 922 + sql += obj->GetName(); 923 + sql += wxT("', '"); 924 + sql += obj->GetColumn(); 925 + sprintf(dummy, "', %d, '", srid); 926 + sql += wxString::FromUTF8(dummy); 927 + sql += type; 928 + sql += wxT("', 2)"); 929 + ret = 930 + sqlite3_get_table(sqlite, sql.ToUTF8(), &results, &rows, &columns, 931 + &errMsg); 932 + if (ret != SQLITE_OK) 933 + { 934 + wxMessageBox(wxT("SQLite SQL error: ") + 935 + wxString::FromUTF8(errMsg), wxT("spatialite-gui"), 936 + wxOK | wxICON_ERROR, this); 937 + sqlite3_free(errMsg); 938 + goto rollback; 939 + } 940 + if (rows < 1) 941 + ; 942 + else 943 + { 944 + for (i = 1; i <= rows; i++) 945 + { 946 + if (results[(i * columns) + 0]) 947 + retval = atoi(results[(i * columns) + 0]); 948 + } 949 + } 950 + sqlite3_free_table(results); 951 + if (!retval) 952 + goto rollback; 953 + ret = sqlite3_exec(sqlite, "COMMIT", NULL, NULL, &errMsg); 954 + if (ret != SQLITE_OK) 955 + { 956 + wxMessageBox(wxT("SQLite SQL error: ") + 957 + wxString::FromUTF8(errMsg), wxT("spatialite-gui"), 958 + wxOK | wxICON_ERROR, this); 959 + sqlite3_free(errMsg); 960 + ::wxEndBusyCursor(); 961 + return; 962 + } 963 + ::wxEndBusyCursor(); 964 + wxMessageBox(wxT("Geometry column \"") + obj->GetName() + 965 + wxT(".") + obj->GetColumn() + 966 + wxT("\" was successfully recovered"), 967 + wxT("spatialite-gui"), wxOK | wxICON_INFORMATION, this); 968 + } 969 + } 970 + return; 971 +rollback: 972 + ret = sqlite3_exec(sqlite, "ROLLBACK", NULL, NULL, &errMsg); 973 + if (ret != SQLITE_OK) 974 + { 975 + wxMessageBox(wxT("SQLite SQL error: ") + wxString::FromUTF8(errMsg), 976 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 977 + sqlite3_free(errMsg); 978 + ::wxEndBusyCursor(); 979 + return; 980 + } 981 + ::wxEndBusyCursor(); 982 + wxMessageBox(wxT 983 + ("Geometry column doesn't satisfies required constraints\n\na ROLLBACK was automatically performed"), 984 + wxT("spatialite-gui"), wxOK | wxICON_WARNING, this); 1039 985 } 1040 986 1041 -void 1042 -MyTableTree::OnCmdShowSql (wxCommandEvent & event) 987 +void MyTableTree::OnCmdShowSql(wxCommandEvent & event) 1043 988 { 1044 989 // 1045 990 // menu event - Showing CREATE TABLE statement 1046 991 // 1047 - wxString sql; 1048 - MyObject *obj = (MyObject *) GetItemData (CurrentItem); 1049 - if (obj == NULL) 1050 - return; 1051 - if (obj->GetType () == MY_TABLE || obj->GetType () == MY_VTABLE) 1052 - { 1053 - sql = 1054 - wxT 1055 - ("SELECT sql FROM sqlite_master\nWHERE type = 'table' AND name = '"); 1056 - sql += obj->GetName (); 1057 - sql += wxT ("'"); 1058 - MainFrame->SetSql (sql, true); 1059 - } 1060 - if (obj->GetType () == MY_VIEW) 1061 - { 1062 - sql = 1063 - wxT 1064 - ("SELECT sql FROM sqlite_master\nWHERE type = 'view' AND name = '"); 1065 - sql += obj->GetName (); 1066 - sql += wxT ("'"); 1067 - MainFrame->SetSql (sql, true); 1068 - } 992 + wxString sql; 993 + MyObject *obj = (MyObject *) GetItemData(CurrentItem); 994 + if (obj == NULL) 995 + return; 996 + if (obj->GetType() == MY_TABLE || obj->GetType() == MY_VTABLE) 997 + { 998 + sql = 999 + wxT("SELECT sql FROM sqlite_master\nWHERE type = 'table' AND name = '"); 1000 + sql += obj->GetName(); 1001 + sql += wxT("'"); 1002 + MainFrame->SetSql(sql, true); 1003 + } 1004 + if (obj->GetType() == MY_VIEW) 1005 + { 1006 + sql = 1007 + wxT("SELECT sql FROM sqlite_master\nWHERE type = 'view' AND name = '"); 1008 + sql += obj->GetName(); 1009 + sql += wxT("'"); 1010 + MainFrame->SetSql(sql, true); 1011 + } 1069 1012 } 1070 1013 1071 -void 1072 -MyTableTree::OnCmdSpatialIndex (wxCommandEvent & event) 1014 +void MyTableTree::OnCmdSpatialIndex(wxCommandEvent & event) 1073 1015 { 1074 1016 // 1075 1017 // menu event - Spatial Index creation-destruction 1076 1018 // 1077 - char *errMsg = NULL; 1078 - int ret; 1079 - wxString sql; 1080 - wxString msg; 1081 - int i; 1082 - char **results; 1083 - int rows; 1084 - int columns; 1085 - int retval = 0; 1086 - sqlite3 *sqlite = MainFrame->GetSqlite (); 1087 - MyObject *obj = (MyObject *) GetItemData (CurrentItem); 1088 - if (obj == NULL) 1089 - return; 1090 - if (obj->GetType () == MY_GEOMETRY) 1091 - { 1092 - // creating the Spatial Index 1093 - ::wxBeginBusyCursor (); 1094 - ret = sqlite3_exec (sqlite, "BEGIN", NULL, NULL, &errMsg); 1095 - if (ret != SQLITE_OK) 1096 - { 1097 - wxMessageBox (wxT ("SQLite SQL error: ") + 1098 - wxString::FromUTF8 (errMsg), 1099 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 1100 - this); 1101 - sqlite3_free (errMsg); 1102 - ::wxEndBusyCursor (); 1103 - return; 1104 - } 1105 - sql = wxT ("SELECT CreateSpatialIndex('"); 1106 - sql += obj->GetName (); 1107 - sql += wxT ("', '"); 1108 - sql += obj->GetColumn (); 1109 - sql += wxT ("')"); 1110 - ret = sqlite3_get_table (sqlite, sql.ToUTF8 (), &results, 1111 - &rows, &columns, &errMsg); 1112 - if (ret != SQLITE_OK) 1113 - { 1114 - wxMessageBox (wxT ("SQLite SQL error: ") + 1115 - wxString::FromUTF8 (errMsg), 1116 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 1117 - this); 1118 - sqlite3_free (errMsg); 1119 - goto rollback; 1120 - } 1121 - if (rows < 1) 1122 - ; 1123 - else 1124 - { 1125 - for (i = 1; i <= rows; i++) 1126 - { 1127 - if (results[(i * columns) + 0]) 1128 - retval = atoi (results[(i * columns) + 0]); 1129 - } 1130 - } 1131 - sqlite3_free_table (results); 1132 - if (!retval) 1133 - goto rollback; 1134 - ret = sqlite3_exec (sqlite, "COMMIT", NULL, NULL, &errMsg); 1135 - if (ret != SQLITE_OK) 1136 - { 1137 - wxMessageBox (wxT ("SQLite SQL error: ") + 1138 - wxString::FromUTF8 (errMsg), 1139 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 1140 - this); 1141 - sqlite3_free (errMsg); 1142 - ::wxEndBusyCursor (); 1143 - return; 1144 - } 1145 - ::wxEndBusyCursor (); 1146 - wxMessageBox (wxT ("Spatial Index idx_") + obj->GetName () + 1147 - wxT ("_") + obj->GetColumn () + 1148 - wxT (" was successfully created"), 1149 - wxT ("spatialite-gui"), wxOK | wxICON_INFORMATION, 1150 - this); 1151 - MainFrame->ClearTableTree (); 1152 - MainFrame->InitTableTree (); 1153 - } 1154 - else if (obj->GetType () == MY_GEOMETRY_INDEX) 1155 - { 1156 - // dropping the Spatial Index 1157 - ::wxBeginBusyCursor (); 1158 - ret = sqlite3_exec (sqlite, "BEGIN", NULL, NULL, &errMsg); 1159 - if (ret != SQLITE_OK) 1160 - { 1161 - wxMessageBox (wxT ("SQLite SQL error: ") + 1162 - wxString::FromUTF8 (errMsg), 1163 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 1164 - this); 1165 - sqlite3_free (errMsg); 1166 - ::wxEndBusyCursor (); 1167 - return; 1168 - } 1169 - sql = wxT ("SELECT DisableSpatialIndex('"); 1170 - sql += obj->GetName (); 1171 - sql += wxT ("', '"); 1172 - sql += obj->GetColumn (); 1173 - sql += wxT ("')"); 1174 - msg = wxT ("Do you really intend to delete the SpatialIndex\n"); 1175 - msg += wxT ("on column '"); 1176 - msg += obj->GetName (); 1177 - msg += wxT ("."); 1178 - msg += obj->GetColumn (); 1179 - msg += wxT ("' ?"); 1180 - wxMessageDialog confirm (this, msg, 1181 - wxT ("Confirming Delete Spatial Index"), 1182 - wxOK | wxCANCEL | wxICON_QUESTION); 1183 - ret = confirm.ShowModal (); 1184 - if (ret != wxID_OK) 1185 - return; 1186 - ret = sqlite3_get_table (sqlite, sql.ToUTF8 (), &results, 1187 - &rows, &columns, &errMsg); 1188 - if (ret != SQLITE_OK) 1189 - { 1190 - wxMessageBox (wxT ("SQLite SQL error: ") + 1191 - wxString::FromUTF8 (errMsg), 1192 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 1193 - this); 1194 - sqlite3_free (errMsg); 1195 - goto rollback; 1196 - } 1197 - if (rows < 1) 1198 - ; 1199 - else 1200 - { 1201 - for (i = 1; i <= rows; i++) 1202 - { 1203 - if (results[(i * columns) + 0]) 1204 - retval = atoi (results[(i * columns) + 0]); 1205 - } 1206 - } 1207 - sqlite3_free_table (results); 1208 - if (!retval) 1209 - goto rollback; 1210 - sql = wxT ("DROP TABLE IF EXISTS idx_"); 1211 - sql += obj->GetName (); 1212 - sql += wxT ("_"); 1213 - sql += obj->GetColumn (); 1214 - ret = sqlite3_exec (sqlite, sql.ToUTF8 (), NULL, NULL, &errMsg); 1215 - if (ret != SQLITE_OK) 1216 - { 1217 - wxMessageBox (wxT ("SQLite SQL error: ") + 1218 - wxString::FromUTF8 (errMsg), 1219 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 1220 - this); 1221 - sqlite3_free (errMsg); 1222 - ::wxEndBusyCursor (); 1223 - return; 1224 - } 1225 - ret = sqlite3_exec (sqlite, "COMMIT", NULL, NULL, &errMsg); 1226 - if (ret != SQLITE_OK) 1227 - { 1228 - wxMessageBox (wxT ("SQLite SQL error: ") + 1229 - wxString::FromUTF8 (errMsg), 1230 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 1231 - this); 1232 - sqlite3_free (errMsg); 1233 - ::wxEndBusyCursor (); 1234 - return; 1235 - } 1236 - ::wxEndBusyCursor (); 1237 - wxMessageBox (wxT ("Spatial Index idx_") + obj->GetName () + 1238 - wxT ("_") + obj->GetColumn () + 1239 - wxT (" was successfully removed"), 1240 - wxT ("spatialite-gui"), wxOK | wxICON_INFORMATION, 1241 - this); 1242 - MainFrame->ClearTableTree (); 1243 - MainFrame->InitTableTree (); 1244 - } 1019 + char *errMsg = NULL; 1020 + int ret; 1021 + wxString sql; 1022 + wxString msg; 1023 + int i; 1024 + char **results; 1025 + int rows; 1026 + int columns; 1027 + int retval = 0; 1028 + sqlite3 *sqlite = MainFrame->GetSqlite(); 1029 + MyObject *obj = (MyObject *) GetItemData(CurrentItem); 1030 + if (obj == NULL) 1245 1031 return; 1246 - rollback: 1247 - ret = sqlite3_exec (sqlite, "ROLLBACK", NULL, NULL, &errMsg); 1248 - if (ret != SQLITE_OK) 1249 - { 1250 - wxMessageBox (wxT ("SQLite SQL error: ") + 1251 - wxString::FromUTF8 (errMsg), wxT ("spatialite-gui"), 1252 - wxOK | wxICON_ERROR, this); 1253 - sqlite3_free (errMsg); 1254 - ::wxEndBusyCursor (); 1255 - return; 1256 - } 1257 - ::wxEndBusyCursor (); 1258 - wxMessageBox (wxT 1259 - ("An error occurred\n\na ROLLBACK was automatically performed"), 1260 - wxT ("spatialite-gui"), wxOK | wxICON_WARNING, this); 1032 + if (obj->GetType() == MY_GEOMETRY) 1033 + { 1034 + // creating the Spatial Index 1035 + ::wxBeginBusyCursor(); 1036 + ret = sqlite3_exec(sqlite, "BEGIN", NULL, NULL, &errMsg); 1037 + if (ret != SQLITE_OK) 1038 + { 1039 + wxMessageBox(wxT("SQLite SQL error: ") + wxString::FromUTF8(errMsg), 1040 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 1041 + sqlite3_free(errMsg); 1042 + ::wxEndBusyCursor(); 1043 + return; 1044 + } 1045 + sql = wxT("SELECT CreateSpatialIndex('"); 1046 + sql += obj->GetName(); 1047 + sql += wxT("', '"); 1048 + sql += obj->GetColumn(); 1049 + sql += wxT("')"); 1050 + ret = 1051 + sqlite3_get_table(sqlite, sql.ToUTF8(), &results, &rows, &columns, 1052 + &errMsg); 1053 + if (ret != SQLITE_OK) 1054 + { 1055 + wxMessageBox(wxT("SQLite SQL error: ") + wxString::FromUTF8(errMsg), 1056 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 1057 + sqlite3_free(errMsg); 1058 + goto rollback; 1059 + } 1060 + if (rows < 1) 1061 + ; 1062 + else 1063 + { 1064 + for (i = 1; i <= rows; i++) 1065 + { 1066 + if (results[(i * columns) + 0]) 1067 + retval = atoi(results[(i * columns) + 0]); 1068 + } 1069 + } 1070 + sqlite3_free_table(results); 1071 + if (!retval) 1072 + goto rollback; 1073 + ret = sqlite3_exec(sqlite, "COMMIT", NULL, NULL, &errMsg); 1074 + if (ret != SQLITE_OK) 1075 + { 1076 + wxMessageBox(wxT("SQLite SQL error: ") + wxString::FromUTF8(errMsg), 1077 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 1078 + sqlite3_free(errMsg); 1079 + ::wxEndBusyCursor(); 1080 + return; 1081 + } 1082 + ::wxEndBusyCursor(); 1083 + wxMessageBox(wxT("Spatial Index \"idx_") + obj->GetName() + 1084 + wxT("_") + obj->GetColumn() + 1085 + wxT("\" was successfully created"), wxT("spatialite-gui"), 1086 + wxOK | wxICON_INFORMATION, this); 1087 + MainFrame->InitTableTree(); 1088 + } else if (obj->GetType() == MY_GEOMETRY_INDEX) 1089 + { 1090 + // dropping the Spatial Index 1091 + ::wxBeginBusyCursor(); 1092 + ret = sqlite3_exec(sqlite, "BEGIN", NULL, NULL, &errMsg); 1093 + if (ret != SQLITE_OK) 1094 + { 1095 + wxMessageBox(wxT("SQLite SQL error: ") + wxString::FromUTF8(errMsg), 1096 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 1097 + sqlite3_free(errMsg); 1098 + ::wxEndBusyCursor(); 1099 + return; 1100 + } 1101 + sql = wxT("SELECT DisableSpatialIndex('"); 1102 + sql += obj->GetName(); 1103 + sql += wxT("', '"); 1104 + sql += obj->GetColumn(); 1105 + sql += wxT("')"); 1106 + msg = wxT("Do you really intend to delete the SpatialIndex\n"); 1107 + msg += wxT("on column \""); 1108 + msg += obj->GetName(); 1109 + msg += wxT("\".\""); 1110 + msg += obj->GetColumn(); 1111 + msg += wxT("\" ?"); 1112 + wxMessageDialog confirm(this, msg, wxT("Confirming Delete Spatial Index"), 1113 + wxOK | wxCANCEL | wxICON_QUESTION); 1114 + ret = confirm.ShowModal(); 1115 + if (ret != wxID_OK) 1116 + return; 1117 + ret = 1118 + sqlite3_get_table(sqlite, sql.ToUTF8(), &results, &rows, &columns, 1119 + &errMsg); 1120 + if (ret != SQLITE_OK) 1121 + { 1122 + wxMessageBox(wxT("SQLite SQL error: ") + wxString::FromUTF8(errMsg), 1123 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 1124 + sqlite3_free(errMsg); 1125 + goto rollback; 1126 + } 1127 + if (rows < 1) 1128 + ; 1129 + else 1130 + { 1131 + for (i = 1; i <= rows; i++) 1132 + { 1133 + if (results[(i * columns) + 0]) 1134 + retval = atoi(results[(i * columns) + 0]); 1135 + } 1136 + } 1137 + sqlite3_free_table(results); 1138 + if (!retval) 1139 + goto rollback; 1140 + sql = wxT("DROP TABLE IF EXISTS \"idx_"); 1141 + sql += obj->GetName(); 1142 + sql += wxT("_"); 1143 + sql += obj->GetColumn(); 1144 + sql += wxT("\""); 1145 + ret = sqlite3_exec(sqlite, sql.ToUTF8(), NULL, NULL, &errMsg); 1146 + if (ret != SQLITE_OK) 1147 + { 1148 + wxMessageBox(wxT("SQLite SQL error: ") + wxString::FromUTF8(errMsg), 1149 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 1150 + sqlite3_free(errMsg); 1151 + ::wxEndBusyCursor(); 1152 + return; 1153 + } 1154 + ret = sqlite3_exec(sqlite, "COMMIT", NULL, NULL, &errMsg); 1155 + if (ret != SQLITE_OK) 1156 + { 1157 + wxMessageBox(wxT("SQLite SQL error: ") + wxString::FromUTF8(errMsg), 1158 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 1159 + sqlite3_free(errMsg); 1160 + ::wxEndBusyCursor(); 1161 + return; 1162 + } 1163 + ::wxEndBusyCursor(); 1164 + wxMessageBox(wxT("Spatial Index idx_") + obj->GetName() + 1165 + wxT("_") + obj->GetColumn() + 1166 + wxT(" was successfully removed"), wxT("spatialite-gui"), 1167 + wxOK | wxICON_INFORMATION, this); 1168 + MainFrame->InitTableTree(); 1169 + } 1170 + return; 1171 +rollback: 1172 + ret = sqlite3_exec(sqlite, "ROLLBACK", NULL, NULL, &errMsg); 1173 + if (ret != SQLITE_OK) 1174 + { 1175 + wxMessageBox(wxT("SQLite SQL error: ") + wxString::FromUTF8(errMsg), 1176 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 1177 + sqlite3_free(errMsg); 1178 + ::wxEndBusyCursor(); 1179 + return; 1180 + } 1181 + ::wxEndBusyCursor(); 1182 + wxMessageBox(wxT 1183 + ("An error occurred\n\na ROLLBACK was automatically performed"), 1184 + wxT("spatialite-gui"), wxOK | wxICON_WARNING, this); 1261 1185 } 1262 1186 1263 -void 1264 -MyTableTree::OnCmdMbrCache (wxCommandEvent & event) 1187 +void MyTableTree::OnCmdMbrCache(wxCommandEvent & event) 1265 1188 { 1266 1189 // 1267 1190 // menu event - MBR cache creation-destruction 1268 1191 // 1269 - char *errMsg = NULL; 1270 - int ret; 1271 - wxString sql; 1272 - wxString msg; 1273 - int i; 1274 - char **results; 1275 - int rows; 1276 - int columns; 1277 - int retval = 0; 1278 - sqlite3 *sqlite = MainFrame->GetSqlite (); 1279 - MyObject *obj = (MyObject *) GetItemData (CurrentItem); 1280 - if (obj == NULL) 1281 - return; 1282 - if (obj->GetType () == MY_GEOMETRY) 1283 - { 1284 - // creating the MBR cache 1285 - ::wxBeginBusyCursor (); 1286 - ret = sqlite3_exec (sqlite, "BEGIN", NULL, NULL, &errMsg); 1287 - if (ret != SQLITE_OK) 1288 - { 1289 - wxMessageBox (wxT ("SQLite SQL error: ") + 1290 - wxString::FromUTF8 (errMsg), 1291 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 1292 - this); 1293 - sqlite3_free (errMsg); 1294 - ::wxEndBusyCursor (); 1295 - return; 1296 - } 1297 - sql = wxT ("SELECT CreateMbrCache('"); 1298 - sql += obj->GetName (); 1299 - sql += wxT ("', '"); 1300 - sql += obj->GetColumn (); 1301 - sql += wxT ("')"); 1302 - ret = sqlite3_get_table (sqlite, sql.ToUTF8 (), &results, 1303 - &rows, &columns, &errMsg); 1304 - if (ret != SQLITE_OK) 1305 - { 1306 - wxMessageBox (wxT ("SQLite SQL error: ") + 1307 - wxString::FromUTF8 (errMsg), 1308 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 1309 - this); 1310 - sqlite3_free (errMsg); 1311 - goto rollback; 1312 - } 1313 - if (rows < 1) 1314 - ; 1315 - else 1316 - { 1317 - for (i = 1; i <= rows; i++) 1318 - { 1319 - if (results[(i * columns) + 0]) 1320 - retval = atoi (results[(i * columns) + 0]); 1321 - } 1322 - } 1323 - sqlite3_free_table (results); 1324 - if (!retval) 1325 - goto rollback; 1326 - ret = sqlite3_exec (sqlite, "COMMIT", NULL, NULL, &errMsg); 1327 - if (ret != SQLITE_OK) 1328 - { 1329 - wxMessageBox (wxT ("SQLite SQL error: ") + 1330 - wxString::FromUTF8 (errMsg), 1331 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 1332 - this); 1333 - sqlite3_free (errMsg); 1334 - ::wxEndBusyCursor (); 1335 - return; 1336 - } 1337 - ::wxEndBusyCursor (); 1338 - wxMessageBox (wxT ("MBR cache cache_") + obj->GetName () + 1339 - wxT ("_") + obj->GetColumn () + 1340 - wxT (" was successfully created"), 1341 - wxT ("spatialite-gui"), wxOK | wxICON_INFORMATION, 1342 - this); 1343 - MainFrame->ClearTableTree (); 1344 - MainFrame->InitTableTree (); 1345 - } 1346 - else if (obj->GetType () == MY_GEOMETRY_CACHED) 1347 - { 1348 - // dropping the MBR cache 1349 - ::wxBeginBusyCursor (); 1350 - ret = sqlite3_exec (sqlite, "BEGIN", NULL, NULL, &errMsg); 1351 - if (ret != SQLITE_OK) 1352 - { 1353 - wxMessageBox (wxT ("SQLite SQL error: ") + 1354 - wxString::FromUTF8 (errMsg), 1355 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 1356 - this); 1357 - sqlite3_free (errMsg); 1358 - ::wxEndBusyCursor (); 1359 - return; 1360 - } 1361 - sql = wxT ("SELECT DisableSpatialIndex('"); 1362 - sql += obj->GetName (); 1363 - sql += wxT ("', '"); 1364 - sql += obj->GetColumn (); 1365 - sql += wxT ("')"); 1366 - msg = wxT ("Do you really intend to delete the MBR cache\n"); 1367 - msg += wxT ("on column '"); 1368 - msg += obj->GetName (); 1369 - msg += wxT ("."); 1370 - msg += obj->GetColumn (); 1371 - msg += wxT ("' ?"); 1372 - wxMessageDialog confirm (this, msg, 1373 - wxT ("Confirming Delete MBR cache"), 1374 - wxOK | wxCANCEL | wxICON_QUESTION); 1375 - ret = confirm.ShowModal (); 1376 - if (ret != wxID_OK) 1377 - return; 1378 - ret = sqlite3_get_table (sqlite, sql.ToUTF8 (), &results, 1379 - &rows, &columns, &errMsg); 1380 - if (ret != SQLITE_OK) 1381 - { 1382 - wxMessageBox (wxT ("SQLite SQL error: ") + 1383 - wxString::FromUTF8 (errMsg), 1384 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 1385 - this); 1386 - sqlite3_free (errMsg); 1387 - goto rollback; 1388 - } 1389 - if (rows < 1) 1390 - ; 1391 - else 1392 - { 1393 - for (i = 1; i <= rows; i++) 1394 - { 1395 - if (results[(i * columns) + 0]) 1396 - retval = atoi (results[(i * columns) + 0]); 1397 - } 1398 - } 1399 - sqlite3_free_table (results); 1400 - if (!retval) 1401 - goto rollback; 1402 - sql = wxT ("DROP TABLE IF EXISTS cache_"); 1403 - sql += obj->GetName (); 1404 - sql += wxT ("_"); 1405 - sql += obj->GetColumn (); 1406 - ret = sqlite3_exec (sqlite, sql.ToUTF8 (), NULL, NULL, &errMsg); 1407 - if (ret != SQLITE_OK) 1408 - { 1409 - wxMessageBox (wxT ("SQLite SQL error: ") + 1410 - wxString::FromUTF8 (errMsg), 1411 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 1412 - this); 1413 - sqlite3_free (errMsg); 1414 - ::wxEndBusyCursor (); 1415 - return; 1416 - } 1417 - ret = sqlite3_exec (sqlite, "COMMIT", NULL, NULL, &errMsg); 1418 - if (ret != SQLITE_OK) 1419 - { 1420 - wxMessageBox (wxT ("SQLite SQL error: ") + 1421 - wxString::FromUTF8 (errMsg), 1422 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 1423 - this); 1424 - sqlite3_free (errMsg); 1425 - ::wxEndBusyCursor (); 1426 - return; 1427 - } 1428 - ::wxEndBusyCursor (); 1429 - wxMessageBox (wxT ("MBR cache cache_") + obj->GetName () + 1430 - wxT ("_") + obj->GetColumn () + 1431 - wxT (" was successfully removed"), 1432 - wxT ("spatialite-gui"), wxOK | wxICON_INFORMATION, 1433 - this); 1434 - MainFrame->ClearTableTree (); 1435 - MainFrame->InitTableTree (); 1436 - } 1192 + char *errMsg = NULL; 1193 + int ret; 1194 + wxString sql; 1195 + wxString msg; 1196 + int i; 1197 + char **results; 1198 + int rows; 1199 + int columns; 1200 + int retval = 0; 1201 + sqlite3 *sqlite = MainFrame->GetSqlite(); 1202 + MyObject *obj = (MyObject *) GetItemData(CurrentItem); 1203 + if (obj == NULL) 1204 + return; 1205 + if (obj->GetType() == MY_GEOMETRY) 1206 + { 1207 + // creating the MBR cache 1208 + ::wxBeginBusyCursor(); 1209 + ret = sqlite3_exec(sqlite, "BEGIN", NULL, NULL, &errMsg); 1210 + if (ret != SQLITE_OK) 1211 + { 1212 + wxMessageBox(wxT("SQLite SQL error: ") + wxString::FromUTF8(errMsg), 1213 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 1214 + sqlite3_free(errMsg); 1215 + ::wxEndBusyCursor(); 1216 + return; 1217 + } 1218 + sql = wxT("SELECT CreateMbrCache('"); 1219 + sql += obj->GetName(); 1220 + sql += wxT("', '"); 1221 + sql += obj->GetColumn(); 1222 + sql += wxT("')"); 1223 + ret = 1224 + sqlite3_get_table(sqlite, sql.ToUTF8(), &results, &rows, &columns, 1225 + &errMsg); 1226 + if (ret != SQLITE_OK) 1227 + { 1228 + wxMessageBox(wxT("SQLite SQL error: ") + wxString::FromUTF8(errMsg), 1229 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 1230 + sqlite3_free(errMsg); 1231 + goto rollback; 1232 + } 1233 + if (rows < 1) 1234 + ; 1235 + else 1236 + { 1237 + for (i = 1; i <= rows; i++) 1238 + { 1239 + if (results[(i * columns) + 0]) 1240 + retval = atoi(results[(i * columns) + 0]); 1241 + } 1242 + } 1243 + sqlite3_free_table(results); 1244 + if (!retval) 1245 + goto rollback; 1246 + ret = sqlite3_exec(sqlite, "COMMIT", NULL, NULL, &errMsg); 1247 + if (ret != SQLITE_OK) 1248 + { 1249 + wxMessageBox(wxT("SQLite SQL error: ") + wxString::FromUTF8(errMsg), 1250 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 1251 + sqlite3_free(errMsg); 1252 + ::wxEndBusyCursor(); 1253 + return; 1254 + } 1255 + ::wxEndBusyCursor(); 1256 + wxMessageBox(wxT("MBR cache \"cache_") + obj->GetName() + 1257 + wxT("_") + obj->GetColumn() + 1258 + wxT("\" was successfully created"), wxT("spatialite-gui"), 1259 + wxOK | wxICON_INFORMATION, this); 1260 + MainFrame->InitTableTree(); 1261 + } else if (obj->GetType() == MY_GEOMETRY_CACHED) 1262 + { 1263 + // dropping the MBR cache 1264 + ::wxBeginBusyCursor(); 1265 + ret = sqlite3_exec(sqlite, "BEGIN", NULL, NULL, &errMsg); 1266 + if (ret != SQLITE_OK) 1267 + { 1268 + wxMessageBox(wxT("SQLite SQL error: ") + wxString::FromUTF8(errMsg), 1269 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 1270 + sqlite3_free(errMsg); 1271 + ::wxEndBusyCursor(); 1272 + return; 1273 + } 1274 + sql = wxT("SELECT DisableSpatialIndex('"); 1275 + sql += obj->GetName(); 1276 + sql += wxT("', '"); 1277 + sql += obj->GetColumn(); 1278 + sql += wxT("')"); 1279 + msg = wxT("Do you really intend to delete the MBR cache\n"); 1280 + msg += wxT("on column \""); 1281 + msg += obj->GetName(); 1282 + msg += wxT("\".\""); 1283 + msg += obj->GetColumn(); 1284 + msg += wxT("\" ?"); 1285 + wxMessageDialog confirm(this, msg, wxT("Confirming Delete MBR cache"), 1286 + wxOK | wxCANCEL | wxICON_QUESTION); 1287 + ret = confirm.ShowModal(); 1288 + if (ret != wxID_OK) 1289 + return; 1290 + ret = 1291 + sqlite3_get_table(sqlite, sql.ToUTF8(), &results, &rows, &columns, 1292 + &errMsg); 1293 + if (ret != SQLITE_OK) 1294 + { 1295 + wxMessageBox(wxT("SQLite SQL error: ") + wxString::FromUTF8(errMsg), 1296 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 1297 + sqlite3_free(errMsg); 1298 + goto rollback; 1299 + } 1300 + if (rows < 1) 1301 + ; 1302 + else 1303 + { 1304 + for (i = 1; i <= rows; i++) 1305 + { 1306 + if (results[(i * columns) + 0]) 1307 + retval = atoi(results[(i * columns) + 0]); 1308 + } 1309 + } 1310 + sqlite3_free_table(results); 1311 + if (!retval) 1312 + goto rollback; 1313 + sql = wxT("DROP TABLE IF EXISTS \"cache_"); 1314 + sql += obj->GetName(); 1315 + sql += wxT("_"); 1316 + sql += obj->GetColumn(); 1317 + sql += wxT("\""); 1318 + ret = sqlite3_exec(sqlite, sql.ToUTF8(), NULL, NULL, &errMsg); 1319 + if (ret != SQLITE_OK) 1320 + { 1321 + wxMessageBox(wxT("SQLite SQL error: ") + wxString::FromUTF8(errMsg), 1322 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 1323 + sqlite3_free(errMsg); 1324 + ::wxEndBusyCursor(); 1325 + return; 1326 + } 1327 + ret = sqlite3_exec(sqlite, "COMMIT", NULL, NULL, &errMsg); 1328 + if (ret != SQLITE_OK) 1329 + { 1330 + wxMessageBox(wxT("SQLite SQL error: ") + wxString::FromUTF8(errMsg), 1331 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 1332 + sqlite3_free(errMsg); 1333 + ::wxEndBusyCursor(); 1334 + return; 1335 + } 1336 + ::wxEndBusyCursor(); 1337 + wxMessageBox(wxT("MBR cache \"cache_") + obj->GetName() + 1338 + wxT("_") + obj->GetColumn() + 1339 + wxT("\" was successfully removed"), wxT("spatialite-gui"), 1340 + wxOK | wxICON_INFORMATION, this); 1341 + MainFrame->InitTableTree(); 1342 + } 1343 + return; 1344 +rollback: 1345 + ret = sqlite3_exec(sqlite, "ROLLBACK", NULL, NULL, &errMsg); 1346 + if (ret != SQLITE_OK) 1347 + { 1348 + wxMessageBox(wxT("SQLite SQL error: ") + wxString::FromUTF8(errMsg), 1349 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 1350 + sqlite3_free(errMsg); 1351 + ::wxEndBusyCursor(); 1352 + return; 1353 + } 1354 + ::wxEndBusyCursor(); 1355 + wxMessageBox(wxT 1356 + ("An error occurred\n\na ROLLBACK was automatically performed"), 1357 + wxT("spatialite-gui"), wxOK | wxICON_WARNING, this); 1358 +} 1359 + 1360 +void MyTableTree::OnCmdRebuildTriggers(wxCommandEvent & event) 1361 +{ 1362 +// 1363 +// menu event - rebuilding Geometry Triggers 1364 +// 1365 + wxString sql; 1366 + MyObject *obj = (MyObject *) GetItemData(CurrentItem); 1367 + if (obj == NULL) 1437 1368 return; 1438 - rollback: 1439 - ret = sqlite3_exec (sqlite, "ROLLBACK", NULL, NULL, &errMsg); 1440 - if (ret != SQLITE_OK) 1441 - { 1442 - wxMessageBox (wxT ("SQLite SQL error: ") + 1443 - wxString::FromUTF8 (errMsg), wxT ("spatialite-gui"), 1444 - wxOK | wxICON_ERROR, this); 1445 - sqlite3_free (errMsg); 1446 - ::wxEndBusyCursor (); 1447 - return; 1448 - } 1449 - ::wxEndBusyCursor (); 1450 - wxMessageBox (wxT 1451 - ("An error occurred\n\na ROLLBACK was automatically performed"), 1452 - wxT ("spatialite-gui"), wxOK | wxICON_WARNING, this); 1369 + if (obj->GetType() == MY_COLUMN || obj->GetType() == MY_GEOMETRY 1370 + || obj->GetType() == MY_GEOMETRY_INDEX 1371 + || obj->GetType() == MY_GEOMETRY_CACHED) 1372 + { 1373 + sql = wxT("SELECT RebuildGeometryTriggers('"); 1374 + sql += obj->GetName(); 1375 + sql += wxT("', '"); 1376 + sql += obj->GetColumn(); 1377 + sql += wxT("')"); 1378 + MainFrame->SetSql(sql, true); 1379 + } 1453 1380 } 1454 1381 1455 -void 1456 -MyTableTree::OnCmdCheckGeometry (wxCommandEvent & event) 1382 +void MyTableTree::OnCmdCheckGeometry(wxCommandEvent & event) 1457 1383 { 1458 1384 // 1459 1385 // menu event - checking geometries 1460 1386 // 1461 - wxString sql; 1462 - MyObject *obj = (MyObject *) GetItemData (CurrentItem); 1463 - if (obj == NULL) 1464 - return; 1465 - if (obj->GetType () == MY_COLUMN) 1466 - { 1467 - sql = wxT ("SELECT Count(*), GeometryType("); 1468 - sql += obj->GetColumn (); 1469 - sql += wxT ("), Srid("); 1470 - sql += obj->GetColumn (); 1471 - sql += wxT (")\nFROM "); 1472 - sql += obj->GetName (); 1473 - sql += wxT ("\nGROUP BY 2, 3"); 1474 - MainFrame->SetSql (sql, true); 1475 - } 1387 + wxString sql; 1388 + MyObject *obj = (MyObject *) GetItemData(CurrentItem); 1389 + if (obj == NULL) 1390 + return; 1391 + if (obj->GetType() == MY_COLUMN || obj->GetType() == MY_GEOMETRY 1392 + || obj->GetType() == MY_GEOMETRY_INDEX 1393 + || obj->GetType() == MY_GEOMETRY_CACHED) 1394 + { 1395 + sql = wxT("SELECT Count(*), GeometryType(\""); 1396 + sql += obj->GetColumn(); 1397 + sql += wxT("\"), Srid(\""); 1398 + sql += obj->GetColumn(); 1399 + sql += wxT("\")\nFROM \""); 1400 + sql += obj->GetName(); 1401 + sql += wxT("\"\nGROUP BY 2, 3"); 1402 + MainFrame->SetSql(sql, true); 1403 + } 1476 1404 } 1477 1405 1478 -void 1479 -MyTableTree::OnCmdSetSrid (wxCommandEvent & event) 1406 +void MyTableTree::OnCmdSetSrid(wxCommandEvent & event) 1480 1407 { 1481 1408 // 1482 1409 // menu event - setting SRID for geometries 1483 1410 // 1484 - SetSridDialog dlg; 1485 - wxString sql; 1486 - wxString strSrid; 1487 - int srid; 1488 - int oldSrid; 1489 - int ret; 1490 - MyObject *obj = (MyObject *) GetItemData (CurrentItem); 1491 - if (obj == NULL) 1492 - return; 1493 - if (obj->GetType () == MY_COLUMN) 1494 - { 1495 - dlg.Create (MainFrame, obj->GetName (), obj->GetColumn ()); 1496 - ret = dlg.ShowModal (); 1497 - if (ret == wxID_OK) 1498 - { 1499 - srid = dlg.GetSrid (); 1500 - oldSrid = dlg.GetOldSrid (); 1501 - sql = wxT ("UPDATE "); 1502 - sql += obj->GetName (); 1503 - sql += wxT (" SET "); 1504 - sql += obj->GetColumn (); 1505 - sql += wxT (" = SetSrid("); 1506 - sql += obj->GetColumn (); 1507 - strSrid.Printf (wxT (", %d)"), srid); 1508 - sql += strSrid; 1509 - sql += wxT ("\nWHERE Srid("); 1510 - sql += obj->GetColumn (); 1511 - strSrid.Printf (wxT (") = %d"), oldSrid); 1512 - sql += strSrid; 1513 - MainFrame->SetSql (sql, true); 1514 - } 1515 - } 1411 + SetSridDialog dlg; 1412 + wxString sql; 1413 + int srid; 1414 + int oldSrid; 1415 + int ret; 1416 + char dummy[128]; 1417 + MyObject *obj = (MyObject *) GetItemData(CurrentItem); 1418 + if (obj == NULL) 1419 + return; 1420 + if (obj->GetType() == MY_COLUMN) 1421 + { 1422 + dlg.Create(MainFrame, obj->GetName(), obj->GetColumn()); 1423 + ret = dlg.ShowModal(); 1424 + if (ret == wxID_OK) 1425 + { 1426 + srid = dlg.GetSrid(); 1427 + oldSrid = dlg.GetOldSrid(); 1428 + sql = wxT("UPDATE "); 1429 + sql += obj->GetName(); 1430 + sql += wxT(" SET "); 1431 + sql += obj->GetColumn(); 1432 + sql += wxT(" = SetSrid("); 1433 + sql += obj->GetColumn(); 1434 + sprintf(dummy, ", %d)", srid); 1435 + sql += wxString::FromUTF8(dummy); 1436 + sql += wxT("\nWHERE Srid("); 1437 + sql += obj->GetColumn(); 1438 + sprintf(dummy, ") = %d", oldSrid); 1439 + sql += wxString::FromUTF8(dummy); 1440 + MainFrame->SetSql(sql, true); 1441 + } 1442 + } 1516 1443 } 1517 1444 1518 -void 1519 -MyTableTree::OnCmdDumpShp (wxCommandEvent & event) 1445 +void MyTableTree::OnCmdDumpShp(wxCommandEvent & event) 1520 1446 { 1521 1447 // 1522 1448 // menu event - dumping as Shapefile 1523 1449 // 1524 - int ret; 1525 - wxString path; 1526 - wxString lastDir; 1527 - MyObject *obj = (MyObject *) GetItemData (CurrentItem); 1528 - if (obj == NULL) 1529 - return; 1530 - if (obj->GetType () == MY_GEOMETRY || obj->GetType () == MY_GEOMETRY_INDEX) 1531 - { 1532 - wxFileDialog *fileDialog = 1533 - new wxFileDialog (this, wxT ("Dump Shapefile"), 1534 - wxT (""), wxT ("shapefile.shp"), 1535 - wxT 1536 - ("Shapefile (*.shp)|*.shp|All files (*.*)|*.*"), 1537 - wxFD_SAVE | wxFD_OVERWRITE_PROMPT, 1538 - wxDefaultPosition, wxDefaultSize, 1539 - wxT ("filedlg")); 1540 - lastDir = MainFrame->GetLastDirectory (); 1541 - if (lastDir.Len () >= 1) 1542 - fileDialog->SetDirectory (lastDir); 1543 - ret = fileDialog->ShowModal (); 1544 - if (ret == wxID_OK) 1545 - { 1450 + int ret; 1451 + wxString path; 1452 + wxString lastDir; 1453 + MyObject *obj = (MyObject *) GetItemData(CurrentItem); 1454 + if (obj == NULL) 1455 + return; 1456 + if (obj->GetType() == MY_GEOMETRY || obj->GetType() == MY_GEOMETRY_INDEX 1457 + || obj->GetType() == MY_GEOMETRY_CACHED) 1458 + { 1459 + wxFileDialog *fileDialog = new wxFileDialog(this, wxT("Dump Shapefile"), 1460 + wxT(""), wxT("shapefile.shp"), 1461 + wxT 1462 + ("Shapefile (*.shp)|*.shp|All files (*.*)|*.*"), 1463 + wxFD_SAVE | 1464 + wxFD_OVERWRITE_PROMPT, 1465 + wxDefaultPosition, 1466 + wxDefaultSize, 1467 + wxT("filedlg")); 1468 + lastDir = MainFrame->GetLastDirectory(); 1469 + if (lastDir.Len() >= 1) 1470 + fileDialog->SetDirectory(lastDir); 1471 + ret = fileDialog->ShowModal(); 1472 + if (ret == wxID_OK) 1473 + { 1546 1474 1547 - wxFileName file (fileDialog->GetPath ()); 1548 - path = file.GetPath (); 1549 - path += file.GetPathSeparator (); 1550 - path += file.GetName (); 1551 - lastDir = file.GetPath (); 1552 - if (MainFrame->IsSetAskCharset () == false) 1553 - { 1554 - // using the default output charset 1555 - MainFrame->SetLastDirectory (lastDir); 1556 - ::wxBeginBusyCursor (); 1557 - MainFrame->DumpShapefile (path, obj->GetName (), 1558 - obj->GetColumn (), 1559 - MainFrame->GetDefaultCharset 1560 - ()); 1561 - ::wxEndBusyCursor (); 1562 - } 1563 - else 1564 - { 1565 - // asking the charset to be used 1566 - DumpShpDialog dlg; 1567 - dlg.Create (MainFrame, path, obj->GetName (), 1568 - obj->GetColumn (), 1569 - MainFrame->GetDefaultCharset ()); 1570 - ret = dlg.ShowModal (); 1571 - if (ret == wxID_OK) 1572 - { 1573 - MainFrame->SetLastDirectory (lastDir); 1574 - ::wxBeginBusyCursor (); 1575 - MainFrame->DumpShapefile (path, obj->GetName (), 1576 - obj->GetColumn (), 1577 - dlg.GetCharset ()); 1578 - ::wxEndBusyCursor (); 1579 - } 1580 - } 1581 - } 1582 - } 1475 + wxFileName file(fileDialog->GetPath()); 1476 + path = file.GetPath(); 1477 + path += file.GetPathSeparator(); 1478 + path += file.GetName(); 1479 + lastDir = file.GetPath(); 1480 + if (MainFrame->IsSetAskCharset() == false) 1481 + { 1482 + // using the default output charset 1483 + MainFrame->SetLastDirectory(lastDir); 1484 + ::wxBeginBusyCursor(); 1485 + MainFrame->DumpShapefile(path, obj->GetName(), obj->GetColumn(), 1486 + MainFrame->GetDefaultCharset()); 1487 + ::wxEndBusyCursor(); 1488 + } else 1489 + { 1490 + // asking the charset to be used 1491 + DumpShpDialog dlg; 1492 + dlg.Create(MainFrame, path, obj->GetName(), obj->GetColumn(), 1493 + MainFrame->GetDefaultCharset()); 1494 + ret = dlg.ShowModal(); 1495 + if (ret == wxID_OK) 1496 + { 1497 + MainFrame->SetLastDirectory(lastDir); 1498 + ::wxBeginBusyCursor(); 1499 + MainFrame->DumpShapefile(path, obj->GetName(), 1500 + obj->GetColumn(), dlg.GetCharset()); 1501 + ::wxEndBusyCursor(); 1502 + } 1503 + } 1504 + } 1505 + } 1583 1506 } 1584 1507 1585 -void 1586 -MyTableTree::OnCmdDumpTxtTab (wxCommandEvent & event) 1508 +void MyTableTree::OnCmdDumpTxtTab(wxCommandEvent & event) 1587 1509 { 1588 1510 // 1589 1511 // menu event - dumping as TxtTab 1590 1512 // 1591 - int ret; 1592 - wxString path; 1593 - wxString lastDir; 1594 - wxString target; 1595 - MyObject *obj = (MyObject *) GetItemData (CurrentItem); 1596 - if (obj == NULL) 1597 - return; 1598 - wxFileDialog *fileDialog = 1599 - new wxFileDialog (this, wxT ("Dump Txt/Tab file"), 1600 - wxT (""), wxT ("table.txt"), 1601 - wxT 1602 - ("File Txt/Tab (*.txt)|*.txt|All files (*.*)|*.*"), 1603 - wxFD_SAVE | wxFD_OVERWRITE_PROMPT, wxDefaultPosition, 1604 - wxDefaultSize, wxT ("filedlg")); 1605 - lastDir = MainFrame->GetLastDirectory (); 1606 - if (lastDir.Len () >= 1) 1607 - fileDialog->SetDirectory (lastDir); 1608 - ret = fileDialog->ShowModal (); 1609 - if (ret == wxID_OK) 1610 - { 1611 - wxFileName file (fileDialog->GetPath ()); 1612 - path = file.GetPath (); 1613 - path += file.GetPathSeparator (); 1614 - path += file.GetName (); 1615 - path += wxT (".txt"); 1616 - lastDir = file.GetPath (); 1617 - if (MainFrame->IsSetAskCharset () == false) 1618 - { 1619 - // using the default output charset 1620 - MainFrame->SetLastDirectory (lastDir); 1621 - ::wxBeginBusyCursor (); 1622 - MainFrame->DumpTxtTab (path, obj->GetName (), 1623 - MainFrame->GetDefaultCharset ()); 1624 - ::wxEndBusyCursor (); 1625 - } 1626 - else 1627 - { 1628 - // asking the charset to be used 1629 - DumpTxtDialog dlg; 1630 - target = wxT ("TXT / TAB"); 1631 - dlg.Create (MainFrame, path, target, 1632 - MainFrame->GetDefaultCharset ()); 1633 - ret = dlg.ShowModal (); 1634 - if (ret == wxID_OK) 1635 - { 1636 - MainFrame->SetLastDirectory (lastDir); 1637 - ::wxBeginBusyCursor (); 1638 - MainFrame->DumpTxtTab (path, obj->GetName (), 1639 - dlg.GetCharset ()); 1640 - ::wxEndBusyCursor (); 1641 - } 1642 - } 1643 - } 1513 + int ret; 1514 + wxString path; 1515 + wxString lastDir; 1516 + wxString target; 1517 + MyObject *obj = (MyObject *) GetItemData(CurrentItem); 1518 + if (obj == NULL) 1519 + return; 1520 + wxFileDialog *fileDialog = new wxFileDialog(this, wxT("Dump Txt/Tab file"), 1521 + wxT(""), wxT("table.txt"), 1522 + wxT 1523 + ("File Txt/Tab (*.txt)|*.txt|All files (*.*)|*.*"), 1524 + wxFD_SAVE | wxFD_OVERWRITE_PROMPT, 1525 + wxDefaultPosition, 1526 + wxDefaultSize, wxT("filedlg")); 1527 + lastDir = MainFrame->GetLastDirectory(); 1528 + if (lastDir.Len() >= 1) 1529 + fileDialog->SetDirectory(lastDir); 1530 + ret = fileDialog->ShowModal(); 1531 + if (ret == wxID_OK) 1532 + { 1533 + wxFileName file(fileDialog->GetPath()); 1534 + path = file.GetPath(); 1535 + path += file.GetPathSeparator(); 1536 + path += file.GetName(); 1537 + path += wxT(".txt"); 1538 + lastDir = file.GetPath(); 1539 + if (MainFrame->IsSetAskCharset() == false) 1540 + { 1541 + // using the default output charset 1542 + MainFrame->SetLastDirectory(lastDir); 1543 + ::wxBeginBusyCursor(); 1544 + MainFrame->DumpTxtTab(path, obj->GetName(), 1545 + MainFrame->GetDefaultCharset()); 1546 + ::wxEndBusyCursor(); 1547 + } else 1548 + { 1549 + // asking the charset to be used 1550 + DumpTxtDialog dlg; 1551 + target = wxT("TXT / TAB"); 1552 + dlg.Create(MainFrame, path, target, MainFrame->GetDefaultCharset()); 1553 + ret = dlg.ShowModal(); 1554 + if (ret == wxID_OK) 1555 + { 1556 + MainFrame->SetLastDirectory(lastDir); 1557 + ::wxBeginBusyCursor(); 1558 + MainFrame->DumpTxtTab(path, obj->GetName(), dlg.GetCharset()); 1559 + ::wxEndBusyCursor(); 1560 + } 1561 + } 1562 + } 1644 1563 } 1645 1564 1646 -void 1647 -MyTableTree::OnCmdDumpCsv (wxCommandEvent & event) 1565 +void MyTableTree::OnCmdDumpCsv(wxCommandEvent & event) 1648 1566 { 1649 1567 // 1650 1568 // menu event - dumping as CSV 1651 1569 // 1652 - int ret; 1653 - wxString path; 1654 - wxString lastDir; 1655 - wxString target; 1656 - MyObject *obj = (MyObject *) GetItemData (CurrentItem); 1657 - if (obj == NULL) 1658 - return; 1659 - wxFileDialog *fileDialog = new wxFileDialog (this, wxT ("Dump CSV file"), 1660 - wxT (""), wxT ("table.csv"), 1661 - wxT 1662 - ("File CSV (*.csv)|*.csv|All files (*.*)|*.*"), 1663 - wxFD_SAVE | 1664 - wxFD_OVERWRITE_PROMPT, 1665 - wxDefaultPosition, 1666 - wxDefaultSize, 1667 - wxT ("filedlg")); 1668 - lastDir = MainFrame->GetLastDirectory (); 1669 - if (lastDir.Len () >= 1) 1670 - fileDialog->SetDirectory (lastDir); 1671 - ret = fileDialog->ShowModal (); 1672 - if (ret == wxID_OK) 1673 - { 1674 - wxFileName file (fileDialog->GetPath ()); 1675 - path = file.GetPath (); 1676 - path += file.GetPathSeparator (); 1677 - path += file.GetName (); 1678 - path += wxT (".csv"); 1679 - lastDir = file.GetPath (); 1680 - if (MainFrame->IsSetAskCharset () == false) 1681 - { 1682 - // using the default output charset 1683 - MainFrame->SetLastDirectory (lastDir); 1684 - ::wxBeginBusyCursor (); 1685 - MainFrame->DumpCsv (path, obj->GetName (), 1686 - MainFrame->GetDefaultCharset ()); 1687 - ::wxEndBusyCursor (); 1688 - } 1689 - else 1690 - { 1691 - // asking the charset to be used 1692 - DumpTxtDialog dlg; 1693 - target = wxT ("CSV"); 1694 - dlg.Create (MainFrame, path, target, 1695 - MainFrame->GetDefaultCharset ()); 1696 - ret = dlg.ShowModal (); 1697 - if (ret == wxID_OK) 1698 - { 1699 - MainFrame->SetLastDirectory (lastDir); 1700 - ::wxBeginBusyCursor (); 1701 - MainFrame->DumpCsv (path, obj->GetName (), 1702 - dlg.GetCharset ()); 1703 - ::wxEndBusyCursor (); 1704 - } 1705 - } 1706 - } 1570 + int ret; 1571 + wxString path; 1572 + wxString lastDir; 1573 + wxString target; 1574 + MyObject *obj = (MyObject *) GetItemData(CurrentItem); 1575 + if (obj == NULL) 1576 + return; 1577 + wxFileDialog *fileDialog = new wxFileDialog(this, wxT("Dump CSV file"), 1578 + wxT(""), wxT("table.csv"), 1579 + wxT 1580 + ("File CSV (*.csv)|*.csv|All files (*.*)|*.*"), 1581 + wxFD_SAVE | wxFD_OVERWRITE_PROMPT, 1582 + wxDefaultPosition, 1583 + wxDefaultSize, 1584 + wxT("filedlg")); 1585 + lastDir = MainFrame->GetLastDirectory(); 1586 + if (lastDir.Len() >= 1) 1587 + fileDialog->SetDirectory(lastDir); 1588 + ret = fileDialog->ShowModal(); 1589 + if (ret == wxID_OK) 1590 + { 1591 + wxFileName file(fileDialog->GetPath()); 1592 + path = file.GetPath(); 1593 + path += file.GetPathSeparator(); 1594 + path += file.GetName(); 1595 + path += wxT(".csv"); 1596 + lastDir = file.GetPath(); 1597 + if (MainFrame->IsSetAskCharset() == false) 1598 + { 1599 + // using the default output charset 1600 + MainFrame->SetLastDirectory(lastDir); 1601 + ::wxBeginBusyCursor(); 1602 + MainFrame->DumpCsv(path, obj->GetName(), 1603 + MainFrame->GetDefaultCharset()); 1604 + ::wxEndBusyCursor(); 1605 + } else 1606 + { 1607 + // asking the charset to be used 1608 + DumpTxtDialog dlg; 1609 + target = wxT("CSV"); 1610 + dlg.Create(MainFrame, path, target, MainFrame->GetDefaultCharset()); 1611 + ret = dlg.ShowModal(); 1612 + if (ret == wxID_OK) 1613 + { 1614 + MainFrame->SetLastDirectory(lastDir); 1615 + ::wxBeginBusyCursor(); 1616 + MainFrame->DumpCsv(path, obj->GetName(), dlg.GetCharset()); 1617 + ::wxEndBusyCursor(); 1618 + } 1619 + } 1620 + } 1707 1621 } 1708 1622 1709 -void 1710 -MyTableTree::OnCmdDumpHtml (wxCommandEvent & event) 1623 +void MyTableTree::OnCmdDumpHtml(wxCommandEvent & event) 1711 1624 { 1712 1625 // 1713 1626 // menu event - dumping as Html 1714 1627 // 1715 - int ret; 1716 - wxString path; 1717 - wxString lastDir; 1718 - wxString target; 1719 - MyObject *obj = (MyObject *) GetItemData (CurrentItem); 1720 - if (obj == NULL) 1721 - return; 1722 - wxFileDialog *fileDialog = new wxFileDialog (this, wxT ("Dump HTML file"), 1723 - wxT (""), wxT ("table.html"), 1724 - wxT 1725 - ("HTML web page (*.html)|*.html|All files (*.*)|*.*"), 1726 - wxFD_SAVE | 1727 - wxFD_OVERWRITE_PROMPT, 1728 - wxDefaultPosition, 1729 - wxDefaultSize, 1730 - wxT ("filedlg")); 1731 - lastDir = MainFrame->GetLastDirectory (); 1732 - if (lastDir.Len () >= 1) 1733 - fileDialog->SetDirectory (lastDir); 1734 - ret = fileDialog->ShowModal (); 1735 - if (ret == wxID_OK) 1736 - { 1737 - wxFileName file (fileDialog->GetPath ()); 1738 - path = file.GetPath (); 1739 - path += file.GetPathSeparator (); 1740 - path += file.GetName (); 1741 - path += wxT (".html"); 1742 - lastDir = file.GetPath (); 1743 - if (MainFrame->IsSetAskCharset () == false) 1744 - { 1745 - // using the default output charset 1746 - MainFrame->SetLastDirectory (lastDir); 1747 - ::wxBeginBusyCursor (); 1748 - MainFrame->DumpHtml (path, obj->GetName (), 1749 - MainFrame->GetDefaultCharset ()); 1750 - ::wxEndBusyCursor (); 1751 - } 1752 - else 1753 - { 1754 - // asking the charset to be used 1755 - DumpTxtDialog dlg; 1756 - target = wxT ("HTML"); 1757 - dlg.Create (MainFrame, path, target, 1758 - MainFrame->GetDefaultCharset ()); 1759 - ret = dlg.ShowModal (); 1760 - if (ret == wxID_OK) 1761 - { 1762 - MainFrame->SetLastDirectory (lastDir); 1763 - ::wxBeginBusyCursor (); 1764 - MainFrame->DumpHtml (path, obj->GetName (), 1765 - dlg.GetCharset ()); 1766 - ::wxEndBusyCursor (); 1767 - } 1768 - } 1769 - } 1628 + int ret; 1629 + wxString path; 1630 + wxString lastDir; 1631 + wxString target; 1632 + MyObject *obj = (MyObject *) GetItemData(CurrentItem); 1633 + if (obj == NULL) 1634 + return; 1635 + wxFileDialog *fileDialog = new wxFileDialog(this, wxT("Dump HTML file"), 1636 + wxT(""), wxT("table.html"), 1637 + wxT 1638 + ("HTML web page (*.html)|*.html|All files (*.*)|*.*"), 1639 + wxFD_SAVE | wxFD_OVERWRITE_PROMPT, 1640 + wxDefaultPosition, 1641 + wxDefaultSize, 1642 + wxT("filedlg")); 1643 + lastDir = MainFrame->GetLastDirectory(); 1644 + if (lastDir.Len() >= 1) 1645 + fileDialog->SetDirectory(lastDir); 1646 + ret = fileDialog->ShowModal(); 1647 + if (ret == wxID_OK) 1648 + { 1649 + wxFileName file(fileDialog->GetPath()); 1650 + path = file.GetPath(); 1651 + path += file.GetPathSeparator(); 1652 + path += file.GetName(); 1653 + path += wxT(".html"); 1654 + lastDir = file.GetPath(); 1655 + if (MainFrame->IsSetAskCharset() == false) 1656 + { 1657 + // using the default output charset 1658 + MainFrame->SetLastDirectory(lastDir); 1659 + ::wxBeginBusyCursor(); 1660 + MainFrame->DumpHtml(path, obj->GetName(), 1661 + MainFrame->GetDefaultCharset()); 1662 + ::wxEndBusyCursor(); 1663 + } else 1664 + { 1665 + // asking the charset to be used 1666 + DumpTxtDialog dlg; 1667 + target = wxT("HTML"); 1668 + dlg.Create(MainFrame, path, target, MainFrame->GetDefaultCharset()); 1669 + ret = dlg.ShowModal(); 1670 + if (ret == wxID_OK) 1671 + { 1672 + MainFrame->SetLastDirectory(lastDir); 1673 + ::wxBeginBusyCursor(); 1674 + MainFrame->DumpHtml(path, obj->GetName(), dlg.GetCharset()); 1675 + ::wxEndBusyCursor(); 1676 + } 1677 + } 1678 + } 1770 1679 } 1771 1680 1772 -void 1773 -MyTableTree::OnCmdEdit (wxCommandEvent & event) 1681 +void MyTableTree::OnCmdEdit(wxCommandEvent & event) 1774 1682 { 1775 1683 // 1776 1684 // menu event - editing row valuew 1777 1685 // 1778 - char **results; 1779 - int rows; 1780 - int columns; 1781 - int i; 1782 - char *errMsg = NULL; 1783 - wxString sql; 1784 - char *column; 1785 - char *type; 1786 - int pk = 0; 1787 - int pb = 0; 1788 - int primaryKeys[1024]; 1789 - int blobCols[1024]; 1790 - for (i = 0; i < 1024; i++) 1791 - { 1792 - primaryKeys[i] = -1; 1793 - blobCols[i] = -1; 1794 - } 1795 - primaryKeys[pk++] = 0; 1796 - MyObject *obj = (MyObject *) GetItemData (CurrentItem); 1797 - if (obj == NULL) 1798 - return; 1799 - sql = wxT ("PRAGMA table_info("); 1800 - sql += obj->GetName (); 1801 - sql += wxT (")"); 1802 - int ret = 1803 - sqlite3_get_table (MainFrame->GetSqlite (), sql.ToUTF8 (), &results, 1804 - &rows, &columns, &errMsg); 1805 - if (ret != SQLITE_OK) 1806 - { 1807 - wxMessageBox (wxT ("SQLite SQL error: ") + 1808 - wxString::FromUTF8 (errMsg), wxT ("spatialite-gui"), 1809 - wxOK | wxICON_ERROR, this); 1810 - sqlite3_free (errMsg); 1811 - return; 1812 - } 1813 - sql = wxT (""); 1814 - if (rows < 1) 1815 - ; 1816 - else 1817 - { 1818 - sql = wxT ("SELECT ROWID"); 1819 - for (i = 1; i <= rows; i++) 1820 - { 1821 - column = results[(i * columns) + 1]; 1822 - sql += wxT (", ") + wxString::FromUTF8 (column); 1823 - type = results[(i * columns) + 2]; 1824 - if (strcasecmp (type, "BLOB") == 0) 1825 - blobCols[pb++] = i; 1826 - if (atoi (results[(i * columns) + 5]) == 0) 1827 - ; 1828 - else 1829 - primaryKeys[pk++] = i; 1830 - } 1831 - } 1832 - sqlite3_free_table (results); 1833 - if (sql.Len () < 1) 1834 - return; 1835 - sql += wxT ("\nFROM "); 1836 - sql += obj->GetName (); 1837 - sql += wxT ("\nORDER BY ROWID"); 1838 - MainFrame->EditTable (sql, primaryKeys, blobCols, obj->GetName ()); 1686 + char **results; 1687 + int rows; 1688 + int columns; 1689 + int i; 1690 + char *errMsg = NULL; 1691 + wxString sql; 1692 + char *column; 1693 + char *type; 1694 + int pk = 0; 1695 + int pb = 0; 1696 + int primaryKeys[1024]; 1697 + int blobCols[1024]; 1698 + for (i = 0; i < 1024; i++) 1699 + { 1700 + primaryKeys[i] = -1; 1701 + blobCols[i] = -1; 1702 + } 1703 + primaryKeys[pk++] = 0; 1704 + MyObject *obj = (MyObject *) GetItemData(CurrentItem); 1705 + if (obj == NULL) 1706 + return; 1707 + sql = wxT("PRAGMA table_info(\""); 1708 + sql += obj->GetName(); 1709 + sql += wxT("\")"); 1710 + int ret = sqlite3_get_table(MainFrame->GetSqlite(), sql.ToUTF8(), &results, 1711 + &rows, &columns, &errMsg); 1712 + if (ret != SQLITE_OK) 1713 + { 1714 + wxMessageBox(wxT("SQLite SQL error: ") + wxString::FromUTF8(errMsg), 1715 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 1716 + sqlite3_free(errMsg); 1717 + return; 1718 + } 1719 + sql = wxT(""); 1720 + if (rows < 1) 1721 + ; 1722 + else 1723 + { 1724 + sql = wxT("SELECT ROWID"); 1725 + for (i = 1; i <= rows; i++) 1726 + { 1727 + column = results[(i * columns) + 1]; 1728 + sql += wxT(", \""); 1729 + sql += wxString::FromUTF8(column); 1730 + sql += wxT("\""); 1731 + type = results[(i * columns) + 2]; 1732 + if (strcasecmp(type, "BLOB") == 0) 1733 + blobCols[pb++] = i; 1734 + if (atoi(results[(i * columns) + 5]) == 0) 1735 + ; 1736 + else 1737 + primaryKeys[pk++] = i; 1738 + } 1739 + } 1740 + sqlite3_free_table(results); 1741 + if (sql.Len() < 1) 1742 + return; 1743 + sql += wxT("\nFROM \""); 1744 + sql += obj->GetName(); 1745 + sql += wxT("\"\nORDER BY ROWID"); 1746 + MainFrame->EditTable(sql, primaryKeys, blobCols, obj->GetName()); 1839 1747 }
Changes to TextCsv.cpp.
1 1 /* 2 2 / TextCsv.cpp 3 3 / methods related to CSV/TXT loading 4 4 / 5 -/ version 1.1, 2008 September 13 5 +/ version 1.2, 2008 October 9 6 6 / 7 7 / Author: Sandro Furieri a-furieri@lqt.it 8 8 / 9 9 / Copyright (C) 2008 Alessandro Furieri 10 10 / 11 11 / This program is free software: you can redistribute it and/or modify 12 12 / it under the terms of the GNU General Public License as published by ................................................................................ 28 28 #define VRTTXT_TEXT 1 29 29 #define VRTTXT_INTEGER 2 30 30 #define VRTTXT_DOUBLE 3 31 31 32 32 struct row_buffer 33 33 { 34 34 /* a complete row */ 35 - int n_cells; /* how many cells are stored into this line */ 36 - char **cells; /* the cells array */ 37 - struct row_buffer *next; /* pointer for linked list */ 35 + int n_cells; /* how many cells are stored into this line */ 36 + char **cells; /* the cells array */ 37 + struct row_buffer *next; /* pointer for linked list */ 38 38 }; 39 39 40 40 struct text_buffer 41 41 { 42 - int max_n_cells; /* the maximun cell index */ 43 - char **titles; /* the column titles array */ 44 - char *types; /* the column types array */ 45 - int n_rows; /* the number of rows */ 46 - struct row_buffer **rows; /* the rows array */ 47 - struct row_buffer *first; /* pointers to build a linked list of rows */ 48 - struct row_buffer *last; 42 + int max_n_cells; /* the maximun cell index */ 43 + char **titles; /* the column titles array */ 44 + char *types; /* the column types array */ 45 + int n_rows; /* the number of rows */ 46 + struct row_buffer **rows; /* the rows array */ 47 + struct row_buffer *first; /* pointers to build a linked list of rows */ 48 + struct row_buffer *last; 49 49 }; 50 50 51 -static void 52 -text_insert_row (struct text_buffer *text, char **fields, int max_cell) 51 +static void text_insert_row(struct text_buffer *text, char **fields, 52 + int max_cell) 53 53 { 54 54 /* inserting a row into the text buffer struct */ 55 - int i; 56 - struct row_buffer *row = 57 - (struct row_buffer *) malloc (sizeof (struct row_buffer)); 58 - row->n_cells = max_cell + 1; 59 - if (max_cell < 0) 60 - row->cells = NULL; 61 - else 62 - { 63 - row->cells = (char **) malloc (sizeof (char *) * (max_cell + 1)); 64 - for (i = 0; i < row->n_cells; i++) 65 - { 66 - /* setting cell values */ 67 - *(row->cells + i) = *(fields + i); 68 - } 69 - } 70 - row->next = NULL; 55 + int i; 56 + struct row_buffer *row = 57 + (struct row_buffer *) malloc(sizeof(struct row_buffer)); 58 + row->n_cells = max_cell + 1; 59 + if (max_cell < 0) 60 + row->cells = NULL; 61 + else 62 + { 63 + row->cells = (char **) malloc(sizeof(char *) * (max_cell + 1)); 64 + for (i = 0; i < row->n_cells; i++) 65 + { 66 + /* setting cell values */ 67 + *(row->cells + i) = *(fields + i); 68 + } 69 + } 70 + row->next = NULL; 71 71 /* inserting the row into the linked list */ 72 - if (!(text->first)) 73 - text->first = row; 74 - if (text->last) 75 - text->last->next = row; 76 - text->last = row; 72 + if (!(text->first)) 73 + text->first = row; 74 + if (text->last) 75 + text->last->next = row; 76 + text->last = row; 77 77 } 78 78 79 -static struct text_buffer * 80 -text_buffer_alloc () 79 +static struct text_buffer *text_buffer_alloc() 81 80 { 82 81 /* allocating and initializing the text buffer struct */ 83 - struct text_buffer *text = 84 - (struct text_buffer *) malloc (sizeof (struct text_buffer)); 85 - text->max_n_cells = 0; 86 - text->titles = NULL; 87 - text->types = NULL; 88 - text->n_rows = 0; 89 - text->rows = NULL; 90 - text->first = NULL; 91 - text->last = NULL; 92 - return text; 82 + struct text_buffer *text = 83 + (struct text_buffer *) malloc(sizeof(struct text_buffer)); 84 + text->max_n_cells = 0; 85 + text->titles = NULL; 86 + text->types = NULL; 87 + text->n_rows = 0; 88 + text->rows = NULL; 89 + text->first = NULL; 90 + text->last = NULL; 91 + return text; 93 92 } 94 93 95 -static void 96 -text_buffer_free (struct text_buffer *text) 94 +static void text_buffer_free(struct text_buffer *text) 97 95 { 98 96 /* memory cleanup - freeing the text buffer */ 99 - int i; 100 - struct row_buffer *row; 101 - if (!text) 102 - return; 103 - row = text->first; 104 - while (row) 105 - { 106 - for (i = 0; i < row->n_cells; i++) 107 - { 108 - if (*(row->cells + i)) 109 - free (*(row->cells + i)); 110 - } 111 - row = row->next; 112 - } 113 - if (text->types) 114 - free (text->types); 115 - free (text); 97 + int i; 98 + struct row_buffer *row; 99 + if (!text) 100 + return; 101 + row = text->first; 102 + while (row) 103 + { 104 + for (i = 0; i < row->n_cells; i++) 105 + { 106 + if (*(row->cells + i)) 107 + free(*(row->cells + i)); 108 + } 109 + row = row->next; 110 + } 111 + if (text->types) 112 + free(text->types); 113 + free(text); 116 114 } 117 115 118 -static int 119 -text_is_integer (char *value) 116 +static int text_is_integer(char *value) 120 117 { 121 118 /* checking if this value can be an INTEGER */ 122 - int invalids = 0; 123 - int digits = 0; 124 - int signs = 0; 125 - char last = '\0'; 126 - char *p = value; 127 - while (*p != '\0') 128 - { 129 - last = *p; 130 - if (*p >= '0' && *p <= '9') 131 - digits++; 132 - else if (*p == '+' || *p == '-') 133 - signs++; 134 - else 135 - signs++; 136 - p++; 137 - } 138 - if (invalids) 139 - return 0; 140 - if (signs > 1) 141 - return 0; 142 - if (signs) 143 - { 144 - if (*value == '+' || *value == '-' || last == '+' || last == '-') 145 - ; 146 - else 147 - return 0; 148 - } 149 - return 1; 119 + int invalids = 0; 120 + int digits = 0; 121 + int signs = 0; 122 + char last = '\0'; 123 + char *p = value; 124 + while (*p != '\0') 125 + { 126 + last = *p; 127 + if (*p >= '0' && *p <= '9') 128 + digits++; 129 + else if (*p == '+' || *p == '-') 130 + signs++; 131 + else 132 + signs++; 133 + p++; 134 + } 135 + if (invalids) 136 + return 0; 137 + if (signs > 1) 138 + return 0; 139 + if (signs) 140 + { 141 + if (*value == '+' || *value == '-' || last == '+' || last == '-') 142 + ; 143 + else 144 + return 0; 145 + } 146 + return 1; 150 147 } 151 148 152 -static int 153 -text_is_double (char *value, char decimal_separator) 149 +static int text_is_double(char *value, char decimal_separator) 154 150 { 155 151 /* checking if this value can be a DOUBLE */ 156 - int invalids = 0; 157 - int digits = 0; 158 - int signs = 0; 159 - int points = 0; 160 - char last = '\0'; 161 - char *p = value; 162 - while (*p != '\0') 163 - { 164 - last = *p; 165 - if (*p >= '0' && *p <= '9') 166 - digits++; 167 - else if (*p == '+' || *p == '-') 168 - points++; 169 - else 170 - { 171 - if (decimal_separator == ',') 172 - { 173 - if (*p == ',') 174 - points++; 175 - else 176 - invalids++; 177 - } 178 - else 179 - { 180 - if (*p == '.') 181 - points++; 182 - else 183 - invalids++; 184 - } 185 - } 186 - p++; 187 - } 188 - if (invalids) 189 - return 0; 190 - if (points > 1) 191 - return 0; 192 - if (signs > 1) 193 - return 0; 194 - if (signs) 195 - { 196 - if (*value == '+' || *value == '-' || last == '+' || last == '-') 197 - ; 198 - else 199 - return 0; 200 - } 201 - return 1; 152 + int invalids = 0; 153 + int digits = 0; 154 + int signs = 0; 155 + int points = 0; 156 + char last = '\0'; 157 + char *p = value; 158 + while (*p != '\0') 159 + { 160 + last = *p; 161 + if (*p >= '0' && *p <= '9') 162 + digits++; 163 + else if (*p == '+' || *p == '-') 164 + points++; 165 + else 166 + { 167 + if (decimal_separator == ',') 168 + { 169 + if (*p == ',') 170 + points++; 171 + else 172 + invalids++; 173 + } else 174 + { 175 + if (*p == '.') 176 + points++; 177 + else 178 + invalids++; 179 + } 180 + } 181 + p++; 182 + } 183 + if (invalids) 184 + return 0; 185 + if (points > 1) 186 + return 0; 187 + if (signs > 1) 188 + return 0; 189 + if (signs) 190 + { 191 + if (*value == '+' || *value == '-' || last == '+' || last == '-') 192 + ; 193 + else 194 + return 0; 195 + } 196 + return 1; 202 197 } 203 198 204 -static void 205 -text_clean_integer (char *value) 199 +static void text_clean_integer(char *value) 206 200 { 207 201 /* cleaning an integer value */ 208 - char last; 209 - char buffer[35536]; 210 - int len = strlen (value); 211 - last = value[len - 1]; 212 - if (last == '-' || last == '+') 213 - { 214 - /* trailing sign; transforming into a leading sign */ 215 - *buffer = last; 216 - strcpy (buffer + 1, value); 217 - buffer[len - 1] = '\0'; 218 - strcpy (value, buffer); 219 - } 202 + char last; 203 + char buffer[35536]; 204 + int len = strlen(value); 205 + last = value[len - 1]; 206 + if (last == '-' || last == '+') 207 + { 208 + /* trailing sign; transforming into a leading sign */ 209 + *buffer = last; 210 + strcpy(buffer + 1, value); 211 + buffer[len - 1] = '\0'; 212 + strcpy(value, buffer); 213 + } 220 214 } 221 215 222 -static void 223 -text_clean_double (char *value) 216 +static void text_clean_double(char *value) 224 217 { 225 218 /* cleaning an integer value */ 226 - char *p; 227 - char last; 228 - char buffer[35536]; 229 - int len = strlen (value); 230 - last = value[len - 1]; 231 - if (last == '-' || last == '+') 232 - { 233 - /* trailing sign; transforming into a leading sign */ 234 - *buffer = last; 235 - strcpy (buffer + 1, value); 236 - buffer[len - 1] = '\0'; 237 - strcpy (value, buffer); 238 - } 239 - p = value; 240 - while (*p != '\0') 241 - { 242 - /* transforming COMMAs into POINTs */ 243 - if (*p == ',') 244 - *p = '.'; 245 - p++; 246 - } 219 + char *p; 220 + char last; 221 + char buffer[35536]; 222 + int len = strlen(value); 223 + last = value[len - 1]; 224 + if (last == '-' || last == '+') 225 + { 226 + /* trailing sign; transforming into a leading sign */ 227 + *buffer = last; 228 + strcpy(buffer + 1, value); 229 + buffer[len - 1] = '\0'; 230 + strcpy(value, buffer); 231 + } 232 + p = value; 233 + while (*p != '\0') 234 + { 235 + /* transforming COMMAs into POINTs */ 236 + if (*p == ',') 237 + *p = '.'; 238 + p++; 239 + } 247 240 } 248 241 249 -static int 250 -text_clean_text (char **value, void *toUtf8) 242 +static int text_clean_text(char **value, void *toUtf8) 251 243 { 252 244 /* cleaning a TEXT value and converting to UTF-8 */ 253 - char *text = *value; 254 - char *utf8text; 255 - int err; 256 - int i; 257 - int oldlen = strlen (text); 258 - int newlen; 259 - for (i = oldlen - 1; i > 0; i++) 260 - { 261 - /* cleaning up trailing spaces */ 262 - if (text[i] == ' ') 263 - text[i] = '\0'; 264 - else 265 - break; 266 - } 267 - utf8text = gaiaConvertToUTF8 (toUtf8, text, oldlen, &err); 268 - if (err) 269 - return 1; 270 - newlen = strlen (utf8text); 271 - if (newlen <= oldlen) 272 - strcpy (*value, utf8text); 273 - else 274 - { 275 - free (*value); 276 - *value = (char *) malloc (newlen + 1); 277 - strcpy (*value, utf8text); 278 - } 279 - return 0; 245 + char *text = *value; 246 + char *utf8text; 247 + int err; 248 + int i; 249 + int oldlen = strlen(text); 250 + int newlen; 251 + for (i = oldlen - 1; i > 0; i++) 252 + { 253 + /* cleaning up trailing spaces */ 254 + if (text[i] == ' ') 255 + text[i] = '\0'; 256 + else 257 + break; 258 + } 259 + utf8text = gaiaConvertToUTF8(toUtf8, text, oldlen, &err); 260 + if (err) 261 + return 1; 262 + newlen = strlen(utf8text); 263 + if (newlen <= oldlen) 264 + strcpy(*value, utf8text); 265 + else 266 + { 267 + free(*value); 268 + *value = (char *) malloc(newlen + 1); 269 + strcpy(*value, utf8text); 270 + } 271 + return 0; 280 272 } 281 273 282 -static struct text_buffer * 283 -text_parse (const char *path, const char *encoding, bool first_line_titles, 284 - char field_separator, char text_separator, char decimal_separator) 274 +static struct text_buffer *text_parse(const char *path, const char *encoding, 275 + bool first_line_titles, 276 + char field_separator, char text_separator, 277 + char decimal_separator) 285 278 { 286 279 /* trying to open and parse the text file */ 287 - int c; 288 - int fld; 289 - int len; 290 - int max_cell; 291 - int is_string = 0; 292 - char last = '\0'; 293 - char *fields[4096]; 294 - char buffer[35536]; 295 - char *p = buffer; 296 - struct text_buffer *text; 297 - int nrows; 298 - int ncols; 299 - int errs; 300 - struct row_buffer *row; 301 - void *toUtf8; 302 - int encoding_errors; 303 - int ir; 304 - char title[64]; 305 - char *first_valid_row; 306 - int i; 307 - char *name; 308 - for (fld = 0; fld < 4096; fld++) 309 - { 310 - /* preparing an empty row */ 311 - fields[fld] = NULL; 312 - } 280 + int c; 281 + int fld; 282 + int len; 283 + int max_cell; 284 + int is_string = 0; 285 + char last = '\0'; 286 + char *fields[4096]; 287 + char buffer[35536]; 288 + char *p = buffer; 289 + struct text_buffer *text; 290 + int nrows; 291 + int ncols; 292 + int errs; 293 + struct row_buffer *row; 294 + void *toUtf8; 295 + int encoding_errors; 296 + int ir; 297 + char title[64]; 298 + char *first_valid_row; 299 + int i; 300 + char *name; 301 + for (fld = 0; fld < 4096; fld++) 302 + { 303 + /* preparing an empty row */ 304 + fields[fld] = NULL; 305 + } 313 306 /* trying to open the text file */ 314 - FILE *in = fopen (path, "rb"); 315 - if (!in) 316 - return NULL; 317 - text = text_buffer_alloc (); 318 - fld = 0; 319 - while ((c = getc (in)) != EOF) 320 - { 321 - /* parsing the file, one char at each time */ 322 - if (c == '\r' && !is_string) 323 - { 324 - last = c; 325 - continue; 326 - } 327 - if (c == field_separator && !is_string) 328 - { 329 - /* insering a field into the fields tmp array */ 330 - last = c; 331 - *p = '\0'; 332 - len = strlen (buffer); 333 - if (len) 334 - { 335 - fields[fld] = (char *) malloc (len + 1); 336 - strcpy (fields[fld], buffer); 337 - } 338 - fld++; 339 - p = buffer; 340 - *p = '\0'; 341 - continue; 342 - } 343 - if (c == text_separator) 344 - { 345 - /* found a text separator */ 346 - if (is_string) 347 - { 348 - is_string = 0; 349 - last = c; 350 - } 351 - else 352 - { 353 - if (last == text_separator) 354 - *p++ = text_separator; 355 - is_string = 1; 356 - } 357 - continue; 358 - } 359 - last = c; 360 - if (c == '\n' && !is_string) 361 - { 362 - /* inserting the row into the text buffer */ 363 - *p = '\0'; 364 - len = strlen (buffer); 365 - if (len) 366 - { 367 - fields[fld] = (char *) malloc (len + 1); 368 - strcpy (fields[fld], buffer); 369 - } 370 - fld++; 371 - p = buffer; 372 - *p = '\0'; 373 - max_cell = -1; 374 - for (fld = 0; fld < 4096; fld++) 375 - { 376 - if (fields[fld]) 377 - max_cell = fld; 378 - } 379 - text_insert_row (text, fields, max_cell); 380 - for (fld = 0; fld < 4096; fld++) 381 - { 382 - /* resetting an empty row */ 383 - fields[fld] = NULL; 384 - } 385 - fld = 0; 386 - continue; 387 - } 388 - *p++ = c; 389 - } 390 - fclose (in); 307 + FILE *in = fopen(path, "rb"); 308 + if (!in) 309 + return NULL; 310 + text = text_buffer_alloc(); 311 + fld = 0; 312 + while ((c = getc(in)) != EOF) 313 + { 314 + /* parsing the file, one char at each time */ 315 + if (c == '\r' && !is_string) 316 + { 317 + last = c; 318 + continue; 319 + } 320 + if (c == field_separator && !is_string) 321 + { 322 + /* insering a field into the fields tmp array */ 323 + last = c; 324 + *p = '\0'; 325 + len = strlen(buffer); 326 + if (len) 327 + { 328 + fields[fld] = (char *) malloc(len + 1); 329 + strcpy(fields[fld], buffer); 330 + } 331 + fld++; 332 + p = buffer; 333 + *p = '\0'; 334 + continue; 335 + } 336 + if (c == text_separator) 337 + { 338 + /* found a text separator */ 339 + if (is_string) 340 + { 341 + is_string = 0; 342 + last = c; 343 + } else 344 + { 345 + if (last == text_separator) 346 + *p++ = text_separator; 347 + is_string = 1; 348 + } 349 + continue; 350 + } 351 + last = c; 352 + if (c == '\n' && !is_string) 353 + { 354 + /* inserting the row into the text buffer */ 355 + *p = '\0'; 356 + len = strlen(buffer); 357 + if (len) 358 + { 359 + fields[fld] = (char *) malloc(len + 1); 360 + strcpy(fields[fld], buffer); 361 + } 362 + fld++; 363 + p = buffer; 364 + *p = '\0'; 365 + max_cell = -1; 366 + for (fld = 0; fld < 4096; fld++) 367 + { 368 + if (fields[fld]) 369 + max_cell = fld; 370 + } 371 + text_insert_row(text, fields, max_cell); 372 + for (fld = 0; fld < 4096; fld++) 373 + { 374 + /* resetting an empty row */ 375 + fields[fld] = NULL; 376 + } 377 + fld = 0; 378 + continue; 379 + } 380 + *p++ = c; 381 + } 382 + fclose(in); 391 383 /* checking if the text file really seems to contain a table */ 392 - nrows = 0; 393 - ncols = 0; 394 - errs = 0; 395 - row = text->first; 396 - while (row) 397 - { 398 - if (first_line_titles == true && row == text->first) 399 - { 400 - /* skipping first line */ 401 - row = row->next; 402 - continue; 403 - } 404 - nrows++; 405 - if (row->n_cells > ncols) 406 - ncols = row->n_cells; 407 - row = row->next; 408 - } 409 - if (nrows == 0 && ncols == 0) 410 - { 411 - text_buffer_free (text); 412 - return NULL; 413 - } 414 - text->n_rows = nrows; 384 + nrows = 0; 385 + ncols = 0; 386 + errs = 0; 387 + row = text->first; 388 + while (row) 389 + { 390 + if (first_line_titles == true && row == text->first) 391 + { 392 + /* skipping first line */ 393 + row = row->next; 394 + continue; 395 + } 396 + nrows++; 397 + if (row->n_cells > ncols) 398 + ncols = row->n_cells; 399 + row = row->next; 400 + } 401 + if (nrows == 0 && ncols == 0) 402 + { 403 + text_buffer_free(text); 404 + return NULL; 405 + } 406 + text->n_rows = nrows; 415 407 /* going to check the column types */ 416 - text->max_n_cells = ncols; 417 - text->types = (char *) malloc (sizeof (char) * text->max_n_cells); 418 - first_valid_row = (char *) malloc (sizeof (char) * text->max_n_cells); 419 - for (fld = 0; fld < text->max_n_cells; fld++) 420 - { 421 - /* initally assuming any cell contains TEXT */ 422 - *(text->types + fld) = VRTTXT_TEXT; 423 - *(first_valid_row + fld) = 1; 424 - } 425 - row = text->first; 426 - while (row) 427 - { 428 - if (first_line_titles == true && row == text->first) 429 - { 430 - /* skipping first line */ 431 - row = row->next; 432 - continue; 433 - } 434 - for (fld = 0; fld < row->n_cells; fld++) 435 - { 436 - if (*(row->cells + fld)) 437 - { 438 - if (text_is_integer (*(row->cells + fld))) 439 - { 440 - if (*(first_valid_row + fld)) 441 - { 442 - *(text->types + fld) = VRTTXT_INTEGER; 443 - *(first_valid_row + fld) = 0; 444 - } 445 - } 446 - else if (text_is_double 447 - (*(row->cells + fld), decimal_separator)) 448 - { 449 - if (*(first_valid_row + fld)) 450 - { 451 - *(text->types + fld) = VRTTXT_DOUBLE; 452 - *(first_valid_row + fld) = 0; 453 - } 454 - else 455 - { 456 - /* promoting an INTEGER column to be of the DOUBLE type */ 457 - if (*(text->types + fld) == VRTTXT_INTEGER) 458 - *(text->types + fld) = VRTTXT_DOUBLE; 459 - } 460 - } 461 - else 462 - { 463 - /* this column is anyway of the TEXT type */ 464 - *(text->types + fld) = VRTTXT_TEXT; 465 - if (*(first_valid_row + fld)) 466 - *(first_valid_row + fld) = 0; 467 - } 468 - } 469 - } 470 - row = row->next; 471 - } 472 - free (first_valid_row); 408 + text->max_n_cells = ncols; 409 + text->types = (char *) malloc(sizeof(char) * text->max_n_cells); 410 + first_valid_row = (char *) malloc(sizeof(char) * text->max_n_cells); 411 + for (fld = 0; fld < text->max_n_cells; fld++) 412 + { 413 + /* initally assuming any cell contains TEXT */ 414 + *(text->types + fld) = VRTTXT_TEXT; 415 + *(first_valid_row + fld) = 1; 416 + } 417 + row = text->first; 418 + while (row) 419 + { 420 + if (first_line_titles == true && row == text->first) 421 + { 422 + /* skipping first line */ 423 + row = row->next; 424 + continue; 425 + } 426 + for (fld = 0; fld < row->n_cells; fld++) 427 + { 428 + if (*(row->cells + fld)) 429 + { 430 + if (text_is_integer(*(row->cells + fld))) 431 + { 432 + if (*(first_valid_row + fld)) 433 + { 434 + *(text->types + fld) = VRTTXT_INTEGER; 435 + *(first_valid_row + fld) = 0; 436 + } 437 + } else if (text_is_double(*(row->cells + fld), decimal_separator)) 438 + { 439 + if (*(first_valid_row + fld)) 440 + { 441 + *(text->types + fld) = VRTTXT_DOUBLE; 442 + *(first_valid_row + fld) = 0; 443 + } else 444 + { 445 + /* promoting an INTEGER column to be of the DOUBLE type */ 446 + if (*(text->types + fld) == VRTTXT_INTEGER) 447 + *(text->types + fld) = VRTTXT_DOUBLE; 448 + } 449 + } else 450 + { 451 + /* this column is anyway of the TEXT type */ 452 + *(text->types + fld) = VRTTXT_TEXT; 453 + if (*(first_valid_row + fld)) 454 + *(first_valid_row + fld) = 0; 455 + } 456 + } 457 + } 458 + row = row->next; 459 + } 460 + free(first_valid_row); 473 461 /* preparing the column names */ 474 - text->titles = (char **) malloc (sizeof (char *) * text->max_n_cells); 475 - if (first_line_titles == true) 476 - { 477 - for (fld = 0; fld < text->max_n_cells; fld++) 478 - { 479 - if (fld >= text->first->n_cells) 480 - { 481 - /* this column name is NULL; setting a default name */ 482 - sprintf (title, "COL%03d", fld + 1); 483 - len = strlen (title); 484 - *(text->titles + fld) = (char *) malloc (len + 1); 485 - strcpy (*(text->titles + fld), title); 486 - } 487 - else 488 - { 489 - if (*(text->first->cells + fld)) 490 - { 491 - len = strlen (*(text->first->cells + fld)); 492 - *(text->titles + fld) = (char *) malloc (len + 1); 493 - strcpy (*(text->titles + fld), 494 - *(text->first->cells + fld)); 495 - name = *(text->titles + fld); 496 - for (i = 0; i < len; i++) 497 - { 498 - /* masking any space in the column name */ 499 - if (*(name + i) == ' ') 500 - *(name + i) = '_'; 501 - } 502 - } 503 - else 504 - { 505 - /* this column name is NULL; setting a default name */ 506 - sprintf (title, "COL%03d", fld + 1); 507 - len = strlen (title); 508 - *(text->titles + fld) = (char *) malloc (len + 1); 509 - strcpy (*(text->titles + fld), title); 510 - } 511 - } 512 - } 513 - } 514 - else 515 - { 516 - for (fld = 0; fld < text->max_n_cells; fld++) 517 - { 518 - sprintf (title, "COL%03d", fld + 1); 519 - len = strlen (title); 520 - *(text->titles + fld) = (char *) malloc (len + 1); 521 - strcpy (*(text->titles + fld), title); 522 - } 523 - } 462 + text->titles = (char **) malloc(sizeof(char *) * text->max_n_cells); 463 + if (first_line_titles == true) 464 + { 465 + for (fld = 0; fld < text->max_n_cells; fld++) 466 + { 467 + if (fld >= text->first->n_cells) 468 + { 469 + /* this column name is NULL; setting a default name */ 470 + sprintf(title, "COL%03d", fld + 1); 471 + len = strlen(title); 472 + *(text->titles + fld) = (char *) malloc(len + 1); 473 + strcpy(*(text->titles + fld), title); 474 + } else 475 + { 476 + if (*(text->first->cells + fld)) 477 + { 478 + len = strlen(*(text->first->cells + fld)); 479 + *(text->titles + fld) = (char *) malloc(len + 1); 480 + strcpy(*(text->titles + fld), *(text->first->cells + fld)); 481 + name = *(text->titles + fld); 482 + for (i = 0; i < len; i++) 483 + { 484 + /* masking any space in the column name */ 485 + if (*(name + i) == ' ') 486 + *(name + i) = '_'; 487 + } 488 + } else 489 + { 490 + /* this column name is NULL; setting a default name */ 491 + sprintf(title, "COL%03d", fld + 1); 492 + len = strlen(title); 493 + *(text->titles + fld) = (char *) malloc(len + 1); 494 + strcpy(*(text->titles + fld), title); 495 + } 496 + } 497 + } 498 + } else 499 + { 500 + for (fld = 0; fld < text->max_n_cells; fld++) 501 + { 502 + sprintf(title, "COL%03d", fld + 1); 503 + len = strlen(title); 504 + *(text->titles + fld) = (char *) malloc(len + 1); 505 + strcpy(*(text->titles + fld), title); 506 + } 507 + } 524 508 /* cleaning cell values when needed */ 525 - toUtf8 = gaiaCreateUTF8Converter (encoding); 526 - if (!toUtf8) 527 - { 528 - text_buffer_free (text); 529 - return NULL; 530 - } 531 - encoding_errors = 0; 532 - row = text->first; 533 - while (row) 534 - { 535 - if (first_line_titles == true && row == text->first) 536 - { 537 - /* skipping first line */ 538 - row = row->next; 539 - continue; 540 - } 541 - for (fld = 0; fld < row->n_cells; fld++) 542 - { 543 - if (*(row->cells + fld)) 544 - { 545 - if (*(text->types + fld) == VRTTXT_INTEGER) 546 - text_clean_integer (*(row->cells + fld)); 547 - else if (*(text->types + fld) == VRTTXT_DOUBLE) 548 - text_clean_double (*(row->cells + fld)); 549 - else 550 - encoding_errors += 551 - text_clean_text (row->cells + fld, toUtf8); 552 - } 553 - } 554 - row = row->next; 555 - } 556 - gaiaFreeUTF8Converter (toUtf8); 557 - if (encoding_errors) 558 - { 559 - text_buffer_free (text); 560 - return NULL; 561 - } 509 + toUtf8 = gaiaCreateUTF8Converter(encoding); 510 + if (!toUtf8) 511 + { 512 + text_buffer_free(text); 513 + return NULL; 514 + } 515 + encoding_errors = 0; 516 + row = text->first; 517 + while (row) 518 + { 519 + if (first_line_titles == true && row == text->first) 520 + { 521 + /* skipping first line */ 522 + row = row->next; 523 + continue; 524 + } 525 + for (fld = 0; fld < row->n_cells; fld++) 526 + { 527 + if (*(row->cells + fld)) 528 + { 529 + if (*(text->types + fld) == VRTTXT_INTEGER) 530 + text_clean_integer(*(row->cells + fld)); 531 + else if (*(text->types + fld) == VRTTXT_DOUBLE) 532 + text_clean_double(*(row->cells + fld)); 533 + else 534 + encoding_errors += text_clean_text(row->cells + fld, toUtf8); 535 + } 536 + } 537 + row = row->next; 538 + } 539 + gaiaFreeUTF8Converter(toUtf8); 540 + if (encoding_errors) 541 + { 542 + text_buffer_free(text); 543 + return NULL; 544 + } 562 545 /* ok, we can now go to prepare the rows array */ 563 - text->rows = 564 - (struct row_buffer **) malloc (sizeof (struct text_row *) * 565 - text->n_rows); 566 - ir = 0; 567 - row = text->first; 568 - while (row) 569 - { 570 - if (first_line_titles == true && row == text->first) 571 - { 572 - /* skipping first line */ 573 - row = row->next; 574 - continue; 575 - } 576 - *(text->rows + ir++) = row; 577 - row = row->next; 578 - } 579 - return text; 546 + text->rows = 547 + (struct row_buffer **) malloc(sizeof(struct text_row *) * text->n_rows); 548 + ir = 0; 549 + row = text->first; 550 + while (row) 551 + { 552 + if (first_line_titles == true && row == text->first) 553 + { 554 + /* skipping first line */ 555 + row = row->next; 556 + continue; 557 + } 558 + *(text->rows + ir++) = row; 559 + row = row->next; 560 + } 561 + return text; 580 562 } 581 563 582 564 void 583 -MyFrame::LoadText (wxString & path, wxString & table, wxString & charset, 584 - bool first_titles, char decimal_separator, char separator, 585 - char text_separator) 565 + MyFrame::LoadText(wxString & path, wxString & table, wxString & charset, 566 + bool first_titles, char decimal_separator, char separator, 567 + char text_separator) 586 568 { 587 569 // 588 570 // loading a CSV/TXT as a new DB table 589 571 // 590 - struct text_buffer *text = NULL; 591 - struct row_buffer *row; 592 - int seed; 593 - int dup; 594 - int idup; 595 - char dummy[65536]; 596 - char dummyName[4096]; 597 - char **col_name = NULL; 598 - int i; 599 - char sql[65536]; 600 - int len; 601 - int ret; 602 - int rows = 0; 603 - char *errMsg = NULL; 604 - bool sqlError = false; 605 - char xtable[1024]; 606 - int current_row; 607 - wxString msg; 572 + struct text_buffer *text = NULL; 573 + struct row_buffer *row; 574 + int seed; 575 + int dup; 576 + int idup; 577 + char dummy[65536]; 578 + char dummyName[4096]; 579 + char **col_name = NULL; 580 + int i; 581 + char sql[65536]; 582 + int len; 583 + int ret; 584 + int rows = 0; 585 + char *errMsg = NULL; 586 + bool sqlError = false; 587 + char xtable[1024]; 588 + int current_row; 589 + wxString msg; 608 590 // 609 591 // performing some checks before starting 610 592 // 611 - if (TableAlreadyExists (table) == true) 612 - { 613 - wxMessageBox (wxT ("a table name '") + table + 614 - wxT ("' already exists"), wxT ("spatialite-gui"), 615 - wxOK | wxICON_ERROR, this); 616 - return; 617 - } 618 - if (gaiaIllegalSqlName (table.ToUTF8 ()) == 1 619 - || gaiaIsReservedSqlName (table.ToUTF8 ()) == 1 620 - || gaiaIsReservedSqliteName (table.ToUTF8 ()) == 1) 621 - { 622 - wxMessageBox (wxT ("'") + table + 623 - wxT 624 - ("' is an invalid TABLE NAME\n\nsame as SQL reserved keyword"), 625 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, this); 626 - return; 627 - } 628 - text = 629 - text_parse (path.ToUTF8 (), charset.ToUTF8 (), first_titles, separator, 630 - text_separator, decimal_separator); 631 - if (!text) 632 - return; 633 - ::wxBeginBusyCursor (); 593 + if (TableAlreadyExists(table) == true) 594 + { 595 + wxMessageBox(wxT("a table name '") + table + wxT("' already exists"), 596 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 597 + return; 598 + } 599 + text = 600 + text_parse(path.ToUTF8(), charset.ToUTF8(), first_titles, separator, 601 + text_separator, decimal_separator); 602 + if (!text) 603 + return; 604 + ::wxBeginBusyCursor(); 634 605 // 635 606 // checking for duplicate / illegal column names and antialising them 636 607 // 637 - col_name = (char **) malloc (sizeof (char *) * text->max_n_cells); 638 - seed = 0; 639 - for (i = 0; i < text->max_n_cells; i++) 640 - { 641 - if (gaiaIllegalSqlName (*(text->titles + i)) 642 - || gaiaIsReservedSqlName (*(text->titles + i)) 643 - || gaiaIsReservedSqliteName (*(text->titles + i))) 644 - sprintf (dummyName, "COL_%d", seed++); 645 - else 646 - strcpy (dummyName, *(text->titles + i)); 647 - dup = 0; 648 - for (idup = 0; idup < i; idup++) 649 - { 650 - if (strcasecmp (dummyName, *(col_name + idup)) == 0) 651 - dup = 1; 652 - } 653 - if (strcasecmp (dummyName, "PKUID") == 0) 654 - dup = 1; 655 - if (strcasecmp (dummyName, "Geometry") == 0) 656 - dup = 1; 657 - if (dup) 658 - sprintf (dummyName, "COL_%d", seed++); 659 - len = strlen (dummyName); 660 - *(col_name + i) = (char *) malloc (len + 1); 661 - strcpy (*(col_name + i), dummyName); 662 - } 608 + col_name = (char **) malloc(sizeof(char *) * text->max_n_cells); 609 + seed = 0; 610 + for (i = 0; i < text->max_n_cells; i++) 611 + { 612 + strcpy(dummyName, *(text->titles + i)); 613 + dup = 0; 614 + for (idup = 0; idup < i; idup++) 615 + { 616 + if (strcasecmp(dummyName, *(col_name + idup)) == 0) 617 + dup = 1; 618 + } 619 + if (strcasecmp(dummyName, "PKUID") == 0) 620 + dup = 1; 621 + if (strcasecmp(dummyName, "Geometry") == 0) 622 + dup = 1; 623 + if (dup) 624 + sprintf(dummyName, "COL_%d", seed++); 625 + len = strlen(dummyName); 626 + *(col_name + i) = (char *) malloc(len + 1); 627 + strcpy(*(col_name + i), dummyName); 628 + } 663 629 // 664 630 // starting a transaction 665 631 // 666 - ret = sqlite3_exec (SqliteHandle, "BEGIN", NULL, 0, &errMsg); 667 - if (ret != SQLITE_OK) 668 - { 669 - wxMessageBox (wxT ("load CSV/TXT error:") + 670 - wxString::FromUTF8 (errMsg), wxT ("spatialite-gui"), 671 - wxOK | wxICON_ERROR, this); 672 - sqlite3_free (errMsg); 673 - sqlError = true; 674 - goto clean_up; 675 - } 632 + ret = sqlite3_exec(SqliteHandle, "BEGIN", NULL, 0, &errMsg); 633 + if (ret != SQLITE_OK) 634 + { 635 + wxMessageBox(wxT("load CSV/TXT error:") + wxString::FromUTF8(errMsg), 636 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 637 + sqlite3_free(errMsg); 638 + sqlError = true; 639 + goto clean_up; 640 + } 676 641 // 677 642 // creating the Table 678 643 // 679 - strcpy (xtable, table.ToUTF8 ()); 680 - sprintf (sql, "CREATE TABLE %s", xtable); 681 - strcat (sql, " (\nPK_UID INTEGER PRIMARY KEY AUTOINCREMENT"); 682 - for (i = 0; i < text->max_n_cells; i++) 683 - { 684 - strcat (sql, ",\n"); 685 - strcat (sql, *(col_name + i)); 686 - if (*(text->types + i) == VRTTXT_INTEGER) 687 - strcat (sql, " INTEGER"); 688 - else if (*(text->types + i) == VRTTXT_DOUBLE) 689 - strcat (sql, " DOUBLE"); 690 - else 691 - strcat (sql, " TEXT"); 692 - } 693 - strcat (sql, ")"); 694 - ret = sqlite3_exec (SqliteHandle, sql, NULL, 0, &errMsg); 695 - if (ret != SQLITE_OK) 696 - { 697 - wxMessageBox (wxT ("load text error:") + 698 - wxString::FromUTF8 (errMsg), wxT ("spatialite-gui"), 699 - wxOK | wxICON_ERROR, this); 700 - sqlite3_free (errMsg); 701 - sqlError = true; 702 - goto clean_up; 703 - } 704 - current_row = 0; 705 - while (current_row < text->n_rows) 706 - { 707 - // 708 - // inserting rows from CSV/TXT 709 - // 710 - sprintf (sql, "INSERT INTO %s (\nPK_UID", xtable); 711 - for (i = 0; i < text->max_n_cells; i++) 712 - { 713 - // columns corresponding to some CSV/TXT column 714 - strcat (sql, ","); 715 - strcat (sql, *(col_name + i)); 716 - } 717 - strcat (sql, ")\nVALUES ("); 718 - sprintf (dummy, "%d", current_row); 719 - strcat (sql, dummy); 720 - for (i = 0; i < text->max_n_cells; i++) 721 - { 722 - // column values 723 - row = *(text->rows + current_row); 724 - strcat (sql, ","); 725 - if (i >= row->n_cells) 726 - strcat (sql, "NULL"); 727 - else 728 - { 729 - if (*(row->cells + i)) 730 - { 731 - if (*(text->types + i) == VRTTXT_INTEGER) 732 - { 733 - sprintf (dummy, "%d", 734 - atoi (*(row->cells + i))); 735 - strcat (sql, dummy); 736 - } 737 - else if (*(text->types + i) == VRTTXT_DOUBLE) 738 - { 739 - sprintf (dummy, "%1.6lf", 740 - atof (*(row->cells + i))); 741 - strcat (sql, dummy); 742 - } 743 - else 744 - { 745 - strcpy (dummy, *(row->cells + i)); 746 - CleanSqlString (dummy); 747 - strcat (sql, "'"); 748 - strcat (sql, dummy); 749 - strcat (sql, "'"); 750 - } 751 - } 752 - else 753 - strcat (sql, "NULL"); 754 - } 755 - } 756 - strcat (sql, ")"); 757 - ret = sqlite3_exec (SqliteHandle, sql, NULL, 0, &errMsg); 758 - if (ret != SQLITE_OK) 759 - { 760 - wxMessageBox (wxT ("load text error:") + 761 - wxString::FromUTF8 (errMsg), 762 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 763 - this); 764 - sqlite3_free (errMsg); 765 - sqlError = true; 766 - goto clean_up; 767 - } 768 - rows++; 769 - current_row++; 770 - } 771 - clean_up: 772 - if (col_name) 773 - { 774 - // releasing memory allocation for column names 775 - for (i = 0; i < text->max_n_cells; i++) 776 - free (*(col_name + i)); 777 - free (col_name); 778 - } 779 - free (text); 780 - if (sqlError == true) 781 - { 782 - // some error occurred - ROLLBACK 783 - ret = sqlite3_exec (SqliteHandle, "ROLLBACK", NULL, 0, &errMsg); 784 - if (ret != SQLITE_OK) 785 - { 786 - wxMessageBox (wxT ("load text error:") + 787 - wxString::FromUTF8 (errMsg), 788 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 789 - this); 790 - sqlite3_free (errMsg); 791 - } 792 - ::wxEndBusyCursor (); 793 - msg.Printf (wxT 794 - ("CSV/TXT not loaded\n\n\na ROLLBACK was automatically performed")); 795 - wxMessageBox (msg, wxT ("spatialite-gui"), wxOK | wxICON_WARNING, 796 - this); 797 - } 798 - else 799 - { 800 - // ok - confirming pending transaction - COMMIT 801 - ret = sqlite3_exec (SqliteHandle, "COMMIT", NULL, 0, &errMsg); 802 - if (ret != SQLITE_OK) 803 - { 804 - wxMessageBox (wxT ("load text error:") + 805 - wxString::FromUTF8 (errMsg), 806 - wxT ("spatialite-gui"), wxOK | wxICON_ERROR, 807 - this); 808 - sqlite3_free (errMsg); 809 - return; 810 - } 811 - ::wxEndBusyCursor (); 812 - msg.Printf (wxT ("CSV/TXT loaded\n\n%d inserted rows"), rows); 813 - wxMessageBox (msg, wxT ("spatialite-gui"), 814 - wxOK | wxICON_INFORMATION, this); 815 - ClearTableTree (); 816 - InitTableTree (); 817 - } 644 + strcpy(xtable, table.ToUTF8()); 645 + sprintf(sql, "CREATE TABLE \"%s\"", xtable); 646 + strcat(sql, " (\n\"PK_UID\" INTEGER PRIMARY KEY AUTOINCREMENT"); 647 + for (i = 0; i < text->max_n_cells; i++) 648 + { 649 + strcat(sql, ",\n\""); 650 + strcat(sql, *(col_name + i)); 651 + if (*(text->types + i) == VRTTXT_INTEGER) 652 + strcat(sql, "\" INTEGER"); 653 + else if (*(text->types + i) == VRTTXT_DOUBLE) 654 + strcat(sql, "\" DOUBLE"); 655 + else 656 + strcat(sql, "\" TEXT"); 657 + } 658 + strcat(sql, ")"); 659 + ret = sqlite3_exec(SqliteHandle, sql, NULL, 0, &errMsg); 660 + if (ret != SQLITE_OK) 661 + { 662 + wxMessageBox(wxT("load text error:") + wxString::FromUTF8(errMsg), 663 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 664 + sqlite3_free(errMsg); 665 + sqlError = true; 666 + goto clean_up; 667 + } 668 + current_row = 0; 669 + while (current_row < text->n_rows) 670 + { 671 + // 672 + // inserting rows from CSV/TXT 673 + // 674 + sprintf(sql, "INSERT INTO \"%s\" (\n\"PK_UID\"", xtable); 675 + for (i = 0; i < text->max_n_cells; i++) 676 + { 677 + // columns corresponding to some CSV/TXT column 678 + strcat(sql, ",\""); 679 + strcat(sql, *(col_name + i)); 680 + strcat(sql, "\""); 681 + } 682 + strcat(sql, ")\nVALUES ("); 683 + sprintf(dummy, "%d", current_row); 684 + strcat(sql, dummy); 685 + for (i = 0; i < text->max_n_cells; i++) 686 + { 687 + // column values 688 + row = *(text->rows + current_row); 689 + strcat(sql, ","); 690 + if (i >= row->n_cells) 691 + strcat(sql, "NULL"); 692 + else 693 + { 694 + if (*(row->cells + i)) 695 + { 696 + if (*(text->types + i) == VRTTXT_INTEGER) 697 + { 698 + sprintf(dummy, "%d", atoi(*(row->cells + i))); 699 + strcat(sql, dummy); 700 + } else if (*(text->types + i) == VRTTXT_DOUBLE) 701 + { 702 + sprintf(dummy, "%1.6lf", atof(*(row->cells + i))); 703 + strcat(sql, dummy); 704 + } else 705 + { 706 + strcpy(dummy, *(row->cells + i)); 707 + CleanSqlString(dummy); 708 + strcat(sql, "'"); 709 + strcat(sql, dummy); 710 + strcat(sql, "'"); 711 + } 712 + } else 713 + strcat(sql, "NULL"); 714 + } 715 + } 716 + strcat(sql, ")"); 717 + ret = sqlite3_exec(SqliteHandle, sql, NULL, 0, &errMsg); 718 + if (ret != SQLITE_OK) 719 + { 720 + wxMessageBox(wxT("load text error:") + wxString::FromUTF8(errMsg), 721 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 722 + sqlite3_free(errMsg); 723 + sqlError = true; 724 + goto clean_up; 725 + } 726 + rows++; 727 + current_row++; 728 + } 729 +clean_up: 730 + if (col_name) 731 + { 732 + // releasing memory allocation for column names 733 + for (i = 0; i < text->max_n_cells; i++) 734 + free(*(col_name + i)); 735 + free(col_name); 736 + } 737 + free(text); 738 + if (sqlError == true) 739 + { 740 + // some error occurred - ROLLBACK 741 + ret = sqlite3_exec(SqliteHandle, "ROLLBACK", NULL, 0, &errMsg); 742 + if (ret != SQLITE_OK) 743 + { 744 + wxMessageBox(wxT("load text error:") + wxString::FromUTF8(errMsg), 745 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 746 + sqlite3_free(errMsg); 747 + } 748 + ::wxEndBusyCursor(); 749 + msg = 750 + wxT("CSV/TXT not loaded\n\n\na ROLLBACK was automatically performed"); 751 + wxMessageBox(msg, wxT("spatialite-gui"), wxOK | wxICON_WARNING, this); 752 + } else 753 + { 754 + // ok - confirming pending transaction - COMMIT 755 + ret = sqlite3_exec(SqliteHandle, "COMMIT", NULL, 0, &errMsg); 756 + if (ret != SQLITE_OK) 757 + { 758 + wxMessageBox(wxT("load text error:") + wxString::FromUTF8(errMsg), 759 + wxT("spatialite-gui"), wxOK | wxICON_ERROR, this); 760 + sqlite3_free(errMsg); 761 + return; 762 + } 763 + ::wxEndBusyCursor(); 764 + sprintf(dummy, "CSV/TXT loaded\n\n%d inserted rows", rows); 765 + msg = wxString::FromUTF8(dummy); 766 + wxMessageBox(msg, wxT("spatialite-gui"), wxOK | wxICON_INFORMATION, this); 767 + InitTableTree(); 768 + } 818 769 }
Added icons/dumpshp.xpm.
1 +/* XPM */ 2 +static const char * dumpshp_xpm[] = { 3 +"16 16 16 1", 4 +" c None", 5 +". c #5AB24A", 6 +"+ c #41A0E9", 7 +"@ c #8BCC5C", 8 +"# c #ECF7E6", 9 +"$ c #D3EDBC", 10 +"% c #D0EBFA", 11 +"& c #0A5EC5", 12 +"* c #9BD48C", 13 +"= c #BCE7B1", 14 +"- c #94B7E3", 15 +"; c #A7D6A3", 16 +"> c #209910", 17 +", c #638F45", 18 +"' c #106CD2", 19 +") c #FFFFFF", 20 +" )))))) ", 21 +" ),@.,) ", 22 +" )),@@,)) ", 23 +" ),,,@@,,,) ", 24 +" )),@@@@,)) ", 25 +" )>#),@.,#=>) ", 26 +" )'#$#,,#.=>) ", 27 +" )'%$$*%%.@@=>) ", 28 +" )'%+*+++@@.;>) ", 29 +" )'%+-+++...;>) ", 30 +" )>$*.+++''>;') ", 31 +" )>$@..'&&-') ", 32 +" )>==>.'&--') ", 33 +" )>>;;--'') ", 34 +" ))>''')) ", 35 +" )))) "};
Added icons/exif.xpm.
1 +/* XPM */ 2 +static const char * exif_xpm[] = { 3 +"16 16 114 2", 4 +" c None", 5 +". c #AA7128", 6 +"+ c #A96F27", 7 +"@ c #A76E26", 8 +"# c #A56C25", 9 +"$ c #A36A23", 10 +"% c #A06822", 11 +"& c #9D6620", 12 +"* c #9B641F", 13 +"= c #98611D", 14 +"- c #955F1C", 15 +"; c #A86F26", 16 +"> c #DDA252", 17 +", c #DA934D", 18 +"' c #D59243", 19 +") c #D1913C", 20 +"! c #CD8E3C", 21 +"~ c #CB8B3A", 22 +"{ c #BE843E", 23 +"] c #CA924B", 24 +"^ c #905B19", 25 +"/ c #D8903F", 26 +"( c #61BCF3", 27 +"_ c #62BDF3", 28 +": c #5DB8F1", 29 +"< c #4DA6E9", 30 +"[ c #368EDE", 31 +"} c #CA9249", 32 +"| c #8C5817", 33 +"1 c #A26A23", 34 +"2 c #DD9148", 35 +"3 c #5CB6F0", 36 +"4 c #5EB8F1", 37 +"5 c #5CB7F0", 38 +"6 c #A47536", 39 +"7 c #A27234", 40 +"8 c #9F7032", 41 +"9 c #A86E26", 42 +"0 c #A16922", 43 +"a c #9E6721", 44 +"b c #D98F46", 45 +"c c #4BA4E8", 46 +"d c #4FA8EA", 47 +"e c #4CA5E8", 48 +"f c #A17233", 49 +"g c #D2A15B", 50 +"h c #CE9256", 51 +"i c #D49244", 52 +"j c #CC8D39", 53 +"k c #9A631F", 54 +"l c #D48A43", 55 +"m c #368DDE", 56 +"n c #3890DF", 57 +"o c #9B6F35", 58 +"p c #CC8F49", 59 +"q c #35C62D", 60 +"r c #40C723", 61 +"s c #3CC321", 62 +"t c #3BCD27", 63 +"u c #43D12E", 64 +"v c #57DA3F", 65 +"w c #96601C", 66 +"x c #CC8A43", 67 +"y c #6EE454", 68 +"z c #CF9037", 69 +"A c #885514", 70 +"B c #925D1A", 71 +"C c #8F5A18", 72 +"D c #6EE46E", 73 +"E c #CA8B51", 74 +"F c #845112", 75 +"G c #38BAED", 76 +"H c #58BFFF", 77 +"I c #62BBFF", 78 +"J c #44B6FF", 79 +"K c #DBEB8C", 80 +"L c #FFFF6D", 81 +"M c #78EF69", 82 +"N c #CE8F45", 83 +"O c #804E10", 84 +"P c #3BCE45", 85 +"Q c #07BE31", 86 +"R c #5AB7FF", 87 +"S c #58B6FF", 88 +"T c #97D1CC", 89 +"U c #F3FA8A", 90 +"V c #C99A40", 91 +"W c #C7883D", 92 +"X c #7D4C0E", 93 +"Y c #4BC84F", 94 +"Z c #36CB21", 95 +"` c #42C825", 96 +" . c #54B8AC", 97 +".. c #42A6FF", 98 +"+. c #00A2FF", 99 +"@. c #7E4D0F", 100 +"#. c #7C4B0E", 101 +"$. c #7A490D", 102 +"%. c #77F35E", 103 +"&. c #A4FF8C", 104 +"*. c #ACFF77", 105 +"=. c #7CF634", 106 +"-. c #75EF55", 107 +";. c #64FF79", 108 +">. c #C59046", 109 +",. c #C6954A", 110 +"'. c #E8D462", 111 +"). c #E9D461", 112 +"!. c #C99644", 113 +"~. c #8C5816", 114 +"{. c #895515", 115 +"]. c #865313", 116 +"^. c #835112", 117 +"/. c #804F10", 118 +" ", 119 +". + @ # $ % & * = - ", 120 +"; > , ' ) ! ~ { ] ^ ", 121 +"# / ( _ ( : < [ } | ", 122 +"1 2 3 4 5 6 7 8 9 0 % & * = - ", 123 +"a b c d e f g h i j ! ~ { ] ^ ", 124 +"k l m n [ o p q r s t u v } | ", 125 +"w x . + @ # $ % & * = - y z A ", 126 +"B C ; > , ' ) ! ~ { ] ^ D E F ", 127 +" # / G H I J K L } | M N O ", 128 +" 1 2 P Q R S T U z A V W X ", 129 +" a b Y Z ` ...+.E F @.#.$. ", 130 +" k l %.&.*.=.-.;.N O ", 131 +" w x >.,.'.).!.V W X ", 132 +" B C ~.{.].^./.@.#.$. ", 133 +" "};
Changes to icons/icon.xpm.
1 1 /* XPM */ 2 2 static const char * icon_xpm[] = { 3 -"32 32 8 1", 3 +"32 32 9 1", 4 4 " c None", 5 -". c #F0C080", 6 -"+ c #D0E0D0", 7 -"@ c #D0FFD0", 8 -"# c #E0F0E0", 9 -"$ c #D0D0FF", 10 -"% c #F0F0F0", 11 -"& c #E0E0FF", 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 -" "}; 5 +". c #5F6431", 6 +"+ c #496E14", 7 +"@ c #AF5C57", 8 +"# c #916864", 9 +"$ c #5F8B22", 10 +"% c #878882", 11 +"& c #9C9D9A", 12 +"* c #C1C2BF", 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 +" & "};
Added icons/icon_info.xpm.
1 +/* XPM */ 2 +static const char * icon_info_xpm[] = { 3 +"128 113 256 2", 4 +" c None", 5 +". c #583F32", 6 +"+ c #653D22", 7 +"@ c #4A4625", 8 +"# c #643E2B", 9 +"$ c #4F452E", 10 +"% c #6E3C2D", 11 +"& c #3A5016", 12 +"* c #5E432D", 13 +"= c #3C4F1C", 14 +"- c #3A5211", 15 +"; c #404F23", 16 +"> c #784129", 17 +", c #92392C", 18 +"' c #495025", 19 +") c #873D2C", 20 +"! c #77413D", 21 +"~ c #3F590F", 22 +"{ c #3F5917", 23 +"] c #6D4745", 24 +"^ c #973D30", 25 +"/ c #42591F", 26 +"( c #8D4226", 27 +"_ c #944028", 28 +": c #864521", 29 +"< c #84452E", 30 +"[ c #844626", 31 +"} c #475829", 32 +"| c #4F5536", 33 +"1 c #3E5F14", 34 +"2 c #3F600B", 35 +"3 c #824743", 36 +"4 c #7B4947", 37 +"5 c #9E4228", 38 +"6 c #8E453B", 39 +"7 c #6A5040", 40 +"8 c #6F4E4D", 41 +"9 c #535843", 42 +"0 c #3F6505", 43 +"a c #8B4846", 44 +"b c #4E5E24", 45 +"c c #894B3F", 46 +"d c #476221", 47 +"e c #9B4925", 48 +"f c #9C492C", 49 +"g c #964A38", 50 +"h c #944A45", 51 +"i c #6B5554", 52 +"j c #76534A", 53 +"k c #426815", 54 +"l c #4B651C", 55 +"m c #9B4946", 56 +"n c #655A43", 57 +"o c #47671C", 58 +"p c #A9473B", 59 +"q c #85504E", 60 +"r c #486815", 61 +"s c #8C4F4A", 62 +"t c #8B4F4F", 63 +"u c #466B0E", 64 +"v c #AA4844", 65 +"w c #536339", 66 +"x c #536430", 67 +"y c #924F4C", 68 +"z c #A54B47", 69 +"A c #7C5749", 70 +"B c #446F04", 71 +"C c #994F4F", 72 +"D c #476D19", 73 +"E c #436F11", 74 +"F c #586443", 75 +"G c #A14E4B", 76 +"H c #795A4A", 77 +"I c #496E12", 78 +"J c #9C504B", 79 +"K c #5C644D", 80 +"L c #417309", 81 +"M c #6B6140", 82 +"N c #506C2B", 83 +"O c #6F5E5C", 84 +"P c #985351", 85 +"Q c #B04D46", 86 +"R c #48720A", 87 +"S c #AF4D4C", 88 +"T c #9D5347", 89 +"U c #66625B", 90 +"V c #825A58", 91 +"W c #785E5C", 92 +"X c #6B6352", 93 +"Y c #4D7217", 94 +"Z c #AB514C", 95 +"` c #746153", 96 +" . c #965752", 97 +".. c #A65350", 98 +"+. c #45770E", 99 +"@. c #497518", 100 +"#. c #77624E", 101 +"$. c #487802", 102 +"%. c #B4514A", 103 +"&. c #965958", 104 +"*. c #B4514F", 105 +"=. c #8B5C5D", 106 +"-. c #4C7710", 107 +";. c #507424", 108 +">. c #A35751", 109 +",. c #AE5454", 110 +"'. c #B0544F", 111 +"). c #B75346", 112 +"!. c #915D59", 113 +"~. c #A35857", 114 +"{. c #A5594D", 115 +"]. c #A75A48", 116 +"^. c #836263", 117 +"/. c #A05B58", 118 +"(. c #AC5854", 119 +"_. c #7F6463", 120 +":. c #B9554E", 121 +"<. c #85635E", 122 +"[. c #786766", 123 +"}. c #8B6260", 124 +"|. c #6B6C5E", 125 +"1. c #B95654", 126 +"2. c #4D7E08", 127 +"3. c #8E635C", 128 +"4. c #4F7D17", 129 +"5. c #B55954", 130 +"6. c #AF5B58", 131 +"7. c #68705A", 132 +"8. c #9E605E", 133 +"9. c #9C6254", 134 +"0. c #6E6E6B", 135 +"a. c #B65B5A", 136 +"b. c #8F6664", 137 +"c. c #A6605D", 138 +"d. c #63764B", 139 +"e. c #B95C50", 140 +"f. c #AB5F5E", 141 +"g. c #BE5A58", 142 +"h. c #956565", 143 +"i. c #976661", 144 +"j. c #8A696A", 145 +"k. c #B95D57", 146 +"l. c #AE605A", 147 +"m. c #8C6965", 148 +"n. c #677654", 149 +"o. c #9D6562", 150 +"p. c #538314", 151 +"q. c #C15C54", 152 +"r. c #777254", 153 +"s. c #627A44", 154 +"t. c #816D6C", 155 +"u. c #B4605C", 156 +"v. c #627C3B", 157 +"w. c #7C7071", 158 +"x. c #C25E5B", 159 +"y. c #508717", 160 +"z. c #51880B", 161 +"A. c #886E6D", 162 +"B. c #558520", 163 +"C. c #986B5E", 164 +"D. c #AA6752", 165 +"E. c #956B69", 166 +"F. c #AC6562", 167 +"G. c #A56766", 168 +"H. c #BE615B", 169 +"I. c #A16966", 170 +"J. c #B86360", 171 +"K. c #B3655F", 172 +"L. c #9B6B6B", 173 +"M. c #C16257", 174 +"N. c #BE6261", 175 +"O. c #568B00", 176 +"P. c #7A7572", 177 +"Q. c #767A51", 178 +"R. c #757774", 179 +"S. c #AA6963", 180 +"T. c #5F8530", 181 +"U. c #AF6865", 182 +"V. c #C7625F", 183 +"W. c #967067", 184 +"X. c #538F04", 185 +"Y. c #AA6B6B", 186 +"Z. c #B9685D", 187 +"`. c #C3655F", 188 +" + c #A56D6A", 189 +".+ c #847676", 190 +"++ c #B96B4D", 191 +"@+ c #588E15", 192 +"#+ c #B36D51", 193 +"$+ c #728246", 194 +"%+ c #B86A69", 195 +"&+ c #B46C69", 196 +"*+ c #C56867", 197 +"=+ c #8F795F", 198 +"-+ c #C8695D", 199 +";+ c #7B7D7A", 200 +">+ c #C16C5A", 201 +",+ c #817C7B", 202 +"'+ c #B66E6B", 203 +")+ c #738460", 204 +"!+ c #BC6E6C", 205 +"~+ c #BE6E68", 206 +"{+ c #BF7052", 207 +"]+ c #5F9226", 208 +"^+ c #AB7470", 209 +"/+ c #B27270", 210 +"(+ c #5A9611", 211 +"_+ c #6E8B49", 212 +":+ c #C56E6A", 213 +"<+ c #599902", 214 +"[+ c #977B78", 215 +"}+ c #659134", 216 +"|+ c #5D961E", 217 +"1+ c #6A8F3F", 218 +"2+ c #A37974", 219 +"3+ c #7E856F", 220 +"4+ c #818380", 221 +"5+ c #738C56", 222 +"6+ c #90807F", 223 +"7+ c #5C9E0C", 224 +"8+ c #858784", 225 +"9+ c #639F1F", 226 +"0+ c #8A8C89", 227 +"a+ c #63A518", 228 +"b+ c #AC8582", 229 +"c+ c #7E975E", 230 +"d+ c #9E8A89", 231 +"e+ c #8E8F8D", 232 +"f+ c #919390", 233 +"g+ c #6AAC21", 234 +"h+ c #949693", 235 +"i+ c #7AA648", 236 +"j+ c #8C9B83", 237 +"k+ c #71AC32", 238 +"l+ c #6FB019", 239 +"m+ c #76AA40", 240 +"n+ c #999B98", 241 +"o+ c #9C9E9B", 242 +"p+ c #9FA19E", 243 +"q+ c #7BB938", 244 +"r+ c #AFA1A2", 245 +"s+ c #A4A6A3", 246 +"t+ c #AAACA8", 247 +"u+ c #ADAFAC", 248 +"v+ c #B0B2AF", 249 +"w+ c #B3B5B2", 250 +"x+ c #C7B5B4", 251 +"y+ c #B8BAB7", 252 +"z+ c #BBBDBA", 253 +"A+ c #C0C2BF", 254 +"B+ c #C7C9C6", 255 +"C+ c #CED0CC", 256 +"D+ c #D0D2CF", 257 +"E+ c #D3D5D2", 258 +"F+ c #D7D9D6", 259 +"G+ c #DEE0DC", 260 +" ", 261 +" s+ ", 262 +" t+w+A+s+ ", 263 +" p+t+z+A+A+z+s+z+ ", 264 +" y+w+A+A+A+A+p+C+E+z+4+ ", 265 +" A+C+u+A+A+A+z+s+E+E+z+t+;+ ", 266 +" p+B+C+y+z+A+A+A+p+C+E+C+A+w+A+0+ ", 267 +" p+C+C+C+v+A+A+A+z+s+E+E+y+F+E+y+ ", 268 +" h+n+A+C+C+B+v+A+A+A+p+C+E+B+C+E+B+e+ ", 269 +" h+p+p+C+C+C+w+A+A+A+z+t+E+D+z+F+E+s+f+ ", 270 +" f+n+p+p+t+C+C+C+u+A+A+A+p+C+E+z+E+E+w+p+t+ ", 271 +" f+8+p+p+p+w+C+C+A+y+A+A+z+t+E+C+A+E+B+p+E+A+f+ ", 272 +" f+e+h+f+f+p+p+n+B+C+C+w+A+A+A+p+C+E+y+F+D+p+B+F+A+ ", 273 +" o+f+p+8+o+p+p+h+C+C+C+u+A+A+z+t+E+B+B+E+u+w+F+B+s+ ", 274 +" e+p+n+p+4+p+p+p+p+C+C+y+z+A+A+p+C+E+z+F+B+p+F+E+A+z+ ", 275 +" e+u+n+p+p+4+p+p+o+u+C+C+v+A+A+z+t+E+z+E+D+n+C+F+z+F+A+t+ ", 276 +" 8+t+u+h+p+n+8+p+p+f+B+C+B+v+A+A+p+C+C+A+E+t+z+F+z+F+F+C+y+ ", 277 +" ;+e+p+u+u+f+p+0+f+p+p+n+C+C+w+A+A+y+t+E+z+F+A+s+F+B+C+F+C+C+A+ ", 278 +" 4+h+u+u+t+f+p+4+o+p+p+s+C+C+u+A+A+p+C+B+B+D+h+D+C+B+F+C+C+C+A+ ", 279 +" 8+o+u+u+u+p+o+p+4+p+p+p+y+C+A+y+A+y+t+E+z+E+s+A+E+A+F+B+C+C+C+B+ ", 280 +" ;+h+t+u+u+u+n+p+p+4+p+p+h+B+C+w+A+A+p+C+A+D+z+s+F+z+F+C+C+C+C+C+C+ ", 281 +" 0+s+u+u+u+u+h+p+f+e+p+p+p+C+C+u+A+y+u+C+A+C+n+E+A+E+D+B+C+C+C+C+C+n+ ", 282 +" 4+o+t+u+u+u+u+f+p+e+f+p+p+v+C+y+z+A+s+C+y+E+p+B+B+C+E+B+C+C+C+C+C+C+o+ ", 283 +" s+h+t+u+u+u+t+h+p+4+o+p+s+y+C+v+A+y+u+B+B+y+t+C+B+E+B+C+C+C+C+C+C+w+y+ ", 284 +" e+z+f+u+u+u+u+p+n+o+4+p+p+n+C+B+w+A+s+D+y+C+n+F+z+E+B+C+C+C+C+C+C+u+C+F+ ", 285 +" 4+w+z+e+u+u+u+u+n+p+e+e+p+n+t+C+w+A+y+v+A+C+p+C+z+F+A+C+C+C+C+C+C+t+D+F+F+w+ ", 286 +" h+z+z+8+u+u+u+u+h+p+0+f+p+s+v+C+u+A+s+C+z+w+w+A+D+A+C+C+C+C+C+B+t+E+F+F+F+y+ ", 287 +" ;+w+s+z+8+u+u+u+u+f+p+0+f+p+s+A+A+y+y+w+z+C+n+B+B+z+B+C+C+C+C+A+t+F+F+F+F+A+z+ ", 288 +" 4+p+v+y+0+u+u+u+t+f+p+4+o+n+t+C+w+A+s+B+B+p+B+A+A+B+C+C+C+C+z+v+F+F+F+F+y+C+A+ ", 289 +" ;+u+w+u+h+u+u+u+o+o+f+0+p+p+w+C+u+y+w+y+y+z+z+B+z+C+C+C+C+v+y+F+F+F+C+z+F+F+z+ ", 290 +" ;+s+s+z+t+p+u+u+u+n+p+0+h+p+t+w+y+z+s+A+A+t+z+C+w+C+C+C+C+t+A+F+F+F+B+A+F+F+F+w+ ", 291 +" f+v+s+z+s+o+u+u+u+h+p+f+f+n+t+B+v+y+w+z+n+A+B+u+C+C+C+C+s+B+F+F+F+z+B+F+F+F+F+ ", 292 +" w.w.[..+.+[.0.U O w..+ 8+v+v+s+z+s+h+u+u+u+f+p+h+f+n+u+B+w+o+h+o+w+B+t+C+C+C+B+o+B+F+F+E+y+E+F+F+F+F+B+ ", 293 +" w.t.W W W W O W W ^.i i i i i W O [.P.4+t+v+v+s+z+s+h+u+u+t+h+n+e+o+s+v+w+y+;+0+s+z+t+C+C+C+B+p+D+F+F+B+z+F+F+F+F+F+F+A+ ", 294 +" P.[.O W O <.<.<.}.}.}.h.b.h.L.}.}.}.^.}.}.^.w.p+v+v+u+t+z+s+h+u+u+o+o+e+n+o+w+v+u+f+4+h+y+u+B+C+C+z+p+E+F+F+A+B+F+F+F+F+F+F+F+w+h+ ", 295 +" [.W W W <.^.W b.h.b.h. +}. + +h. +h.h.I.}.<.A.e+v+v+v+h+w+z+s+n+u+u+h+p+e+n+h+w+y+u+;+0+u+v+A+C+C+w+s+F+F+F+y+C+F+F+F+F+F+F+F+F+u+ ", 296 +" w.O ^.W b.}.}.}.h.h.}.}.h.h.h.i.i.}.i.h.h.=.o.h.w.p+v+v+v+f+z+y+s+o+u+u+h+p+f+f+s+v+v+e+4+p+t+y+C+C+u+u+F+F+C+z+E+F+F+F+F+F+F+F+F+E+f+ ", 297 +" [.W ^.W ^.h.}.h.h.I.i.h.I.o.&+o.&+o.&+I.&+Y.o.Y.o.[+;+p+v+v+v+n+z+u+u+n+u+u+f+n+h+f+v+t+e+;+e+t+v+C+C+s+y+F+F+B+A+F+F+F+F+F+F+F+F+F+F+A+ ", 298 +" ,+_.^.^.^.L.}.}.}.h.Y.h.I.Y.o.&+G.G.&+o.&+S.G.&+i.&+L.4+e+p+v+v+v+p+z+t+w+h+u+s+h+0+o+f+A+n+;+8+p+o+C+C+p+A+F+F+z+B+F+F+F+F+F+F+F+F+F+G+G+s+ ", 299 +" w._.^.^.h.L.h. +h.I.I.}.h.i.}.o.G.o.&+&+o.&+&+o.&+S.E.,+s+e+p+v+v+v+h+z+s+w+h+u+o+p+0+p+o+w+e+4+e+h+C+B+s+B+F+E+y+E+F+F+F+F+F+F+F+F+G+G+G+y+0+ ", 300 +" .+W m.^.L.h.h. +h.G.&+o.&+&+o.&+%+G.o.G.G.!.G.G.!.S.G.P.h+s+f+p+v+v+t+n+z+s+w+h+u+h+n+n+n+t+s+4+4+f+B+A+s+B+F+C+z+F+F+F+F+F+F+F+F+G+G+G+G+G+ ", 301 +" t.^.^.^.I.b.I. +h.G.&+G.G.&+&+o.!+!+G.!+!+!+G.~+~+G.~+W.f+o+s+f+p+v+v+s+s+z+s+w+n+u+h+h+t+e+A+8+4+8+A+z+s+C+F+A+B+F+F+F+F+F+F+F+G+G+G+G+G+G+A+ ", 302 +" t.^.m.h.h.<.i. +h.Y.&+Y.G.&+&+o.%+!+!+G.!+!+!+G.~+~+G.^+,+p+s+r+e+d+[+^+8.o.b+d+v+e+r+[+6+t+0+s+4+;+y+w+u+E+E+v+C+F+F+F+F+F+F+G+G+G+G+G+G+G+G+ ", 303 +" [.j.m.h.L.h.Y.h.V h.Y.Y.o.&+&+&+G.!+!+&+G.!+!+&+F.~+~+/+P.t+n+2+~.G G P J G .. .y t t q C .6+e+0+R.u+v+u+F+y+t+E+F+F+F+F+C+F+G+G+G+G+G+G+G+G+A+ ", 304 +" O m.<.h.L.}.Y.Y.o.S.&+o.h.o.o.S.o.!+!+!+G.!+!+!+U.%+~+~+<.o+r+L.Z y G G ..q s y .q ..G J a C y ^.,+t+t+y+D+p+y+C+F+F+F+C+A+G+G+G+G+G+G+G+G+G+F+ ", 305 +" [.^.^.h.L.h. +Y.I.G.&+&+G.&+!+!+G.8.F.G.G.!.S.S.G.o.G.F./.O V P J y t y C >...C Z ,...P G G y y h a q r+z+A+p+y+D+F+F+E+z+C+G+G+G+G+G+G+G+G+G+G+u+ ", 306 +" w._.W h.L.h.I.Y.Y.o.&+&+&+G.!+!+!+G.:+:+:+~+F.:+:+:+U.:+*+v Q h '.S *.Z C Z '.'.P Z Z ,.C J m ..s C h y !.r+s+y+E+F+F+B+A+G+G+G+G+G+G+G+G+G+G+G+F+n+ ", 307 +" ,+_.^.}.}.h.I.Y.Y.i.&+&+&+o.!+!+!+%+U.:+:+:+F.:+:+:+:+U.*+Q S S h '.S *.S P Z '.Z (.P Z ,.'.a m (.G 3 C ~.s V z+F+F+D+z+E+G+G+G+G+G+G+G+G+G+G+G+G+t+ ", 308 +" [.m.<.L.b.h.I.Y.o.&+&+&+S.U.!+!+!+G.:+:+:+:+G.:+:+:+:+U.k.S *.S h '.S *.S P Z '.Z 5.y Z ,.,.G y G m ..q .s &.b+E+z+B+G+G+G+G+G+G+G+G+G+G+G+G+E+z+ ", 309 +" w.j.^.L.L.h.Y.I.h.o.&+&+&+G.!+!+!+!+F.:+:+:+:+F.:+:+:+:+U.S S '.Q h '.S *.S '.J '.Z 5.(.C ,.'.z h h m y y t f.f.q [+F+G+G+G+G+G+G+G+G+G+G+E+y+t+z+w+ ", 310 +" _.^.E.L.b.Y.Y.Y.o.&+I.o.o.&+!+!+!+U.~+:+:+:+~+F.:+:+:+:+>.v S '.Q G G *.*.*.'.C '.'.5.'.y ,.Z m y 3 /...6. .~.J /.i.C+G+G+G+G+G+G+G+C+A+u+t+A+C+B+ ", 311 +" .+j.}.L.h.o.Y.Y.i.&+&+&+&+G.G.G.G.G.G.:+:+:+:+F.:+*+N.N.k.m S S '.Q S J *.*.*.'.C '.'.6.J y q y m Z 6.J (.(.6.t f.F.8.b+G+G+G+G+C+A+A+w+y+B+C+C+C+t+ ", 312 +" _.W L.L.h.Y.Y.Y.o.&+&+&+G.%+:+J.u.>.h 6 6 6 6 c 6 ) ) 6 m y G G ..m G s J J J J y y >...*.%.>.Z '.S S P u.6.u.c.c.F.F.!.x+C+A+A+B+z+y+C+C+C+C+C+z+ ", 313 +" .+_.<.L.b. +Y.Y.i.&+&+f.>.h g ^ , _ ) 5 ^ 5 5 5 ) 5 5 5 v '.h Z Z 5.Q %.J :.%.:.1.%.G 1.1.%.*...'.v '.N.6.>.J.J.J.&.F.f./.=.B+B+z+A+C+C+C+C+C+C+B+ ", 314 +" A.^.E.}.h.Y.G. .3 ) ) ) ) ) , _ ( ( < f e f e f < 5 f p Q 1.J %.%.:.%.%.J :.%.1.1.%.G 1.1.Q 1.*.C N.N.5.a.c.J.J.u.~. .f.8.q [+B+C+C+C+C+C+B+v+C+v+ ", 315 +" .+_.b.h.V 3 % ) % ( ( ( ( > ( ( ( ( ( [ e e f f f g f p %.Q 1.J %.%.:.%.:.J :.%.g.1.%.G 1.1.Q *.1./.k.5.N.N.l.>.6.u.J.&.&.P /.!.A+C+C+C+z+y+z+u+v+ ", 316 +" t.8 4 % % > > % % ( ( : [ < ( ( ( f < ].%.e.H.*+F.*+%.Q 1.Q 1.G %.%.:.%.:.J :.%.g.1.%.z 5.1.Q 1.1...6.k.k.k.N.c.J.6.P P &.f.f.!.b+B+y+y+B+C+w+4+ ", 317 +" 9 . # % # > > > > < > > [ > f g (.J.~+F.:+:+:+:+:+F.H.Q 1.1.%.*.>.%.:.:.%.:.J :.%.g.1.%.1...1.*.*.1.g.~.N.N.N.N.~.P /.u.u.&.f.f.P E.A+C+C+C+B+ ", 318 +" F / ' . + + # > > > > [ ( g .!.F.&+~+~+!+F.:+:+:+:+:+c.v %.1.1.%.S >.%.:.%.%.:.J :.%.g.1.Q g.(.*.g.g.`.`.c.N.f.~.~.6./.u.u.u./.P ~.c.!.x+C+C+C+f+ ", 319 +" |.F / o r @ . + + > [ > > c >.U.&+S.&+~+%+F.F.o.U.~+:+:+:+*+h *.1.1.1.%.S >.%.:.%.%.:.G '.%.g.1.Q g...1.5.u.l.l./.P a.N.N.k.P (.z ,.6.!.c.c.&.b+C+C+u+N / w ", 320 +" w / k d o d $ * + * > > c !.&+&+&+&+G.~+~+~+~+~+F.:+~+%+%+f.h y J C >...Z Z ..%.1.%.Z '.G C G >.>.J >. .>.u.N.g.g.x.~.5.5.5.*.J (.u.u.u.&.c.c.c.V B+B+s.I r k d w ", 321 +" K / r D D E D I $ # * # s G. +o.&+&+&+&+S.~+~+~+~+~+U.:+:+:+*+S Z (.:.:.k.5.Z J D.D.D.D.D.#+#+>.e.M.q.).M.e.6.g.g.g.1.1.>.k.5.5.k.N./.u.u.u.f.&.c. .=.r+0+R D I D k o } K ", 322 +" w / u r R D +.@.b * # 8 h.I. +h.&+&+&+&+&+F.~+~+~+~+!+%+:+:+:+k.S J 5.:.:.q.:.:.Z #+{+{+{+{+{+{+{.q.M.:.q.).e.G :.g.g.V.g.>.5.N.N.N.N./.u.u.u.u.&.8.8.!.[+* l D o d u d E d x n. ", 323 +" n.d d u o r d D o 2.' . }.<.I.h.h.o.&+&+&+&+G.!+~+~+~+~+%+~+:+:+:+Q S J :.:.%.q.:.:.'.#+{+{+{+{+{+{+T M.q.M.).e.M.l.V.x.g.g.x.6.u.N.N.N.N./.l.u.J.K.!.8.c.8.=.! | D o R o L o B o l d. ", 324 +" w 1 o B r L D $.D D N U ^.E.}.I.I.I.h.G.&+&+&+G.~+~+~+~+~+F.:+:+:+S Q S J :.:.%.q.:.:.(.{+{+{+{+{+{+{+T :.e.q.-+-+-+>.g.g.x.x.x.x.~.N.N.N.N.J.c.K.c.c.c.8.c./.h.I.U } u o R o R r B o o w ", 325 +" w 1 o B r L r $.D +.N P.b.E.b.I.I.L.I.S.o.o.&+G.~+~+~+~+~+F.:+:+S Q S Q J :.:.%.:.:.:.(.++{+{+{+++{+{+T q.q.-+-+M.M.l.x.x.x.x.x.V.c.N.N.N.N.J.!.c.K.K.K.!.c.F.h.I.d+ } u o D d u d o d o w ", 326 +" F d d u d D d I r $.d .+E.b.h.I.I.h.S.&+&+&+o.G.F.%+~+~+~+U.:+S v *.Q S J :.:.:.:.:.:.>.{+{+{+{+++{+{+{.).M.M.M.M.M.{.1.1.g.g.V.`.f.N.u.f.f.u.c.K.K.K.K.!./.&+o.h.[+ ; r o B r L r $.r D v. ", 327 +" s.o k B u R E E u u / .+^.<.I.I.I.h.&+&+&+&+I.!+!+&+S.F.U.U.Q S Q *.S S >.:.:.:.:.:.:.>.{+{+{+{+++{+{+{.:.M.M.M.M.-+Z.J.`.`.`.J.l./.c.J.N.N.N.f.K.K.K.K.&.F.&+I.}.[+ & 0 u u E E u E u o s. ", 328 +" o E r L r $.r $.r u w w._.^.I.I.I.h.&+&+&+&+I.!+!+!+!+!+F.h m J m J G Z >.:.:.1.:.:.:.{.{+++{+{+++{+++D.-+M.M.-+:+`.K./.l.l.l.N.`.N.f.N.N.N.N.l.f.K.K.K.&.&+&+o.b.[+ K k o B d u d I o E o ", 329 +" N o k B u B R u E E l w.j.^.h.I.I.i.&+&+&+&+G.!+!+!+!+!+G.v Z Z S S z J C ....>.G ....>.D.].D.D.].].D.9.l.l.K.K.J.J.`.l.`.`.`.x.x.k.~.a.k.k.k.5.P ..(.l.S.Y.o.I.}.[+ ' ~ d 1 B B D R d o N ", 330 +" d k o u o u o r d o w w.j.^.b.h.I.o.&+&+&+&+G.!+!+!+!+~+y v '.Z Z S S ..Z 1.*.1.%.%.*.C :.).M.e.).e.M.>.q.q.q.q.q.q.q.(.g.g.x.x.x.g.P 5.5.a.k.k./.l.!+!+!+=.I.Y.}.[+ 9 0 1 0 u L D $.D +.-. ", 331 +" s.r $.r $.r L k B k u 7. [.j.<.L.h.<.G.&+&+&+&+G.!+!+!+!+..a S Z '.Z S S J Q 1.1.1.%.%.%.J :.).e.:.M.-+-+l.V.V.V.V.V.V.q.>.g.g.g.g.x.`.c.N.N.k.k.k.P K.!+U.G.h.Y.Y.}.A. 9 0 1 u k L D $.D $.I s. ", 332 +" o D $.D $.r L k B k u 7. 6+j.<.L.L.}.o.o.S.&+S.F.!+!+!+(.z C S '.'.Z S S J %.1.%.1.%.%.:.J e.).).M.-+-+-+c.q.q.q.x.q.x.V.l.`.`.`.`.`.`.f.k.N.N.N.N.c.&+G.U.&+i.Y.Y.}.A. 9 { / 2 d u d u r $.I ;. ", 333 +" D D $.D $.r B d u r 0 K .+j.^.L.L.b.Y.Y.o.o.o.!+!+!+(.z ..h S '.'.Z S S J %.1.1.1.%.Q 1.>.e.).e.M.M.M.M.>.V.V.V.V.V.x.x.6.x.g.g.g.g.g.~.k.5.5.5.6.8.G.&+&+&+h.Y.Y.^. |.~ 1 0 u L u L o Y N D ", 334 +" I D I d D o u u 2 k { F _.^.L.L.b.Y.Y.Y.Y.i.G.F.G z z ..h *.'.'.S S S J %.1.%.1.%.Q 1.>.%.M.M.M.M.M.M.l.x.x.x.x.V.V.V.l.H.H.g.g.g.g.>.a.6./.c.%+G.&+&+&+&+i.Y.Y.W w ~ 0 2 L B I $.E 2.-.-. ", 335 +" o D $.I $.L u L k 0 1 d [.^.L.L.b.Y.Y.Y.Y.o.%+f.a a a J h *.Z '.S S S J :.%.%.1.%.Q 1.G M.-+-+-+-+-+-+l.V.V.x.x.g.x.x.6.g.x.V.H.k.6.P /.>.u.:+:+F.&+&+&+&+o.Y.h._. - ~ 0 r L u L $.R 2.-.-. ", 336 +" I -.$.+.R $.u L B k 0 2 n. t.W h.L.b.Y.Y.Y.Y.o.f.m m ..m P s C J >.,.'.S J :.%.%.1.:.%.Q >.-+-+M.M.M.M.M.l.g.q.x.V.V.V.V.6.a.(.>.>.f.N.l.(.u.:+:+:+S.&+&+&+&+o.o.}.[+ 7.& { { o u r L L +.2.2.;. ", 337 +" x 2.@.$.E $.R u E d 1 { / .+_.<.b.b.Y.Y.Y.Y.!.m G ..G m J h '.z ..G C h y ..G G ..(.S Q J e.M.M.-+-+>+>+l.u.u.l.l.l.l.l. .u.N.N.N.N.N.l.6.:+:+:+:+S.&+&+&+&+=.h.b.A. & { 2 k B u R E r Y @.z.v. ", 338 +" d.-.R $.R u I o k B 1 0 { b [.b.m.^.Y.Y.Y.Y.t m ....G m G J '.z ,.z '.z J 5.S Q 5.z ..l./.6.6.6.6.6.6.(.~.(.g.g.g.g.k.k.~.5.5.5.5.5.5.6.~+:+:+:+:+F.&+&+&+o.}.I.}. / - 2 1 B B I $.R 2.z.@.-.d. ", 339 +" o $.D -.@.L $.u B B 1 0 { { [.j.E.^.h.I.Y.y 3 G ....m G m J '.Z Z Z '.z J 5.S 5.S *.H.k.>.x.H.x.g.g.g.g.6.5.g.g.g.1.*.*.J '.5.k.k.k.k.%+!+:+:+:+:+F.&+G.o.Y.h.I.t. / - 2 1 B B u $.L 4.z.4.X.4.)+ ", 340 +" s.-.p.$.2.E L $.u B L r 0 ~ { .+^.E.b.h.h.4 a t G ....m G m J Z Z Z z '.z J *.5.S Q *.*.5.>.g.g.g.x.`.`.`.u.N.H.H.g.H.H.H./.N.N.N.N.k.:+%+%+:+:+:+:+G.o.Y.Y.o.I.L. ' = { { k k r $.$.@.z.2.z.p.1+ ", 341 +" ;.z.p.$.2.I L $.u B u d { { ' F W E.E.V a 3 q 4 P ....m G J J Z '.z z '.z J '.Q *.k.k.k.5.>.g.g.g.g.g.g.g.6.k.H.H.H.H.H.H./.N.N.N.k.*+:+%+%+:+!+F.G.o.Y.Y.Y.i.I.E. w = ~ 1 k B u u E D o z.y.p.z.T. ", 342 +" ;.z.2.$.2.I R D o k B u 1 2 - } |.E.j.] 3 t t q y t s C G J J Z '.z z '.'.J S S k.k.k.k.k.f.H.H.H.H.H.H.H.6.5.1.1.1.1.1.1.J 5.5.k.H.:+:+%+S.G.G.%+!+G.Y.Y.Y.h.h.P.; - 2 1 E B u R $.L -.z.Y @.X.T. ", 343 +" c+;.z.4.$.-.Y R $.L D E B u 1 1 - w U ] 3 t t q a C h y t a y Z '.z z ,.z C *.*.S S *.S S G *.*.1.1.1.1.1.,.'.1.1.1.1.1.k.~.5.*+*+~+U.U.o.U.!+!+!+!+o.Y.Y./+<.9 ; = { r B B D $.$.R p.z.y.y.@+;._+ ", 344 +" _+Y 4.@.2.z.p.@.L $.R u B B k 1 / = | 7 q t t t C h h C C 3 y P y C h ,./.k.k.k.5.1.5.5.>.1.1.1.g.k.H.H.u.N.`.`.`.`.`.H.P c.U.F.%+!+~+G.%+!+!+!+!+o.^+#.| & - ~ 2 u k o I $.$.@.z.z.p.X.X.@+1+ ", 345 +" 5+B.z.X.4.p.z.2.E $.$.E D o k k 1 ~ - = $ j q C h h C C 3 ....m m m P &.~.~.~.f.f.f.l./.u.u.u.u.u.u.l.f.c.f.f.f.f.f.>.F.!+~+~+~+~+~+G.!+!+!+'+ +n ; - ~ 1 k B E u I $.I D 4.z.z.p.(+@+@+c+ ", 346 +" s.B.p.X.z.4.z.z.-.E I R E u u B E 2 ~ ~ - ; n 4 y C C 3 G m G l.l.l.&.6.6.6.6.6.6.u.8.l.u.u.u.u.J.J.c.u.J.J.J.J.a.:+F.~+~+~+~+~+~+G./+W.#.| = = ~ 1 E B u u R $.$.@.-.z.@.p.@+(+@+}+ ", 347 +" T.p.z.X.p.2.z.-.-.@.L $.$.I u u B u 2 { = & = | 7 7 s ~.l.l.l.l.&.u.u.u.u.u.u.6.P 5.a.a.5.a.a.J./.u.J.J.J.a.:+:+F.~+~+!+/+C.#.| = & - ~ 2 u k k k I $.$.R -.p.X.O.p.y.@+@+@+1+ ", 348 +" )+T.y.z.z.4.p.z.z.p.-.E $.$.R u u r u u k 2 1 { & & ; | 7 A q 3./.F.6.6.6.6.6./.a.a.a.a.,.'.'.P Z '.5.!+'+^+C.H #.n | ; - - ~ 2 u B B u u u E D $.R -.p.X.z.p.@+<+(+(+B._+ ", 349 +" v.p.B.@+(+@+p.p.z.z.2.-.R $.D E I u u u B B E k 2 1 & = & & = ; ; F n #.H ` H H H 7 ` ` X n n n | ; = & & & { ~ 1 2 l B B u u u E $.$.$.R -.o z.X.z.p.@+<+(+9+|+1+ ", 350 +" 1+]+(+@+(+(+p.p.z.z.z.Y @.R R $.$.$.R I u u u u B B u u k 2 2 1 1 ~ - & - { ~ ~ ~ ~ ~ ~ ~ { 1 2 k u B B B u u k r r E $.$.$.R -.4.p.X.X.z.;.p.(+<+(+9+|+_+ ", 351 +" R.0.n.B.|+|+@+<+@+p.@.p.X.X.z.p.4.-.@.R $.$.R r E I I u u u u k u B r B B B B B B E u u u r o u u u I E R +.$.$.$.R R R 4.p.X.X.X.p.y.@+(+7+B.(+9+]+s. ", 352 +" 0+R.R.4+4+f+4+3+v.]+|+@+@+@+(+@+y.p.p.z.X.X.z.p.-.o R R R +.$.$.$.$.$.$.R r E R R R R R R +.$.$.$.I $.$.$.+.R R -.-.4.p.p.4.X.X.z.p.@+@+7+7+(+9+a+]+}+d. ", 353 +" R.4+n+0+8+f+h+0+n+4+n.T.]+a+9+(+(+7+<+X.@+y.p.p.z.p.X.X.z.z.y.p.2.4.4.-.-.o R -.-.-.-.-.-.-.-.-.-.;.4.p.p.z.X.X.X.X.@+p.p.p.4.@+<+7+(+(+a+9+9+}+5+ ", 354 +" e+;+h+h+f+8+e+n+n+e+n+e+0+p+R.)+_+]+9+9+7+(+@+(+7+<+4.@+@+@+y.y.p.p.z.@+X.X.X.p.X.X.X.X.X.X.X.X.X.X.X.p.z.z.p.p.@+@+@+@+(+7+7+7+y.(+7+a+9+]+_+ ", 355 +" 0+n+h+h+8+e+e+e+f+e+e+e+f+p+o+p+p+A+u+j+5+1+|+9+a+9+p.(+(+(+<+7+7+7+<+(+@+@+@+4.@+@+@+@+@+@+@+@+@+@+|+|+p.7+7+7+<+(+(+9+a+g+l+g+9+]+1+s. ", 356 +" 0+R.n+o+0+h+8+f+f+8+f+e+f+f+e+w+s+t+p+f+e+f+p+s+P.X M v.T.|+9+a+a+a+g+a+a+7+9+(+@+B.(+(+9+9+9+9+9+9+9+k+g+g+]+g+l+g+g+g+9+]+1+$+Q.r.3+ ", 357 +" R.R.R.f+o+f+f+8+0+n+4+h+0+0+n+n+8+0+f+p+p+n+n+e+4+8+P.8 4 q V W H #.M M x $+T.}+|+9+q+q+q+q+q+k+k+k+m+m+m+m+i+1+_+Q.r.=+W.L.L.h.h._..+ ", 358 +" ;+0.;+R.0+e+n+f+0+8+4+s+4+n+e+o+f+v+y+w+s+h+f+h+p+s+t+s+o+n+w.] ] ] 4 3 3 ! ! 4 s 8. +2+W.W.W.2+2+b+^+I.I.h. +^+^+^+Y.h. + + + +^.^.t. ", 359 +" 0.4+4+e+4+0+e+f+e+;+f+e+o+e+h+w+A+z+w+y+B+G+G+G+G+C+B+F+E+C+B+A+n+i i 8 q q q t V + + + + + +h.Y.Y.Y.Y.Y.i.I.Y.Y.Y.Y.I.h.I.h.}.W A..+ ", 360 +" R.0.0+8+0+0+8+f+8+o+4+n+R.p+A+z+t+n+n+s+w+z+w+y+A+G+G+G+G+G+G+G+G+G+B+d+W i ] V }.<.h.I. + + + +h.Y.Y.Y.Y.Y.h.Y.Y.o.h.h.<.}.b.b.[..+ ", 361 +" 0.R.;+;+8+8+f+4+h+4+p+;+s+y+p+h+s+u+t+t+p+s+p+t+w+u+t+y+A+F+G+G+G+G+G+G+G+B+w.t.j.m.E._.b.}.}.}.b.<.h.h.h.b.b.<.}.b.E.L.<.b.j.[+ ", 362 +" R.0.R.;+8+;+8+;+n+8+h+;+o+w+p+h+h+o+o+p+t+A+B+z+w+t+p+v+t+s+s+f+s+A+F+G+G+G+C+ .+A.W b.E.E.E.<.L.L.L.L.L.<.L.b.m.[+.+ ", 363 +" p+8+R.;+R.;+;+;+0+R.f+e+e+p+p+e+0+h+n+o+n+t+t+n+t+v+z+A+B+B+B+B+A+v+s+h+4+p+A+B+ [.w.t.[.W [.t.t.[.w.w. ", 364 +" p+p+e+8+;+;+;+;+8+R.;+8+f+o+s+w+o+8+e+h+f+f+p+s+n+t+u+u+s+h+p+t+w+w+w+w+v+A+o+0. ", 365 +" p+s+h+8+e+n+h+;+R.R.8+8+8+0+f+8+0+0+0+h+p+s+o+n+u+s+h+f+h+e+8+p+v+u+p+f+n+v+w+n+ ", 366 +" n+s+o+e+e+p+n+4+;+ ;+;+;+e+n+f+o+t+z+B+y+s+f+f+8+4+e+h+s+s+t+n+s+v+s+h+f+s+A+t+p+ ", 367 +" o+s+s+n+h+s+o+8+0. 0+0+8+4+R.8+4+8+p+n+w+C+F+F+F+D+z+s+h+8+f+t+w+s+p+u+t+t+ ", 368 +" h+s+t+p+p+s+s+0+R. 8+8+8+f+4+;+o+h+h+s+A+F+F+F+F+F+y+0.0.h+u+v+ ", 369 +" h+e+n+s+t+v+f+4+ 8+e+p+f+8+8+;+e+8+8+w+E+E+v+ ", 370 +" 0+4+e+f+o+n+8+ o+s+u+u+o+8+o+e+h+ ", 371 +" f+n+ s+t+p+o+ ", 372 +" "};
Added icons/kill_spindex.xpm.
1 +/* XPM */ 2 +static const char * kill_spindex_xpm[] = { 3 +"16 16 124 2", 4 +" c None", 5 +". c #ECCE40", 6 +"+ c #EBCC3F", 7 +"@ c #EACB3E", 8 +"# c #E9C93C", 9 +"$ c #E9C73B", 10 +"% c #E8C43A", 11 +"& c #E7C238", 12 +"* c #E6C036", 13 +"= c #E5BD35", 14 +"- c #E4BB33", 15 +"; c #E3B831", 16 +"> c #FAED9A", 17 +", c #F9EB99", 18 +"' c #F9E897", 19 +") c #F8E594", 20 +"! c #F7E291", 21 +"~ c #F6DF8E", 22 +"{ c #F5DB8B", 23 +"] c #EBC756", 24 +"^ c #F1D964", 25 +"/ c #FAEB9A", 26 +"( c #F4D848", 27 +"_ c #F3D344", 28 +": c #F1CE3F", 29 +"< c #F0C83A", 30 +"[ c #F5DC8C", 31 +"} c #EDCB62", 32 +"| c #EACA3D", 33 +"1 c #F9E993", 34 +"2 c #F7E172", 35 +"3 c #F3D445", 36 +"4 c #F2CE41", 37 +"5 c #F0C93C", 38 +"6 c #F5DC8A", 39 +"7 c #EFD070", 40 +"8 c #E4BB3D", 41 +"9 c #EFD45B", 42 +"0 c #F9EA99", 43 +"a c #F4D647", 44 +"b c #F2D042", 45 +"c c #F0CB3D", 46 +"d c #F3D56E", 47 +"e c #F3D77F", 48 +"f c #E7C04A", 49 +"g c #F5E180", 50 +"h c #F8E68E", 51 +"i c #F3D243", 52 +"j c #F1CD3F", 53 +"k c #EFC739", 54 +"l c #EAC658", 55 +"m c #ECCD4F", 56 +"n c #F9E998", 57 +"o c #F3D54A", 58 +"p c #F1CF45", 59 +"q c #F0CA40", 60 +"r c #EEC238", 61 +"s c #F4D989", 62 +"t c #E1B42E", 63 +"u c #E0B12C", 64 +"v c #DFAE2B", 65 +"w c #DEAC29", 66 +"x c #DCA927", 67 +"y c #DBA625", 68 +"z c #DAA323", 69 +"A c #F2DA75", 70 +"B c #F8E693", 71 +"C c #F7E391", 72 +"D c #F6E08D", 73 +"E c #F5DB8A", 74 +"F c #F4D788", 75 +"G c #F2D384", 76 +"H c #F1CF7F", 77 +"I c #F0CC7C", 78 +"J c #EFC97A", 79 +"K c #E3B448", 80 +"L c #E2B62F", 81 +"M c #F3D786", 82 +"N c #EBB62F", 83 +"O c #ECBC4A", 84 +"P c #F1CE80", 85 +"Q c #D68B39", 86 +"R c #C35812", 87 +"S c #BC4204", 88 +"T c #B94503", 89 +"U c #E0B22D", 90 +"V c #EECC70", 91 +"W c #F2D283", 92 +"X c #F1CE7E", 93 +"Y c #D58A35", 94 +"Z c #D17438", 95 +"` c #F7B58D", 96 +" . c #FED6B8", 97 +".. c #F5A872", 98 +"+. c #CB6B2D", 99 +"@. c #DFAF2B", 100 +"#. c #E7BD55", 101 +"$. c #DEAA2E", 102 +"%. c #BC4C06", 103 +"&. c #F6B58D", 104 +"*. c #FF924D", 105 +"=. c #FF7711", 106 +"-. c #FF8621", 107 +";. c #EB8A40", 108 +">. c #B94403", 109 +",. c #E7BC4F", 110 +"'. c #E6BA4C", 111 +"). c #DCA726", 112 +"!. c #FECDAE", 113 +"~. c #FFFFFF", 114 +"{. c #EF7F18", 115 +"]. c #DFAE2D", 116 +"^. c #DEAB2B", 117 +"/. c #F49D63", 118 +"(. c #FF7F18", 119 +"_. c #F87600", 120 +":. c #EE7600", 121 +"<. c #E16803", 122 +"[. c #C3571A", 123 +"}. c #C96425", 124 +"|. c #E67721", 125 +"1. c #EA7905", 126 +"2. c #DD6401", 127 +"3. c #BD4D04", 128 +" ", 129 +" . + @ # $ % & * = - ; ", 130 +" + > , ' ) ! ~ { ] ; ", 131 +" + ^ / ( _ : < [ } ; ", 132 +" | 1 2 3 4 5 6 7 8 ", 133 +" 9 0 a b c d e f ", 134 +" $ g h i j k [ l ", 135 +" m n o p q r s t u v w x y z ", 136 +"% A B C D 6 E F G H I J K z ", 137 +"& * = - ; L M N O P Q R S T ", 138 +" U V W X Y Z ` ...+. ", 139 +" @.G #.$.%.&.*.=.-.;.>.", 140 +" @.,.'.). S !.~.~.~.{.S ", 141 +" ].^.y T /.(._.:.<.T ", 142 +" w x [.}.|.1.2.3. ", 143 +" T S T "};
Added icons/memdb_clock.xpm.
1 +/* XPM */ 2 +static const char * memdb_clock_xpm[] = { 3 +"16 16 158 2", 4 +" c None", 5 +". c #C6AB7E", 6 +"+ c #CDB378", 7 +"@ c #D0B87B", 8 +"# c #CDB47A", 9 +"$ c #C4A971", 10 +"% c #B99D71", 11 +"& c #C2AA86", 12 +"* c #D2BA78", 13 +"= c #E3D9C8", 14 +"- c #EAE7DD", 15 +"; c #F1F1EE", 16 +"> c #F0F0EC", 17 +", c #E4E0D2", 18 +"' c #D2C4A8", 19 +") c #B89C67", 20 +"! c #C0A885", 21 +"~ c #DCCC97", 22 +"{ c #EEEBE1", 23 +"] c #D9E1EE", 24 +"^ c #ACBEDF", 25 +"/ c #96ADD5", 26 +"( c #92AAD4", 27 +"_ c #A3B7DC", 28 +": c #CEDAE8", 29 +"< c #DFD9C6", 30 +"[ c #B69B68", 31 +"} c #CCB374", 32 +"| c #ECE9DF", 33 +"1 c #C2CFE6", 34 +"2 c #AEBFDF", 35 +"3 c #DCE3F1", 36 +"4 c #ECF1F3", 37 +"5 c #EBF1F4", 38 +"6 c #D9E2F1", 39 +"7 c #A3BADC", 40 +"8 c #AFC1DE", 41 +"9 c #D8CFB7", 42 +"0 c #A48358", 43 +"a c #BCA177", 44 +"b c #DBCFB7", 45 +"c c #D7E0ED", 46 +"d c #AABDDE", 47 +"e c #FFFFFF", 48 +"f c #EEF0F0", 49 +"g c #DAE5E7", 50 +"h c #F7FFFF", 51 +"i c #F3FEFF", 52 +"j c #98B4DC", 53 +"k c #C4D1E1", 54 +"l c #BBA473", 55 +"m c #987C59", 56 +"n c #BEA26D", 57 +"o c #E6E1D3", 58 +"p c #A4B9DB", 59 +"q c #D6E3F1", 60 +"r c #F5FBFE", 61 +"s c #F3F5F5", 62 +"t c #959E9F", 63 +"u c #E9F0F0", 64 +"v c #F2F8F8", 65 +"w c #ADB9BE", 66 +"x c #C2DAF0", 67 +"y c #8BA7D1", 68 +"z c #D3CAA9", 69 +"A c #9B7B53", 70 +"B c #BDA16C", 71 +"C c #EEECE4", 72 +"D c #8AA5D1", 73 +"E c #E9F6FA", 74 +"F c #EEF8FD", 75 +"G c #F9FFFF", 76 +"H c #798081", 77 +"I c #A4AEB1", 78 +"J c #777F81", 79 +"K c #BAC6C9", 80 +"L c #D3F0FA", 81 +"M c #7295C9", 82 +"N c #E2DFC9", 83 +"O c #9E7B54", 84 +"P c #B89A67", 85 +"Q c #ECEADD", 86 +"R c #819FCF", 87 +"S c #E2F3FA", 88 +"T c #E9F6FD", 89 +"U c #E3F0F2", 90 +"V c #848C8D", 91 +"W c #C2CFD2", 92 +"X c #EBFBFF", 93 +"Y c #CCECFA", 94 +"Z c #6D90C7", 95 +"` c #E1DDC1", 96 +" . c #9D7953", 97 +".. c #AD8E5E", 98 +"+. c #DDD3B7", 99 +"@. c #90AAD1", 100 +"#. c #C1DBF0", 101 +"$. c #E6F7FF", 102 +"%. c #E3F2FA", 103 +"&. c #B6C0C5", 104 +"*. c #DEEDF1", 105 +"=. c #E8FCFF", 106 +"-. c #A9C6AE", 107 +";. c #719760", 108 +">. c #668E4F", 109 +",. c #5F8744", 110 +"'. c #6E773E", 111 +"). c #A0855E", 112 +"!. c #C0A978", 113 +"~. c #C6D1DA", 114 +"{. c #88AAD9", 115 +"]. c #EBFEFF", 116 +"^. c #EEFAFF", 117 +"/. c #F2FDFF", 118 +"(. c #F2FEFF", 119 +"_. c #ABC5A8", 120 +":. c #81AB61", 121 +"<. c #B4D495", 122 +"[. c #D0E6BA", 123 +"}. c #8FBB6A", 124 +"|. c #578F2D", 125 +"1. c #376B19", 126 +"2. c #A28257", 127 +"3. c #D8CCA2", 128 +"4. c #A5B7CD", 129 +"5. c #89AAD8", 130 +"6. c #CFDFEF", 131 +"7. c #F3F6FA", 132 +"8. c #F3F5FA", 133 +"9. c #618A49", 134 +"0. c #B1D390", 135 +"a. c #B1D692", 136 +"b. c #8CBC65", 137 +"c. c #8FBC67", 138 +"d. c #A68855", 139 +"e. c #D6C896", 140 +"f. c #BFCACC", 141 +"g. c #869FC8", 142 +"h. c #7692C5", 143 +"i. c #7390C4", 144 +"j. c #4C7B31", 145 +"k. c #B6D49C", 146 +"l. c #B2D295", 147 +"m. c #9A7850", 148 +"n. c #B1975A", 149 +"o. c #CEBD85", 150 +"p. c #DED6A4", 151 +"q. c #DED5A0", 152 +"r. c #3E6E1E", 153 +"s. c #8BBA62", 154 +"t. c #87BA60", 155 +"u. c #87B960", 156 +"v. c #917553", 157 +"w. c #93724E", 158 +"x. c #97744D", 159 +"y. c #606E31", 160 +"z. c #538C28", 161 +"A. c #8DBA64", 162 +" ", 163 +" . + @ # $ % ", 164 +" & * = - ; > , ' ) ", 165 +" ! ~ { ] ^ / ( _ : < [ ", 166 +" } | 1 2 3 4 5 6 7 8 9 0 ", 167 +" a b c d e f g h h i j k l m ", 168 +" n o p q r s t u v w x y z A ", 169 +" B C D E F G H I J K L M N O ", 170 +" P Q R S T U V J W X Y Z ` . ", 171 +" ..+.@.#.$.%.&.*.=.-.;.>.,.'. ", 172 +" ).!.~.{.].^./.(._.:.<.[.}.|.1.", 173 +" 2.3.4.5.6.7.8.9.0.a.e b.c.1.", 174 +" d.e.f.g.h.i.j.k.e e e l.1.", 175 +" m.n.o.p.q.r.s.t.e u.c.1.", 176 +" v.w.x.x.y.z.A.l.A.z.1.", 177 +" 1.1.1.1.1. "};
Added icons/memdb_load.xpm.
1 +/* XPM */ 2 +static const char * memdb_load_xpm[] = { 3 +"16 16 121 2", 4 +" c None", 5 +". c #BABABA", 6 +"+ c #B8B8B8", 7 +"@ c #B7B7B7", 8 +"# c #B6B6B6", 9 +"$ c #B4B4B4", 10 +"% c #B3B3B3", 11 +"& c #BBBBBB", 12 +"* c #D0D0D0", 13 +"= c #E8E8E8", 14 +"- c #F3F3F3", 15 +"; c #FDFDFD", 16 +"> c #FCFCFC", 17 +", c #EDEDED", 18 +"' c #E0E0E0", 19 +") c #C2C2C2", 20 +"! c #ADADAD", 21 +"~ c #E1E1E1", 22 +"{ c #FEFEFE", 23 +"] c #FFFFFF", 24 +"^ c #FBFBFB", 25 +"/ c #CFCFCF", 26 +"( c #A9A9A9", 27 +"_ c #B9B9B9", 28 +": c #F8F8F8", 29 +"< c #EAEAEA", 30 +"[ c #A7A7A7", 31 +"} c #F7F7F7", 32 +"| c #E7E7E7", 33 +"1 c #EFEFEF", 34 +"2 c #F6F6F6", 35 +"3 c #FAFAFA", 36 +"4 c #F0F0F0", 37 +"5 c #DEDEDE", 38 +"6 c #C3C3C3", 39 +"7 c #E6E6E6", 40 +"8 c #A5A5A5", 41 +"9 c #B5B5B5", 42 +"0 c #EBEBEB", 43 +"a c #D6D6D6", 44 +"b c #D5D5D5", 45 +"c c #D1D1D1", 46 +"d c #BCBCBC", 47 +"e c #C0C0C0", 48 +"f c #E5E5E5", 49 +"g c #A3A3A3", 50 +"h c #F5F5F5", 51 +"i c #EEEEEE", 52 +"j c #E2E2E2", 53 +"k c #CDCDCD", 54 +"l c #6EA43C", 55 +"m c #659F31", 56 +"n c #DEE1DD", 57 +"o c #A0A0A0", 58 +"p c #B2B2B2", 59 +"q c #F4F4F4", 60 +"r c #DDDDDD", 61 +"s c #E3E3E3", 62 +"t c #C9C9C9", 63 +"u c #67A036", 64 +"v c #81B35A", 65 +"w c #579828", 66 +"x c #9B9E99", 67 +"y c #B0B0B0", 68 +"z c #6FA53D", 69 +"A c #6EA338", 70 +"B c #68A134", 71 +"C c #629D30", 72 +"D c #7CAF55", 73 +"E c #AACB91", 74 +"F c #74AB4F", 75 +"G c #468F18", 76 +"H c #AEAEAE", 77 +"I c #F2F2F2", 78 +"J c #D8D8D8", 79 +"K c #6BA337", 80 +"L c #B0CE96", 81 +"M c #ADCD94", 82 +"N c #A8CB90", 83 +"O c #90BC74", 84 +"P c #A1C78A", 85 +"Q c #68A546", 86 +"R c #358707", 87 +"S c #ACACAC", 88 +"T c #D4D4D4", 89 +"U c #639F31", 90 +"V c #8EBA6F", 91 +"W c #89B86B", 92 +"X c #85B666", 93 +"Y c #80B361", 94 +"Z c #82B567", 95 +"` c #98C283", 96 +" . c #5CA03C", 97 +".. c #257F00", 98 +"+. c #DBDBDB", 99 +"@. c #5B9B29", 100 +"#. c #A9CA90", 101 +"$. c #A5C88D", 102 +"%. c #A1C68A", 103 +"&. c #9EC588", 104 +"*. c #85B66A", 105 +"=. c #97C282", 106 +"-. c #66A548", 107 +";. c #217D00", 108 +">. c #CECECE", 109 +",. c #529722", 110 +"'. c #4A911C", 111 +"). c #448F16", 112 +"!. c #3C8B10", 113 +"~. c #5E9F3A", 114 +"{. c #96C180", 115 +"]. c #62A346", 116 +"^. c #217D03", 117 +"/. c #A1A1A1", 118 +"(. c #9F9F9F", 119 +"_. c #ABABAB", 120 +":. c #959595", 121 +"<. c #2E8306", 122 +"[. c #5FA143", 123 +"}. c #207B01", 124 +"|. c #1E7B03", 125 +" ", 126 +" . + @ # $ % ", 127 +" & * = - ; > , ' ) ! ", 128 +" . ~ { ] ] ] ] ] ] ^ / ( ", 129 +" _ : { ] ] ] ] ] ] ^ < [ ", 130 +" @ } | 1 2 ^ 3 4 5 6 7 8 ", 131 +" 9 2 0 5 a b c 6 d e f g ", 132 +" $ h i 7 j 7 ~ k l m n o ", 133 +" p q < ~ r s 5 t u v w x ", 134 +" y - | r z A B C D E F G ", 135 +" H I j J K L M E N O P Q R ", 136 +" S 4 5 T U M V W X Y Z ` ...", 137 +" ( 5 - +.@.#.$.%.&.*.=.-.;. ", 138 +" 8 >., ,.'.).!.~.{.].^. ", 139 +" /.(./._.[ :.<.[.}. ", 140 +" ;.|. "};
Added icons/memdb_new.xpm.
1 +/* XPM */ 2 +static const char * memdb_new_xpm[] = { 3 +"16 16 137 2", 4 +" c None", 5 +". c #BABABA", 6 +"+ c #B8B8B8", 7 +"@ c #B7B7B7", 8 +"# c #B6B6B6", 9 +"$ c #B4B4B4", 10 +"% c #B3B3B3", 11 +"& c #BBBBBB", 12 +"* c #D0D0D0", 13 +"= c #E8E8E8", 14 +"- c #F3F3F3", 15 +"; c #FDFDFD", 16 +"> c #FCFCFC", 17 +", c #EDEDED", 18 +"' c #E0E0E0", 19 +") c #C2C2C2", 20 +"! c #ADADAD", 21 +"~ c #E1E1E1", 22 +"{ c #FEFEFE", 23 +"] c #FFFFFF", 24 +"^ c #FBFBFB", 25 +"/ c #CFCFCF", 26 +"( c #A9A9A9", 27 +"_ c #EAC93D", 28 +": c #E2C54C", 29 +"< c #EACC55", 30 +"[ c #EACA55", 31 +"} c #E9C753", 32 +"| c #E7C34E", 33 +"1 c #E8C559", 34 +"2 c #FCF7E8", 35 +"3 c #EAEAEA", 36 +"4 c #A7A7A7", 37 +"5 c #F3DC73", 38 +"6 c #F6E289", 39 +"7 c #F4DE84", 40 +"8 c #F3D981", 41 +"9 c #F1D378", 42 +"0 c #E8C14F", 43 +"a c #F0DFAF", 44 +"b c #F8F7F6", 45 +"c c #E7E7E7", 46 +"d c #D8D8D8", 47 +"e c #C7C7C7", 48 +"f c #E6E6E6", 49 +"g c #A5A5A5", 50 +"h c #E8C63B", 51 +"i c #F8E793", 52 +"j c #F4D85F", 53 +"k c #F6E090", 54 +"l c #F2D57C", 55 +"m c #E9C352", 56 +"n c #CFBD89", 57 +"o c #CCCCCC", 58 +"p c #C9C9C9", 59 +"q c #B5B5B5", 60 +"r c #C1C1C1", 61 +"s c #E5E5E5", 62 +"t c #A3A3A3", 63 +"u c #E8C63A", 64 +"v c #F1D86A", 65 +"w c #F8E796", 66 +"x c #F2CF47", 67 +"y c #F4DC89", 68 +"z c #E2B837", 69 +"A c #E3D098", 70 +"B c #E2E2E2", 71 +"C c #CDCDCD", 72 +"D c #E3E3E3", 73 +"E c #A0A0A0", 74 +"F c #E7C338", 75 +"G c #F8E68F", 76 +"H c #F7E38D", 77 +"I c #F2D260", 78 +"J c #F4D784", 79 +"K c #E1B63A", 80 +"L c #E0C47B", 81 +"M c #DDC27D", 82 +"N c #DFC179", 83 +"O c #DCC183", 84 +"P c #CBC4B6", 85 +"Q c #BDBDBD", 86 +"R c #BFBFBF", 87 +"S c #9E9E9E", 88 +"T c #E7C238", 89 +"U c #F0D76D", 90 +"V c #EFD267", 91 +"W c #EDCF66", 92 +"X c #F3D984", 93 +"Y c #F4D788", 94 +"Z c #F1CF7D", 95 +"` c #E8BD58", 96 +" . c #E6B852", 97 +".. c #DAA425", 98 +"+. c #D9C393", 99 +"@. c #C5C2BD", 100 +"#. c #9B9B9B", 101 +"$. c #E4BC34", 102 +"%. c #E3B831", 103 +"&. c #E1B52F", 104 +"*. c #DCB137", 105 +"=. c #F0D07D", 106 +"-. c #EDC76D", 107 +";. c #E3B345", 108 +">. c #D8B567", 109 +",. c #DBD3C3", 110 +"'. c #C0C0C0", 111 +"). c #969696", 112 +"!. c #DCAD2F", 113 +"~. c #E7BC52", 114 +"{. c #DBAC39", 115 +"]. c #D6C192", 116 +"^. c #D2D2D2", 117 +"/. c #DBDBDB", 118 +"(. c #D6D6D6", 119 +"_. c #B0B0B0", 120 +":. c #DEDEDE", 121 +"<. c #909090", 122 +"[. c #DEAD2A", 123 +"}. c #E4B644", 124 +"|. c #DCB863", 125 +"1. c #F1EEE6", 126 +"2. c #C4C4C4", 127 +"3. c #8B8B8B", 128 +"4. c #DCA927", 129 +"5. c #C7A657", 130 +"6. c #CECECE", 131 +"7. c #F4F4F4", 132 +"8. c #F5F5F5", 133 +"9. c #EFEFEF", 134 +"0. c #8A8A8A", 135 +"a. c #A1A1A1", 136 +"b. c #9F9F9F", 137 +"c. c #ABABAB", 138 +"d. c #959595", 139 +"e. c #8D8D8D", 140 +"f. c #898989", 141 +" ", 142 +" . + @ # $ % ", 143 +" & * = - ; > , ' ) ! ", 144 +" . ~ { ] ] ] ] ] ] ^ / ( ", 145 +" _ : < [ } | 1 2 ] ] ^ 3 4 ", 146 +" _ 5 6 7 8 9 0 a b c d e f g ", 147 +" h i j k l m n o p q @ r s t ", 148 +" u v w x y z A B f ~ C ) ) D E ", 149 +" F G H I J K L M N O P Q R B S ", 150 +"T U V W X Y Z ` ...+.@.+ & ~ #.", 151 +" $.%.&.*.=.-.;.>.,.d '.% @ ' ).", 152 +" !.~.{.].^./.(.R _.% :.<.", 153 +" [.}.|.1./.^./.(.'.p f 2.3.", 154 +" 4.5.g 6., 7.8.7.9.B . 0. ", 155 +" a.b.a.c.4 d.e.f. ", 156 +" "};
Added icons/memdb_save.xpm.
1 +/* XPM */ 2 +static const char * memdb_save_xpm[] = { 3 +"16 16 158 2", 4 +" c None", 5 +". c #BABABA", 6 +"+ c #B8B8B8", 7 +"@ c #B7B7B7", 8 +"# c #B6B6B6", 9 +"$ c #B4B4B4", 10 +"% c #B3B3B3", 11 +"& c #BBBBBB", 12 +"* c #D0D0D0", 13 +"= c #E8E8E8", 14 +"- c #F3F3F3", 15 +"; c #FDFDFD", 16 +"> c #FCFCFC", 17 +", c #EDEDED", 18 +"' c #E0E0E0", 19 +") c #C2C2C2", 20 +"! c #ADADAD", 21 +"~ c #E1E1E1", 22 +"{ c #FEFEFE", 23 +"] c #FFFFFF", 24 +"^ c #FBFBFB", 25 +"/ c #CFCFCF", 26 +"( c #A9A9A9", 27 +"_ c #B9B9B9", 28 +": c #F8F8F8", 29 +"< c #EAEAEA", 30 +"[ c #A7A7A7", 31 +"} c #F7F7F7", 32 +"| c #E7E7E7", 33 +"1 c #EFEFEF", 34 +"2 c #F6F6F6", 35 +"3 c #FAFAFA", 36 +"4 c #F0F0F0", 37 +"5 c #DEDEDE", 38 +"6 c #C3C3C3", 39 +"7 c #E6E6E6", 40 +"8 c #A5A5A5", 41 +"9 c #B5B5B5", 42 +"0 c #EBEBEB", 43 +"a c #D6D6D6", 44 +"b c #D5D5D5", 45 +"c c #D1D1D1", 46 +"d c #BCBCBC", 47 +"e c #C0C0C0", 48 +"f c #E5E5E5", 49 +"g c #A3A3A3", 50 +"h c #F5F5F5", 51 +"i c #EEEEEE", 52 +"j c #E2E2E2", 53 +"k c #6E97D4", 54 +"l c #7B9ED4", 55 +"m c #7198D0", 56 +"n c #82A4D6", 57 +"o c #688ECD", 58 +"p c #6990CD", 59 +"q c #759AD0", 60 +"r c #7399D1", 61 +"s c #628BC8", 62 +"t c #B2B2B2", 63 +"u c #F4F4F4", 64 +"v c #DDDDDD", 65 +"w c #E3E3E3", 66 +"x c #658DCC", 67 +"y c #B0CDF3", 68 +"z c #B3C7E3", 69 +"A c #A1BFEA", 70 +"B c #6089C9", 71 +"C c #B0B0B0", 72 +"D c #D9D9D9", 73 +"E c #5B86C7", 74 +"F c #9EC0EF", 75 +"G c #6E93CC", 76 +"H c #F7FBFF", 77 +"I c #F1F8FF", 78 +"J c #8CAFE4", 79 +"K c #618AC7", 80 +"L c #AEAEAE", 81 +"M c #F2F2F2", 82 +"N c #D8D8D8", 83 +"O c #DCDCDC", 84 +"P c #5D88C8", 85 +"Q c #A1BFEF", 86 +"R c #FAFCFD", 87 +"S c #FBFCFE", 88 +"T c #FDFDFE", 89 +"U c #FCFDFE", 90 +"V c #FAFBFD", 91 +"W c #FBFCFD", 92 +"X c #85A8DD", 93 +"Y c #537FC1", 94 +"Z c #ACACAC", 95 +"` c #D4D4D4", 96 +" . c #D2D2D2", 97 +".. c #DBDBDB", 98 +"+. c #658DCA", 99 +"@. c #99B8EA", 100 +"#. c #7EA5DD", 101 +"$. c #80A6DD", 102 +"%. c #7CA3DB", 103 +"&. c #7AA0D9", 104 +"*. c #79A0D9", 105 +"=. c #789FD8", 106 +"-. c #789ED8", 107 +";. c #5D84BF", 108 +">. c #618BC9", 109 +",. c #92B5E6", 110 +"'. c #81A7E2", 111 +"). c #81A7E1", 112 +"!. c #7DA3DE", 113 +"~. c #7BA1DC", 114 +"{. c #799FDB", 115 +"]. c #779ED9", 116 +"^. c #739AD4", 117 +"/. c #577EBB", 118 +"(. c #CECECE", 119 +"_. c #5481C4", 120 +":. c #97B6EA", 121 +"<. c #EAF3F3", 122 +"[. c #E6F1ED", 123 +"}. c #E6F1EF", 124 +"|. c #E6F0EF", 125 +"1. c #E5F1ED", 126 +"2. c #EDF5F3", 127 +"3. c #799CD5", 128 +"4. c #4470B0", 129 +"5. c #A1A1A1", 130 +"6. c #9F9F9F", 131 +"7. c #ABABAB", 132 +"8. c #517FC3", 133 +"9. c #9AB6EF", 134 +"0. c #E8F3EA", 135 +"a. c #84BF51", 136 +"b. c #98C96F", 137 +"c. c #99C971", 138 +"d. c #84BF54", 139 +"e. c #E9F4E4", 140 +"f. c #7B9CDD", 141 +"g. c #3A69AA", 142 +"h. c #5583C6", 143 +"i. c #BACEEF", 144 +"j. c #FFFFDD", 145 +"k. c #C7EE87", 146 +"l. c #D7F4A2", 147 +"m. c #D7F6A2", 148 +"n. c #C7EE8C", 149 +"o. c #FFFFE0", 150 +"p. c #85A2DD", 151 +"q. c #3E6AAB", 152 +"r. c #3368BA", 153 +"s. c #5884C3", 154 +"t. c #688BD3", 155 +"u. c #708FE1", 156 +"v. c #6C8DDC", 157 +"w. c #6D8BDA", 158 +"x. c #6E8AD7", 159 +"y. c #6C8BCD", 160 +"z. c #446DAB", 161 +"A. c #2E5FA6", 162 +" . + @ # $ % ", 163 +" & * = - ; > , ' ) ! ", 164 +". ~ { ] ] ] ] ] ] ^ / ( ", 165 +"_ : { ] ] ] ] ] ] ^ < [ ", 166 +"@ } | 1 2 ^ 3 4 5 6 7 8 ", 167 +"9 2 0 5 a b c 6 d e f g ", 168 +"$ h i 7 j 7 k l m n o p q r s ", 169 +"t u < ~ v w x y ] z ] ] ] ] A B ", 170 +"C - | v D ' E F ] G ] ] H I J K ", 171 +"L M j N b O P Q R S T U V W X Y ", 172 +"Z 4 5 ` ...+.@.#.$.%.&.*.=.-.;.", 173 +"( 5 - .. ...>.,.'.).!.~.{.].^./.", 174 +" 8 (., u h _.:.<.[.}.|.1.2.3.4.", 175 +" 5.6.5.7.8.9.0.a.b.c.d.e.f.g.", 176 +" h.i.j.k.l.m.n.o.p.q.", 177 +" r.s.t.u.v.w.x.y.z.A."};
Added icons/network.xpm.
1 +/* XPM */ 2 +static const char * network_xpm[] = { 3 +"16 16 37 1", 4 +" c None", 5 +". c #707070", 6 +"+ c #C5C5C5", 7 +"@ c #A8A8A8", 8 +"# c #9A9A9A", 9 +"$ c #D1D1D1", 10 +"% c #737373", 11 +"& c #A4A4A4", 12 +"* c #979797", 13 +"= c #A0A0A0", 14 +"- c #D5D5D5", 15 +"; c #989898", 16 +"> c #777777", 17 +", c #C7C7C7", 18 +"' c #A2A2A2", 19 +") c #8D8D8D", 20 +"! c #9B9B9B", 21 +"~ c #A1A1A1", 22 +"{ c #7F7F7F", 23 +"] c #8A8A8A", 24 +"^ c #949494", 25 +"/ c #A7A7A7", 26 +"( c #909090", 27 +"_ c #939393", 28 +": c #A3A3A3", 29 +"< c #7B7B7B", 30 +"[ c #A5A5A5", 31 +"} c #9D9D9D", 32 +"| c #7D7D7D", 33 +"1 c #9F9F9F", 34 +"2 c #848484", 35 +"3 c #727272", 36 +"4 c #7E7E7E", 37 +"5 c #858585", 38 +"6 c #9E9E9E", 39 +"7 c #DADADA", 40 +"8 c #FFFFFF", 41 +" ", 42 +" ", 43 +" 888888 ", 44 +" 8@/[&~=8 ", 45 +" 8@87-$,+!8 ", 46 +"888@8&=1#;;+^888", 47 +"866666:88*666668", 48 +"8777775 {777778", 49 +"855555#88%.....8", 50 +"888'8*(]24<+>888", 51 +" 8}87-$,+38 ", 52 +" 8_)5|>%8 ", 53 +" 888888 ", 54 +" ", 55 +" ", 56 +" "};
Added indent_me.
1 +indent -npsl -nbfda -l80 -i2 -ci2 -cbi2 -cp2 -ts2 -cli2 -bl -ce -lp -npcs -nut *.h *.cpp 2 +
Added mac_resource/wxmac.icns.
cannot compute difference between binary files
Changes to win_resource/icon.ico.
cannot compute difference between binary files
Added win_resource/spatialite-icon.png.
cannot compute difference between binary files