91 Parameters.
Add_Grid(
"TRANSPARENCY",
"TRANSPARENCY_GRID",
_TL(
"Transparency Band"),
92 _TL(
"Band values used to define transparency. Transparency will be linearly scaled from full transparency to full opacity value range. Can be combined with overall transparency."),
96 Parameters.
Add_Double(
"TRANSPARENCY_GRID",
"TRANSPARENCY_GRID_STRETCH.MIN",
_TL(
"Full Transparency"),
_TL(
""), 0.);
97 Parameters.
Add_Double(
"TRANSPARENCY_GRID",
"TRANSPARENCY_GRID_STRETCH.MAX",
_TL(
"Full Opacity" ),
_TL(
""), 0.);
111 Parameters[
"TRANSPARENCY_GRID"].Get_Parent()->Set_Value((
void *)&
m_pObject->asGrids()->Get_System());
125 int Classify = Parameters[
"COLOR_SYMBOLS"].asInt();
143 if( (pGrid = _Get_Grid(0, Parameters)) != NULL ) {
Set_Stretch(Parameters, pGrid,
"_R"); }
144 if( (pGrid = _Get_Grid(1, Parameters)) != NULL ) {
Set_Stretch(Parameters, pGrid,
"_G"); }
145 if( (pGrid = _Get_Grid(2, Parameters)) != NULL ) {
Set_Stretch(Parameters, pGrid,
"_B"); }
262 m_Stretch[0].Set_Histogram(
Get_Grid(0));
263 m_Stretch[1].Set_Histogram(
Get_Grid(1));
264 m_Stretch[2].Set_Histogram(
Get_Grid(2));
281 if( NameField < 0 ) { NameField =
m_pObject->asGrids()->Get_Z_Name_Field(); }
285 bool bReset = Parameters[
"BAND"].asChoice()->
Get_Count() !=
m_pObject->asGrids()->Get_NZ();
287 if( Parameters(
"BAND") ) { Parameters[
"BAND"].asChoice()->Set_Items(List); }
291 if( Parameters(
"COMPOSITE_R") ) { Parameters[
"COMPOSITE_R"].asChoice()->Set_Items(List);
if( bReset ) { Parameters[
"COMPOSITE_R"].Set_Value(2); } }
292 if( Parameters(
"COMPOSITE_G") ) { Parameters[
"COMPOSITE_G"].asChoice()->Set_Items(List);
if( bReset ) { Parameters[
"COMPOSITE_G"].Set_Value(1); } }
293 if( Parameters(
"COMPOSITE_B") ) { Parameters[
"COMPOSITE_B"].asChoice()->Set_Items(List);
if( bReset ) { Parameters[
"COMPOSITE_B"].Set_Value(0); } }
306 return(
m_pObject && i >= 0 && i < m_pObject->asGrids()->Get_NZ() ?
m_pObject->asGrids()->Get_Grid_Ptr(i) : NULL );
322 case 0: Choice =
m_Parameters[
"COMPOSITE_R"].asInt();
break;
323 case 1: Choice =
m_Parameters[
"COMPOSITE_G"].asInt();
break;
324 case 2: Choice =
m_Parameters[
"COMPOSITE_B"].asInt();
break;
329 if(
m_pObject && Choice < m_pObject->asGrids()->Get_NZ() )
331 return(
m_pObject->asGrids()->Get_Grid_Name(Choice, Style) );
338 case 0: pGrid =
m_Parameters[
"COMPOSITE_R_GRID"].asGrid();
break;
339 case 1: pGrid =
m_Parameters[
"COMPOSITE_G_GRID"].asGrid();
break;
340 case 2: pGrid =
m_Parameters[
"COMPOSITE_B_GRID"].asGrid();
break;
359 case 0: Choice = Parameters[
"COMPOSITE_R"].asInt();
break;
360 case 1: Choice = Parameters[
"COMPOSITE_G"].asInt();
break;
361 case 2: Choice = Parameters[
"COMPOSITE_B"].asInt();
break;
366 if(
m_pObject && Choice < m_pObject->asGrids()->Get_NZ() )
368 return(
m_pObject->asGrids()->Get_Grid_Ptr(Choice) );
373 case 0:
return( Parameters[
"COMPOSITE_R_GRID"].asGrid() );
374 case 1:
return( Parameters[
"COMPOSITE_G_GRID"].asGrid() );
375 case 2:
return( Parameters[
"COMPOSITE_B_GRID"].asGrid() );
388CSG_String CSG_Map_Grids::_Get_List_Attributes(
void)
392 for(
int i=0;
m_pObject && i<
m_pObject->asGrids()->Get_Attributes().Get_Field_Count(); i++)
394 List +=
m_pObject->asGrids()->Get_Attributes().Get_Field_Name(i); List +=
"|";
401CSG_String CSG_Map_Grids::_Get_List_Bands(
int Attribute)
407 if( Attribute < 0 || Attribute >=
m_pObject->asGrids()->Get_Attributes().Get_Field_Count() )
409 Attribute =
m_pObject->asGrids()->Get_Z_Name_Field();
412 for(
int i=0; i<
m_pObject->asGrids()->Get_NZ(); i++)
414 List +=
m_pObject->asGrids()->Get_Attributes()[i].asString(Attribute); List +=
"|";
462 for(
int i=0; i<3; i++)
484 switch( m_Stretch_Extent )
502 CSG_Simple_Statistics s;
551 #pragma omp parallel for
552 for(
int y=0; y<pImage->
Get_NY(); y++)
for(
int x=0; x<pImage->
Get_NX(); x++)
554 if( Image.HasAlpha() )
556 pImage->
Set_Value(x, y,
SG_GET_RGBA(Image.GetRed(x, y), Image.GetGreen(x, y), Image.GetBlue(x, y), Image.GetAlpha(x, y)));
560 pImage->
Set_Value(x, y,
SG_GET_RGB (Image.GetRed(x, y), Image.GetGreen(x, y), Image.GetBlue(x, y)));
576 if( Width > 0 && Height > 0 && Image.Create(Width, Height) )
597 if( bFitSize || Width < 1 ) { Width = bFitSize ?
Get_Grid()->
Get_NX() : Bitmap.GetWidth (); }
598 if( bFitSize || Height < 1 ) { Height = bFitSize ?
Get_Grid()->
Get_NY() : Bitmap.GetHeight(); }
600 if( Width > 0 && Height > 0 && Bitmap.Create(Width, Height) )
623 wxMemoryDC dc; wxSize s(
Get_Legend()->Get_Size(Zoom, 1.));
625 Bitmap.Create(s.GetWidth(), s.GetHeight());
627 dc.SelectObject(Bitmap);
628 dc.SetBackground(*wxWHITE_BRUSH);
633 dc.SelectObject(wxNullBitmap);
688 m_Bands.bBandStatistics =
m_Parameters(
"COMPOSITE_FIT")->asInt() != 0;
695 _Draw_Points(dc_Map);
699 _Draw_Cells (dc_Map);
707void CSG_Map_Grids::_Draw_Cells(
CSG_Map_DC &dc_Map)
711 int ya =
m_pObject->asGrids()->Get_System().Get_yWorld_to_Grid(dc_Map.
rWorld().
Get_YMin());
if( ya < 0 ) { ya = 0; }
716 double axDC = dc_Map.
xWorld2DC(
m_pObject->asGrids()->Get_System().Get_xGrid_to_World(xa)) + dDC / 2.;
717 double ayDC = dc_Map.
yWorld2DC(
m_pObject->asGrids()->Get_System().Get_yGrid_to_World(ya)) - dDC / 2.;
722 for(
int y=ya, yaDC=(
int)(ayDC), ybDC=(
int)(ayDC+dDC); y<=yb; y++, ybDC=yaDC, yaDC=(int)(yDC-=dDC))
724 double xDC = axDC;
int Color;
726 for(
int x=xa, xaDC=(
int)(axDC-dDC), xbDC=(
int)(axDC); x<=xb; x++, xaDC=xbDC, xbDC=(int)(xDC+=dDC))
728 if( _Draw_Get_Color(Color, x, y) )
730 if( m_Alpha.is_Okay() )
732 m_Alpha.Set_Alpha(Color,
m_pObject->asGrids()->Get_System(), x, y);
742void CSG_Map_Grids::_Draw_Points(
CSG_Map_DC &dc_Map)
744 CSG_Rect rMap(dc_Map.
rWorld()); rMap.Intersect(
m_pObject->asGrids()->Get_Extent(
true));
746 int axDC = (int)dc_Map.
xWorld2DC(rMap.Get_XMin());
if( axDC < 0 ) { axDC = 0; }
747 int bxDC = (int)dc_Map.
xWorld2DC(rMap.Get_XMax());
if( bxDC >= dc_Map.
rDC().GetWidth () ) { bxDC = dc_Map.
rDC().GetWidth () - 1; }
748 int byDC = (int)dc_Map.
yWorld2DC(rMap.Get_YMax());
if( byDC < 0 ) { byDC = 0; }
749 int ayDC = (int)dc_Map.
yWorld2DC(rMap.Get_YMin());
if( ayDC >= dc_Map.
rDC().GetHeight() ) { ayDC = dc_Map.
rDC().GetHeight() - 1; }
751 int nyDC = abs(ayDC - byDC);
753 #pragma omp parallel for
754 for(
int iyDC=0; iyDC<=nyDC; iyDC++)
756 int Color, yDC = ayDC - iyDC; CSG_Point Point(dc_Map.
xDC2World(axDC), dc_Map.
yDC2World(yDC));
758 for(
int xDC=axDC; xDC<=bxDC; Point.x+=dc_Map.
DC2World(), xDC++)
760 if( _Draw_Get_Color(Color, Point) )
762 if( m_Alpha.is_Okay() )
764 m_Alpha.Set_Alpha(Color, Point.x, Point.y);
774inline bool CSG_Map_Grids::_Draw_Get_Color(
int &Color,
int x,
int y)
776 if( !m_Bands.bOverlay )
778 return( m_Bands[0]->is_InGrid(x, y) &&
m_pSymbology->Get_Class_Color_byValue(m_Bands[0]->asDouble(x, y), Color) );
781 for(
int i=0; i<3; i++)
783 if( m_Bands[i] == NULL )
785 ((BYTE *)&Color)[i] = 0;
791 if( m_Bands[i]->Get_System() ==
m_pObject->asGrids()->Get_System() )
793 if( !m_Bands[i]->is_InGrid(x, y) )
798 Value = m_Bands[i]->asDouble(x, y);
800 else if( !m_Bands[i]->Get_Value(
m_pObject->asGrids()->Get_System().Get_Grid_to_World(x, y), Value, m_Bands.Resampling))
805 Value = 255. * (m_Bands.bBandStatistics ? m_Stretch[i].to_Relative(Value) :
m_pSymbology->Get_Stretch_to_Relative(Value));
807 ((BYTE *)&Color)[i] = Value <= 0. ? 0 : Value >= 255. ? 255 : (BYTE)Value;
815inline bool CSG_Map_Grids::_Draw_Get_Color(
int &Color,
const CSG_Point &Point)
819 if( !m_Bands.bOverlay )
821 return( m_Bands.pBands[0]->Get_Value(Point, Value, m_Bands.Resampling,
false) &&
m_pSymbology->Get_Class_Color_byValue(Value, Color) );
824 for(
int i=0; i<3; i++)
826 if( m_Bands[i] == NULL )
828 ((BYTE *)&Color)[i] = 0;
832 if( !m_Bands[i]->Get_Value(Point, Value, m_Bands.Resampling,
false) )
837 Value = 255. * (m_Bands.bBandStatistics ? m_Stretch[i].to_Relative(Value) :
m_pSymbology->Get_Stretch_to_Relative(Value));
839 ((BYTE *)&Color)[i] = Value <= 0. ? 0 : Value >= 255. ? 255 : (BYTE)Value;
bool SG_UI_Process_Set_Busy(bool bOn, const CSG_String &Message)
#define SG_GET_RGBA(r, g, b, a)
#define SG_GET_RGB(r, g, b)
const SG_Char * Get_Name(void) const
class CSG_Grids * asGrids(bool bPolymorph=false) const
class CSG_Grid * asGrid(bool bPolymorph=false) const
int Get_xWorld_to_Grid(double xWorld) const
const CSG_Simple_Statistics & Get_Statistics(void)
const CSG_Histogram & Get_Histogram(size_t nClasses=0)
virtual void Set_Value(sLong i, BYTE Value, bool bScaled=true)
bool Create(const CSG_Grid &Grid)
const CSG_Grid_System & Get_System(void) const
const CSG_Simple_Statistics & Get_Statistics(void)
const CSG_Histogram & Get_Histogram(size_t nClasses=0)
double Get_Quantile(double Quantile) const
bool Get_Image(wxImage &Image)
double yDC2World(double y)
bool Draw_Image_Begin(double Transparency, Mode Mode=Mode::Transparent)
double yWorld2DC(double y, bool bRound=true)
double xDC2World(double x)
const CSG_Rect & rWorld(void) const
double xWorld2DC(double x, bool bRound=true)
const wxRect & rDC(void) const
void Draw_Image_Pixels(int x1, int y1, int x2, int y2, int Color)
void Draw_Image_Pixel(int x, int y, int Color)
wxBitmap Get_Bitmap(void)
bool Draw_Image_End(void)
const double & DC2World(void) const
const double & World2DC(void) const
virtual bool Parameter_Changed(CSG_Parameters &Parameters, CSG_Parameter &Parameter, int Flags)
virtual bool Set_Stretch_Extent(const CSG_Rect &Extent)
CSG_String Get_Grid_Name(int Band, int Style=SG_GRIDS_NAME_GRID)
virtual bool Get_Bitmap_Legend(wxBitmap &Bitmap, double Zoom)
virtual bool Add_Parameters(CSG_Parameters &Parameters)
virtual bool Get_Bitmap(wxBitmap &Bitmap, bool bFitSize=true, int Width=0, int Height=0)
CSG_Map_Grids(CSG_Grids *pGrids=NULL)
virtual bool Parameters_Changed(void)
bool Set_Grid_Choices(CSG_Parameters &Parameters, int NameField=-1)
CSG_Grid * Get_Grid(void)
virtual bool DataObject_Changed(void)
virtual bool Get_Image(wxImage &Image, bool bFitSize=true, int Width=0, int Height=0)
virtual void On_Draw(CSG_Map_DC &dc_Map, int Flags)
virtual bool asImage(CSG_Grid *pImage)
class CSG_Map_Legend * Get_Legend(void)
virtual bool Parameters_Changed(void)
bool Classify(const CSG_MetaData &Options)
virtual bool DataObject_Changed(void)
virtual bool Parameter_Changed(CSG_Parameters &Parameters, CSG_Parameter &Parameter, int Flags)
CSG_Data_Object * m_pObject
bool Set_Stretch(CSG_Parameters &Parameters, CSG_Data_Object *pObject=NULL, const CSG_String &Suffix="")
bool Set_Stretch_Range(double Minimum, double Maximum)
bool Set_Object(CSG_Data_Object *pObject)
CSG_Rect Get_Extent(void) const
CSG_Parameters m_Parameters
class CSG_Map_Symbology * m_pSymbology
virtual bool Add_Parameters(CSG_Parameters &Parameters)
void Draw(wxDC &dc, double Zoom, double Zoom_Map, wxPoint Position, wxSize *pSize=NULL)
bool Set_Children_Enabled(bool bEnabled=true)
CSG_Grid * asGrid(void) const
bool Cmp_Identifier(const CSG_String &Identifier) const
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)
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)
bool Set_Parameter(const CSG_String &ID, CSG_Parameter *pValue)
CSG_Parameter * Add_Grid(const CSG_String &ParentID, const CSG_String &ID, const CSG_String &Name, const CSG_String &Description, int Constraint, bool bSystem_Dependent=true, TSG_Data_Type Preferred_Type=SG_DATATYPE_Undefined)
double Get_XMax(void) const
double Get_XMin(void) const
double Get_YMin(void) const
double Get_YMax(void) const
static CSG_String Format(const char *Format,...)
bool Create(const class wxString *pString)
@ SG_DATAOBJECT_TYPE_Grids
#define PARAMETER_CHECK_ENABLE
#define PARAMETER_CHECK_VALUES
#define PARAMETER_INPUT_OPTIONAL