SAGA API Version 9.14
Loading...
Searching...
No Matches
map_legend.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_legend.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#include "map_symbology.h"
52#include "map_legend.h"
53#include "map_layer.h"
54
55
57// //
58// //
59// //
61
62//---------------------------------------------------------
63#define ZOOMED(x) ((int)(m_Zoom * (double)x))
64
65//---------------------------------------------------------
66#define SPACE_VERTICAL ZOOMED(5)
67#define BOX_WIDTH ZOOMED(30)
68#define BOX_HEIGHT ZOOMED(12)
69#define BOX_SPACE ZOOMED(2)
70#define TICK_WIDTH ZOOMED(5)
71#define SIZE_HEIGHT ZOOMED(100)
72
73//---------------------------------------------------------
74#define FONT_SIZE_TITLE ZOOMED(10)
75#define FONT_SIZE_SUBTITLE ZOOMED(8)
76#define FONT_SIZE_LABEL ZOOMED(8)
77
78//---------------------------------------------------------
79#define BOX_STYLE_RECT 0x01
80#define BOX_STYLE_LINE 0x02
81#define BOX_STYLE_SYMB 0x04
82#define BOX_STYLE_OUTL 0x08
83#define BOX_STYLE_FILL 0x10
84
85
87// //
88// //
89// //
91
92//---------------------------------------------------------
93enum
94{
98};
99
100
102// //
103// //
104// //
106
107//---------------------------------------------------------
109{
110 m_pLayer = pLayer;
111 m_pSymbology = pLayer->Get_Symbology();
112
114}
115
116
118// //
120
121//---------------------------------------------------------
123{
124 m_Orientation = Orientation == VERTICAL ? VERTICAL : HORIZONTAL;
125}
126
127//---------------------------------------------------------
128wxSize CSG_Map_Legend::Get_Size(double Zoom, double Zoom_Map)
129{
130 wxMemoryDC dc;
131
132 Draw(dc, Zoom, Zoom_Map, wxPoint(0, 0), NULL);
133
134 return( m_Size );
135}
136
137//---------------------------------------------------------
138void CSG_Map_Legend::Draw(wxDC &dc, double Zoom, double Zoom_Map, wxPoint Position, wxSize *pSize)
139{
140 //-----------------------------------------------------
141 m_Zoom = Zoom > 0. ? Zoom : 1.;
142 m_Position = Position;
143 m_Size = wxSize(BOX_WIDTH, 0);
144
145 m_Zoom_Map = Zoom_Map;
146
147 //-----------------------------------------------------
148 m_oldPen = dc.GetPen ();
149 m_oldBrush = dc.GetBrush();
150 m_oldFont = dc.GetFont ();
151
152 //-----------------------------------------------------
153 m_xBox = m_Position.x;
158
159 //-----------------------------------------------------
161
162 //-----------------------------------------------------
163 switch( m_pLayer->Get_Object()->Get_ObjectType() )
164 {
166 switch( m_pLayer->Get_Object()->asShapes()->Get_Type() )
167 {
168 case SHAPE_TYPE_Point :
172 default : break;
173 }
174 break;
175
180 default : break;
181 }
182
183 //-----------------------------------------------------
184 dc.SetPen (m_oldPen );
185 dc.SetBrush(m_oldBrush);
186 dc.SetFont (m_oldFont );
187
188 //-----------------------------------------------------
189 if( pSize )
190 {
191 *pSize = m_Size;
192 }
193}
194
195
197// //
199
200//---------------------------------------------------------
201inline void CSG_Map_Legend::_Set_Size(int xSet, int yAdd)
202{
203 if( m_Size.x < xSet )
204 {
205 m_Size.x = xSet;
206 }
207
208 m_Position.y += yAdd;
209 m_Size .y += yAdd;
210}
211
212//---------------------------------------------------------
213inline void CSG_Map_Legend::_Set_Font(wxDC &dc, int Style)
214{
215 wxFont Font(dc.GetFont());
216
217 switch( Style )
218 {
219 case FONT_LABEL : Font.SetPointSize(FONT_SIZE_LABEL ); Font.SetStyle(wxFONTSTYLE_ITALIC); Font.SetWeight(wxFONTWEIGHT_NORMAL); break;
220 case FONT_SUBTITLE: Font.SetPointSize(FONT_SIZE_SUBTITLE); Font.SetStyle(wxFONTSTYLE_NORMAL); Font.SetWeight(wxFONTWEIGHT_BOLD ); break;
221 case FONT_TITLE : Font.SetPointSize(FONT_SIZE_TITLE ); Font.SetStyle(wxFONTSTYLE_NORMAL); Font.SetWeight(wxFONTWEIGHT_BOLD ); break;
222 }
223
224 dc.SetFont(Font);
225}
226
227//---------------------------------------------------------
228inline void CSG_Map_Legend::_Draw_Title(wxDC &dc, int Style, wxString Text)
229{
230 if( !Text.IsEmpty() )
231 {
232 wxCoord dx_Text, dy_Text;
233
234 _Set_Font(dc, Style);
235
237
238 dc.GetTextExtent(Text, &dx_Text, &dy_Text);
239
240 dy_Text += SPACE_VERTICAL;
241
242 _Set_Size(dx_Text, dy_Text);
243 }
244}
245
246//---------------------------------------------------------
247inline void CSG_Map_Legend::_Draw_Label(wxDC &dc, int y, wxString Text, int yAlign)
248{
249 wxCoord dx_Text, dy_Text;
250
251 switch( yAlign )
252 {
253 default:
254 case SG_DC_TEXTALIGN_TOP : yAlign = SG_DC_TEXTALIGN_TOPLEFT ; break;
257 }
258
260
261 SG_DC_Draw_Text(dc, yAlign, m_xText, y, Text);
262
263 dc.GetTextExtent(Text, &dx_Text, &dy_Text);
264
265 _Set_Size((m_xText - m_xBox) + dx_Text, 0);
266}
267
268//---------------------------------------------------------
269inline void CSG_Map_Legend::_Draw_Box(wxDC &dc, int y, int dy, int Style, int LineColor, int FillColor, wxString Text)
270{
271 if( (Style & BOX_STYLE_OUTL) != 0 ) { wxPen Pen (dc.GetPen ()); Pen .SetColour(SG_Get_wxColor(LineColor)); dc.SetPen (Pen ); }
272 if( (Style & BOX_STYLE_FILL) != 0 ) { wxBrush Brush(dc.GetBrush()); Brush.SetColour(SG_Get_wxColor(FillColor)); dc.SetBrush(Brush); }
273
274 if( !Text.IsEmpty() )
275 {
276 _Draw_Label(dc, y, Text, SG_DC_TEXTALIGN_TOP);
277 }
278
279 _Set_Size(0, dy);
280
281 dy -= BOX_SPACE;
282
283 //-----------------------------------------------------
284 if( (Style & BOX_STYLE_RECT) != 0 )
285 {
286 dc.DrawRectangle(m_xBox, y, m_dxBox, dy);
287 }
288
289 if( (Style & BOX_STYLE_LINE) != 0 )
290 {
291 dc.DrawLine(m_xBox , y + dy / 2, m_xBox + m_dxBox / 4, y);
292 dc.DrawLine(m_xBox + m_dxBox / 4, y , m_xBox + 3 * m_dxBox / 4, y + dy);
293 dc.DrawLine(m_xBox + 3 * m_dxBox / 4, y + dy , m_xBox + m_dxBox , y + dy / 2);
294 }
295
296 if( (Style & BOX_STYLE_SYMB) != 0 )
297 {
298 ((CSG_Map_Shapes_Point *)m_pLayer)->Draw_Symbol(dc, m_xBox + m_dxBox / 2, y + dy / 2, dy / 2);
299 }
300}
301
302//---------------------------------------------------------
303inline void CSG_Map_Legend::_Draw_Box(wxDC &dc, int y, int dy, int Style, int iClass)
304{
305 int LineColor = SG_Get_Color(dc.GetTextForeground());
306 int FillColor = SG_Get_Color(dc.GetBrush().IsOk() ? dc.GetBrush().GetColour() : dc.GetTextBackground());
307
308 wxString Text;
309
310 if( iClass >= 0 )
311 {
312 if( (Style & BOX_STYLE_OUTL) == 0 )
313 {
314 LineColor = m_pSymbology->Get_Class_Color(iClass);
315 }
316
317 if( (Style & BOX_STYLE_FILL) != 0 )
318 {
319 FillColor = m_pSymbology->Get_Class_Color(iClass);
320 }
321
322 Text = m_pSymbology->Get_Class_Name(iClass);
323 }
324
325 _Draw_Box(dc, y, dy, Style, LineColor, FillColor, Text);
326}
327
328//---------------------------------------------------------
329void CSG_Map_Legend::_Draw_Boxes(wxDC &dc, int y, int Style, double zFactor)
330{
331 switch( m_pSymbology->Get_Mode() )
332 {
334 _Draw_Continuum(dc, m_Position.y, zFactor);
335 break;
336
337 default:
338 for(int iClass=m_pSymbology->Get_Class_Count()-1; iClass>=0; iClass--, y+=BOX_HEIGHT)
339 {
340 _Draw_Box(dc, y, BOX_HEIGHT, Style, iClass);
341 }
342 break;
343 }
344}
345
346
348// //
350
351//---------------------------------------------------------
353{
354 int size_Min, size_Max; double size_Min_Value, size_dValue; wxString size_Name;
355
356 dc.SetBrush(pLayer->Get_Def_Brush());
357 dc.SetPen (pLayer->Get_Def_Pen ());
358
359 if( pLayer->Get_Style_Size(size_Min, size_Max, size_Min_Value, size_dValue, &size_Name) )
360 {
361 _Draw_Title(dc, FONT_SUBTITLE, size_Name);
362
363 int nClasses = (int)((double)SIZE_HEIGHT / (double)BOX_HEIGHT);
364 double dySize = (double)(size_Max - size_Min) / (double)nClasses;
365
366 for(int iClass=nClasses, iSize=size_Max; iClass>=0; iClass--, iSize-=dySize)
367 {
368 int dy = (int)(2.0 * m_Zoom_Map * iSize) + BOX_SPACE;
369 int y = m_Position.y + SIZE_HEIGHT - iClass * BOX_HEIGHT;
370
371 pLayer->Draw_Symbol(dc, m_xBox + m_dxBox / 2, y + dy / 2, dy / 2);
372
373 _Draw_Label(dc, y, wxString::Format("%f", size_Min_Value + (iSize - size_Min) / size_dValue), SG_DC_TEXTALIGN_TOP);
374 }
375
376 _Set_Size(0, SIZE_HEIGHT + dc.GetFont().GetPointSize());
377
378 if( m_pSymbology->Get_Mode() == CSG_Map_Symbology::SINGLE )
379 {
380 return;
381 }
382 }
383
384 //-----------------------------------------------------
387}
388
389//---------------------------------------------------------
391{
392 int size_Min, size_Max; double size_Min_Value, size_dValue; wxString size_Name;
393
394 if( pLayer->Get_Style_Size(size_Min, size_Max, size_Min_Value, size_dValue, &size_Name) )
395 {
396 _Draw_Title(dc, FONT_SUBTITLE, size_Name);
397
398 wxPen Pen = pLayer->Get_Def_Pen();
399
400 for(int iSize=size_Min; iSize<=size_Max; iSize++)
401 {
402 Pen.SetWidth(iSize); dc.SetPen(Pen);
403
404 int y = m_Position.y;
405
407 _Draw_Label(dc, y, wxString::Format("%f", size_Min_Value + (iSize - size_Min) / size_dValue), SG_DC_TEXTALIGN_TOP);
408 }
409
410 if( m_pSymbology->Get_Mode() == CSG_Map_Symbology::SINGLE )
411 {
412 return;
413 }
414 }
415
416 //-----------------------------------------------------
417 dc.SetPen (pLayer->Get_Def_Pen());
418
421}
422
423//---------------------------------------------------------
429
430//---------------------------------------------------------
436
437//---------------------------------------------------------
443
444//---------------------------------------------------------
446{
447 switch( m_pSymbology->Get_Mode() )
448 {
449 default:
451 break;
452
455 if( !pLayer->Get_Object()->asGrid()->Get_Unit().is_Empty() )
456 {
457 _Draw_Title(dc, FONT_SUBTITLE, wxString::Format("[%s]", pLayer->Get_Object()->asGrid()->Get_Unit().c_str()));
458 }
459
461 break;
462
467 break;
468
470 _Draw_Layer_Image(dc, m_Position.y, pLayer);
471 break;
472 }
473}
474
475//---------------------------------------------------------
477{
478 switch( m_pSymbology->Get_Mode() )
479 {
480 default:
482 break;
483
486 if( *pLayer->Get_Object()->asGrids()->Get_Unit() )
487 {
488 _Draw_Title(dc, FONT_SUBTITLE, wxString::Format("[%s]", pLayer->Get_Object()->asGrids()->Get_Unit()));
489 }
490
492 break;
493
498 break;
499 }
500}
501
502//---------------------------------------------------------
503void CSG_Map_Legend::_Draw_CompositeBand(wxDC &dc, int y, int dy, int Style, int Band, CSG_Map_Grid *pLayer)
504{
505 if( Band >= 0 && Band < 3 && pLayer && pLayer->Get_Composite_Band(Band) )
506 {
507 _Draw_CompositeBand(dc, y, dy, Style, Band, pLayer->Get_Composite_Band(Band)->Get_Name());
508 }
509}
510
511//---------------------------------------------------------
512void CSG_Map_Legend::_Draw_CompositeBand(wxDC &dc, int y, int dy, int Style, int Band, CSG_Map_Grids *pLayer)
513{
514 if( Band >= 0 && Band < 3 && pLayer && pLayer->Get_Grid(Band) )
515 {
516 _Draw_CompositeBand(dc, y, dy, Style, Band, pLayer->Get_Grid_Name(Band).wx_str());
517 }
518}
519
520//---------------------------------------------------------
521void CSG_Map_Legend::_Draw_CompositeBand(wxDC &dc, int y, int dy, int Style, int Band, const wxString &Text)
522{
523 if( !Text.IsEmpty() )
524 {
525 _Draw_Label(dc, y, Text, SG_DC_TEXTALIGN_TOP);
526 }
527
528 _Set_Size(0, dy);
529
530 dy -= BOX_SPACE;
531
532 //-----------------------------------------------------
534
535 for(int x=m_xBox; x<m_xBox+m_dxBox; x++)
536 {
537 dc.SetPen(wxPen(SG_Get_wxColor(Colors[x])));
538
539 dc.DrawLine(x, y, x, y + dy);
540 }
541
542 //-----------------------------------------------------
543 if( (Style & BOX_STYLE_OUTL) != 0 )
544 {
545 dc.SetPen(dc.GetTextForeground());
546
547 dc.DrawLine(m_xBox , y , m_xBox + m_dxBox, y );
548 dc.DrawLine(m_xBox + m_dxBox, y , m_xBox + m_dxBox, y + dy);
549 dc.DrawLine(m_xBox + m_dxBox, y + dy, m_xBox , y + dy);
550 dc.DrawLine(m_xBox , y + dy, m_xBox , y );
551 }
552}
553
554//---------------------------------------------------------
556{
557 int nx, ny;
558
559 if( pLayer->Get_Extent().Get_XRange() > pLayer->Get_Extent().Get_YRange() )
560 {
561 nx = m_dxBox;
562 ny = (int)(pLayer->Get_Extent().Get_YRange() / (pLayer->Get_Extent().Get_XRange() / nx));
563 }
564 else
565 {
566 ny = m_dxBox;
567 nx = (int)(pLayer->Get_Extent().Get_XRange() / (pLayer->Get_Extent().Get_YRange() / ny));
568 }
569
570 dc.DrawBitmap(*pLayer->Get_Thumbnail(nx, ny), m_xBox, ay, false);
571
572 SG_DC_Draw_Edge(dc, SG_DC_EDGE_STYLE_SIMPLE, m_xBox, ay, m_xBox + nx, ay + ny);
573
574 //-----------------------------------------------------
575 _Set_Size(0, ny);
576
577 ny += BOX_SPACE;
578}
579
580
582// //
584
585//---------------------------------------------------------
586#define METRIC_HEIGHT ZOOMED(200)
587#define METRIC_GET_STRING(z, dz) wxString::Format("%.*f", dz >= 1. ? 0 : 1 + (int)fabs(log10(dz)), z)
588#define METRIC_POS_V(Value) ( yBox + METRIC_HEIGHT - (int)((double)METRIC_HEIGHT * m_pSymbology->Get_Stretch_to_Relative((Value) / zFactor)))
589#define METRIC_POS_H(Value) (m_xBox + (int)((double)METRIC_HEIGHT * m_pSymbology->Get_Stretch_to_Relative((Value) / zFactor)))
590
591//---------------------------------------------------------
592void CSG_Map_Legend::_Draw_Continuum(wxDC &dc, int y, double zFactor)
593{
594 double zMin = m_pSymbology->Get_Stretch_from_Relative(0.);
595 double zMax = m_pSymbology->Get_Stretch_from_Relative(1.);
596
597 //-----------------------------------------------------
598 if( zMin >= zMax )
599 {
600 if( m_pLayer->Get_Stretch_Range() > 0. )
601 {
603 }
604
606 }
607
608 //-----------------------------------------------------
609 else
610 {
611 zMin *= zFactor; zMax *= zFactor;
612
614
615 wxSize TextSize = dc.GetTextExtent(wxString::Format("01234567"));
616
617 double zToDC = METRIC_HEIGHT / (zMax - zMin), dz = pow(10., floor(log10(zMax - zMin)) - 1.);
618
619 while( zToDC * dz < TextSize.y ) { dz *= 2.; }
620
621 dc.SetPen(dc.GetTextForeground());
622
623 if( m_Orientation == VERTICAL )
624 {
625 _Draw_Continuum_V(dc, y, zMin, zMax, zFactor, dz, TextSize.y);
626 }
627 else
628 {
629 _Draw_Continuum_H(dc, y, zMin, zMax, zFactor, dz, TextSize.y);
630 }
631 }
632}
633
634//---------------------------------------------------------
635void CSG_Map_Legend::_Draw_Continuum_V(wxDC &dc, int yBox, double zMin, double zMax, double zFactor, double dz, int dyFont)
636{
637 CSG_Colors Colors(m_pSymbology->Get_Colors());
638
639 Colors.Set_Count(METRIC_HEIGHT);
640
641 wxPen oldPen(dc.GetPen());
642
643 for(int i=0, iy=yBox+METRIC_HEIGHT; i<Colors.Get_Count(); i++, iy--)
644 {
645 dc.SetPen(wxPen(SG_Get_wxColor(Colors[i])));
646
647 dc.DrawLine(m_xBox, iy, m_xTick, iy);
648 }
649
650 dc.SetPen(oldPen);
651
653
654 switch( m_pSymbology->Get_Stretch_Mode() )
655 {
656 //-----------------------------------------------------
657 case CSG_Scaler::LINEAR: default:
658 {
659 double z = dz * floor(zMin / dz); if( z < zMin ) { z += dz; }
660
661 for(; z<=zMax; z+=dz)
662 {
663 int y = METRIC_POS_V(z); dc.DrawLine(m_xTick, y, m_xText, y);
664
666 }
667 }
668 break;
669
670 //-----------------------------------------------------
672 {
673 int y0 = METRIC_POS_V(zMax) + (1 + dyFont);
674
675 double z = dz * floor(zMax / dz); if( z > zMax ) { z -= dz; }
676
677 for(; z>=zMin; z-=dz)
678 {
679 int y = METRIC_POS_V(z); dc.DrawLine(m_xTick, y, m_xText, y);
680
681 if( abs(y0 - y) >= (int)(0.75 * dyFont) )
682 {
684 }
685
686 while( dz >= 10. && abs(y - METRIC_POS_V(z - dz)) > 2 * dyFont )
687 {
688 dz *= 0.1;
689 }
690 }
691 }
692 break;
693
694 //-----------------------------------------------------
696 {
697 int y0 = METRIC_POS_V(zMin) - (1 + dyFont);
698
699 double z = dz * floor(zMin / dz); if( z < zMin ) { z += dz; }
700
701 for(; z<=zMax; z+=dz)
702 {
703 int y = METRIC_POS_V(z); dc.DrawLine(m_xTick, y, m_xText, y);
704
705 if( abs(y0 - y) >= (int)(0.75 * dyFont) )
706 {
708 }
709
710 while( dz >= 10. && abs(y - METRIC_POS_V(z + dz)) > 2 * dyFont )
711 {
712 dz *= 0.1;
713 }
714 }
715 }
716 break;
717 }
718
719 //-----------------------------------------------------
720 _Set_Size(0, METRIC_HEIGHT + dc.GetFont().GetPointSize());
721}
722
723//---------------------------------------------------------
724void CSG_Map_Legend::_Draw_Continuum_H(wxDC &dc, int yBox, double zMin, double zMax, double zFactor, double dz, int dyFont)
725{
726 CSG_Colors Colors(m_pSymbology->Get_Colors());
727
728 Colors.Set_Count(METRIC_HEIGHT);
729
730 wxPen oldPen(dc.GetPen());
731
732 int yTick = yBox + m_dxBox;
733 int yText = yBox + m_dxBox + m_dxTick;
734
735 for(int i=0, ix=m_xBox; i<Colors.Get_Count(); i++, ix++)
736 {
737 dc.SetPen(wxPen(SG_Get_wxColor(Colors[i])));
738
739 dc.DrawLine(ix, yBox, ix, yTick);
740 }
741
742 dc.SetPen(oldPen);
743
745
746 switch( m_pSymbology->Get_Stretch_Mode() )
747 {
748 //-----------------------------------------------------
749 case CSG_Scaler::LINEAR: default:
750 {
751 int x0 = METRIC_POS_H(zMin) - METRIC_HEIGHT;
752
753 double z = dz * floor(zMin / dz); if( z < zMin ) { z += dz; }
754
755 for(; z<=zMax; z+=dz)
756 {
757 int x = METRIC_POS_H(z); dc.DrawLine(x, yTick, x, yText);
758
759 wxString Label(METRIC_GET_STRING(z, dz)); wxSize s(dc.GetTextExtent(Label));
760
761 if( abs(x0 - x) >= (int)(1.25 * s.x) )
762 {
763 x0 = x; SG_DC_Draw_Text(dc, SG_DC_TEXTALIGN_TOPCENTER, x, yText, Label);
764 }
765 }
766 }
767 break;
768
769 //-----------------------------------------------------
771 {
772 int x0 = METRIC_POS_H(zMax) + METRIC_HEIGHT;
773
774 double z = dz * floor(zMax / dz); if( z > zMax ) { z -= dz; }
775
776 for(; z>=zMin; z-=dz)
777 {
778 int x = METRIC_POS_H(z); dc.DrawLine(x, yTick, x, yText);
779
780 wxString Label(METRIC_GET_STRING(z, dz)); wxSize s(dc.GetTextExtent(Label));
781
782 if( abs(x0 - x) >= (int)(1.25 * s.x) )
783 {
784 x0 = x; SG_DC_Draw_Text(dc, SG_DC_TEXTALIGN_TOPCENTER, x, yText, Label);
785 }
786
787 while( abs(x - METRIC_POS_H(z - dz)) > 2 * s.x )
788 {
789 dz *= 0.1;
790 }
791 }
792 }
793 break;
794
795 //-----------------------------------------------------
797 {
798 int x0 = METRIC_POS_H(zMin) - METRIC_HEIGHT;
799
800 double z = dz * floor(zMin / dz); if( z < zMin ) { z += dz; }
801
802 for(; z<=zMax; z+=dz)
803 {
804 int x = METRIC_POS_H(z); dc.DrawLine(x, yTick, x, yText);
805
806 wxString Label(METRIC_GET_STRING(z, dz)); wxSize s(dc.GetTextExtent(Label));
807
808 if( abs(x0 - x) >= (int)(1.25 * s.x) )
809 {
810 x0 = x; SG_DC_Draw_Text(dc, SG_DC_TEXTALIGN_TOPCENTER, x, yText, Label);
811 }
812
813 while( abs(x - METRIC_POS_H(z + dz)) > 2 * s.x )
814 {
815 dz *= 0.1;
816 }
817 }
818 }
819 break;
820 }
821
822 //-----------------------------------------------------
824}
825
826
828// //
829// //
830// //
832
833//---------------------------------------------------------
@ SG_COLORS_BLACK_GREEN
Definition api_core.h:1384
@ SG_COLORS_BLACK_BLUE
Definition api_core.h:1385
@ SG_COLORS_BLACK_RED
Definition api_core.h:1383
bool Set_Count(int nColors)
int Get_Count(void) const
Definition api_core.h:1482
const SG_Char * Get_Name(void) const
class CSG_Grids * asGrids(bool bPolymorph=false) const
class CSG_Grid * asGrid(bool bPolymorph=false) const
const CSG_String & Get_Unit(void) const
Definition grid.h:553
const SG_Char * Get_Unit(void) const
Definition grids.h:178
CSG_Grid * Get_Composite_Band(int Band)
Definition map_grid.cpp:403
CSG_String Get_Grid_Name(int Band, int Style=SG_GRIDS_NAME_GRID)
class CSG_Map_Symbology * Get_Symbology(void)
Definition map_layer.h:136
CSG_Data_Object * Get_Object(void) const
Definition map_layer.h:96
CSG_Rect Get_Extent(void) const
const class wxBitmap * Get_Thumbnail(int dx, int dy)
wxSize Get_Size(double Zoom, double Zoom_Map)
void _Draw_Boxes(wxDC &dc, int y, int Style, double zFactor=1.0)
void Draw(wxDC &dc, double Zoom, double Zoom_Map, wxPoint Position, wxSize *pSize=NULL)
void _Draw_Layer_Image(wxDC &dc, int y, class CSG_Map_Layer *pLayer)
void _Draw_Polygon(wxDC &dc, class CSG_Map_Shapes_Polygon *pLayer)
void _Draw_Line(wxDC &dc, class CSG_Map_Shapes_Line *pLayer)
CSG_Map_Legend(class CSG_Map_Layer *pLayer)
void Set_Orientation(int Orientation)
void _Draw_Grid(wxDC &dc, class CSG_Map_Grid *pLayer)
void _Draw_Point(wxDC &dc, class CSG_Map_Shapes_Point *pLayer)
double m_Zoom_Map
Definition map_legend.h:95
void _Draw_TIN(wxDC &dc, class CSG_Map_TIN *pLayer)
void _Draw_Continuum_H(wxDC &dc, int y, double zMin, double zMax, double zFactor, double dz, int dyFont)
void _Draw_Label(wxDC &dc, int y, wxString Text, int yAlign)
class CSG_Map_Symbology * m_pSymbology
Definition map_legend.h:109
void _Set_Font(wxDC &dc, int Style)
void _Draw_Title(wxDC &dc, int Style, wxString Text)
wxPoint m_Position
Definition map_legend.h:97
void _Draw_Continuum_V(wxDC &dc, int y, double zMin, double zMax, double zFactor, double dz, int dyFont)
wxBrush m_oldBrush
Definition map_legend.h:103
void _Set_Size(int xSet, int yAdd)
void _Draw_PointCloud(wxDC &dc, class CSG_Map_PointCloud *pLayer)
class CSG_Map_Layer * m_pLayer
Definition map_legend.h:107
void _Draw_Continuum(wxDC &dc, int y, double zFactor)
wxString m_Title
Definition map_legend.h:88
void _Draw_CompositeBand(wxDC &dc, int y, int dy, int Style, int Band, class CSG_Map_Grid *pLayer)
void _Draw_Grids(wxDC &dc, class CSG_Map_Grids *pLayer)
wxString m_Subtitle
Definition map_legend.h:88
void _Draw_Box(wxDC &dc, int y, int dy, int Style, int LineColor, int FillColor, wxString Text)
bool Get_Style_Size(int &min_Size, int &max_Size, double &min_Value, double &dValue, wxString *pName)
void Draw_Symbol(wxDC &dc, int x, int y, int size)
bool Get_Outline(void)
Definition map_layer.h:750
bool Get_Style_Size(int &minSize, int &maxSize, double &Minimum, double &Scale, wxString *pName)
wxBrush Get_Def_Brush(void) const
Definition map_layer.h:650
wxPen Get_Def_Pen(void) const
Definition map_layer.h:649
double Get_YRange(void) const
Definition geo_tools.h:511
double Get_XRange(void) const
Definition geo_tools.h:510
const SG_Char * c_str(void) const
bool is_Empty(void) const
const class wxString & wx_str(void) const
Definition api_core.h:595
@ 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_Get_wxColor(int Color)
Definition dc_helper.cpp:70
void SG_DC_Draw_Text(wxDC &dc, int Align, int x, int y, const wxString &Text)
int SG_Get_Color(const wxColour &Color)
Definition dc_helper.cpp:64
void SG_DC_Draw_Edge(wxDC &dc, int Edge_Style, int ax, int ay, int bx, int by)
#define SG_DC_TEXTALIGN_YCENTER
Definition dc_helper.h:128
#define SG_DC_TEXTALIGN_TOPCENTER
Definition dc_helper.h:132
#define SG_DC_TEXTALIGN_BOTTOM
Definition dc_helper.h:129
#define SG_DC_TEXTALIGN_BOTTOMLEFT
Definition dc_helper.h:137
@ SG_DC_EDGE_STYLE_SIMPLE
Definition dc_helper.h:98
#define SG_DC_TEXTALIGN_TOPLEFT
Definition dc_helper.h:131
#define SG_DC_TEXTALIGN_TOP
Definition dc_helper.h:127
#define SG_DC_TEXTALIGN_CENTERLEFT
Definition dc_helper.h:134
#define BOX_STYLE_SYMB
#define BOX_STYLE_RECT
@ FONT_SUBTITLE
@ FONT_LABEL
@ FONT_TITLE
#define BOX_SPACE
#define TICK_WIDTH
#define BOX_STYLE_LINE
#define FONT_SIZE_LABEL
#define FONT_SIZE_SUBTITLE
#define METRIC_POS_V(Value)
#define METRIC_POS_H(Value)
#define BOX_HEIGHT
#define BOX_WIDTH
#define BOX_STYLE_OUTL
#define METRIC_HEIGHT
#define FONT_SIZE_TITLE
#define BOX_STYLE_FILL
#define SPACE_VERTICAL
#define SIZE_HEIGHT
#define METRIC_GET_STRING(z, dz)
@ SHAPE_TYPE_Polygon
Definition shapes.h:105
@ SHAPE_TYPE_Line
Definition shapes.h:104
@ SHAPE_TYPE_Points
Definition shapes.h:103
@ SHAPE_TYPE_Point
Definition shapes.h:102