SAGA API Version 9.14
Loading...
Searching...
No Matches
map_layer.cpp
Go to the documentation of this file.
1
3// //
4// SAGA //
5// //
6// System for Automated Geoscientific Analyses //
7// //
8// Application Programming Interface //
9// //
10// Library: SAGA_API //
11// //
12//-------------------------------------------------------//
13// //
14// map_layer.cpp //
15// //
16// Copyright (C) 2026 by //
17// Olaf Conrad //
18// //
19//-------------------------------------------------------//
20// //
21// This file is part of 'SAGA - System for Automated //
22// Geoscientific Analyses'. SAGA is free software; you //
23// can redistribute it and/or modify it under the terms //
24// of the GNU General Public License as published by the //
25// Free Software Foundation, either version 2 of the //
26// License, or (at your option) any later version. //
27// //
28// SAGA is distributed in the hope that it will be //
29// useful, but WITHOUT ANY WARRANTY; without even the //
30// implied warranty of MERCHANTABILITY or FITNESS FOR A //
31// PARTICULAR PURPOSE. See the GNU General Public //
32// License for more details. //
33// //
34// You should have received a copy of the GNU General //
35// Public License along with this program; if not, see //
36// <http://www.gnu.org/licenses/>. //
37// //
38//-------------------------------------------------------//
39// //
40// e-mail: oconrad@saga-gis.org //
41// //
42// contact: Olaf Conrad //
43// Institute of Geography //
44// University of Hamburg //
45// Germany //
46// //
48
49//---------------------------------------------------------
50#include "../dc_helper.h"
51
52#include "map_symbology.h"
53#include "map_legend.h"
54
55#include "map_layer.h"
56
57#include "map_classify.h"
58
59
61// //
62// //
63// //
65
66//---------------------------------------------------------
68{
69 static CSG_Parameters Parameters;
70
71 if( Parameters.Get_Count() == 0 )
72 {
73 Parameters.Set_Name("Layer Setting Defaults");
74
75 Parameters.Add_Choice("", "STRETCH" , _TL("Stretch" ), _TL(""), CSG_String::Format("%s|%s|%s", _TL("Linear"), _TL("Standard Deviation"), _TL("Percent Clip")), 1);
76 Parameters.Add_Range ("", "STRETCH_LINEAR" , _TL("Linear" ), _TL(""), 0., 100., 0., true, 100., true);
77 Parameters.Add_Double("", "STRETCH_STDDEV" , _TL("Standard Deviation"), _TL(""), 2., 0., true);
78 Parameters.Add_Bool ("", "STRETCH_STDDEV_RANGE", _TL("Keep in Range" ), _TL(""), true);
79 Parameters.Add_Range ("", "STRETCH_PERCENT" , _TL("Percent Clip" ), _TL(""), 1., 99., 0., true, 100., true);
80 Parameters.Add_Choice("", "STRETCH_INVALID" , _TL("Invalid Range" ), _TL(""), CSG_String::Format("%s|%s|%s", _TL("ignore"), _TL("ask what to do"), _TL("adjust to full range")), 2);
81 }
82
83 return( Parameters );
84}
85
86
88// //
89// //
90// //
92
93//---------------------------------------------------------
94#define CLASSIFY_UNIQUE 0
95#define CLASSIFY_EQUAL 1
96#define CLASSIFY_DEFINED 2
97#define CLASSIFY_QUANTILE 3
98#define CLASSIFY_GEOMETRIC 4
99#define CLASSIFY_NATURAL 5
100#define CLASSIFY_STDDEV 6
101#define CLASSIFY_MANUAL 7
102
103//---------------------------------------------------------
104#define DEF_LAYER_COLOUR_COUNT 10
105
119
120
122// //
123// //
124// //
126
127//---------------------------------------------------------
129{
130 m_Type = Type;
131 m_pObject = NULL;
132
134 m_pLegend = new CSG_Map_Legend (this);
135
136 m_pThumbnail = new wxBitmap();
137
139}
140
141//---------------------------------------------------------
143{
144 if( m_pSymbology ) { delete(m_pSymbology); }
145 if( m_pLegend ) { delete(m_pLegend ); }
146
147 if( m_pThumbnail ) { delete(m_pThumbnail); }
148}
149
150
152// //
154
155//---------------------------------------------------------
157{
158 if( pObject && pObject->Get_ObjectType() != m_Type )
159 {
160 return( false );
161 }
162
163 if( m_pObject != pObject )
164 {
165 m_pObject = pObject;
166
167 if( m_pObject )
168 {
169 m_pSymbology->Update();
170
171 if( m_Parameters["STRETCH"].asInt() == 3 && Get_Stretch_Range() == 0. )
172 {
173 m_Parameters["STRETCH"].Set_Value(1);
174 }
175 }
176
178 }
179
180 return( true );
181}
182
183
185// //
187
188//---------------------------------------------------------
190{
191 //-----------------------------------------------------
192 // Nodes...
193
194 if( !Parameters("NODE_DISPLAY") ) { Parameters.Add_Node("", "NODE_DISPLAY", _TL("Display" ), _TL("") ); }
195 if( !Parameters("NODE_LEGEND" ) ) { Parameters.Add_Node("", "NODE_LEGEND" , _TL("Legend" ), _TL(""), true); }
196 if( !Parameters("NODE_DISPLAY") ) { Parameters.Add_Node("", "NODE_DISPLAY", _TL("Display" ), _TL("") ); }
197 if( !Parameters("NODE_COLORS" ) ) { Parameters.Add_Node("", "NODE_COLORS" , _TL("Colors" ), _TL("") ); }
198 if( !Parameters("NODE_SIZE" ) ) { Parameters.Add_Node("", "NODE_SIZE" , _TL("Size" ), _TL("") ); }
199 if( !Parameters("NODE_LABEL" ) ) { Parameters.Add_Node("", "NODE_LABEL" , _TL("Labels" ), _TL("") ); }
200 if( !Parameters("NODE_CHART" ) ) { Parameters.Add_Node("", "NODE_CHART" , _TL("Charts" ), _TL("") ); }
201
202 //-----------------------------------------------------
203 // Values...
204
208 {
209 Parameters.Add_Choice("NODE_VALUES",
210 "TABLE_FLT_STYLE" , _TL("Floating Point Numbers"),
211 _TL("Specify floating point decimal precision in table and similar views."),
212 CSG_String::Format("%s|%s|%s",
213 _TL("system default"),
214 _TL("compact"),
215 _TL("fix number of decimals")
216 ), 1
217 );
218
219 Parameters.Add_Int("TABLE_FLT_STYLE",
220 "TABLE_FLT_DECIMALS", _TL("Decimals"),
221 _TL(""),
222 6, 0, true
223 );
224 }
225
226 //-----------------------------------------------------
227 // Legend...
228
229 Parameters.Add_Bool ("NODE_LEGEND" , "LEGEND_SHOW" , _TL("Map Legends" ), _TL("Include in map legends."), true);
230 Parameters.Add_Choice("NODE_LEGEND" , "LEGEND_ORIENTATION", _TL("Orientation" ), _TL(""), CSG_String::Format("%s|%s", _TL("vertical"), _TL("horizontal")), 0);
231 Parameters.Add_Choice("NODE_LEGEND" , "LEGEND_TITLE" , _TL("Title" ), _TL(""), CSG_String::Format("%s|%s|%s", _TL("data set"), _TL("user defined"), _TL("none")), 0);
232 Parameters.Add_String("LEGEND_TITLE", "LEGEND_TITLE_TEXT" , _TL("User Defined"), _TL(""), _TL("Title"));
233
237 {
238 Parameters.Add_Choice("NODE_LEGEND" , "LEGEND_FIELD" , _TL("Field Labeling"), _TL(""), CSG_String::Format("%s|%s|%s", _TL("automatic"), _TL("user defined"), _TL("none")), 0);
239 Parameters.Add_String("LEGEND_FIELD", "LEGEND_FIELD_TEXT", _TL("User Defined" ), _TL(""), _TL("Label"));
240 }
241
242 //-----------------------------------------------------
243 // Display...
244
245 Parameters.Add_Bool ("NODE_DISPLAY", "SHOW_ALWAYS", _TL("Show at all scales"), _TL(""), true);
246 Parameters.Add_Range ("SHOW_ALWAYS" , "SHOW_RANGE" , _TL("Scale Range"),
247 _TL("only show within scale range; values are given as extent measured in map units"),
248 100., 1000., 0., true
249 );
250
252 {
253 Parameters.Add_Choice("NODE_DISPLAY", "TRANSPARENCY_MODE", _TL("Overlay Mode"), _TL(""), CSG_String::Format("%s/%s|%s", _TL("Transparency"), _TL("Opacity"), _TL("Hachure")));
254 }
255
256 Parameters.Add_Double(Parameters("TRANSPARENCY_MODE") ? "TRANSPARENCY_MODE" : "NODE_DISPLAY",
257 "TRANSPARENCY", _TL("Transparency"),
258 _TL("Transparency specified as percentage."),
259 0., 0., true, 100., true
260 )->Set_Collapsed();
261
262 //-----------------------------------------------------
263 // Symbology...
264
267 {
268 Parameters.Add_Choice("NODE_COLORS", "COLOR_SYMBOLS", _TL("Type"), _TL(""), CSG_String::Format("%s|%s|%s|%s",
269 _TL("Single Symbol" ), // CSG_Map_Symbology::SINGLE
270 _TL("Classification" ), // CSG_Map_Symbology::CLASSIFIED
271 _TL("Discrete Colors" ), // CSG_Map_Symbology::DISCRETE
272 _TL("Graduated Colors") // CSG_Map_Symbology::GRADUATED
274 }
276 {
277 Parameters.Add_Choice("NODE_COLORS", "COLOR_SYMBOLS", _TL("Type"), _TL(""), CSG_String::Format("%s|%s|%s|%s|%s",
278 _TL("Single Symbol" ), // CSG_Map_Symbology::SINGLE
279 _TL("Classification" ), // CSG_Map_Symbology::CLASSIFIED
280 _TL("Discrete Colors" ), // CSG_Map_Symbology::DISCRETE
281 _TL("Graduated Colors"), // CSG_Map_Symbology::GRADUATED
282 _TL("RGB Coded Values") // CSG_Map_Symbology::COMPOSITE >> RGB !!!
284 }
285 else if( m_Type == SG_DATAOBJECT_TYPE_Grid )
286 {
287 Parameters.Add_Choice("NODE_COLORS", "COLOR_SYMBOLS", _TL("Type"), _TL(""), CSG_String::Format("%s|%s|%s|%s|%s|%s",
288 _TL("Single Symbol" ), // CSG_Map_Symbology::SINGLE
289 _TL("Classification" ), // CSG_Map_Symbology::CLASSIFIED
290 _TL("Discrete Colors" ), // CSG_Map_Symbology::DISCRETE
291 _TL("Graduated Colors"), // CSG_Map_Symbology::GRADUATED
292 _TL("RGB Composite" ), // CSG_Map_Symbology::COMPOSITE
293 _TL("RGB Coded Values") // CSG_Map_Symbology::RGB
295 }
296 else if( m_Type == SG_DATAOBJECT_TYPE_Grids )
297 {
298 Parameters.Add_Choice("NODE_COLORS", "COLOR_SYMBOLS", _TL("Type"), _TL(""), CSG_String::Format("%s|%s|%s|%s|%s",
299 _TL("Single Symbol" ), // CSG_Map_Symbology::SINGLE
300 _TL("Classification" ), // CSG_Map_Symbology::CLASSIFIED
301 _TL("Discrete Colors" ), // CSG_Map_Symbology::DISCRETE
302 _TL("Graduated Colors"), // CSG_Map_Symbology::GRADUATED
303 _TL("RGB Composite" ) // CSG_Map_Symbology::COMPOSITE
305
306 Parameters.Add_Choice("NODE_COLORS", "BAND" , _TL("Band" ), _TL(""), CSG_String::Format("<%s>", _TL("not set")));
307 Parameters.Add_Choice("NODE_COLORS", "COMPOSITE_FIT", _TL("Statistics"), _TL(""), CSG_String::Format("%s|%s", _TL("all bands"), _TL("each band")), 1);
308 Parameters.Add_Choice("NODE_COLORS", "COMPOSITE_R" , _TL("Red" ), _TL(""), "");
309 Parameters.Add_Choice("NODE_COLORS", "COMPOSITE_G" , _TL("Green" ), _TL(""), "");
310 Parameters.Add_Choice("NODE_COLORS", "COMPOSITE_B" , _TL("Blue" ), _TL(""), "");
311 }
312
313 //-----------------------------------------------------
314 // Symbology: Single Symbol...
315
316 static BYTE s_Def_Layer_Colour = 0;
317
318 Parameters.Add_Node("NODE_COLORS",
319 "NODE_SINGLE" , _TL("Single Symbol"),
320 _TL("")
321 );
322
323 Parameters.Add_Color("NODE_SINGLE",
324 "SINGLE_COLOR" , _TL("Color"),
325 _TL(""),
326 s_Def_Layer_Colours[s_Def_Layer_Colour++ % DEF_LAYER_COLOUR_COUNT]
327 );
328
329 //-----------------------------------------------------
330 // Symbology: Classified...
331
332 Parameters.Add_Node("NODE_COLORS", "NODE_CLASSIFIED", _TL("Classification"), _TL(""));
333
337 {
338 Parameters.Add_Choice("NODE_CLASSIFIED", "CLASSIFIED_FIELD" , _TL("Field" ), _TL(""), CSG_String::Format("<%s>", _TL("not set")));
339 Parameters.Add_Choice("NODE_CLASSIFIED", "CLASSIFIED_NORMALIZE", _TL("Normalization"), _TL(""), CSG_String::Format("<%s>", _TL("not set")));
340 }
341
342 CSG_Table *pLUT = Parameters.Add_FixedTable("NODE_CLASSIFIED", "CLASSIFIED_LUT", _TL("Look-up Table"), _TL(""))->asTable();
343
344 pLUT->Get_MetaData().Add_Child("SAGA_GUI_LUT_TYPE", m_Type);
345
346 pLUT->Add_Field(_TL("Color" ), SG_DATATYPE_Color ); // CSG_Map_Symbology::LUT_COLOR
347 pLUT->Add_Field(_TL("Name" ), SG_DATATYPE_String); // CSG_Map_Symbology::LUT_TITLE
348 pLUT->Add_Field(_TL("Description"), SG_DATATYPE_String); // CSG_Map_Symbology::LUT_DESCRIPTION
349 pLUT->Add_Field(_TL("Minimum" ), SG_DATATYPE_Double); // CSG_Map_Symbology::LUT_MIN
350 pLUT->Add_Field(_TL("Maximum" ), SG_DATATYPE_Double); // CSG_Map_Symbology::LUT_MAX
351
352 #define ADD_LUT_CLASS(name, desc, min, max) { CSG_Table_Record &r = *pLUT->Add_Record();\
353 r.Set_Value(0, SG_Color_Get_Random()); r.Set_Value(1, name); r.Set_Value(2, desc); r.Set_Value(3, min); r.Set_Value(4, max);\
354 }
355
356 ADD_LUT_CLASS(_TL("Class 1"), _TL( "First Class"), 0., 1.);
357 ADD_LUT_CLASS(_TL("Class 2"), _TL("Second Class"), 1., 2.);
358
359 #undef ADD_LUT_CLASS
360
363 {
364 Parameters.Add_Grid_Resampling("NODE_CLASSIFIED", "CLASSIFIED_RESAMPLING", _TL("Resampling"), _TL(""), CSG_Grid_Resampling::Interpolations, CSG_Grid_Resampling::NearestNeighbour);
365 }
366
367 //-----------------------------------------------------
368 // Symbology: Stretched...
369
370 Parameters.Add_Node("NODE_COLORS",
371 "NODE_STRETCH", _TL("Histogram Stretch"),
372 _TL("")
373 );
374
378 {
379 Parameters.Add_Choice("NODE_STRETCH", "STRETCH_FIELD" , _TL("Field" ), _TL(""), CSG_String::Format("<%s>", _TL("not set")));
380 Parameters.Add_Choice("NODE_STRETCH", "STRETCH_NORMALIZE", _TL("Normalization"), _TL(""), CSG_String::Format("<%s>", _TL("not set")));
381
382 Parameters.Add_Choice("STRETCH_NORMALIZE", "STRETCH_NORMALIZE_FORMAT", _TL("Labeling"), _TL(""),
383 CSG_String::Format("%s|%s", _TL("fraction"), _TL("percentage")), 0
384 );
385 }
386
388 {
389 Parameters.Add_Range("NODE_STRETCH", "STRETCH_RANGE_R", _TL("Red" ), _TL(""));
390 Parameters.Add_Range("NODE_STRETCH", "STRETCH_RANGE_G", _TL("Green"), _TL(""));
391 Parameters.Add_Range("NODE_STRETCH", "STRETCH_RANGE_B", _TL("Blue" ), _TL(""));
392 }
393
394 //-----------------------------------------------------
395 Parameters.Add_Colors("NODE_STRETCH",
396 "STRETCH_COLORS" , _TL("Colors"),
397 _TL("")
398 );
399
400 //-----------------------------------------------------
401 Parameters.Add_Choice("NODE_STRETCH",
402 "STRETCH" , _TL("Stretch Type"),
403 _TL("Specify how to adjust histogram stretch."),
404 CSG_String::Format("%s|%s|%s|%s",
405 _TL("Minimum Maximum"),
406 _TL("Standard Deviation"),
407 _TL("Percent Clip"),
408 _TL("Manual")
409 ),
410 Get_Defaults()["STRETCH"].asInt()
411 );
412
413 Parameters.Add_Range("STRETCH",
414 "STRETCH_LINEAR" , _TL("Minimum Maximum"),
415 _TL("Apply the stretch between the minimum and maximum values specified as percentage of the full value range."),
416 Get_Defaults()["STRETCH_LINEAR.MIN"].asDouble(),
417 Get_Defaults()["STRETCH_LINEAR.MAX"].asDouble(), 0., true, 100., true
418 );
419
420 Parameters.Add_Double("STRETCH",
421 "STRETCH_STDDEV" , _TL("Standard Deviation"),
422 _TL("Apply the stretch between a specified number of standard deviations."),
423 Get_Defaults()["STRETCH_STDDEV"].asDouble(), 0., true
424 );
425
426 Parameters.Add_Bool("STRETCH_STDDEV",
427 "STRETCH_STDDEV_RANGE" , _TL("Keep in Range"),
428 _TL("Prevents that minimum or maximum stretch values fall outside of the actual data value range."),
429 Get_Defaults()["STRETCH_STDDEV_RANGE"].asBool()
430 );
431
432 Parameters.Add_Range("STRETCH",
433 "STRETCH_PERCENT" , _TL("Percent Clip"),
434 _TL("Adjust the stretch to the percentiles specified here."),
435 Get_Defaults()["STRETCH_PERCENT.MIN"].asDouble(),
436 Get_Defaults()["STRETCH_PERCENT.MAX"].asDouble(), 0., true, 100., true
437 );
438
439 //-----------------------------------------------------
440 Parameters.Add_Range("NODE_STRETCH",
441 "STRETCH_RANGE" , _TL("Range"),
442 _TL("")
443 );
444
445 Parameters.Add_Choice("NODE_STRETCH",
446 "STRETCH_INTERVALS" , _TL("Scaling"),
447 _TL(""),
448 CSG_String::Format("%s|%s|%s|%s",
449 _TL("linear intervals"),
450 _TL("increasing geometric intervals"),
451 _TL("decreasing geometric intervals"),
452 _TL("histogram equalize")
453 ), 0
454 );
455
456 Parameters.Add_Double("STRETCH_INTERVALS",
457 "STRETCH_INTERVALS_LOG" , _TL("Geometric Interval Factor"),
458 _TL(""),
459 1., 0., true, 16., true
460 );
461
462 //-----------------------------------------------------
463 return( true );
464}
465
466//---------------------------------------------------------
468{
469 m_Parameters.Assign_Values(&Parameters);
470
472
473 return( true );
474}
475
476
478// //
480
481//---------------------------------------------------------
482bool CSG_Map_Layer::Parameter_Changed(CSG_Parameters &Parameters, CSG_Parameter &Parameter, int Flags)
483{
484 if( Flags & PARAMETER_CHECK_VALUES )
485 {
486 if( m_pObject && m_pObject->asTable(true) )
487 {
488 if( Parameter.Cmp_Identifier("COLOR_SYMBOLS")
489 || Parameter.Cmp_Identifier("STRETCH_FIELD")
490 || Parameter.Cmp_Identifier("STRETCH_NORMALIZE")
491 || Parameter.Cmp_Identifier("STRETCH_NORMALIZE_FORMAT") )
492 {
493 if( Parameter.Cmp_Identifier("STRETCH_FIELD")
494 || Parameter.Cmp_Identifier("STRETCH_NORMALIZE")
495 || Parameter.Cmp_Identifier("STRETCH_NORMALIZE_FORMAT") )
496 {
497 m_Normalization.Destroy(); // invalidate, might need updates
498
499 if( Parameters("STRETCH")->asInt() == 3 ) // manual? no adjustment!
500 {
501 Parameters.Set_Parameter("STRETCH", 1); // standard deviation!
502 }
503 }
504
505 if( Parameters("COLOR_SYMBOLS")->asInt() == 2 || Parameters("COLOR_SYMBOLS")->asInt() == 3 ) // discrete/graduated
506 {
507 Set_Stretch(Parameters);
508 }
509 }
510
511 if( Parameter.Cmp_Identifier("CLASSIFIED_FIELD") || (Parameter.Cmp_Identifier("COLOR_SYMBOLS") && Parameter.asInt() == 1) ) // CSG_Map_Symbology::CLASSIFIED
512 {
513 int Field = Parameters("CLASSIFIED_FIELD")->asInt();
514
515 if( Field >= 0 && Field < m_pObject->asTable(true)->Get_Field_Count() )
516 {
517 TSG_Data_Type Type = m_pObject->asTable(true)->is_Field_Numeric(Field)
519
520 Parameters("CLASSIFIED_LUT")->asTable()->Set_Field_Type(CSG_Map_Symbology::LUT_MIN, Type);
521 Parameters("CLASSIFIED_LUT")->asTable()->Set_Field_Type(CSG_Map_Symbology::LUT_MAX, Type);
522 }
523 }
524 }
525
526 if( Parameter.Cmp_Identifier("STRETCH")
527 || Parameter.Cmp_Identifier("STRETCH_LINEAR")
528 || Parameter.Cmp_Identifier("STRETCH_STDDEV")
529 || Parameter.Cmp_Identifier("STRETCH_STDDEV_RANGE")
530 || Parameter.Cmp_Identifier("STRETCH_PERCENT")
531 || Parameter.Cmp_Identifier("BAND") )
532 {
533 Set_Stretch(Parameters);
534 }
535
536 if( Parameter.Cmp_Identifier("STRETCH_RANGE" )
537 || Parameter.Cmp_Identifier("STRETCH_RANGE_R")
538 || Parameter.Cmp_Identifier("STRETCH_RANGE_G")
539 || Parameter.Cmp_Identifier("STRETCH_RANGE_B") )
540 {
541 Parameters.Set_Parameter("STRETCH", 3); // manual
542 }
543 }
544
545 //-----------------------------------------------------
546 if( Flags & PARAMETER_CHECK_ENABLE )
547 {
548 if( Parameter.Cmp_Identifier("LEGEND_SHOW")
549 || Parameter.Cmp_Identifier("COLOR_SYMBOLS") )
550 {
551 Parameters.Set_Enabled("LEGEND_ORIENTATION",
552 Parameters("LEGEND_SHOW")->asBool()
553 && Parameters("COLOR_SYMBOLS")->asInt() == CSG_Map_Symbology::GRADUATED
554 );
555 }
556
557 if( Parameter.Cmp_Identifier("LEGEND_TITLE") )
558 {
559 Parameters.Set_Enabled("LEGEND_TITLE_TEXT", Parameter.asInt() == 1);
560 }
561
562 if( Parameter.Cmp_Identifier("LEGEND_FIELD") )
563 {
564 Parameters.Set_Enabled("LEGEND_FIELD_TEXT", Parameter.asInt() == 1);
565 }
566
567 if( Parameter.Cmp_Identifier("SHOW_ALWAYS") )
568 {
569 Parameters.Set_Enabled("SHOW_RANGE", Parameter.asBool() == false);
570 }
571
572 if( Parameter.Cmp_Identifier("COLOR_SYMBOLS") )
573 {
574 int Value = Parameter.asInt();
575
576 Parameters.Set_Enabled("NODE_SINGLE" , Value == CSG_Map_Symbology::SINGLE);
577 Parameters.Set_Enabled("NODE_CLASSIFIED", Value == CSG_Map_Symbology::CLASSIFIED);
578
579 switch( Get_ObjectType() )
580 {
581 default :
582 Parameters.Set_Enabled("NODE_STRETCH", Value != CSG_Map_Symbology::SINGLE && Value != CSG_Map_Symbology::CLASSIFIED && Value != CSG_Map_Symbology::RGB);
583 break;
584
586 Parameters.Set_Enabled("NODE_STRETCH", Value != CSG_Map_Symbology::SINGLE && Value != CSG_Map_Symbology::CLASSIFIED);
587 break;
588
590 Parameters.Set_Enabled("NODE_STRETCH", Value != 4 && Value != CSG_Map_Symbology::SINGLE && Value != CSG_Map_Symbology::CLASSIFIED);
591 Parameters.Set_Enabled("NODE_RGB" , Value == 4); // RGB Coded Values
592 break;
593 }
594
595 Parameters.Set_Enabled("STRETCH_COLORS" , Value == CSG_Map_Symbology::DISCRETE || Value == CSG_Map_Symbology::GRADUATED);
596 }
597
598 if( Parameter.Cmp_Identifier("STRETCH_FIELD") )
599 {
600 Parameters.Set_Enabled("STRETCH_NORMALIZE", Get_Fields_Choice(Parameter) >= 0);
601 }
602
603 if( Parameter.Cmp_Identifier("STRETCH_NORMALIZE") )
604 {
605 Parameter.Set_Children_Enabled(Get_Fields_Choice(Parameter) >= 0);
606 }
607
608 if( Parameter.Cmp_Identifier("STRETCH_INTERVALS") )
609 {
610 Parameters.Set_Enabled("STRETCH_INTERVALS_LOG", Parameter.asInt() == 1 || Parameter.asInt() == 2);
611 }
612
613 CSG_Parameter *pStretch = Parameters("STRETCH");
614
615 if( pStretch )
616 {
617 Parameters.Set_Enabled("STRETCH_LINEAR" , pStretch->asInt() == 0);
618 Parameters.Set_Enabled("STRETCH_STDDEV" , pStretch->asInt() == 1);
619 Parameters.Set_Enabled("STRETCH_PERCENT", pStretch->asInt() == 2);
620 }
621 }
622
623 //-----------------------------------------------------
624 return( true );
625}
626
627
629// //
631
632//---------------------------------------------------------
634{
635 m_Normalization.Destroy(); // invalidate
636
637 if( m_Parameters["COLOR_SYMBOLS"].asInt() == 2 || m_Parameters["COLOR_SYMBOLS"].asInt() == 3 ) // discrete/graduated
638 {
640
641 m_pSymbology->Update();
642 }
643
644 //-----------------------------------------------------
645 return( true );
646}
647
648
650// //
652
653//---------------------------------------------------------
655{
656 m_pSymbology->Set_Mode(m_Parameters["COLOR_SYMBOLS"].asInt());
657
658 m_pSymbology->Set_NoData_Color(m_Parameters("NODATA_COLOR") ? m_Parameters["NODATA_COLOR"].asColor() : SG_COLOR_GREY_LIGHT);
659
660 m_pSymbology->Set_Single_Color(m_Parameters["SINGLE_COLOR"].asColor());
661
662 m_pSymbology->Set_Stretch(
663 m_Parameters["STRETCH_RANGE.MIN" ].asDouble(),
664 m_Parameters["STRETCH_RANGE.MAX" ].asDouble(),
665 m_Parameters["STRETCH_INTERVALS" ].asInt (),
666 m_Parameters["STRETCH_INTERVALS_LOG" ].asDouble()
667 );
668
669 m_pSymbology->Update();
670
671 m_pLegend->m_Title = Get_Legend_Title ();
672 m_pLegend->m_Subtitle = Get_Legend_Subtitle();
673 m_pLegend->Set_Orientation(m_Parameters["LEGEND_ORIENTATION"].asInt() == 0 ? CSG_Map_Legend::VERTICAL : CSG_Map_Legend::HORIZONTAL);
674
675 //-----------------------------------------------------
676 return( true );
677}
678
679
681// //
683
684//---------------------------------------------------------
686{
687 int n = 0;
688
689 for(int i=0; i<m_Parameters.Get_Count(); i++)
690 {
691 CSG_Parameter *pTarget = Target(m_Parameters[i].Get_Identifier());
692
693 if( pTarget && pTarget->Get_Type() == m_Parameters[i].Get_Type() )
694 {
695 n++; pTarget->Assign(m_Parameters(i));
696 }
697 }
698
699 return( n == m_Parameters.Get_Count() );
700}
701
702//---------------------------------------------------------
704{
705 int n = 0;
706
707 for(int i=0; i<m_Parameters.Get_Count(); i++)
708 {
709 CSG_Parameter *pSource = Source(m_Parameters[i].Get_Identifier());
710
711 if( pSource && pSource->Get_Type() == m_Parameters[i].Get_Type() )
712 {
713 n++; m_Parameters[i].Assign(pSource);
714 }
715 }
716
717 return( n == m_Parameters.Get_Count() );
718}
719
720
722// //
724
725//---------------------------------------------------------
726bool CSG_Map_Layer::Set_Stretch(CSG_Parameters &Parameters, CSG_Data_Object *pObject, const CSG_String &Suffix)
727{
728 if( Parameters["STRETCH"].asInt() == 3 ) // keep current stretch if set to 'manual'!
729 {
730 if( Get_Stretch_Range() <= 0. )
731 {
732 Parameters["STRETCH"].Set_Value(0); // linear stretch
733 Set_Stretch(Parameters, pObject, Suffix);
734 Parameters["STRETCH"].Set_Value(3); // manual
735 }
736
737 return( false );
738 }
739
740 if( !pObject )
741 {
742 if( !m_pObject )
743 {
744 return( false );
745 }
746
747 pObject = m_pObject;
748 }
749
750 //-----------------------------------------------------
751 int Field = -1; CSG_Table *pTable = _Get_Field_Table(Field, Parameters);
752
753 if( pTable && Field < 0 )
754 {
755 return( false );
756 }
757
758 if( pObject->asGrids() && Parameters["COLOR_SYMBOLS"].asInt() != CSG_Map_Symbology::COMPOSITE )
759 {
760 int i = Parameters("BAND") ? Parameters["BAND"].asInt() : -1;
761
762 if( i < 0 || i >= pObject->asGrids()->Get_NZ() || !(pObject = pObject->asGrids()->Get_Grid_Ptr(i)) )
763 {
764 return( false );
765 }
766 }
767
768 //-----------------------------------------------------
770
771 double Minimum, Maximum;
772
773 switch( Parameters["STRETCH"].asInt() )
774 {
775 case 0: // linear
776 {
777 CSG_Simple_Statistics Statistics = pTable ? pTable->Get_Statistics(Field) : pObject->asGrid() ? pObject->asGrid()->Get_Statistics() : pObject->asGrids()->Get_Statistics();
778
779 Minimum = Statistics.Get_Minimum() + Statistics.Get_Range() * Parameters["STRETCH_LINEAR.MIN"].asDouble() / 100.;
780 Maximum = Statistics.Get_Minimum() + Statistics.Get_Range() * Parameters["STRETCH_LINEAR.MAX"].asDouble() / 100.;
781 }
782 break;
783
784 case 1: // standard deviation
785 {
786 CSG_Simple_Statistics Statistics = pTable ? pTable->Get_Statistics(Field) : pObject->asGrid() ? pObject->asGrid()->Get_Statistics() : pObject->asGrids()->Get_Statistics();
787
788 Minimum = Statistics.Get_Mean() - Statistics.Get_StdDev() * Parameters["STRETCH_STDDEV"].asDouble();
789 Maximum = Statistics.Get_Mean() + Statistics.Get_StdDev() * Parameters["STRETCH_STDDEV"].asDouble();
790
791 if( Parameters["STRETCH_STDDEV_RANGE"].asBool() )
792 {
793 if( Minimum < Statistics.Get_Minimum() ) { Minimum = Statistics.Get_Minimum(); }
794 if( Maximum > Statistics.Get_Maximum() ) { Maximum = Statistics.Get_Maximum(); }
795 }
796 }
797 break;
798
799 case 2: // percentile
800 {
801 const CSG_Histogram &Histogram = pTable ? pTable->Get_Histogram(Field) : pObject->asGrid() ? pObject->asGrid()->Get_Histogram() : pObject->asGrids()->Get_Histogram();
802
803 Minimum = Histogram.Get_Percentile(Parameters["STRETCH_PERCENT.MIN"].asDouble());
804 Maximum = Histogram.Get_Percentile(Parameters["STRETCH_PERCENT.MAX"].asDouble());
805 }
806 break;
807
808 default: SG_UI_Process_Set_Busy(false); return( false );
809 }
810
811 if( Minimum >= Maximum )//&& g_pData->Get_Parameter("STRETCH_NORANGE")->asInt() != 0 )
812 {
813 CSG_Simple_Statistics Statistics = pTable ? pTable->Get_Statistics(Field) : pObject->asGrid() ? pObject->asGrid()->Get_Statistics() : pObject->asGrids()->Get_Statistics();
814
815 if( Statistics.Get_Range() > 0. )//&& (g_pData->Get_Parameter("STRETCH_NORANGE")->asInt() == 2 || DLG_Message_Confirm(wxString::Format("%s\n\n%s", _TL("Minimum stretch range value equals maximum!"), _TL("Adjust to full range?")), _TL("Histogram Stretch"))) )
816 {
817 Minimum = Statistics.Get_Minimum();
818 Maximum = Statistics.Get_Maximum();
819
820 bool bCallback = Parameters.Set_Callback(false);
821 Parameters.Set_Parameter("STRETCH", 3); // 'manual'
822 Parameters.Set_Callback(bCallback);
823 }
824 }
825
827
828 Parameters.Set_Parameter("STRETCH_RANGE" + Suffix + ".MIN", Minimum);
829 Parameters.Set_Parameter("STRETCH_RANGE" + Suffix + ".MAX", Maximum);
830
831 return( true );
832}
833
834//---------------------------------------------------------
836{
837 return( m_Parameters["STRETCH_RANGE.MIN"].asDouble() );
838}
839
840//---------------------------------------------------------
842{
843 return( m_Parameters["STRETCH_RANGE.MAX"].asDouble() );
844}
845
846//---------------------------------------------------------
848{
850}
851
852//---------------------------------------------------------
854{
855 if( m_Parameters["COLOR_SYMBOLS"].asInt() != CSG_Map_Symbology::DISCRETE
856 && m_Parameters["COLOR_SYMBOLS"].asInt() != CSG_Map_Symbology::GRADUATED
857 && m_Parameters["COLOR_SYMBOLS"].asInt() != CSG_Map_Symbology::COMPOSITE )
858 {
859 m_Parameters["COLOR_SYMBOLS"].Set_Value( CSG_Map_Symbology::GRADUATED );
860 }
861
862 m_Parameters["STRETCH_RANGE.MIN"].Set_Value(Minimum < Maximum ? Minimum : Maximum);
863 m_Parameters["STRETCH_RANGE.MAX"].Set_Value(Minimum < Maximum ? Maximum : Minimum);
864
865 m_Parameters["STRETCH"].Set_Value(3); // 'manual'
866
867 return( true );
868}
869
870//---------------------------------------------------------
872{
873 int Field = -1; CSG_Table *pTable = _Get_Field_Table(Field, m_Parameters);
874
875 if( pTable )
876 {
877 return( Field < 0 ? false : Set_Stretch_Range(pTable->Get_Minimum(Field), pTable->Get_Maximum(Field)) );
878 }
879
880 CSG_Data_Object *pObject = m_pObject;
881
882 if( pObject )
883 {
884 if( pObject->asGrids() && m_Parameters["COLOR_SYMBOLS"].asInt() != CSG_Map_Symbology::COMPOSITE )
885 {
886 int Band = m_Parameters("BAND") ? m_Parameters["BAND"].asInt() : -1;
887
888 if( Band < 0 || Band >= pObject->asGrids()->Get_NZ() || !(pObject = pObject->asGrids()->Get_Grid_Ptr(Band)) )
889 {
890 return( false );
891 }
892 }
893
894 if( pObject->asGrid () ) { return( Set_Stretch_Range(pObject->asGrid ()->Get_Min(), pObject->asGrid ()->Get_Max()) ); }
895 if( pObject->asGrids() ) { return( Set_Stretch_Range(pObject->asGrids()->Get_Min(), pObject->asGrids()->Get_Max()) ); }
896 }
897
898 return( false );
899}
900
901
903// //
905
906//---------------------------------------------------------
907const wxBitmap * CSG_Map_Layer::Get_Thumbnail(int dx, int dy)
908{
909 if( dx > 0 && dy > 0 && (!m_pThumbnail->IsOk() || m_pThumbnail->GetWidth() != dx || m_pThumbnail->GetHeight() != dy) )
910 {
911 m_pThumbnail->Create(dx, dy);
912
914 }
915
916 return( m_pThumbnail );
917}
918
919//---------------------------------------------------------
921{
922 if( m_pObject && m_pThumbnail->IsOk() && m_pThumbnail->GetWidth() > 0 && m_pThumbnail->GetHeight() > 0 )
923 {
924 CSG_Map_DC dc_Map(Get_Extent(), m_pThumbnail->GetSize(), 1., SG_Get_Color(SG_System_Get_Color(wxSYS_COLOUR_WINDOW)));
925
927 {
928 wxBitmap Bitmap;
929
930 if( dc_Map.Get_Bitmap(Bitmap) )
931 {
932 wxMemoryDC dc;
933
934 dc.SelectObject(*m_pThumbnail);
935 dc.DrawBitmap(Bitmap, 0, 0, false);
936 dc.SelectObject(wxNullBitmap);
937
938 return( true );
939 }
940 }
941 }
942
943 return( false );
944}
945
946
948// //
950
951//---------------------------------------------------------
953{
954 if( m_pObject )
955 {
956 switch( Get_ObjectType() )
957 {
958 case SG_DATAOBJECT_TYPE_Grid : return( m_pObject->asGrid ()->Get_Extent(true) );
959 case SG_DATAOBJECT_TYPE_Grids : return( m_pObject->asGrids ()->Get_Extent(true) );
960 case SG_DATAOBJECT_TYPE_Shapes : return( m_pObject->asShapes ()->Get_Extent () );
961 case SG_DATAOBJECT_TYPE_PointCloud: return( m_pObject->asPointCloud()->Get_Extent () );
962 case SG_DATAOBJECT_TYPE_TIN : return( m_pObject->asTIN ()->Get_Extent () );
963 default : break;
964 }
965 }
966
967 return( CSG_Rect(0., 0., 0., 0.) );
968}
969
970
972// //
974
975//---------------------------------------------------------
977{
978 return( *m_Parameters["CLASSIFIED_LUT"].asTable() );
979}
980
981//---------------------------------------------------------
983{
984 return( *m_Parameters["STRETCH_COLORS"].asColors() );
985}
986
987//---------------------------------------------------------
989{
990 return( *m_Parameters["STRETCH_COLORS"].asColors() );
991}
992
993//---------------------------------------------------------
995{
996 return( Colors.Create(m_pSymbology->Get_Colors()) );
997}
998
999//---------------------------------------------------------
1001{
1002 return( m_Parameters["STRETCH_COLORS"].asColors()->Create(Colors) );
1003}
1004
1005
1007// //
1009
1010//---------------------------------------------------------
1011bool CSG_Map_Layer::Set_Normalization(int Field_Value, int Field_Normalize, double Scale_Normalize, sLong maxSamples)
1012{
1013 m_Normalization.Destroy();
1014
1015 CSG_Table *pTable = m_pObject ? m_pObject->asTable(true) : NULL;
1016
1017 if( !pTable || Field_Value < 0 || Field_Normalize < 0 || Field_Value >= pTable->Get_Field_Count() || Field_Normalize >= pTable->Get_Field_Count() )
1018 {
1019 return( false );
1020 }
1021
1022 m_Normalization.Add_Field("Normalized", SG_DATATYPE_Double);
1023
1024 for(sLong i=0; i<pTable->Get_Count(); i++)
1025 {
1026 double Value, Normalize;
1027
1028 if( pTable->Get_Value(i, Field_Normalize, Normalize) && Normalize != 0. && pTable->Get_Value(i, Field_Value, Value) )
1029 {
1030 m_Normalization.Add_Record()->Set_Value(0, Scale_Normalize * Value / Normalize);
1031 }
1032 }
1033
1034 return( m_Normalization.Get_Count() );
1035}
1036
1037//---------------------------------------------------------
1038CSG_Table * CSG_Map_Layer::_Get_Field_Table(int &Field, const CSG_Parameters &Parameters)
1039{
1040 CSG_Table *pTable = m_pObject ? m_pObject->asTable(true) : NULL; Field = -1;
1041
1042 if( pTable && Parameters("STRETCH_FIELD") && Parameters("STRETCH_NORMALIZE") && Parameters("STRETCH_NORMALIZE_FORMAT") )
1043 {
1044 Field = Get_Fields_Choice(Parameters["STRETCH_FIELD"]); if( Field >= pTable->Get_Field_Count() ) { Field = -1; }
1045
1046 if( Field >= 0 )
1047 {
1048 if( m_Normalization.Get_Count() || Set_Normalization(Field, Get_Fields_Choice(Parameters["STRETCH_NORMALIZE"]), Parameters["STRETCH_NORMALIZE_FORMAT"].asInt() == 0 ? 1. : 100.) )
1049 {
1050 pTable = &m_Normalization; Field = 0;
1051 }
1052 }
1053 }
1054
1055 return( pTable );
1056}
1057
1058
1060// //
1062
1063//---------------------------------------------------------
1065{
1066 switch( m_Parameters["LEGEND_TITLE"].asInt() )
1067 {
1068 case 0: return( m_pObject ? m_pObject->Get_Name() : SG_T("")); // data set
1069 case 1: return( m_Parameters["LEGEND_TITLE_TEXT"].asString()); // user defined
1070 default: return( "" ); // none
1071 }
1072}
1073
1074//---------------------------------------------------------
1076{
1077 wxString s; CSG_Table *pTable = m_pObject ? m_pObject->asTable(true) : NULL;
1078
1079 if( pTable && m_Parameters["LEGEND_FIELD"].asInt() != 2 ) // no labeling?
1080 {
1081 if( m_Parameters["LEGEND_FIELD"].asInt() == 1 ) // user defined
1082 {
1083 s = m_Parameters["LEGEND_FIELD_TEXT"].asString();
1084 }
1085 else // automatic
1086 {
1087 int Value = -1, Normal = -1;
1088
1089 switch( m_Parameters["COLOR_SYMBOLS"].asInt() )
1090 {
1091 case 1: // CSG_Map_Symbology::CLASSIFIED
1092 Value = Get_Fields_Choice(m_Parameters["CLASSIFIED_FIELD" ]);
1093 Normal = Get_Fields_Choice(m_Parameters["CLASSIFIED_NORMALIZE"]);
1094 break;
1095
1096 case 2: // CSG_Map_Symbology::DISCRETE
1097 case 3: // CSG_Map_Symbology::GRADUATED
1098 Value = Get_Fields_Choice(m_Parameters["STRETCH_FIELD" ]);
1099 Normal = Get_Fields_Choice(m_Parameters["STRETCH_NORMALIZE"]);
1100 break;
1101
1102 case 4: // CSG_Map_Symbology::RGB
1103 Value = Get_Fields_Choice(m_Parameters["RGB_FIELD"]); // point clouds only!
1104 break;
1105 }
1106
1107 if( Value >= 0 )
1108 {
1109 s = pTable->Get_Field_Name(Value);
1110
1111 if( Normal >= 0 )
1112 {
1113 s += " / "; s += pTable->Get_Field_Name(Normal);
1114 }
1115 }
1116 }
1117 }
1118
1119 return( s );
1120}
1121
1122//---------------------------------------------------------
1123bool CSG_Map_Layer::Get_Field_Value(sLong Index, int Field, int Normalize, double Scale, wxString &Value) const
1124{
1125 CSG_Table *pTable = m_pObject ? m_pObject->asTable(true) : NULL;
1126
1127 if( pTable && Index >= 0 && Index < pTable->Get_Count() )
1128 {
1129 if( Field < 0 || Field >= pTable->Get_Field_Count() )
1130 {
1131 Value.Printf("%s: %lld", _TL("Index"), Index + 1);
1132
1133 return( true );
1134 }
1135
1136 //-------------------------------------------------
1137 if( m_pSymbology->Get_Mode() == CSG_Map_Symbology::CLASSIFIED )
1138 {
1139 if( !SG_Data_Type_is_Numeric(pTable->Get_Field_Type(Field)) )
1140 {
1141 CSG_String s;
1142
1143 if( pTable->Get_Value(Index, Field, s) )
1144 {
1145 Value = m_pSymbology->Get_Class_Name_byValue(s.c_str());
1146
1147 return( true );
1148 }
1149 }
1150 else
1151 {
1152 double d;
1153
1154 if( Get_Field_Value(Index, Field, Normalize, Scale, d) )
1155 {
1156 Value = m_pSymbology->Get_Class_Name_byValue(d);
1157
1158 return( true );
1159 }
1160 }
1161 }
1162
1163 //-------------------------------------------------
1164 else if( m_pSymbology->Get_Mode() == CSG_Map_Symbology::RGB )
1165 {
1166 double d;
1167
1168 if( pTable->Get_Value(Index, Field, d) )
1169 {
1170 Value.Printf("R%03d G%03d B%03d", SG_GET_R((int)d), SG_GET_G((int)d), SG_GET_B((int)d));
1171
1172 return( true );
1173 }
1174 }
1175
1176 //-------------------------------------------------
1177 else // CSG_Map_Symbology::DISCRETE || CSG_Map_Symbology::GRADUATED
1178 {
1179 double d;
1180
1181 if( Get_Field_Value(Index, Field, Normalize, Scale, d) )
1182 {
1183 Value.Printf("%f", d);
1184
1185 return( true );
1186 }
1187 }
1188 }
1189
1190 return( false );
1191}
1192
1193//---------------------------------------------------------
1194bool CSG_Map_Layer::Get_Field_Value(sLong Index, int Field, int Normalize, double Scale, double &Value) const
1195{
1196 CSG_Table *pTable = m_pObject ? m_pObject->asTable(true) : NULL;
1197
1198 if( pTable && Index >= 0 && Index < pTable->Get_Count() && Field >= 0 && Field < pTable->Get_Field_Count() )
1199 {
1200 if( pTable->Get_Value(Index, Field, Value) )
1201 {
1202 if( Normalize < 0 )
1203 {
1204 return( true );
1205 }
1206
1207 double Divisor;
1208
1209 if( pTable->Get_Value(Index, Normalize, Divisor) && Divisor != 0. )
1210 {
1211 Value *= Scale / Divisor;
1212
1213 return( true );
1214 }
1215 }
1216 }
1217
1218 return( false );
1219}
1220
1221
1223// //
1225
1226//---------------------------------------------------------
1227bool CSG_Map_Layer::Set_Fields_Choice(CSG_Parameter &Choice, bool bNumeric, bool bAddNone, bool bSelectNone)
1228{
1229 CSG_Parameter_Choice *pChoice = Choice.asChoice();
1230
1231 if( pChoice )
1232 {
1233 CSG_Table *pTable = m_pObject ? m_pObject->asTable(true) : NULL;
1234
1235 if( pTable )
1236 {
1237 CSG_String Fields;
1238
1239 for(int i=0; i<pTable->Get_Field_Count(); i++)
1240 {
1241 if( !bNumeric || SG_Data_Type_is_Numeric(pTable->Get_Field_Type(i)) )
1242 {
1243 Fields += CSG_String::Format("{%d}%s|", i, pTable->Get_Field_Name(i));
1244 }
1245 }
1246
1247 if( !Fields.is_Empty() )
1248 {
1249 if( bAddNone )
1250 {
1251 Fields += CSG_String::Format("{-1}<%s>", _TL("none"));
1252
1253 if( pChoice->Get_Count() <= 1 || Get_Fields_Choice(Choice) < 0 )
1254 {
1255 bSelectNone = true;
1256 }
1257 }
1258
1259 pChoice->Set_Items(Fields);
1260
1261 if( bAddNone && bSelectNone )
1262 {
1263 pChoice->Set_Value(pChoice->Get_Count() - 1);
1264 }
1265
1266 return( true );
1267 }
1268 }
1269
1270 pChoice->asChoice()->Set_Items(CSG_String::Format("{-1}<%s>", _TL("none")));
1271 }
1272
1273 return( false );
1274}
1275
1276//---------------------------------------------------------
1278{
1279 int Field; return( Choice.asChoice() && Choice.asChoice()->Get_Data(Field) ? Field : -1 );
1280}
1281
1282
1284// //
1286
1287//---------------------------------------------------------
1288bool CSG_Map_Layer::Draw(CSG_Map_DC &dc_Map, int Flags, CSG_Data_Object *pObject)
1289{
1290 if( pObject && pObject->is_Valid() && pObject->Get_ObjectType() == Get_ObjectType() )
1291 {
1292 CSG_Data_Object *pOriginal = m_pObject;
1293
1294 m_pObject = pObject;
1295
1296 On_Draw(dc_Map, Flags);
1297
1298 m_pObject = pOriginal;
1299 }
1300 else if( m_pObject && m_pObject->is_Valid() )
1301 {
1302 On_Draw(dc_Map, Flags);
1303 }
1304
1305 dc_Map.SetBrush(wxNullBrush);
1306 dc_Map.SetPen (wxNullPen );
1307
1308 return( true );
1309}
1310
1311
1313// //
1315
1316//---------------------------------------------------------
1318{
1319 int Method = -1;
1320
1321 if( !m_pObject || !Options.Get_Content("METHOD", Method) )
1322 {
1323 return( false );
1324 }
1325
1326 //-----------------------------------------------------
1327 CSG_Map_Classify Classify; CSG_Table *pTable = m_pObject->asTable(true); int Field = -1;
1328
1329 if( pTable )
1330 {
1331 if( !Options.Get_Content("FIELD", Field) || Field < 0 || Field >= pTable->Get_Field_Count() )
1332 {
1333 return( false );
1334 }
1335
1336 Classify.Create(pTable, Field);
1337 }
1338 else
1339 {
1340 Classify.Create(m_pObject);
1341 }
1342
1343 //-----------------------------------------------------
1344 int Classes_Max; Options.Get_Content("CLASSES_MAX", Classes_Max = 1024);
1345 int Classes ; Options.Get_Content("CLASSES" , Classes = 10);
1346 int Increasing ; Options.Get_Content("INCREASING" , Increasing = 1);
1347 int Histogram ; Options.Get_Content("HISTOGRAM" , Histogram = 1);
1348 double StdDev ; Options.Get_Content("STDDEV" , StdDev = 0.5);
1349 double StdDev_Max ; Options.Get_Content("STDDEV_MAX" , StdDev_Max = 4.0);
1350 double Interval ; Options.Get_Content("INTERVAL" , Interval = 0.0);
1351 double Offset; bool bOffset = Options.Get_Content("OFFSET", Offset = 0.0);
1352
1353 switch( Method )
1354 {
1355 case 0: Classify.Classify_Unique (Classes_Max ); break;
1356 case 1: Classify.Classify_Equal (Classes ); break;
1357 case 2: if( bOffset )
1358 { Classify.Classify_Defined (Interval, Offset ); }
1359 else { Classify.Classify_Defined (Interval ); } break;
1360 case 3: Classify.Classify_Quantile (Classes, Histogram == 1); break;
1361 case 4: Classify.Classify_Geometric(Classes, Increasing == 1); break;
1362 case 5: Classify.Classify_Natural (Classes ); break;
1363 case 6: Classify.Classify_StdDev (StdDev, StdDev_Max ); break;
1364 }
1365
1366 //-----------------------------------------------------
1367 int ColorsID = -1; Options.Get_Content("COLORS", ColorsID);
1368 CSG_Colors Colors; if( !Colors.Create(0, ColorsID) ) { Colors.Create(*m_Parameters["STRETCH_COLORS"].asColors()); }
1369
1370 if( Classify.Set_LUT(*m_Parameters["CLASSIFIED_LUT"].asTable(), Colors, 1) )
1371 {
1372 if( m_Parameters["CLASSIFIED_LUT"].asTable()->Get_MetaData().Get_Child("SAGA_GUI_LUT_TYPE") == NULL )
1373 {
1374 m_Parameters["CLASSIFIED_LUT"].asTable()->Get_MetaData().Add_Child("SAGA_GUI_LUT_TYPE", Get_ObjectType());
1375 }
1376
1377 m_Parameters["COLOR_SYMBOLS"].Set_Value(CSG_Map_Symbology::CLASSIFIED); // Lookup Table
1378
1379 if( pTable )
1380 {
1381 m_Parameters["CLASSIFIED_FIELD" ].Set_Value(Field);
1382 m_Parameters["CLASSIFIED_NORMALIZE"].Set_Value(-1);
1383 }
1384
1385 return( true );
1386 }
1387
1388 return( false );
1389}
1390
1391
1393// //
1394// //
1395// //
1397
1398//---------------------------------------------------------
bool SG_UI_Process_Set_Busy(bool bOn, const CSG_String &Message)
bool SG_Data_Type_is_Numeric(TSG_Data_Type Type)
Definition api_core.cpp:199
#define SG_COLOR_BLUE_DARK
Definition api_core.h:1366
#define SG_GET_B(rgb)
Definition api_core.h:1350
#define SG_COLOR_GREY_LIGHT
Definition api_core.h:1356
#define SG_GET_G(rgb)
Definition api_core.h:1349
signed long long sLong
Definition api_core.h:158
#define SG_COLOR_GREEN_DARK
Definition api_core.h:1363
#define SG_T(s)
Definition api_core.h:537
#define SG_COLOR_GREEN
Definition api_core.h:1362
#define SG_COLOR_PINK
Definition api_core.h:1370
#define SG_GET_R(rgb)
Definition api_core.h:1348
#define SG_COLOR_RED
Definition api_core.h:1358
#define SG_COLOR_BLUE_GREEN
Definition api_core.h:1368
#define SG_COLOR_PURPLE
Definition api_core.h:1369
#define SG_COLOR_RED_DARK
Definition api_core.h:1359
TSG_Data_Type
Definition api_core.h:1043
@ SG_DATATYPE_Double
Definition api_core.h:1054
@ SG_DATATYPE_Color
Definition api_core.h:1057
@ SG_DATATYPE_String
Definition api_core.h:1055
#define _TL(s)
Definition api_core.h:1619
#define SG_COLOR_YELLOW_DARK
Definition api_core.h:1361
#define SG_COLOR_BLUE
Definition api_core.h:1365
bool Create(void)
virtual bool is_Valid(void) const =0
CSG_MetaData & Get_MetaData(void) const
Definition dataobject.h:237
class CSG_Grids * asGrids(bool bPolymorph=false) const
virtual TSG_Data_Object_Type Get_ObjectType(void) const =0
Returns the object type as defined by TSG_Data_Object_Type. Used for run time type checking.
class CSG_Grid * asGrid(bool bPolymorph=false) const
class CSG_Table * asTable(bool bPolymorph=false) const
double Get_Max(void)
Definition grid.cpp:1027
const CSG_Simple_Statistics & Get_Statistics(void)
Definition grid.cpp:1099
const CSG_Histogram & Get_Histogram(size_t nClasses=0)
Definition grid.cpp:1175
double Get_Min(void)
Definition grid.cpp:1022
int Get_NZ(void) const
Definition grids.h:190
double Get_Max(void)
Definition grids.cpp:1472
const CSG_Simple_Statistics & Get_Statistics(void)
Definition grids.cpp:1544
CSG_Grid * Get_Grid_Ptr(int i) const
Definition grids.h:265
const CSG_Histogram & Get_Histogram(size_t nClasses=0)
Definition grids.cpp:1644
double Get_Min(void)
Definition grids.cpp:1467
double Get_Percentile(double Percentile) const
void SetBrush(const wxBrush &Brush)
Definition map_dc.cpp:495
void SetPen(const wxPen &Pen)
Definition map_dc.cpp:482
wxBitmap Get_Bitmap(void)
Definition map_dc.cpp:171
CSG_Table m_Normalization
Definition map_layer.h:159
bool Set_Normalization(int Field_Value, int Field_Normalize, double Scale_Normalize, sLong maxSamples=0)
bool Draw(CSG_Map_DC &dc_Map, int Flags=0, CSG_Data_Object *pObject=NULL)
virtual bool Parameters_Changed(void)
bool Set_Fields_Choice(CSG_Parameter &Choice, bool bNumeric, bool bAddNone, bool bSelectNone=false)
class CSG_Map_Legend * m_pLegend
Definition map_layer.h:155
bool Get_Field_Value(sLong Index, int Field, int Normalize, double Scale, wxString &Value) const
bool Classify(const CSG_MetaData &Options)
static int Get_Fields_Choice(CSG_Parameter &Choice)
CSG_Table & Get_LUT(void)
virtual bool DataObject_Changed(void)
TSG_Data_Object_Type m_Type
Definition map_layer.h:147
virtual ~CSG_Map_Layer(void)
bool Set_Colors(const CSG_Colors &Colors)
virtual bool Parameter_Changed(CSG_Parameters &Parameters, CSG_Parameter &Parameter, int Flags)
CSG_Data_Object * m_pObject
Definition map_layer.h:151
wxString Get_Legend_Subtitle(void) const
static CSG_Parameters & Get_Defaults(void)
Definition map_layer.cpp:67
bool Set_Stretch_FullRange(void)
bool Set_Thumbnail(void)
const TSG_Data_Object_Type & Get_ObjectType(void) const
Definition map_layer.h:93
class wxBitmap * m_pThumbnail
Definition map_layer.h:157
virtual void On_Draw(CSG_Map_DC &dc_Map, int Flags)
Definition map_layer.h:164
wxString Get_Legend_Title(void) const
bool Set_Parameters(const CSG_Parameters &Parameters)
bool Set_Stretch(CSG_Parameters &Parameters, CSG_Data_Object *pObject=NULL, const CSG_String &Suffix="")
double Get_Stretch_Minimum(void) const
bool Sync_Back(CSG_Parameters &Target) const
double Get_Stretch_Range(void) const
bool Set_Stretch_Range(double Minimum, double Maximum)
bool Sync_Forward(const CSG_Parameters &Source)
bool Set_Object(CSG_Data_Object *pObject)
CSG_Rect Get_Extent(void) const
double Get_Stretch_Maximum(void) const
CSG_Parameters m_Parameters
Definition map_layer.h:149
class CSG_Map_Symbology * m_pSymbology
Definition map_layer.h:153
CSG_Colors & Get_Colors(void)
virtual bool Add_Parameters(CSG_Parameters &Parameters)
const class wxBitmap * Get_Thumbnail(int dx, int dy)
CSG_Map_Layer(void)
Definition map_layer.h:90
const CSG_String & Get_Content(void) const
Definition metadata.h:139
CSG_MetaData * Add_Child(void)
Definition metadata.cpp:169
bool Set_Items(const SG_Char *String)
CSG_String Get_Data(void) const
int Get_Count(void) const
Definition parameters.h:692
bool Assign(CSG_Parameter *pSource)
bool Set_Collapsed(bool bOn=true)
bool Set_Children_Enabled(bool bEnabled=true)
class CSG_Parameter_Choice * asChoice(void) const
virtual TSG_Parameter_Type Get_Type(void) const =0
bool asBool(void) const
Definition parameters.h:286
virtual bool Set_Value(int Value)
bool Cmp_Identifier(const CSG_String &Identifier) const
CSG_Table * asTable(void) const
int asInt(void) const
Definition parameters.h:287
void Set_Name(const CSG_String &Name)
bool Set_Callback(bool bActive=true)
CSG_Parameter * Add_Grid_Resampling(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, CSG_Grid_Resampling Methods=CSG_Grid_Resampling::Interpolations, CSG_Grid_Resampling Default=CSG_Grid_Resampling::Bicubic_2)
CSG_Parameter * Add_Choice(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, const CSG_String &Items, int Default=0)
int Get_Count(void) const
void Set_Enabled(bool bEnabled=true)
CSG_Parameter * Add_Double(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, double Value=0.0, double Minimum=0.0, bool bMinimum=false, double Maximum=0.0, bool bMaximum=false)
CSG_Parameter * Add_Int(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Value=0, int Minimum=0, bool bMinimum=false, int Maximum=0, bool bMaximum=false)
CSG_Parameter * Add_Node(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, bool bCollapsed=false)
CSG_Parameter * Add_Color(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Value=0)
CSG_Parameter * Add_FixedTable(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, CSG_Table *pInit=NULL)
bool Set_Parameter(const CSG_String &ID, CSG_Parameter *pValue)
CSG_Parameter * Add_Bool(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, bool Value=false)
CSG_Parameter * Add_String(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, const CSG_String &String, bool bLongText=false, bool bPassword=false)
CSG_Parameter * Add_Range(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, double Range_Min=0.0, double Range_Max=0.0, double Minimum=0.0, bool bMinimum=false, double Maximum=0.0, bool bMaximum=false)
CSG_Parameter * Add_Colors(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Palette=0, int nColors=11, bool bRevert=false)
double Get_Maximum(void)
Definition mat_tools.h:749
double Get_Mean(void)
Definition mat_tools.h:753
double Get_StdDev(void)
Definition mat_tools.h:755
double Get_Minimum(void)
Definition mat_tools.h:748
double Get_Range(void)
Definition mat_tools.h:750
static CSG_String Format(const char *Format,...)
const SG_Char * c_str(void) const
bool is_Empty(void) const
const SG_Char * Get_Field_Name(int Field) const
Definition table.h:372
sLong Get_Count(void) const
Definition table.h:410
double Get_Minimum(int Field) const
Definition table.h:391
virtual bool Get_Value(sLong Index, int Field, CSG_String &Value) const
Definition table.cpp:1159
const CSG_Histogram & Get_Histogram(int Field, size_t nClasses=0) const
Definition table.h:400
int Get_Field_Count(void) const
Definition table.h:371
virtual bool Add_Field(const CSG_String &Name, TSG_Data_Type Type, int Position=-1)
Definition table.cpp:479
const CSG_Simple_Statistics & Get_Statistics(int Field) const
Definition table.h:398
TSG_Data_Type Get_Field_Type(int Field) const
Definition table.h:373
double Get_Maximum(int Field) const
Definition table.h:392
CSG_String SG_Get_DataObject_Name(TSG_Data_Object_Type Type)
TSG_Data_Object_Type
Definition dataobject.h:117
@ SG_DATAOBJECT_TYPE_PointCloud
Definition dataobject.h:123
@ SG_DATAOBJECT_TYPE_Grids
Definition dataobject.h:119
@ SG_DATAOBJECT_TYPE_TIN
Definition dataobject.h:122
@ SG_DATAOBJECT_TYPE_Shapes
Definition dataobject.h:121
@ SG_DATAOBJECT_TYPE_Grid
Definition dataobject.h:118
wxColour SG_System_Get_Color(wxSystemColour index)
Definition dc_helper.cpp:81
int SG_Get_Color(const wxColour &Color)
Definition dc_helper.cpp:64
static int s_Def_Layer_Colours[DEF_LAYER_COLOUR_COUNT]
#define ADD_LUT_CLASS(name, desc, min, max)
#define DEF_LAYER_COLOUR_COUNT
#define LAYER_DRAW_FLAG_THUMBNAIL
Definition map_layer.h:74
#define LAYER_DRAW_FLAG_NOLABELS
Definition map_layer.h:78
#define LAYER_DRAW_FLAG_NOEDITS
Definition map_layer.h:77
#define asDouble(i)
#define PARAMETER_CHECK_ENABLE
Definition parameters.h:191
#define PARAMETER_CHECK_VALUES
Definition parameters.h:190