//--------------------------------------------------------- void CVariogram_Diagram::On_Draw(wxDC &dc, wxRect rDraw) { if( m_pVariogram->Get_Count() > 0 ) { int i, ix, iy, jx, jy; double x, dx; //------------------------------------------------- if( m_pModel->Get_Data_Count() > 0 ) { ix = Get_xToScreen(m_pModel->Get_Data_XMax()); dc.SetPen (wxPen(wxColour( 0, 127, 0), 2)); dc.DrawLine(ix, Get_yToScreen(m_yMin), ix, Get_yToScreen(m_yMax)); } //------------------------------------------------- if( m_bPairs && m_pVariogram->Get_Maximum(CSG_Variogram::FIELD_COUNT) > 0 ) { double dScale = m_yMax / m_pVariogram->Get_Maximum(CSG_Variogram::FIELD_COUNT); dc.SetPen (wxColour(191, 191, 191)); dc.SetBrush(wxColour(191, 191, 191)); for(i=0; i<m_pVariogram->Get_Count(); i++) { CSG_Table_Record *pRecord = m_pVariogram->Get_Record(i); ix = Get_xToScreen(pRecord->asDouble(CSG_Variogram::FIELD_DISTANCE)); iy = Get_yToScreen(pRecord->asDouble(CSG_Variogram::FIELD_COUNT ) * dScale); dc.DrawCircle(ix, iy, 3); } } //------------------------------------------------- dc.SetPen (wxColour(127, 127, 127)); dc.SetBrush(wxColour( 0, 0, 0)); for(i=0; i<m_pVariogram->Get_Count(); i++) { CSG_Table_Record *pRecord = m_pVariogram->Get_Record(i); ix = Get_xToScreen(pRecord->asDouble(CSG_Variogram::FIELD_DISTANCE)); iy = Get_yToScreen(pRecord->asDouble(CSG_Variogram::FIELD_VAR_EXP )); dc.DrawCircle(ix, iy, 3); } //------------------------------------------------- if( m_pModel->is_Okay() ) { dc.SetPen(wxPen(*wxRED, 2)); dx = (m_xMax - m_xMin) / (double)rDraw.GetWidth(); ix = Get_xToScreen(m_xMin); iy = Get_yToScreen(m_pModel->Get_Value(m_xMin)); for(x=m_xMin+dx; x<=m_xMax; x+=dx) { jx = ix; jy = iy; ix = Get_xToScreen(x); iy = Get_yToScreen(m_pModel->Get_Value(x)); dc.DrawLine(jx, jy, ix, iy); } } } }
//--------------------------------------------------------- bool CSemiVariogram::On_Execute(void) { bool bLog, bResult = false; int Attribute; CSG_Trend Model; CSG_Shapes *pPoints; CSG_Table *pVariogram; //----------------------------------------------------- pPoints = Parameters("POINTS") ->asShapes(); Attribute = Parameters("ATTRIBUTE") ->asInt(); bLog = Parameters("LOG") ->asBool(); pVariogram = Parameters("VARIOGRAM") ->asTable(); //----------------------------------------------------- if( SG_UI_Get_Window_Main() ) { static CVariogram_Dialog dlg; if( dlg.Execute(pPoints, Attribute, bLog, pVariogram, &Model) ) { bResult = true; } } //----------------------------------------------------- else { int nSkip = Parameters("VAR_NSKIP") ->asInt(); int nClasses = Parameters("VAR_NCLASSES") ->asInt(); double maxDistance = Parameters("VAR_MAXDIST") ->asDouble(); Model.Set_Formula(Parameters("VAR_MODEL")->asString()); if( CSG_Variogram::Calculate(pPoints, Attribute, bLog, pVariogram, nClasses, maxDistance, nSkip) ) { Model.Clr_Data(); for(int i=0; i<pVariogram->Get_Count(); i++) { CSG_Table_Record *pRecord = pVariogram->Get_Record(i); Model.Add_Data(pRecord->asDouble(CSG_Variogram::FIELD_DISTANCE), pRecord->asDouble(CSG_Variogram::FIELD_VAR_EXP)); } bResult = Model.Get_Trend() || Model.Get_Parameter_Count() == 0; } } //----------------------------------------------------- if( bResult ) { Message_Add(Model.Get_Formula(), false); for(int i=0; i<pVariogram->Get_Count(); i++) { CSG_Table_Record *pRecord = pVariogram->Get_Record(i); pRecord->Set_Value(CSG_Variogram::FIELD_VAR_MODEL, Model.Get_Value(pRecord->asDouble(CSG_Variogram::FIELD_DISTANCE))); } } return( bResult ); }