1 
2 ///////////////////////////////////////////////////////////
3 //                                                       //
4 //                         SAGA                          //
5 //                                                       //
6 //      System for Automated Geoscientific Analyses      //
7 //                                                       //
8 //                    User Interface                     //
9 //                                                       //
10 //                    Program: SAGA                      //
11 //                                                       //
12 //-------------------------------------------------------//
13 //                                                       //
14 //                    WKSP_Shapes.h                      //
15 //                                                       //
16 //          Copyright (C) 2005 by 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 //    contact:    Olaf Conrad                            //
40 //                Institute of Geography                 //
41 //                University of Goettingen               //
42 //                Goldschmidtstr. 5                      //
43 //                37077 Goettingen                       //
44 //                Germany                                //
45 //                                                       //
46 //    e-mail:     oconrad@saga-gis.org                   //
47 //                                                       //
48 ///////////////////////////////////////////////////////////
49 
50 //---------------------------------------------------------
51 #ifndef _HEADER_INCLUDED__SAGA_GUI__WKSP_Shapes_H
52 #define _HEADER_INCLUDED__SAGA_GUI__WKSP_Shapes_H
53 
54 
55 ///////////////////////////////////////////////////////////
56 //														 //
57 //														 //
58 //														 //
59 ///////////////////////////////////////////////////////////
60 
61 //---------------------------------------------------------
62 #include "wksp_layer.h"
63 
64 
65 ///////////////////////////////////////////////////////////
66 //														 //
67 //														 //
68 //														 //
69 ///////////////////////////////////////////////////////////
70 
71 //---------------------------------------------------------
72 enum
73 {
74 	EDIT_SHAPE_MODE_Normal	= 0,
75 	EDIT_SHAPE_MODE_Split,
76 	EDIT_SHAPE_MODE_Move
77 };
78 
79 
80 ///////////////////////////////////////////////////////////
81 //														 //
82 //														 //
83 //														 //
84 ///////////////////////////////////////////////////////////
85 
86 //---------------------------------------------------------
87 class CWKSP_Shapes : public CWKSP_Layer
88 {
89 public:
90 	CWKSP_Shapes(CSG_Shapes *pShapes);
91 	virtual ~CWKSP_Shapes(void);
92 
Get_Type(void)93 	virtual TWKSP_Item			Get_Type				(void)	{	return( WKSP_ITEM_Shapes );	}
94 
Get_Shapes(void)95 	CSG_Shapes *				Get_Shapes				(void)	{	return( (CSG_Shapes *)m_pObject );	}
Get_Table(void)96 	class CWKSP_Table *			Get_Table				(void)	{	return( m_pTable );		}
97 
98 	virtual wxString			Get_Description			(void);
99 
100 	virtual wxMenu *			Get_Menu				(void);
101 
102 	virtual bool				On_Command				(int Cmd_ID);
103 	virtual bool				On_Command_UI			(wxUpdateUIEvent &event);
104 
105 	virtual wxString			Get_Value				(CSG_Point ptWorld, double Epsilon);
106 	virtual double				Get_Value_Minimum		(void);
107 	virtual double				Get_Value_Maximum		(void);
108 	virtual double				Get_Value_Range			(void);
109 	virtual double				Get_Value_Mean			(void);
110 	virtual double				Get_Value_StdDev		(void);
111 
Get_Field_Value(void)112 	int							Get_Field_Value			(void)	{	return( m_fValue  );	}
Get_Field_Normal(void)113 	int							Get_Field_Normal		(void)	{	return( m_fNormal );	}
Get_Scale_Normal(void)114 	double						Get_Scale_Normal		(void)	{	return( m_dNormal );	}
Get_Field_Info(void)115 	int							Get_Field_Info			(void)	{	return( m_fInfo   );	}
Get_Field_Label(void)116 	int							Get_Field_Label			(void)	{	return( m_fLabel  );	}
117 
118 	wxString					Get_Name_Attribute		(void);
119 
120 	bool						Set_Metrics				(int zField, int nField, int nType);
121 
is_Editing(void)122 	bool						is_Editing				(void)	{	return( m_Edit_pShape != NULL );	}
123 
124 	virtual wxMenu *			Edit_Get_Menu			(void);
125 	virtual TSG_Rect			Edit_Get_Extent			(void);
126 	virtual bool				Edit_On_Key_Down		(int KeyCode);
127 	virtual bool				Edit_On_Mouse_Down		(CSG_Point Point, double ClientToWorld, int Key);
128 	virtual bool				Edit_On_Mouse_Up		(CSG_Point Point, double ClientToWorld, int Key);
129 	virtual bool				Edit_On_Mouse_Move		(wxWindow *pMap, CSG_Rect rWorld, wxPoint pt, wxPoint ptLast, int Key);
130 	virtual bool				Edit_Set_Index			(int Index);
131 	virtual bool				Edit_Set_Attributes		(void);
132 
133 
134 protected:
135 
136 	bool						m_bNoData, m_Edit_bGleam;
137 
138 	int							m_fValue, m_fNormal, m_bVertices, m_fInfo,
139 								m_fLabel, m_Label_Prec, m_Label_Eff, m_Label_Eff_Size,
140 								m_Edit_Mode, m_Edit_iPart, m_Edit_iPoint;
141 
142 	double						m_dNormal;
143 
144 	wxColour					m_Edit_Color, m_Sel_Color, m_Label_Eff_Color;
145 
146 	CSG_Simple_Statistics		m_Metrics;
147 
148 	CSG_Shape					*m_Edit_pShape;
149 
150 	class CWKSP_Table			*m_pTable;
151 
152 
153 	virtual void				On_Create_Parameters	(void);
154 	virtual void				On_DataObject_Changed	(void);
155 	virtual void				On_Parameters_Changed	(void);
156 
157 	virtual int					On_Parameter_Changed	(CSG_Parameters *pParameters, CSG_Parameter *pParameter, int Flags);
158 
159 	virtual void				On_Update_Views			(void);
160 
161 	virtual void				On_Draw					(CWKSP_Map_DC &dc_Map, int Flags);
162 
163 	bool						Get_Class_Color			(CSG_Shape *pShape, int &Color);
164 
165 	void						AttributeList_Set		(CSG_Parameter *pFields, bool bAddNoField);
166 
167 	CSG_Parameter *				BrushList_Add			(const CSG_String &ParentID, const CSG_String &Identifier, const CSG_String &Name, const CSG_String &Description);
168 	wxBrushStyle				BrushList_Get_Style		(const CSG_String &Identifier);
169 
170 	CSG_Parameter *				PenList_Add				(const CSG_String &ParentID, const CSG_String &Identifier, const CSG_String &Name, const CSG_String &Description);
171 	int							PenList_Get_Style		(const CSG_String &Identifier);
172 
173 	virtual void				Draw_Initialize			(CWKSP_Map_DC &dc_Map, int Flags)												= 0;
174 	virtual void				Draw_Shape				(CWKSP_Map_DC &dc_Map, CSG_Shape *pShape, int Selection)			= 0;
175 	virtual void				Draw_Label				(CWKSP_Map_DC &dc_Map, CSG_Shape *pShape, const wxString &Label)	= 0;
176 
177 	virtual void				Edit_Shape_Draw_Move	(wxDC &dc, const CSG_Rect &rWorld, const wxPoint &Point, const TSG_Point &ptWorld);
178 	virtual void				Edit_Shape_Draw_Move	(wxDC &dc, const CSG_Rect &rWorld, const wxPoint &Point);
179 	virtual void				Edit_Shape_Draw			(CWKSP_Map_DC &dc_Map);
180 	virtual int					Edit_Shape_HitTest		(CSG_Point Point, double max_Dist, int &iPart, int &iPoint);
181 	virtual void				Edit_Snap_Point_ToLine	(CSG_Point Point, CSG_Point &snap_Point, double &snap_Dist, CSG_Shape *pShape);
182 
183 
184 private:
185 
186 	void						_LUT_Create				(void);
187 	void						_LUT_Import				(void);
188 
189 	void						_Draw_Shape				(CWKSP_Map_DC &dc_Map, CSG_Shape *pShape, int Selection = 0);
190 	void						_Draw_Label				(CWKSP_Map_DC &dc_Map, CSG_Shape *pShape, int PointSize = 0);
191 
192 
193 	//-----------------------------------------------------
194 	// Charts...
195 
196 	int							m_Chart_Type, m_Chart_sField, m_Chart_sType;
197 
198 	double						m_Chart_sSize, m_Chart_sRange;
199 
200 	CSG_Points_Int				m_Chart;
201 
202 	CSG_Parameters				m_Chart_Options;
203 
204 
_Chart_is_Valid(void)205 	bool						_Chart_is_Valid			(void)	{	return( m_Chart.Get_Count() > 0 );	}
206 	bool						_Chart_Set_Options		(void);
207 	bool						_Chart_Get_Options		(void);
208 
209 	void						_Draw_Chart				(CWKSP_Map_DC &dc_Map, CSG_Shape *pShape);
210 	void						_Draw_Chart_Pie			(CWKSP_Map_DC &dc_Map, CSG_Table_Record *pRecord, bool bOutline, int x, int y, int size);
211 	void						_Draw_Chart_Bar			(CWKSP_Map_DC &dc_Map, CSG_Table_Record *pRecord, bool bOutline, int x, int y, int sx, int sy);
212 
213 
214 	//-----------------------------------------------------
215 	// Editing...
216 
217 	CSG_Shapes					m_Edit_Shapes;
218 
219 
220 	bool						_Edit_Shape				(void);
221 	bool						_Edit_Shape_Start		(void);
222 	bool						_Edit_Shape_Stop		(void);
223 	bool						_Edit_Shape_Stop		(bool bSave);
224 	bool						_Edit_Shape_Add			(void);
225 	bool						_Edit_Shape_Del			(void);
226 	bool						_Edit_Part_Add			(void);
227 	bool						_Edit_Part_Del			(void);
228 	bool						_Edit_Point_Del			(void);
229 	bool						_Edit_Merge				(void);
230 	bool						_Edit_Split				(void);
231 	bool						_Edit_Move				(bool bToggle = true);
232 
233 	void						_Edit_Shape_Draw_Point	(wxDC &dc, TSG_Point_Int Point, bool bSelected);
234 	void						_Edit_Shape_Draw_Point	(wxDC &dc, int x, int y, bool bSelected);
235 
236 	void						_Edit_Snap_Point		(CSG_Point &Point, double ClientToWorld);
237 	void						_Edit_Snap_Point		(CSG_Point Point, CSG_Point &snap_Point, double &snap_Dist, CSG_Shapes *pShapes, bool bLine);
238 	void						_Edit_Snap_Point		(CSG_Point Point, CSG_Point &snap_Point, double &snap_Dist, CSG_Shape *pShape);
239 
240 };
241 
242 
243 ///////////////////////////////////////////////////////////
244 //														 //
245 //														 //
246 //														 //
247 ///////////////////////////////////////////////////////////
248 
249 //---------------------------------------------------------
250 #endif // #ifndef _HEADER_INCLUDED__SAGA_GUI__WKSP_Shapes_H
251