1 
2 ///////////////////////////////////////////////////////////
3 //                                                       //
4 //                         SAGA                          //
5 //                                                       //
6 //      System for Automated Geoscientific Analyses      //
7 //                                                       //
8 //                     Tool Library                      //
9 //                  Grid_Visualisation                   //
10 //                                                       //
11 //-------------------------------------------------------//
12 //                                                       //
13 //                 Grid_Color_Rotate.cpp                 //
14 //                                                       //
15 //                 Copyright (C) 2003 by                 //
16 //                      Olaf Conrad                      //
17 //                                                       //
18 //-------------------------------------------------------//
19 //                                                       //
20 // This file is part of 'SAGA - System for Automated     //
21 // Geoscientific Analyses'. SAGA is free software; you   //
22 // can redistribute it and/or modify it under the terms  //
23 // of the GNU General Public License as published by the //
24 // Free Software Foundation, either version 2 of the     //
25 // License, or (at your option) any later version.       //
26 //                                                       //
27 // SAGA is distributed in the hope that it will be       //
28 // useful, but WITHOUT ANY WARRANTY; without even the    //
29 // implied warranty of MERCHANTABILITY or FITNESS FOR A  //
30 // PARTICULAR PURPOSE. See the GNU General Public        //
31 // License for more details.                             //
32 //                                                       //
33 // You should have received a copy of the GNU General    //
34 // Public License along with this program; if not, see   //
35 // <http://www.gnu.org/licenses/>.                       //
36 //                                                       //
37 //-------------------------------------------------------//
38 //                                                       //
39 //    e-mail:     oconrad@saga-gis.org                   //
40 //                                                       //
41 //    contact:    Olaf Conrad                            //
42 //                Institute of Geography                 //
43 //                University of Goettingen               //
44 //                Goldschmidtstr. 5                      //
45 //                37077 Goettingen                       //
46 //                Germany                                //
47 //                                                       //
48 ///////////////////////////////////////////////////////////
49 
50 //---------------------------------------------------------
51 #include "Grid_Color_Rotate.h"
52 
53 
54 ///////////////////////////////////////////////////////////
55 //														 //
56 //														 //
57 //														 //
58 ///////////////////////////////////////////////////////////
59 
60 //---------------------------------------------------------
CGrid_Color_Rotate(void)61 CGrid_Color_Rotate::CGrid_Color_Rotate(void)
62 {
63 	Set_Name		(_TL("Color Palette Rotation"));
64 
65 	Set_Author		("O.Conrad (c) 2003");
66 
67 	Set_Description	(_TW(
68 		"The 'Color Palette Rotator' rotates the grids color palette. "
69 	));
70 
71 	Parameters.Add_Grid  ("", "GRID"  , _TL("Grid"  ), _TL(""), PARAMETER_INPUT);
72 	Parameters.Add_Colors("", "COLORS", _TL("Colors"), _TL(""));
73 	Parameters.Add_Bool  ("", "DOWN"  , _TL("Down"  ), _TL(""), true);
74 }
75 
76 
77 ///////////////////////////////////////////////////////////
78 //														 //
79 ///////////////////////////////////////////////////////////
80 
81 //---------------------------------------------------------
On_Execute(void)82 bool CGrid_Color_Rotate::On_Execute(void)
83 {
84 	CSG_Colors Colors = *Parameters("COLORS")->asColors();
85 
86 	if( Colors.Get_Count() < 2 )
87 	{
88 		return( false );
89 	}
90 
91 	CSG_Grid *pGrid = Parameters("GRID")->asGrid();
92 
93 	bool bDown = Parameters("DOWN")->asBool();
94 
95 	int n = Colors.Get_Count() - 1, d = bDown ? 1 : -1;
96 
97 	do
98 	{
99 		long Color = Colors[bDown ? 0 : n];
100 
101 		for(int i=0, j=bDown?0:n; i<n; i++, j+=d)
102 		{
103 			Colors[j] = Colors[j + d];
104 		}
105 
106 		Colors[bDown ? n : 0] = Color;
107 
108 		DataObject_Set_Colors(pGrid, Colors);
109 	}
110 	while( Process_Get_Okay() );
111 
112 	return( SG_UI_Process_Set_Okay() );
113 }
114 
115 
116 ///////////////////////////////////////////////////////////
117 //														 //
118 //														 //
119 //														 //
120 ///////////////////////////////////////////////////////////
121 
122 //---------------------------------------------------------
123