//--------------------------------------------------------- bool DLG_Get_FILE_Filter_GDAL_Read(int Type, wxString &Filter) { bool bResult; CSG_Table Formats; SG_UI_ProgressAndMsg_Lock(true); SG_RUN_TOOL(bResult, "io_gdal", 10, // GDAL Formats SG_TOOL_PARAMETER_SET("FORMATS" , &Formats) && SG_TOOL_PARAMETER_SET("TYPE" , Type ) // all (rasters and vectors) && SG_TOOL_PARAMETER_SET("ACCESS" , 0 ) // read && SG_TOOL_PARAMETER_SET("RECOGNIZED", true ) // add an entry for all recognized files ); SG_UI_ProgressAndMsg_Lock(false); if( bResult && Formats.Get_Count() > 0 ) { Filter += Formats[Formats.Get_Count() - 1].asString(2); Filter.Replace("*.sdat;", ""); // we go for *.sgrd Filter.Replace("*.xml;" , ""); // too much noise } return( bResult ); }
//--------------------------------------------------------- bool COGR_Export_KML::On_Execute(void) { CSG_Shapes Shapes, *pShapes = Parameters("SHAPES")->asShapes(); //----------------------------------------------------- if( pShapes->Get_Projection().Get_Type() == SG_PROJ_TYPE_CS_Undefined ) { Message_Add(_TL("layer uses undefined coordinate system, assuming geographic coordinates")); } else if( pShapes->Get_Projection().Get_Type() != SG_PROJ_TYPE_CS_Geographic ) { Message_Fmt("\n%s (%s: %s)\n", _TL("re-projection to geographic coordinates"), _TL("original"), pShapes->Get_Projection().Get_Name().c_str()); bool bResult; SG_RUN_TOOL(bResult, "pj_proj4", 2, SG_TOOL_PARAMETER_SET("SOURCE" , pShapes) && SG_TOOL_PARAMETER_SET("TARGET" , &Shapes) && SG_TOOL_PARAMETER_SET("CRS_PROJ4", SG_T("+proj=longlat +ellps=WGS84 +datum=WGS84")) ); if( bResult ) { pShapes = &Shapes; Message_Fmt("\n%s: %s\n", _TL("re-projection"), _TL("success")); } else { Message_Fmt("\n%s: %s\n", _TL("re-projection"), _TL("failed" )); } } //----------------------------------------------------- CSG_OGR_DataSet DataSource; if( !DataSource.Create(Parameters("FILE")->asString(), "KML") ) { Error_Set(_TL("KML file creation failed")); return( false ); } if( !DataSource.Write(pShapes) ) { Error_Set(_TL("failed to store data")); return( false ); } return( true ); }
//--------------------------------------------------------- bool CPanSharp_PCA::On_Execute(void) { //----------------------------------------------------- bool bResult; CSG_Parameters Tool_Parms; CSG_Table Eigen; //----------------------------------------------------- // get the principal components for the low resolution bands SG_RUN_TOOL_KEEP_PARMS(bResult, "statistics_grid", 8, Tool_Parms, SG_TOOL_PARAMETER_SET("GRIDS" , Parameters("GRIDS" )) && SG_TOOL_PARAMETER_SET("METHOD" , Parameters("METHOD")) && SG_TOOL_PARAMETER_SET("EIGEN" , &Eigen) && SG_TOOL_PARAMETER_SET("COMPONENTS", 0) // get all components ); if( !bResult ) { return( false ); } //----------------------------------------------------- CSG_Parameter_Grid_List *pPCA = Tool_Parms.Get_Parameter("PCA")->asGridList(); int i, n = pPCA->Get_Grid_Count(); CSG_Grid *PCA = new CSG_Grid[n]; CSG_Grid *pPan = Parameters("PAN")->asGrid(); //----------------------------------------------------- // replace first principal component with the high resolution panchromatic band Process_Set_Text(_TL("Replace first PC with PAN")); double Offset_Pan, Offset, Scale; if( Parameters("PAN_MATCH")->asInt() == 0 ) // scale PAN band to fit first PC histogram { Offset_Pan = pPan->Get_Min(); Offset = pPCA->Get_Grid(0)->Get_Min(); Scale = pPCA->Get_Grid(0)->Get_Range() / pPan->Get_Range(); } else { Offset_Pan = pPan->Get_Mean(); Offset = pPCA->Get_Grid(0)->Get_Mean(); Scale = pPCA->Get_Grid(0)->Get_StdDev() / pPan->Get_StdDev(); } PCA[0].Create(Get_System()); for(int y=0; y<Get_NY() && Set_Progress(y); y++) { #pragma omp parallel for for(int x=0; x<Get_NX(); x++) { if( pPan->is_NoData(x, y) ) { PCA[0].Set_NoData(x, y); } else { PCA[0].Set_Value(x, y, Offset + Scale * (pPan->asDouble(x, y) - Offset_Pan)); } } } //----------------------------------------------------- // resample all other PCs to match the high resolution of the PAN band TSG_Grid_Resampling Resampling = Get_Resampling(Parameters("RESAMPLING")->asInt()); for(i=1; i<n; i++) { Process_Set_Text("%s: %s ...", _TL("Resampling"), pPCA->Get_Grid(i)->Get_Name()); PCA[i].Create(Get_System()); PCA[i].Assign(pPCA->Get_Grid(i), Resampling); delete(pPCA->Get_Grid(i)); // PCA tool was unmanaged, so we have to delete the output } delete(pPCA->Get_Grid(0)); pPCA->Del_Items(); for(i=0; i<n; i++) { pPCA->Add_Item(&PCA[i]); } //----------------------------------------------------- // inverse principal component rotation for the high resolution bands SG_RUN_TOOL_KEEP_PARMS(bResult, "statistics_grid", 10, Tool_Parms, SG_TOOL_PARAMETER_SET("PCA" , Tool_Parms("PCA")) && SG_TOOL_PARAMETER_SET("GRIDS", Parameters("SHARPEN")) && SG_TOOL_PARAMETER_SET("EIGEN", &Eigen) ); delete[](PCA); if( !bResult ) { return( false ); } CSG_Parameter_Grid_List *pHiRes = Parameters("SHARPEN")->asGridList(); CSG_Parameter_Grid_List *pLoRes = Parameters("GRIDS" )->asGridList(); CSG_Parameter_Grid_List *pGrids = Tool_Parms("GRIDS" )->asGridList(); if( !Parameters("OVERWRITE")->asBool() ) { pHiRes->Del_Items(); } for(i=0; i<pLoRes->Get_Grid_Count() && i<pGrids->Get_Grid_Count(); i++) { if( pHiRes->Get_Grid(i) ) { pHiRes->Get_Grid(i)->Assign(pGrids->Get_Grid(i)); delete(pGrids->Get_Grid(i)); } else { pHiRes->Add_Item(pGrids->Get_Grid(i)); } pHiRes->Get_Grid(i)->Set_Name(pLoRes->Get_Grid(i)->Get_Name()); } return( true ); }
//--------------------------------------------------------- bool CSG_Shapes::Create(const CSG_String &File_Name) { Destroy(); SG_UI_Msg_Add(CSG_String::Format("%s: %s...", _TL("Load shapes"), File_Name.c_str()), true); //----------------------------------------------------- bool bResult = File_Name.BeforeFirst(':').Cmp("PGSQL") && SG_File_Exists(File_Name) && _Load_ESRI(File_Name); if( bResult ) { Set_File_Name(File_Name, true); } //----------------------------------------------------- else if( File_Name.BeforeFirst(':').Cmp("PGSQL") == 0 ) // database source { CSG_String s(File_Name); s = s.AfterFirst(':'); CSG_String Host (s.BeforeFirst(':')); s = s.AfterFirst(':'); CSG_String Port (s.BeforeFirst(':')); s = s.AfterFirst(':'); CSG_String DBName(s.BeforeFirst(':')); s = s.AfterFirst(':'); CSG_String Table (s.BeforeFirst(':')); CSG_Tool *pTool = SG_Get_Tool_Library_Manager().Get_Tool("db_pgsql", 0); // CGet_Connections if( pTool != NULL ) { SG_UI_ProgressAndMsg_Lock(true); //--------------------------------------------- CSG_Table Connections; CSG_String Connection = DBName + " [" + Host + ":" + Port + "]"; pTool->Settings_Push(); if( pTool->On_Before_Execution() && SG_TOOL_PARAMETER_SET("CONNECTIONS", &Connections) && pTool->Execute() ) // CGet_Connections { for(int i=0; !bResult && i<Connections.Get_Count(); i++) { if( !Connection.Cmp(Connections[i].asString(0)) ) { bResult = true; } } } pTool->Settings_Pop(); //--------------------------------------------- if( bResult && (bResult = (pTool = SG_Get_Tool_Library_Manager().Get_Tool("db_pgsql", 20)) != NULL) == true ) // CPGIS_Shapes_Load { pTool->Settings_Push(); bResult = pTool->On_Before_Execution() && SG_TOOL_PARAMETER_SET("CONNECTION", Connection) && SG_TOOL_PARAMETER_SET("TABLES" , Table) && SG_TOOL_PARAMETER_SET("SHAPES" , this) && pTool->Execute(); pTool->Settings_Pop(); } SG_UI_ProgressAndMsg_Lock(false); } } //----------------------------------------------------- if( bResult ) { Set_Modified(false); Set_Update_Flag(); SG_UI_Process_Set_Ready(); SG_UI_Msg_Add(_TL("okay"), false, SG_UI_MSG_STYLE_SUCCESS); return( true ); } for(int iShape=Get_Count()-1; iShape>=0; iShape--) // be kind, keep at least those shapes that have been loaded successfully { if( !Get_Shape(iShape)->is_Valid() ) { Del_Shape(iShape); } } if( Get_Count() <= 0 ) { Destroy(); } SG_UI_Process_Set_Ready(); SG_UI_Msg_Add(_TL("failed"), false, SG_UI_MSG_STYLE_FAILURE); return( false ); }
//--------------------------------------------------------- bool CWaterRetentionCapacity::On_Execute(void) { CSG_Shapes *pInput = Parameters("SHAPES")->asShapes(); CSG_Shapes *pOutput = Parameters("OUTPUT")->asShapes(); if( pInput->Get_Field_Count() < 5 ) { Error_Set(_TL("Plot hole data has to provide at the very least five attributes (horizon depth, TF, L, Ar, Mo).")); return( false ); } pOutput->Create(SHAPE_TYPE_Point, _TL("Water Retention Capacity")); pOutput->Add_Field("CCC" , SG_DATATYPE_Double); pOutput->Add_Field("CIL" , SG_DATATYPE_Double); pOutput->Add_Field("Permeability" , SG_DATATYPE_Double); pOutput->Add_Field("Equivalent Moisture" , SG_DATATYPE_Double); pOutput->Add_Field("Water Retention Capacity", SG_DATATYPE_Double); //----------------------------------------------------- CSG_Grid *pDEM = Parameters("DEM")->asGrid(); CSG_Matrix Data(5, pInput->Get_Field_Count() / 5); for(int iPoint=0; iPoint<pInput->Get_Count(); iPoint++) { CSG_Shape *pPoint = pInput->Get_Shape(iPoint); for(int iHorizon=0, n=0; iHorizon<Data.Get_NRows(); iHorizon++, n+=5) { for(int i=0; i<5; i++) { Data[iHorizon][i] = pPoint->asDouble(n + i); } } double Slope, Aspect; if( !pDEM->Get_Gradient(pPoint->Get_Point(0), Slope, Aspect, GRID_RESAMPLING_BSpline) ) { Slope = 0.0; } Get_WaterRetention(Data, 1. - tan(Slope), pOutput->Add_Shape(pPoint, SHAPE_COPY_GEOM)); } //----------------------------------------------------- CSG_Grid *pRetention = Parameters("RETENTION")->asGrid(); if( pRetention ) { switch( Parameters("INTERPOL")->asInt() ) { default: // Multlevel B-Spline Interpolation SG_RUN_TOOL_ExitOnError("grid_spline", 4, SG_TOOL_PARAMETER_SET("SHAPES" , pOutput) && SG_TOOL_PARAMETER_SET("FIELD" , pOutput->Get_Field_Count() - 1) && SG_TOOL_PARAMETER_SET("TARGET_DEFINITION", 1) // grid or grid system && SG_TOOL_PARAMETER_SET("TARGET_OUT_GRID" , pRetention) ); break; case 1: // Inverse Distance Weighted SG_RUN_TOOL_ExitOnError("grid_gridding", 1, SG_TOOL_PARAMETER_SET("SHAPES" , pOutput) && SG_TOOL_PARAMETER_SET("FIELD" , pOutput->Get_Field_Count() - 1) && SG_TOOL_PARAMETER_SET("TARGET_DEFINITION", 1) // grid or grid system && SG_TOOL_PARAMETER_SET("TARGET_OUT_GRID" , pRetention) && SG_TOOL_PARAMETER_SET("SEARCH_RANGE" , 1) // global && SG_TOOL_PARAMETER_SET("SEARCH_POINTS_ALL", 1) // all points within search distance ); break; } if( Parameters("SLOPECORR")->asBool() ) { #pragma omp parallel for for(int y=0; y<Get_NY(); y++) { for(int x=0; x<Get_NX(); x++) { if( !pRetention->is_NoData(x, y) ) { double Slope, Aspect; if( !pDEM->Get_Gradient(x, y, Slope, Aspect) ) { Slope = 0.0; } pRetention->Mul_Value(x, y, 1. - tan(Slope)); } } } } } //----------------------------------------------------- return( true ); }
//--------------------------------------------------------- bool CPoint_Zonal_Multi_Grid_Regression::On_Execute(void) { //----------------------------------------------------- CSG_Shapes *pPoints = Parameters("POINTS" )->asShapes(); CSG_Shapes *pZones = Parameters("ZONES" )->asShapes(); CSG_Grid *pRegression = Parameters("REGRESSION")->asGrid (); pRegression->Assign_NoData(); CSG_Grid Regression(*Get_System(), SG_DATATYPE_Float); SG_UI_Progress_Lock(true); // suppress dialogs from popping up for(int i=0; i<pZones->Get_Count() && Process_Get_Okay(); i++) { CSG_Shape_Polygon *pZone = (CSG_Shape_Polygon *)pZones->Get_Shape(i); //------------------------------------------------- // select all points located in current zone polygon bool bResult; CSG_Shapes Zone(SHAPE_TYPE_Polygon); Zone.Add_Shape(pZone); SG_RUN_TOOL(bResult, "shapes_tools", 5, // select points by location SG_TOOL_PARAMETER_SET("LOCATIONS", &Zone) && SG_TOOL_PARAMETER_SET("SHAPES" , pPoints) ); if( !bResult ) { SG_UI_Process_Set_Okay(); // don't stop overall work flow, if tool execution failed for current zone } else if( pPoints->Get_Selection_Count() > 0 ) { //--------------------------------------------- // copy selected points to a new (temporary) points layer CSG_Shapes Selection; SG_RUN_TOOL(bResult, "shapes_tools", 6, // copy selected points to a new layer SG_TOOL_PARAMETER_SET("INPUT" , pPoints) && SG_TOOL_PARAMETER_SET("OUTPUT", &Selection) ); pPoints->asShapes()->Select(); // unselect everything from original points layer //--------------------------------------------- // perform the regression analysis, regression grid for zone is temporary SG_RUN_TOOL(bResult, "statistics_regression", 1, // multiple linear regression for points and predictor grids SG_TOOL_PARAMETER_SET("PREDICTORS", Parameters("PREDICTORS")) && SG_TOOL_PARAMETER_SET("REGRESSION", &Regression ) && SG_TOOL_PARAMETER_SET("POINTS" , &Selection ) && SG_TOOL_PARAMETER_SET("ATTRIBUTE" , Parameters("ATTRIBUTE" )) && SG_TOOL_PARAMETER_SET("RESAMPLING", Parameters("RESAMPLING")) && SG_TOOL_PARAMETER_SET("COORD_X" , Parameters("COORD_X" )) && SG_TOOL_PARAMETER_SET("COORD_Y" , Parameters("COORD_Y" )) && SG_TOOL_PARAMETER_SET("INTERCEPT" , Parameters("INTERCEPT" )) && SG_TOOL_PARAMETER_SET("METHOD" , Parameters("METHOD" )) && SG_TOOL_PARAMETER_SET("P_VALUE" , Parameters("P_VALUE" )) ); //--------------------------------------------- // use zone polygon as mask for copying zonal regression result to final regression grid if( !bResult ) { SG_UI_Process_Set_Okay(); // don't stop overall work flow, if tool execution failed for current zone } else { #pragma omp parallel for // speed up using multiple processors for(int y=0; y<Get_NY(); y++) { for(int x=0; x<Get_NX(); x++) { if( !Regression.is_NoData(x, y) && pZone->Contains(Get_System()->Get_Grid_to_World(x, y)) ) { pRegression->Set_Value(x, y, Regression.asDouble(x, y)); } } } } } } //----------------------------------------------------- SG_UI_Progress_Lock(false); //----------------------------------------------------- Set_Residuals(pPoints, pRegression); //----------------------------------------------------- return( true ); }
//--------------------------------------------------------- bool CKriging_Regression::On_Execute(void) { //----------------------------------------------------- CSG_Shapes Points(SHAPE_TYPE_Point); CSG_Grid *pPrediction = Parameters("PREDICTION")->asGrid(); CSG_Grid *pRegression = Parameters("REGRESSION")->asGrid(); CSG_Grid *pResiduals = Parameters("RESIDUALS" )->asGrid(); CSG_Grid *pVariance = Parameters("VARIANCE" )->asGrid(); //----------------------------------------------------- if( !pResiduals ) { pResiduals = pPrediction; } //----------------------------------------------------- SG_RUN_TOOL_ExitOnError("statistics_regression", 1, // Multiple Regression Analysis (Points and Predictor Grids) SG_TOOL_PARAMETER_SET("PREDICTORS", Parameters("PREDICTORS")) && SG_TOOL_PARAMETER_SET("POINTS" , Parameters("POINTS" )) && SG_TOOL_PARAMETER_SET("ATTRIBUTE" , Parameters("FIELD" )) && SG_TOOL_PARAMETER_SET("INFO_COEFF", Parameters("INFO_COEFF")) && SG_TOOL_PARAMETER_SET("INFO_MODEL", Parameters("INFO_MODEL")) && SG_TOOL_PARAMETER_SET("INFO_STEPS", Parameters("INFO_STEPS")) && SG_TOOL_PARAMETER_SET("RESAMPLING", Parameters("RESAMPLING")) && SG_TOOL_PARAMETER_SET("COORD_X" , Parameters("COORD_X" )) && SG_TOOL_PARAMETER_SET("COORD_Y" , Parameters("COORD_Y" )) && SG_TOOL_PARAMETER_SET("INTERCEPT" , Parameters("INTERCEPT" )) && SG_TOOL_PARAMETER_SET("METHOD" , Parameters("METHOD" )) && SG_TOOL_PARAMETER_SET("P_VALUE" , Parameters("P_VALUE" )) && SG_TOOL_PARAMETER_SET("REGRESSION", pRegression) && SG_TOOL_PARAMETER_SET("RESIDUALS" , &Points ) ); //----------------------------------------------------- CSG_Tool *pK = Parameters("KRIGING")->asInt() == 0 ? (CSG_Tool *)&m_SK : (CSG_Tool *)&m_OK; Process_Set_Text(pK->Get_Name()); pK->Set_Manager(NULL); if( !pK->Set_Parameter("POINTS" , &Points) || !pK->Set_Parameter("FIELD" , 2) // residual || !pK->Set_Parameter("LOG" , Parameters("LOG" )) || !pK->Set_Parameter("BLOCK" , Parameters("BLOCK" )) || !pK->Set_Parameter("DBLOCK" , Parameters("DBLOCK" )) || !pK->Set_Parameter("SEARCH_RANGE" , Parameters("SEARCH_RANGE" )) || !pK->Set_Parameter("SEARCH_RADIUS" , Parameters("SEARCH_RADIUS" )) || !pK->Set_Parameter("SEARCH_POINTS_ALL", Parameters("SEARCH_POINTS_ALL")) || !pK->Set_Parameter("SEARCH_POINTS_MIN", Parameters("SEARCH_POINTS_MIN")) || !pK->Set_Parameter("SEARCH_POINTS_MAX", Parameters("SEARCH_POINTS_MAX")) || !pK->Set_Parameter("SEARCH_DIRECTION" , Parameters("SEARCH_DIRECTION" )) || !pK->Set_Parameter("TARGET_DEFINITION", 1) // grid or grid system || !pK->Set_Parameter("PREDICTION" , pResiduals) || !pK->Set_Parameter("VARIANCE" , pVariance ) || (!SG_UI_Get_Window_Main() && ( // saga_cmd !pK->Set_Parameter("VAR_MAXDIST" , Parameters("VAR_MAXDIST" )) || !pK->Set_Parameter("VAR_NCLASSES" , Parameters("VAR_NCLASSES" )) || !pK->Set_Parameter("VAR_NSKIP" , Parameters("VAR_NSKIP" )) || !pK->Set_Parameter("VAR_MODEL" , Parameters("VAR_MODEL" )))) ) { Error_Set(CSG_String::Format("%s [%s].[%s]", _TL("could not initialize tool"), _TL("statistics_regression"), pK->Get_Name().c_str())); return( false ); } if( !pK->Execute() ) { Error_Set(CSG_String::Format("%s [%s].[%s]", _TL("could not execute tool" ), _TL("statistics_regression"), pK->Get_Name().c_str())); return( false ); } //----------------------------------------------------- #pragma omp parallel for for(int y=0; y<Get_NY(); y++) { for(int x=0; x<Get_NX(); x++) { if( pRegression->is_NoData(x, y) || pResiduals->is_NoData(x, y) ) { pPrediction->Set_NoData(x, y); } else { pPrediction->Set_Value(x, y, pRegression->asDouble(x, y) + pResiduals->asDouble(x, y)); } } } //----------------------------------------------------- pRegression->Fmt_Name("%s.%s [%s]", Parameters("POINTS")->asShapes()->Get_Name(), Parameters("FIELD")->asString(), _TL("Regression")); pPrediction->Fmt_Name("%s.%s [%s]", Parameters("POINTS")->asShapes()->Get_Name(), Parameters("FIELD")->asString(), _TL("Prediction")); if( Parameters("RESIDUALS")->asGrid() ) { pResiduals->Fmt_Name("%s.%s [%s]", Parameters("POINTS")->asShapes()->Get_Name(), Parameters("FIELD")->asString(), _TL("Residuals")); } if( pVariance ) { pVariance ->Fmt_Name("%s.%s [%s]", Parameters("POINTS")->asShapes()->Get_Name(), Parameters("FIELD")->asString(), _TL("Quality")); } //----------------------------------------------------- return( true ); }
//--------------------------------------------------------- bool CGrid_PCA_Focal::On_Execute(void) { int i; //----------------------------------------------------- CSG_Grid_Cell_Addressor Kernel; Kernel.Set_Radius( Parameters("KERNEL_RADIUS")->asInt(), Parameters("KERNEL_TYPE" )->asInt() == 0 ); CSG_Parameter_Grid_List *pPCA, *pGrids = Parameters("BASE")->asGridList(); pGrids->Del_Items(); for(i=0; i<Kernel.Get_Count()-1; i++) { CSG_Grid *pGrid = SG_Create_Grid(Get_System()); if( !pGrid ) { Error_Set(_TL("failed to allocate memory")); for(i=0; i<pGrids->Get_Grid_Count(); i++) { delete(pGrids->Get_Grid(i)); } pGrids->Del_Items(); return( false ); } pGrid->Fmt_Name("x(%d)-y(%d)", Kernel.Get_X(i + 1), Kernel.Get_Y(i + 1)); pGrids->Add_Item(pGrid); } //----------------------------------------------------- CSG_Grid *pGrid = Parameters("GRID")->asGrid(); for(int y=0; y<Get_NY() && Set_Progress(y); y++) { #pragma omp parallel for private(i) for(int x=0; x<Get_NX(); x++) { if( pGrid->is_NoData(x, y) ) { for(i=0; i<pGrids->Get_Grid_Count(); i++) { pGrids->Get_Grid(i)->Set_NoData(x, y); } } else { double z = pGrid->asDouble(x, y); for(i=0; i<pGrids->Get_Grid_Count(); i++) { int ix = Kernel.Get_X(i + 1, x); int iy = Kernel.Get_Y(i + 1, y); pGrids->Get_Grid(i)->Set_Value(x, y, pGrid->is_InGrid(ix, iy) ? z - pGrid->asDouble(ix, iy) : 0.0); } } } } //----------------------------------------------------- bool bResult; CSG_Parameters PCA_Parms; SG_RUN_TOOL_KEEP_PARMS(bResult, "statistics_grid", 8, PCA_Parms, // pca analysis for grids SG_TOOL_PARAMETER_SET("GRIDS" , Parameters("BASE" )) && SG_TOOL_PARAMETER_SET("METHOD" , Parameters("METHOD" )) && SG_TOOL_PARAMETER_SET("EIGEN" , Parameters("EIGEN" )) && SG_TOOL_PARAMETER_SET("COMPONENTS", Parameters("COMPONENTS")->asInt()) ); if( !Parameters("BASE_OUT")->asBool() ) { for(i=0; i<pGrids->Get_Grid_Count(); i++) { delete(pGrids->Get_Grid(i)); } pGrids->Del_Items(); } //----------------------------------------------------- pGrids = Parameters("PCA")->asGridList(); pPCA = PCA_Parms ("PCA")->asGridList(); if( !Parameters("OVERWRITE")->asBool() || (pGrids->Get_Grid_Count() > 0 && !Get_System().is_Equal(pGrids->Get_Grid(0)->Get_System())) ) { pGrids->Del_Items(); } for(i=0; i<pPCA->Get_Grid_Count(); i++) { if( pGrids->Get_Grid(i) ) { pGrids->Get_Grid(i)->Assign(pPCA->Get_Grid(i)); delete(pPCA->Get_Grid(i)); } else { pGrids->Add_Item(pPCA->Get_Grid(i)); } pGrids->Get_Grid(i)->Fmt_Name("%s [PC%0*d]", pGrid->Get_Name(), pPCA->Get_Grid_Count() < 10 ? 1 : 2, i + 1); } //----------------------------------------------------- return( bResult ); }