wxArt2D
layerdlg.cpp
1 /*! \file editor/src/layerdlg.cpp
2  \author Klaas Holwerda
3 
4  Copyright: 2000-2004 (c) Klaas Holwerda
5 
6  Licence: wxWidgets Licence
7 
8  RCS-ID: $Id: layerdlg.cpp,v 1.68 2009/07/04 10:26:39 titato Exp $
9 */
10 
11 #include "a2dprec.h"
12 
13 #ifdef __BORLANDC__
14 #pragma hdrstop
15 #endif
16 
17 #ifndef WX_PRECOMP
18 #include "wx/wx.h"
19 #endif
20 
21 #include "wx/canvas/canmod.h"
22 #include "wx/canvas/styledialg.h"
23 
24 #include <wx/statline.h>
25 
26 #include "wx/canvas/layerdlg.h"
27 
28 #if defined(__WXMSW__) && defined(__MEMDEBUG__)
29 #include <wx/msw/msvcrt.h>
30 #endif
31 
32 #define LPD_B_W 20
33 #define LPD_B_H 20
34 
35 #ifdef __UNIX__
36 #define LPD_PATTERNBOX_W 50
37 #else
38 #define LPD_PATTERNBOX_W 30
39 #endif
40 
41 const int LAY_BUTTON_HIDE = wxID_HIGHEST + 4801 ;
42 
43 const int LAY_BUTTON_CANCEL = wxID_HIGHEST + 4802 ;
44 
45 const int LAY_BUTTON_VISIBLE = wxID_HIGHEST + 4803 ;
46 
47 const int LAY_BUTTON_OUTLINE = wxID_HIGHEST + 5961 ;
48 
49 const int LAY_BUTTON_READ = wxID_HIGHEST + 4804 ;
50 
51 const int LAY_BUTTON_SELECT = wxID_HIGHEST + 4805 ;
52 
53 const int LAY_BUTTON_PREV = wxID_HIGHEST + 4806 ;
54 
55 const int LAY_BUTTON_NEXT = wxID_HIGHEST + 4807 ;
56 
57 const int LAY_EDIT_NAME = wxID_HIGHEST + 4808 ;
58 
59 const int LAY_BUTTON_RESTORE = wxID_HIGHEST + 4812 ;
60 
61 const int LAY_BUTTON_SAVETOFILE = wxID_HIGHEST + 4813 ;
62 
63 const int LAY_BUTTON_LOADFROMFILE = wxID_HIGHEST + 4814 ;
64 
65 const int LAY_BUTTON_SORT = wxID_HIGHEST + 4815 ;
66 
67 const int ID_AVAILABLE = wxID_HIGHEST + 5000;
68 const int ID_LAYERNAME = wxID_HIGHEST + 5100;
69 const int ID_VISIBLE = wxID_HIGHEST + 5200;
70 const int ID_SELECTABLE = wxID_HIGHEST + 5300;
71 const int ID_READ = wxID_HIGHEST + 5400;
72 const int ID_OUTLINE = wxID_HIGHEST + 5450;
73 const int ID_LAYERFILLCOLOR = wxID_HIGHEST + 5500;
74 const int ID_LAYERSTROKECOLOR = wxID_HIGHEST + 5600;
75 const int ID_LAYERPATTERN = wxID_HIGHEST + 5700;
76 const int ID_INMAP = wxID_HIGHEST + 5800;
77 const int ID_OUTMAP = wxID_HIGHEST + 5900;
78 const int ID_NUMBER = wxID_HIGHEST + 5950;
79 const int ID_AvailableTimer = wxID_HIGHEST + 5960;
80 
81 // check document every 3 seconds
82 #define CHECKTIME 3000
83 
84 BEGIN_EVENT_TABLE( LayerPropertiesDialog, wxDialog )
85 
87  EVT_DO( LayerPropertiesDialog::OnDoEvent )
88 
89  EVT_BUTTON ( LAY_BUTTON_SORT, LayerPropertiesDialog::CmSort )
90 
91  EVT_BUTTON ( LAY_BUTTON_HIDE, LayerPropertiesDialog::CmHide )
92 
93  EVT_BUTTON ( LAY_BUTTON_CANCEL, LayerPropertiesDialog::CmCancel )
94 
95  EVT_BUTTON ( LAY_BUTTON_RESTORE, LayerPropertiesDialog::CmRestore )
96 
97  EVT_BUTTON ( LAY_BUTTON_SAVETOFILE, LayerPropertiesDialog::CmSaveToFile )
98 
99  EVT_BUTTON ( LAY_BUTTON_LOADFROMFILE, LayerPropertiesDialog::CmLoadFromFile )
100 
101  EVT_BUTTON ( LAY_BUTTON_VISIBLE, LayerPropertiesDialog::CmVisible )
102 
103  EVT_BUTTON ( LAY_BUTTON_READ, LayerPropertiesDialog::CmRead )
104 
105  EVT_BUTTON ( LAY_BUTTON_OUTLINE, LayerPropertiesDialog::CmOutLine )
106 
107  EVT_BUTTON ( LAY_BUTTON_SELECT, LayerPropertiesDialog::CmSelect )
108 
109  EVT_BUTTON ( LAY_BUTTON_PREV, LayerPropertiesDialog::CmPrev )
110 
111  EVT_BUTTON ( LAY_BUTTON_NEXT, LayerPropertiesDialog::CmNext )
112 
113  EVT_CUSTOM_RANGE( wxEVT_COMMAND_TEXT_ENTER, ID_LAYERNAME, ID_LAYERNAME + 9, LayerPropertiesDialog::Cm_LayerName )
114 
115  EVT_CUSTOM_RANGE( wxEVT_COMMAND_BUTTON_CLICKED, ID_NUMBER, ID_NUMBER + 9, LayerPropertiesDialog::Cm_NumberBox )
116 
117  EVT_CUSTOM_RANGE( wxEVT_COMMAND_CHECKBOX_CLICKED , ID_VISIBLE, ID_VISIBLE + 9, LayerPropertiesDialog::Cm_VisibleBox )
118  EVT_CUSTOM_RANGE( wxEVT_COMMAND_CHECKBOX_CLICKED , ID_SELECTABLE, ID_SELECTABLE + 9, LayerPropertiesDialog::Cm_SelectBox )
119  EVT_CUSTOM_RANGE( wxEVT_COMMAND_CHECKBOX_CLICKED , ID_READ, ID_READ + 9, LayerPropertiesDialog::Cm_ReadBox )
120  EVT_CUSTOM_RANGE( wxEVT_COMMAND_CHECKBOX_CLICKED , ID_OUTLINE, ID_OUTLINE + 9, LayerPropertiesDialog::Cm_OutLineBox )
121 
122  EVT_CUSTOM_RANGE( wxEVT_COMMAND_BUTTON_CLICKED, ID_LAYERFILLCOLOR, ID_LAYERFILLCOLOR + 9, LayerPropertiesDialog::Cm_F_BitB )
123  EVT_CUSTOM_RANGE( wxEVT_COMMAND_BUTTON_CLICKED, ID_LAYERSTROKECOLOR, ID_LAYERSTROKECOLOR + 9, LayerPropertiesDialog::Cm_B_BitB )
124  EVT_CUSTOM_RANGE( wxEVT_COMMAND_BUTTON_CLICKED, ID_LAYERPATTERN, ID_LAYERPATTERN + 9, LayerPropertiesDialog::Cm_P_BitB )
125 
126  EVT_CUSTOM_RANGE( wxEVT_COMMAND_TEXT_ENTER , ID_INMAP, ID_INMAP + 9, LayerPropertiesDialog::Cm_InMap )
127  EVT_CUSTOM_RANGE( wxEVT_COMMAND_TEXT_ENTER , ID_OUTMAP, ID_OUTMAP + 9, LayerPropertiesDialog::Cm_OutMap )
128 
129  EVT_CHAR( LayerPropertiesDialog::OnChar )
130  EVT_CHAR_HOOK( LayerPropertiesDialog::OnCharHook )
131 
132  EVT_CLOSE( LayerPropertiesDialog::OnCloseWindow )
133 
134 END_EVENT_TABLE()
135 
136 
137 //****** IMPLEMENTATION OF THE LAYER PROPERTIES DIALOG CLASS ******
138 
139 a2dLayerInfo* LayerPropertiesDialog::GetLocalLayerInfo( int i )
140 {
141  if ( m_onorder )
142  return m_controlslayersetup->GetOrderIndex()[i];
143  else
144  return m_controlslayersetup->GetLayerIndex()[i];
145 }
146 
147 a2dLayerInfo* LayerPropertiesDialog::GetDocLayerInfo( int i )
148 {
149  if ( m_onorder )
150  return m_layersetup->GetOrderIndex()[i];
151  else
152  return m_layersetup->GetLayerIndex()[i];
153 }
154 
155 
156 
157 // Constructor
158 LayerPropertiesDialog::LayerPropertiesDialog( a2dHabitat* habitat, wxFrame* parent, a2dLayers* layersetup, const wxString& title, long style, const wxString& name ):
159  wxDialog( parent, -1, title, wxDefaultPosition, wxDefaultSize, style, name )
160 
161 {
162  m_habitat = habitat;
163 /*
164  a2dDocviewGlobals->GetDocviewCommandProcessor()->ConnectEvent( wxEVT_CHANGED_DOCUMENT, this );
165  //a2dDocviewGlobals->GetDocviewCommandProcessor()->ConnectEvent( wxEVT_ACTIVATE_VIEW, this );
166  a2dDocviewGlobals->GetDocviewCommandProcessor()->ConnectEvent( wxEVT_DO, this );
167  a2dDocviewGlobals->GetDocviewCommandProcessor()->ConnectEvent( wxEVT_UNDO, this );
168  a2dDocviewGlobals->GetDocviewCommandProcessor()->ConnectEvent( wxEVT_REDO, this );
169  a2dDocviewGlobals->GetDocviewCommandProcessor()->ConnectEvent( a2dEVT_COM_EVENT, this );
170 */
171  a2dCanvasGlobals->ConnectEvent( a2dEVT_COM_EVENT, this );
172  //drawingPart->ConnectEvent( a2dEVT_COM_EVENT, this );
173 
174  SetExtraStyle( GetExtraStyle() | wxWS_EX_BLOCK_EVENTS );
175 
176  m_dialogLastUpdate = wxDateTime::Now();
177 
178  m_fillpatterns = new FillPatterns();
179 
180  m_parent = parent;
181 
182  m_brush = new wxBrush(); // must be done.
183  m_onorder = false;
184 
185  // no standard colours
186  // set extra part of dialog true
187  m_cdata = new wxColourData();
188  m_cdata->SetChooseFull( true );
189 
190  long style_noresize;
191 #ifdef __UNIX__
192  style_noresize = ( wxCAPTION );
193 #else
194  style_noresize = ( wxSYSTEM_MENU | wxCAPTION );
195 #endif
196 
197  // make colour dialog
198  m_cd = new wxColourDialog( this, m_cdata );
199 
200  wxFlexGridSizer* alllayerline = new wxFlexGridSizer( 11 );
201  alllayerline->AddGrowableCol( 1 );
202  wxSizer* all = new wxBoxSizer( wxVERTICAL );
203  all->Add( alllayerline, 0, wxGROW );
204 
205  m_numberlabel = new wxStaticText( this, -1, _T( "Nr" ) );
206  alllayerline->Add( m_numberlabel, 0, wxALIGN_CENTRE );
207  m_namelabel = new wxStaticText( this, -1, _T( "Name" ) );
208  alllayerline->Add( m_namelabel, 0, wxALIGN_CENTRE | wxALL, 2 );
209  m_visiblelabel = new wxStaticText( this, -1, _T( "Vis" ) );
210  alllayerline->Add( m_visiblelabel, 0, wxALIGN_CENTRE | wxALL, 2 );
211  m_selectablelabel = new wxStaticText( this, -1, _T( "Sel" ) );
212  alllayerline->Add( m_selectablelabel, 0, wxALIGN_CENTRE | wxALL, 2 );
213  m_outlinelabel = new wxStaticText( this, -1, _T( "OutL" ) );
214  alllayerline->Add( m_outlinelabel, 0, wxALIGN_CENTRE | wxALL, 2 );
215  m_readlayerlabel = new wxStaticText( this, -1, _T( "Read" ) );
216  alllayerline->Add( m_readlayerlabel, 0, wxALIGN_CENTRE | wxALL, 2 );
217  m_filllabel = new wxStaticText( this, -1, _T( "Fill" ) );
218  alllayerline->Add( m_filllabel, 0, wxALIGN_CENTRE | wxALL, 2 );
219  m_borderlabel = new wxStaticText( this, -1, _T( "Stroke" ) );
220  alllayerline->Add( m_borderlabel, 0, wxALIGN_CENTRE | wxALL, 2 );
221  m_patternlabel = new wxStaticText( this, -1, _T( "Pattern" ) );
222  alllayerline->Add( m_patternlabel, 0, wxALIGN_CENTRE | wxALL, 2 );
223  m_mappinglabel = new wxStaticText( this, -1, _T( "inMap" ) );
224  alllayerline->Add( m_mappinglabel, 0, wxALIGN_CENTRE | wxALL, 2 );
225  m_mappinglabel = new wxStaticText( this, -1, _T( "outMap" ) );
226  alllayerline->Add( m_mappinglabel, 0, wxALIGN_CENTRE | wxALL, 2 );
227 
228  // make the controls
229  for ( int i = 0; i < 10; i++ )
230  {
231  wxString nrbuf;
232 
233  nrbuf.Printf( _T( "%03d" ), i + 1 );
234 
235  m_numberbox[i] = new wxButton( this, ID_NUMBER + i, nrbuf, wxDefaultPosition, wxSize( 25, 20 ), wxBU_EXACTFIT );
236  alllayerline->Add( m_numberbox[i], 0, wxALIGN_CENTER_VERTICAL | wxALIGN_CENTRE | wxGROW );
237 
238  m_namebox[i] = new wxTextCtrl( this, ID_LAYERNAME + i, _T( "" ), wxDefaultPosition, wxSize( 50, 20 ), wxTE_PROCESS_ENTER );
239  alllayerline->Add( m_namebox[i], 0, wxALIGN_CENTRE | wxALL | wxGROW, 0 );
240  m_namebox[i]->SetToolTip( _( "Layer name" ) );
241 
242  m_visiblebox[i] = new wxCheckBox( this, ID_VISIBLE + i, _T( "" ), wxDefaultPosition, wxDefaultSize, 0 );
243  alllayerline->Add( m_visiblebox[i], 0, wxALIGN_CENTRE | wxALL, 1 );
244 
245  m_selectablebox[i] = new wxCheckBox( this, ID_SELECTABLE + i, _T( "" ), wxDefaultPosition, wxDefaultSize, 0 );
246  alllayerline->Add( m_selectablebox[i], 0, wxALIGN_CENTRE | wxALL, 1 );
247 
248  m_outlinebox[i] = new wxCheckBox( this, ID_OUTLINE + i, _T( "" ), wxDefaultPosition, wxDefaultSize, 0 );
249  alllayerline->Add( m_outlinebox[i], 0, wxALIGN_CENTRE | wxALL, 1 );
250 
251  m_readlayerbox[i] = new wxCheckBox( this, ID_READ + i, _T( "" ), wxDefaultPosition, wxDefaultSize, 0 );
252  alllayerline->Add( m_readlayerbox[i], 0, wxALIGN_CENTRE | wxALL, 1 );
253 
254  m_fillbut[i] = new wxButton( this, ID_LAYERFILLCOLOR + i, _T( "" ), wxDefaultPosition, wxSize( 20, 20 ), wxSIMPLE_BORDER );
255  alllayerline->Add( m_fillbut[i], 0, wxALIGN_CENTRE | wxALL, 1 );
256 
257  m_borderbut[i] = new wxButton( this, ID_LAYERSTROKECOLOR + i, _T( "" ), wxDefaultPosition, wxSize( 20, 20 ), wxSIMPLE_BORDER );
258  alllayerline->Add( m_borderbut[i], 0, wxALIGN_CENTRE | wxALL, 1 );
259 
260  m_p_bitm[i] = new wxBitmap( LPD_PATTERNBOX_W, LPD_B_H, -1 );
261  m_patternbut[i] = new wxBitmapButton( this, ID_LAYERPATTERN + i, *m_p_bitm[i], wxDefaultPosition, wxSize( 40, 20 ), wxSIMPLE_BORDER );
262  alllayerline->Add( m_patternbut[i], 0, wxALIGN_CENTRE | wxALL, 1 );
263  m_patterns[i] = 0;
264 
265  m_gdsinmap[i] = new wxTextCtrl( this, ID_INMAP + i, _T( "" ), wxDefaultPosition, wxSize( 30, -1 ), wxTE_PROCESS_ENTER );
266  alllayerline->Add( m_gdsinmap[i], 0, wxALIGN_CENTRE | wxALL, 1 );
267 
268  m_gdsoutmap[i] = new wxTextCtrl( this, ID_OUTMAP + i, _T( "" ), wxDefaultPosition, wxSize( 30, -1 ), wxTE_PROCESS_ENTER );
269  alllayerline->Add( m_gdsoutmap[i], 0, wxALIGN_CENTRE | wxALL, 1 );
270  }
271 
272  wxStaticBox* item1 = new wxStaticBox( this, -1, _T( "" ) );
273  wxSizer* botline = new wxStaticBoxSizer( item1, wxVERTICAL );
274 
275  wxSizer* botline1 = new wxBoxSizer( wxHORIZONTAL );
276  botline->Add( botline1 );
277 
278  m_buttonSORT = new wxButton( this, LAY_BUTTON_SORT, _T( "Sort Order" ), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT );
279  botline1->Add( m_buttonSORT, 0, wxALIGN_CENTRE | wxALL, 0 );
280 
281  m_buttonVISIBLE = new wxButton( this, LAY_BUTTON_VISIBLE, _T( "Hide All" ), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT );
282  botline1->Add( m_buttonVISIBLE, 0, wxALIGN_CENTRE | wxALL, 0 );
283  m_buttonSELECT = new wxButton( this, LAY_BUTTON_SELECT, _T( "None Selectable" ), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT );
284  botline1->Add( m_buttonSELECT, 0, wxALIGN_CENTRE | wxALL, 0 );
285  m_buttonREAD = new wxButton( this, LAY_BUTTON_READ, _T( "Read Non" ), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT );
286  botline1->Add( m_buttonREAD, 0, wxALIGN_CENTRE | wxALL, 0 );
287  m_buttonOutLine = new wxButton( this, LAY_BUTTON_OUTLINE, _T( "OutLine" ), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT );
288  botline1->Add( m_buttonOutLine, 0, wxALIGN_CENTRE | wxALL, 0 );
289 
290  botline->Add( new wxStaticLine( this, -1, wxDefaultPosition, wxSize( 200, 2 ), wxLI_HORIZONTAL ) , 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxALL, 2 );
291 
292  wxSizer* botline2 = new wxBoxSizer( wxHORIZONTAL );
293  botline->Add( botline2 );
294 
295  m_buttonHIDE = new wxButton( this, LAY_BUTTON_HIDE, _T( "Hide" ), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT );
296  botline2->Add( m_buttonHIDE, 0, wxALIGN_CENTRE | wxALL, 0 );
297  m_buttonCANCEL = new wxButton( this, LAY_BUTTON_CANCEL, _T( "Cancel" ), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT );
298  botline2->Add( m_buttonCANCEL, 0, wxALIGN_CENTRE | wxALL, 0 );
299 
300  botline2->Add( new wxStaticLine( this, -1, wxDefaultPosition, wxSize( 2, 20 ), wxLI_VERTICAL ) , 0, wxALIGN_CENTRE | wxALL, 2 );
301 
302  m_buttonPREV = new wxButton( this, LAY_BUTTON_PREV, _T( "< Previous" ), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT );
303  botline2->Add( m_buttonPREV, 0, wxALIGN_CENTRE | wxALL, 0 );
304  m_buttonNEXT = new wxButton( this, LAY_BUTTON_NEXT, _T( "Next >" ), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT );
305  botline2->Add( m_buttonNEXT, 0, wxALIGN_CENTRE | wxALL, 0 );
306  m_buttonRESTORE = new wxButton( this, LAY_BUTTON_RESTORE, _T( "Restore" ), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT );
307 
308  wxSizer* botline3 = new wxBoxSizer( wxHORIZONTAL );
309  botline->Add( botline3 );
310  botline3->Add( m_buttonRESTORE, 0, wxALIGN_CENTRE | wxALL, 0 );
311  m_buttonSAVETOFILE = new wxButton( this, LAY_BUTTON_SAVETOFILE, _T( "Save File" ), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT );
312  botline3->Add( m_buttonSAVETOFILE, 0, wxALIGN_CENTRE | wxALL, 0 );
313  m_buttonLOADFROMFILE = new wxButton( this, LAY_BUTTON_LOADFROMFILE, _T( "Load File" ), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT );
314  botline3->Add( m_buttonLOADFROMFILE, 0, wxALIGN_CENTRE | wxALL, 0 );
315 
316  all->Add( botline );
317 
318  SetSizer( all );
319 
320  all->Fit( this );
321  SetAutoLayout( true );
322 
323  all->SetSizeHints( this );
324 
325  m_startvalue = 0;
326 
328  if ( !drawingPart )
329  return;
330 
331  a2dLayers* layers = drawingPart->GetDrawing()->GetLayerSetup();
332  if ( !layers )
333  return;
334 
335  if ( drawingPart && layersetup )
336  layersetup->SetAvailable( drawingPart->GetShowObject()->GetRoot() );
337 
338  if ( layersetup )
339  Init( layersetup );
340  else
341  Init( m_habitat->GetLayerSetup() );
342 
343  Centre( wxBOTH );
344  Layout();
345 
346 }
347 
348 LayerPropertiesDialog::~LayerPropertiesDialog()
349 {
350 /*
351  a2dDocviewGlobals->GetDocviewCommandProcessor()->DisconnectEvent( wxEVT_DO, this );
352  a2dDocviewGlobals->GetDocviewCommandProcessor()->DisconnectEvent( wxEVT_UNDO, this );
353  a2dDocviewGlobals->GetDocviewCommandProcessor()->DisconnectEvent( wxEVT_REDO, this );
354  a2dDocviewGlobals->GetDocviewCommandProcessor()->DisconnectEvent( a2dEVT_COM_EVENT, this );
355 */
356  a2dCanvasGlobals->DisconnectEvent( a2dEVT_COM_EVENT, this );
357 
358  delete m_fillpatterns;
359  delete m_brush;
360 
361  delete m_cdata;
362  delete m_cd;
363 
364  for ( int i = 0; i < 10; i++ )
365  {
366  delete m_p_bitm[i];
367  }
368 }
369 
370 void LayerPropertiesDialog::Init( a2dLayers* layersetup )
371 {
372  if ( !layersetup )
373  return;
374 
375  m_backuplayersetup = wxStaticCast( layersetup->Clone( a2dObject::clone_deep ) , a2dLayers );
376  m_controlslayersetup = wxStaticCast( layersetup->Clone( a2dObject::clone_deep ) , a2dLayers );
377  m_layersetup = layersetup;
378 
379  m_buttonPREV->Enable();
380  m_buttonNEXT->Enable();
381 
382  if ( m_startvalue <= 0 )
383  m_buttonPREV->Disable();
384 
385  if ( m_startvalue + 10 >= wxMAXLAYER - 1 )
386  m_buttonNEXT->Disable();
387 
388  FillControls( m_startvalue );
389 }
390 
391 void LayerPropertiesDialog::OnComEvent( a2dComEvent& event )
392 {
393  if ( GetEvtHandlerEnabled() )
394  {
396 
397  if ( !part || !part->GetDrawing() )
398  return;
399 
400  int layer = m_habitat->GetLayer();
401  a2dLayerInfo* layerinfo = GetLocalLayerInfo( layer );
402 
403  if ( event.GetId() == a2dComEvent::sm_changedProperty )
404  {
405  a2dNamedProperty* property = event.GetProperty();
406  a2dObject* object = property->GetRefObjectNA();
407 
408  if ( 0 != wxDynamicCast( property, a2dStrokeProperty ) )
409  {
410  a2dStroke stroke = ( ( a2dStrokeProperty* )property )->GetValue();
411  if ( layerinfo->GetStroke() != stroke )
412  layerinfo->SetStroke( stroke );
413  FillControls( m_startvalue );
414  }
415  else if ( 0 != wxDynamicCast( property, a2dFillProperty ) )
416  {
417  a2dFill fill = ( ( a2dFillProperty* )property )->GetValue();
418  if ( layerinfo->GetFill() != fill )
419  layerinfo->SetFill( fill );
420  FillControls( m_startvalue );
421  }
422  else if ( property->GetId() == a2dCanvasObject::PROPID_Layer )
423  {
424  layerinfo->SetLayer( property->GetUint16() );
425  FillControls( m_startvalue );
426  }
427  else
428  event.Skip();
429  }
430  else if ( event.GetId() == a2dDrawingPart::sig_changedLayers )
431  {
432  Init( part->GetDrawing()->GetLayerSetup() );
433  }
434  else if ( event.GetId() == a2dDrawing::sig_changedLayer )
435  {
436  //Init( doc->GetLayerSetup() );
437  m_controlslayersetup->SetAvailable( part->GetDrawing()->GetLayerSetup() );
438  FillControls( m_startvalue );
439  }
440  else if ( event.GetId() == a2dHabitat::sig_changedLayer )
441  {
442  m_controlslayersetup->SetAvailable( part->GetDrawing()->GetLayerSetup() );
443  FillControls( m_startvalue );
444  }
445  else if ( event.GetId() == a2dDrawing::sig_layersetupChanged )
446  {
447  Init( part->GetDrawing()->GetLayerSetup() );
448  }
449  else if ( event.GetId() == a2dCanvasGlobal::sig_changedActiveDrawing )
450  {
452  if ( part && part->GetShowObject() && part->GetShowObject()->GetRoot() )
453  {
454  if ( m_layersetup != part->GetShowObject()->GetRoot()->GetLayerSetup() )
455  {
456  part->GetShowObject()->GetRoot()->SetAvailable();
457  part->GetDrawing()->DisconnectEvent( a2dEVT_COM_EVENT, this );
458  Init( part->GetShowObject()->GetRoot()->GetLayerSetup() );
459  part->GetDrawing()->ConnectEvent( a2dEVT_COM_EVENT, this );
460 
461  }
462  }
463  }
464  }
465 }
466 
467 void LayerPropertiesDialog::OnDoEvent( a2dCommandProcessorEvent& event )
468 {
469  if ( GetEvtHandlerEnabled() )
470  {
472  if ( !drawingPart )
473  return;
474 
475  a2dLayers* layers = drawingPart->GetDrawing()->GetLayerSetup();
476  if ( !layers )
477  return;
478  }
479 }
480 
481 void LayerPropertiesDialog::FillControls( int start )
482 {
483  wxColour kleurtje;
484  wxColour kleurtje2;
485 
486  int All_Hided = true;
487  int All_Read = true;
488  int All_Outline = true;
489 
490  int currentInsertLayer = m_habitat->GetLayer();
491 
492  for ( int i = start; i < start + 10; i++ )
493  {
494  wxString buf;
495  int x = i - m_startvalue;
496 
497  a2dLayerInfo* layerinfo = GetLocalLayerInfo( i );
498 
499  bool available = layerinfo->GetAvailable();
500 
501  buf.Printf( wxT( "%i" ), layerinfo->GetLayer() );
502  m_numberbox[x]->SetBackgroundColour( currentInsertLayer == i ? wxColour( 184, 232, 241 ) : wxColour( 255, 255, 255 ) );
503  m_numberbox[x]->SetForegroundColour( available ? wxColour( 255, 0, 0 ) : wxColour( 0, 0, 0 ) );
504  m_numberbox[x]->SetLabel( buf );
505 
506  m_namebox[x]->SetBackgroundColour( currentInsertLayer == i ? wxColour( 184, 232, 241 ) : wxColour( 255, 255, 255 ) );
507  m_namebox[x]->SetForegroundColour( available ? wxColour( 255, 0, 0 ) : wxColour( 0, 0, 0 ) );
508  m_namebox[x]->SetValue( layerinfo->GetName() );
509  m_namebox[x]->SetToolTip( layerinfo->GetFeature() );
510 
511  if ( layerinfo->GetVisible() )
512  All_Hided = false;
513 
514  m_visiblebox[x]->SetValue( layerinfo->GetVisible() ? true : false );
515  m_selectablebox[x]->SetValue( layerinfo->GetSelectable() ? true : false );
516 
517  if ( !layerinfo->GetFill().GetFilling() )
518  All_Outline = false;
519  m_outlinebox[x]->SetValue( !layerinfo->GetFill().GetFilling() ? true : false );
520 
521  if ( ! layerinfo->GetRead() )
522  m_readlayerbox[x]->SetValue( false );
523  else
524  {
525  All_Read = false;
526  m_readlayerbox[x]->SetValue( true );
527  }
528 
529  // fill of polygons rect
530  kleurtje = layerinfo->GetFillColour();
531  m_fillbut[x]->SetBackgroundColour( kleurtje );
532 
533  // stroke of polygons rect
534  kleurtje = layerinfo->GetStrokeColour();
535  m_borderbut[x]->SetBackgroundColour( kleurtje );
536 
537  {
538  //update the bitmap to show fill and stroke properties
539  int w = m_patternbut[x]->GetBitmapLabel().GetWidth();
540  int h = m_patternbut[x]->GetBitmapLabel().GetHeight();
541  a2dMemDcDrawer* drawer = new a2dMemDcDrawer( w, h );
542  drawer->BeginDraw();
543  drawer->SetDrawerFill( layerinfo->GetFill() );
544  drawer->SetDrawerStroke( layerinfo->GetStroke() );
545  drawer->DrawRoundedRectangle( 0, 0, w, h, 0 );
546  drawer->EndDraw();
547  m_patternbut[x]->SetBitmapLabel( drawer->GetBuffer() );
548  m_patternbut[x]->Refresh( true );
549  delete drawer;
550 
551  }
552 
553  buf.Printf( wxT( "%i" ), layerinfo->GetInMapping() );
554  m_gdsinmap[x]->SetValue( buf );
555 
556  buf.Printf( wxT( "%i" ), layerinfo->GetOutMapping() );
557  m_gdsoutmap[x]->SetValue( buf );
558 
559  m_fillbut[x]->Refresh();
560  m_borderbut[x]->Refresh();
561  m_patternbut[x]->Refresh();
562  }
563 
564  if ( All_Hided )
565  {
566  m_buttonVISIBLE->SetLabel( _T( "Show All" ) );
567  m_buttonSELECT->SetLabel( _T( "All Selectable" ) );
568  }
569 
570  if ( m_onorder )
571  m_buttonSORT->SetLabel( _T( "Sort Layer" ) );
572  else
573  m_buttonSORT->SetLabel( _T( "Sort Order" ) );
574 
575  if ( All_Outline )
576  m_buttonOutLine->SetLabel( _T( "Outline All" ) );
577  else
578  m_buttonOutLine->SetLabel( _T( "Outline Non" ) );
579 
580  if ( All_Read )
581  m_buttonREAD->SetLabel( _T( "Read All" ) );
582 
583  //will update dialog and all its (bitmap)buttons
584  Refresh( true );
585 }
586 
587 void LayerPropertiesDialog::StoreControls( unsigned int start, unsigned int nrLayers )
588 {
589  bool changed = false;
590 
591  SetEvtHandlerEnabled( false );
592 
593  //first take over control settings into the local layer setup
594  //via command activate the changed settings.
595  unsigned int i;
596  for ( i = start; i < start + nrLayers; i++ )
597  {
598  int x = i - m_startvalue;
599 
600  a2dLayerInfo* layerinfo = GetLocalLayerInfo( i );
601 
602  layerinfo->SetName( m_namebox[x]->GetValue() );
603  layerinfo->SetVisible( ( bool )m_visiblebox[x]->GetValue() );
604  layerinfo->SetSelectable( ( bool )m_selectablebox[x]->GetValue() );
605  layerinfo->SetRead( ( bool )( m_readlayerbox[x]->GetValue() ) );
606  layerinfo->SetStrokeColour( m_borderbut[x]->GetBackgroundColour() );
607  layerinfo->SetFillColour( m_fillbut[x]->GetBackgroundColour() );
608 
609  // if pattern is not full or non, use pattern fill
610  if ( m_patterns[x] != 0 && m_patterns[x] != 1 )
611  {
612  a2dFill pfill = layerinfo->GetFill();
613  pfill.SetStipple( *( m_fillpatterns->GetPattern( m_patterns[x] ) ) );
614  pfill.SetColour( m_fillbut[x]->GetBackgroundColour() );
615  pfill.SetColour2( m_fillbut[x]->GetBackgroundColour() );
616  }
617  else
618  {
619  a2dFill fill = a2dFill( m_fillbut[x]->GetBackgroundColour() );
620  layerinfo->SetFill( fill );
621  }
622 
623  long t;
624  m_gdsinmap[x]->GetValue().ToLong( &t );
625  layerinfo->SetInMapping( t );
626  m_gdsoutmap[x]->GetValue().ToLong( &t );
627  layerinfo->SetOutMapping( t );
628 
629 
630  a2dLayerInfo* layerinfodoc = GetDocLayerInfo( i );
631 
632  //better give layer as part of command to keep insertion layer the same.
633  if ( layerinfo->GetName() != layerinfodoc->GetName() )
634  {
635  changed = true;
636  layerinfodoc->SetName( layerinfo->GetName() );
637  }
638 
639  if ( layerinfo->GetVisible() != layerinfodoc->GetVisible() )
640  {
641  changed = true;
642  layerinfodoc->SetVisible( layerinfo->GetVisible() );
643  }
644 
645  if ( layerinfo->GetSelectable() != layerinfodoc->GetSelectable() )
646  {
647  changed = true;
648  layerinfodoc->SetSelectable( layerinfo->GetSelectable() );
649  }
650 
651  if ( layerinfo->GetRead() != layerinfodoc->GetRead() )
652  {
653  changed = true;
654  layerinfodoc->SetRead( layerinfo->GetRead() );
655  }
656 
657  if ( layerinfo->GetStroke().GetColour() != layerinfodoc->GetStroke().GetColour() )
658  {
659  changed = true;
660  layerinfodoc->SetStrokeColour( layerinfo->GetStroke().GetColour() );
661  }
662  if ( layerinfo->GetFill().GetColour() != layerinfodoc->GetFill().GetColour() )
663  {
664  changed = true;
665  layerinfodoc->SetFillColour( layerinfo->GetFill().GetColour() );
666  }
667 
668  if ( &layerinfo->GetFill().GetStipple() != &layerinfodoc->GetFill().GetStipple() )
669  {
670  changed = true;
671  layerinfodoc->SetFill( layerinfo->GetFill() );
672  }
673 
674  if ( layerinfo->GetInMapping() != layerinfodoc->GetInMapping() )
675  {
676  changed = true;
677  layerinfodoc->SetInMapping( layerinfo->GetInMapping() );
678  }
679 
680  if ( layerinfo->GetOutMapping() != layerinfodoc->GetOutMapping() )
681  {
682  changed = true;
683  layerinfodoc->SetOutMapping( layerinfo->GetOutMapping() );
684  }
685  }
686 
687 
688  if ( changed )
689  {
690  a2dComEvent changedlayer( m_layersetup->GetRoot(), m_layersetup, a2dDrawing::sig_layersetupChanged );
691  ProcessEvent( changedlayer );
692  }
693 
694  SetEvtHandlerEnabled( true );
695 }
696 
697 void LayerPropertiesDialog::CmHide( wxCommandEvent& )
698 {
699  Show( false );
700 
702  if ( !drawingPart )
703  return;
704 
705  a2dLayers* layers = drawingPart->GetDrawing()->GetLayerSetup();
706  if ( !layers )
707  return;
708  layers->SetPending( true );
709 }
710 
711 void LayerPropertiesDialog::CmCancel( wxCommandEvent& event )
712 {
713  m_layersetup = wxStaticCast( m_backuplayersetup->Clone( a2dObject::clone_deep ) , a2dLayers );
714  m_controlslayersetup = wxStaticCast( m_backuplayersetup->Clone( a2dObject::clone_deep ) , a2dLayers );
715 
716  FillControls( m_startvalue );
717  StoreControls( m_startvalue, m_startvalue + 10 );
718 
719  CmHide( event );
720 }
721 
722 void LayerPropertiesDialog::CmRestore( wxCommandEvent& WXUNUSED( event ) )
723 {
724  m_layersetup = wxStaticCast( m_backuplayersetup->Clone( a2dObject::clone_deep ) , a2dLayers );
725  m_controlslayersetup = wxStaticCast( m_backuplayersetup->Clone( a2dObject::clone_deep ) , a2dLayers );
726 
727  FillControls( m_startvalue );
728 
730  if ( !drawingPart )
731  return;
732 
733  a2dLayers* layers = drawingPart->GetDrawing()->GetLayerSetup();
734  if ( !layers )
735  return;
736 
737  SetEvtHandlerEnabled( false ); //prevent OnComEvent on this one.
738  drawingPart->GetDrawing()->SetLayerSetup( m_layersetup );
739  SetEvtHandlerEnabled( true );
740 }
741 
742 void LayerPropertiesDialog::CmSaveToFile( wxCommandEvent& WXUNUSED( event ) )
743 {
744  wxString fullname = _( "Mywxart2dlayers.cvg" );
745 
746  wxString* layerfiledir = a2dGeneralGlobals->GetVariablesHash().GetVariableString( wxT( "lastLayerFileSavePath" ) );
747 
748  if ( !layerfiledir )
749  layerfiledir = a2dGeneralGlobals->GetVariablesHash().GetVariableString( wxT( "layerFileSavePath" ) );
750 
751  wxFileDialog fileDialog( this,
752  _( "Choose layer file to load" ),
753  layerfiledir ? *layerfiledir : wxT( "" ),
754  fullname,
755  wxT( "*.cvg" ),
756  wxFD_SAVE | wxFD_OVERWRITE_PROMPT
757  );
758 
759  if ( fileDialog.ShowModal() != wxID_OK )
760  return;
761 
762  fullname = fileDialog.GetPath();
763 
764  a2dGeneralGlobals->GetVariablesHash().SetVariableString( wxT( "lastLayerFileSavePath" ), wxPathOnly( fullname ) );
765 
766  SetEvtHandlerEnabled( false ); //prevent OnComEvent on this one.
767 
768  SetCursor( wxCURSOR_WAIT );
769  m_layersetup->SaveLayers( fullname );
770 
771  SetEvtHandlerEnabled( true );
772  SetCursor( wxCURSOR_ARROW );
773 }
774 
775 void LayerPropertiesDialog::CmLoadFromFile( wxCommandEvent& WXUNUSED( event ) )
776 {
777  wxString fullname;
778 
779  wxString* path = a2dGeneralGlobals->GetVariablesHash().GetVariableString( wxT( "lastLayerFileSavePath" ) );
780 
781  wxFileDialog fileDialog( this,
782  _( "Choose layer file to load" ),
783  path ? *path : wxT( "" ),
784  fullname,
785  wxT( "*.cvg" ),
786  wxFD_OPEN | wxFD_FILE_MUST_EXIST
787  );
788 
789  if ( fileDialog.ShowModal() != wxID_OK )
790  return;
791 
792  fullname = fileDialog.GetPath();
793 
794  a2dGeneralGlobals->GetVariablesHash().SetVariableString( wxT( "lastLayerFileSavePath" ), wxPathOnly( fullname ) );
795 
796  SetCursor( wxCURSOR_WAIT );
797 #if wxART2D_USE_CVGIO
798 
799  a2dLayers* layersetup = new a2dLayers();
800  layersetup->LoadLayers( fullname );
801 
803  if ( !drawingPart )
804  return;
805 
806  a2dLayers* layers = drawingPart->GetDrawing()->GetLayerSetup();
807  if ( !layers )
808  return;
809  drawingPart->GetDrawing()->SetLayerSetup( layersetup );
810 #else
811  wxFAIL_MSG( wxT( "wxART2D_USE_CVGIO is needed to load object from a file CVG file" ) );
812 #endif //wxART2D_USE_CVGIO
813 
814 
815  SetEvtHandlerEnabled( false ); //prevent OnComEvent on this one.
816  Init( layersetup );
817  SetEvtHandlerEnabled( true ); //prevent OnComEvent on this one.
818  FillControls( m_startvalue );
819  SetCursor( wxCURSOR_ARROW );
820 }
821 
822 
823 void LayerPropertiesDialog::OnCloseWindow( wxCloseEvent& WXUNUSED( event ) )
824 {
825  Show( false );
826 
828  if ( !drawingPart )
829  return;
830 
831  if ( drawingPart->GetDrawing()->GetLayerSetup() )
832  drawingPart->GetDrawing()->GetLayerSetup()->SetPending( true );
833 }
834 
835 void LayerPropertiesDialog::CmSort( wxCommandEvent& )
836 {
837  wxString buf;
838  buf = m_buttonSORT->GetLabel();
839  if ( buf == wxT( "Sort Layer" ) )
840  m_onorder = false;
841  else
842  m_onorder = true;
843 
844  FillControls( m_startvalue );
845 }
846 
847 void LayerPropertiesDialog::CmVisible( wxCommandEvent& )
848 {
849  wxString buf;
850  bool onoff = false;
851  buf = m_buttonVISIBLE->GetLabel();
852  if ( buf == wxT( "Hide All" ) )
853  {
854  onoff = false;
855  m_buttonVISIBLE->SetLabel( wxT( "Show All" ) );
856  }
857  else
858  {
859  onoff = true;
860  m_buttonVISIBLE->SetLabel( wxT( "Hide All" ) );
861  }
862 
863  m_controlslayersetup->SetAll_Layers_Visible( onoff );
864 
865  m_layersetup->SetAll_Layers_Visible( onoff );
866  FillControls( m_startvalue );
867 }
868 
869 void LayerPropertiesDialog::CmRead( wxCommandEvent& )
870 {
871  wxString buf;
872  bool onoff = false;
873  buf = m_buttonREAD->GetLabel();
874  if ( buf == wxT( "Read Non" ) )
875  {
876  onoff = false;
877  m_buttonREAD->SetLabel( _T( "Read All" ) );
878  }
879  else
880  {
881  onoff = true;
882  m_buttonREAD->SetLabel( wxT( "Read Non" ) );
883  }
884 
885  m_controlslayersetup->SetAll_Layers_Read( onoff );
886  m_layersetup->SetAll_Layers_Read( onoff );
887 
888  FillControls( m_startvalue );
889 }
890 
891 void LayerPropertiesDialog::CmOutLine( wxCommandEvent& )
892 {
893  wxString buf;
894  bool onoff = false;
895  buf = m_buttonOutLine->GetLabel();
896  if ( buf == wxT( "Outline Non" ) )
897  {
898  onoff = false;
899  m_buttonOutLine->SetLabel( _T( "Outline All" ) );
900  }
901  else
902  {
903  onoff = true;
904  m_buttonOutLine->SetLabel( wxT( "Outline Non" ) );
905  }
906 
907  m_controlslayersetup->SetAll_Layers_Outline( onoff );
908  m_layersetup->SetAll_Layers_Outline( onoff );
909 
910  FillControls( m_startvalue );
911 }
912 
913 void LayerPropertiesDialog::CmSelect( wxCommandEvent& )
914 {
915  wxString buf;
916  bool onoff = false;
917  buf = m_buttonSELECT->GetLabel();
918  if ( buf == wxT( "All Selectable" ) )
919  {
920  onoff = true;
921  m_buttonSELECT->SetLabel( _T( "None Selectable" ) );
922  }
923  else
924  {
925  onoff = false;
926  m_buttonSELECT->SetLabel( _T( "All Selectable" ) );
927  }
928 
929  m_controlslayersetup->SetAll_Layers_Selectable( onoff );
930  m_layersetup->SetAll_Layers_Selectable( onoff );
931 
932  FillControls( m_startvalue );
933 }
934 
935 void LayerPropertiesDialog::CmPrev( wxCommandEvent& )
936 {
937  m_buttonNEXT->Enable();
938  if ( m_startvalue - 10 >= 0 )
939  {
940  m_startvalue -= 10;
941  FillControls( m_startvalue );
942  }
943 
944  if ( m_startvalue <= 0 )
945  m_buttonPREV->Disable();
946  SetFocus();
947  Show( true );
948  Refresh();
949 }
950 
951 void LayerPropertiesDialog::CmNext( wxCommandEvent& )
952 {
953  m_buttonPREV->Enable();
954  if ( m_startvalue + 10 < wxMAXLAYER )
955  {
956  m_startvalue += 10;
957  FillControls( m_startvalue );
958  }
959 
960  if ( m_startvalue + 10 >= wxMAXLAYER - 1 )
961  m_buttonNEXT->Disable();
962  SetFocus();
963  Show( true );
964  Refresh();
965 }
966 
967 void LayerPropertiesDialog::Cm_F_BitB( wxEvent& event )
968 {
969  if ( m_cd->ShowModal() == wxID_OK )
970  {
971  wxColour col;
972  *m_cdata = m_cd->GetColourData();
973  col = m_cdata->GetColour();
974  int x = event.GetId() - ID_LAYERFILLCOLOR;
975  int i = x + m_startvalue;
976 
977  a2dLayerInfo* layerinfo = GetLocalLayerInfo( i );
978  a2dLayerInfo* layerinfodoc = GetDocLayerInfo( i );
979 
980  layerinfo->SetFillColour( col );
981 
982  if ( col != layerinfodoc->GetFill().GetColour() )
983  {
984  layerinfodoc->SetFillColour( col );
985  layerinfodoc->SignalChange();
986  }
987  FillControls( m_startvalue );
988  }
989  SetFocus();
990  Show( true );
991  Refresh( true );
992 }
993 
994 void LayerPropertiesDialog::Cm_B_BitB( wxEvent& event )
995 {
996  if ( m_cd->ShowModal() == wxID_OK )
997  {
998  wxColour col;
999  *m_cdata = m_cd->GetColourData();
1000  col = m_cdata->GetColour();
1001 
1002  int x = event.GetId() - ID_LAYERSTROKECOLOR;
1003  int i = x + m_startvalue;
1004 
1005  a2dLayerInfo* layerinfo = GetLocalLayerInfo( i );
1006  a2dLayerInfo* layerinfodoc = GetDocLayerInfo( i );
1007  layerinfo->SetStrokeColour( col );
1008  if ( col != layerinfodoc->GetStroke().GetColour() )
1009  {
1010  layerinfodoc->SetStrokeColour( col );
1011  layerinfodoc->SignalChange();
1012  }
1013  FillControls( m_startvalue );
1014  }
1015  SetFocus();
1016  Show( true );
1017  Refresh();
1018 }
1019 
1020 void LayerPropertiesDialog::Cm_P_BitB( wxEvent& event )
1021 {
1022  //the button pressed given indirect the layer
1023  int x = event.GetId() - ID_LAYERPATTERN;
1024  int i = x + m_startvalue;
1025 
1026  PatternDialog patternDialog( this, m_fillpatterns, wxT( "Patterns" ), ( wxSYSTEM_MENU | wxCAPTION ) );
1027  int choosen = patternDialog.ShowModal();
1028  patternDialog.Close();
1029 
1030  wxBitmap pat = *( m_fillpatterns->GetPattern( choosen ) );
1031 
1032  a2dLayerInfo* layerinfo = GetLocalLayerInfo( i );
1033  a2dLayerInfo* layerinfodoc = GetDocLayerInfo( i );
1034 
1035  // if pattern is not full or non, use pattern fill
1036  if ( choosen != 0 && choosen != 1 )
1037  {
1038  a2dFillStyle style = layerinfo->GetFill().GetStyle();
1039  a2dFill pfill = a2dFill( pat );
1040 
1041  if ( style != a2dFILL_STIPPLE_MASK_OPAQUE &&
1043  style != a2dFILL_STIPPLE )
1044  //the default is transparent
1045  pfill.SetStyle( a2dFILL_STIPPLE_MASK_OPAQUE_TRANSPARENT );
1046  else if ( style == a2dFILL_STIPPLE )
1047  pfill.SetStyle( a2dFILL_STIPPLE_MASK_OPAQUE_TRANSPARENT );
1048  else
1049  pfill.SetStyle( style );
1050  pfill.SetColour( layerinfo->GetFill().GetColour() );
1051  pfill.SetColour2( layerinfo->GetFill().GetColour2() );
1052  layerinfo->SetFill( pfill );
1053  }
1054  else
1055  {
1056  if ( choosen == 0 )
1057  {
1058  a2dFill fill = a2dFill( layerinfo->GetFill().GetColour(), a2dFILL_TRANSPARENT );
1059  layerinfo->SetFill( fill );
1060  }
1061  else
1062  {
1063  a2dFill fill = a2dFill( layerinfo->GetFill().GetColour(), a2dFILL_SOLID );
1064  layerinfo->SetFill( fill );
1065  }
1066  }
1067 
1068  layerinfodoc->SetFill( layerinfo->GetFill() );
1069  layerinfodoc->SignalChange();
1070  FillControls( m_startvalue );
1071 
1072  SetFocus();
1073  Show( true );
1074  Refresh();
1075 }
1076 
1077 void LayerPropertiesDialog::Cm_LayerName( wxEvent& event )
1078 {
1079  int x = event.GetId() - ID_LAYERNAME;
1080  int i = x + m_startvalue;
1081  a2dLayerInfo* layerinfo = GetLocalLayerInfo( i );
1082  a2dLayerInfo* layerinfodoc = GetDocLayerInfo( i );
1083  layerinfo->SetName( m_namebox[x]->GetValue() );
1084  layerinfodoc->SetName( m_namebox[x]->GetValue() );
1085  layerinfodoc->SignalChange();
1086 }
1087 
1088 void LayerPropertiesDialog::Cm_InMap( wxEvent& event )
1089 {
1090  int x = event.GetId() - ID_INMAP;
1091  int i = x + m_startvalue;
1092  a2dLayerInfo* layerinfo = GetLocalLayerInfo( i );
1093  a2dLayerInfo* layerinfodoc = GetDocLayerInfo( i );
1094  long t;
1095  m_gdsinmap[x]->GetValue().ToLong( &t );
1096  layerinfo->SetInMapping( t );
1097  layerinfodoc->SetInMapping( t );
1098  layerinfodoc->SignalChange();
1099 }
1100 
1101 void LayerPropertiesDialog::Cm_OutMap( wxEvent& event )
1102 {
1103  int x = event.GetId() - ID_OUTMAP;
1104  int i = x + m_startvalue;
1105  long t;
1106  m_gdsoutmap[x]->GetValue().ToLong( &t );
1107  a2dLayerInfo* layerinfo = GetLocalLayerInfo( i );
1108  a2dLayerInfo* layerinfodoc = GetDocLayerInfo( i );
1109  layerinfo->SetOutMapping( t );
1110  layerinfodoc->SetOutMapping( t );
1111  layerinfodoc->SignalChange();
1112 }
1113 
1114 void LayerPropertiesDialog::Cm_NumberBox( wxEvent& event )
1115 {
1116  //the button pressed given indirect the layer
1117  int dlayer = event.GetId() - ID_NUMBER; //which button
1118 
1119  int currentInsertLayer = m_habitat->GetLayer();
1120 
1121  if ( currentInsertLayer != m_startvalue + dlayer )
1122  {
1123  int oldinstlayer = currentInsertLayer-m_startvalue;
1124  m_numberbox[ oldinstlayer ]->SetBackgroundColour( *wxWHITE );
1125  m_namebox[ oldinstlayer ]->SetBackgroundColour( *wxWHITE );
1126  m_numberbox[ oldinstlayer ]->Refresh();
1127  m_namebox[ oldinstlayer ]->Refresh();
1128 
1129  m_habitat->SetLayer( m_startvalue + dlayer, true );
1130 
1131  m_numberbox[ dlayer ]->SetBackgroundColour( wxColour( 184, 232, 241 ) );
1132  m_namebox[ dlayer ]->SetBackgroundColour( wxColour( 184, 232, 241 ) );
1133  m_numberbox[ dlayer ]->Refresh();
1134  m_namebox[ dlayer ]->Refresh();
1135  }
1136 }
1137 
1138 void LayerPropertiesDialog::Cm_VisibleBox( wxEvent& event )
1139 {
1140  int x = event.GetId() - ID_VISIBLE; //which button
1141  int i = x + m_startvalue;
1142 
1143  a2dLayerInfo* layerinfo = GetLocalLayerInfo( i );
1144  layerinfo->SetVisible( ( bool )m_visiblebox[ x ]->GetValue() );
1145 
1147  if ( !drawingPart )
1148  return;
1149 
1150  a2dLayers* layers = drawingPart->GetDrawing()->GetLayerSetup();
1151  if ( !layers )
1152  return;
1153  a2dLayerInfo* layerinfodoc = layers->GetLayerIndex()[ i ];
1154 
1155  layers->SetVisible( i, layerinfo->GetVisible() );
1156  drawingPart->Update();
1157  layerinfodoc->SetVisible( layerinfo->GetVisible() );
1158  layerinfodoc->SignalChange();
1159 }
1160 
1161 void LayerPropertiesDialog::Cm_OutLineBox( wxEvent& event )
1162 {
1163  //the button pressed given indirect the layer
1164  int x = event.GetId() - ID_OUTLINE; //which button
1165  int i = m_startvalue + x;
1166 
1167  a2dLayerInfo* layerinfo = GetDocLayerInfo( i );
1168  a2dFill fill = layerinfo->GetFill();
1169  fill.SetFilling( ! ( bool )m_outlinebox[ x ]->GetValue() );
1170  layerinfo->SetFill( fill );
1171 
1173  if ( !drawingPart )
1174  return;
1175 
1176  a2dLayers* layers = drawingPart->GetDrawing()->GetLayerSetup();
1177  if ( !layers )
1178  return;
1179  a2dLayerInfo* layerinfodoc = layers->GetLayerIndex()[ i ];
1180 
1181  layerinfodoc->SetFill( fill );
1182  //layerinfodoc->SetFilling( fill.GetFilling() );
1183  layerinfodoc->SignalChange();
1184 }
1185 
1186 void LayerPropertiesDialog::Cm_SelectBox( wxEvent& event )
1187 {
1188  //the button pressed given indirect the layer
1189  int x = event.GetId() - ID_SELECTABLE; //which button
1190  int i = m_startvalue + x;
1191 
1192  a2dLayerInfo* layerinfo = GetDocLayerInfo( i );
1193  layerinfo->SetSelectable( ( bool )m_selectablebox[ x ]->GetValue() );
1194 
1196  if ( !drawingPart )
1197  return;
1198 
1199  a2dLayers* layers = drawingPart->GetDrawing()->GetLayerSetup();
1200  if ( !layers )
1201  return;
1202  a2dLayerInfo* layerinfodoc = layers->GetLayerIndex()[ i ];
1203  layerinfodoc->SetSelectable( layerinfo->GetSelectable() );
1204  layerinfodoc->SignalChange();
1205 }
1206 
1207 void LayerPropertiesDialog::Cm_ReadBox( wxEvent& event )
1208 {
1209  //the button pressed given indirect the layer
1210  int x = event.GetId() - ID_READ; //which button
1211  int i = m_startvalue + x;
1212 
1213  a2dLayerInfo* layerinfo = GetDocLayerInfo( i );
1214  layerinfo->SetRead( ( bool )m_readlayerbox[ x ]->GetValue() );
1215 
1217  if ( !drawingPart )
1218  return;
1219 
1220  a2dLayers* layers = drawingPart->GetDrawing()->GetLayerSetup();
1221  if ( !layers )
1222  return;
1223  a2dLayerInfo* layerinfodoc = layers->GetLayerIndex()[ i ];
1224  layerinfodoc->SetRead( layerinfo->GetRead() );
1225  layerinfodoc->SignalChange();
1226 }
1227 
1228 void LayerPropertiesDialog::OnChar( wxKeyEvent& event )
1229 {
1230  if ( event.GetKeyCode() == WXK_RETURN )
1231  {
1232  }
1233  else if ( event.GetKeyCode() == WXK_PAGEDOWN )
1234  {
1235  wxCommandEvent eventc;
1236  CmNext( eventc );
1237  }
1238  else if ( event.GetKeyCode() == WXK_PAGEUP )
1239  {
1240  wxCommandEvent eventc;
1241  CmPrev( eventc );
1242  }
1243  else
1244  {
1245  // key code is within legal range. we call event.Skip() so the
1246  // event can be processed either in the base wxWindows class
1247  // or the native control.
1248 
1249  event.Skip();
1250  }
1251 }
1252 
1253 void LayerPropertiesDialog::OnCharHook( wxKeyEvent& event )
1254 {
1255  if ( event.GetKeyCode() == WXK_RETURN )
1256  {
1257  event.Skip();
1258  }
1259  else if ( event.GetKeyCode() == WXK_PAGEDOWN )
1260  {
1261  wxCommandEvent eventc;
1262  CmNext( eventc );
1263  }
1264  else if ( event.GetKeyCode() == WXK_PAGEUP )
1265  {
1266  wxCommandEvent eventc;
1267  CmPrev( eventc );
1268  }
1269  else
1270  {
1271  // key code is within legal range. we call event.Skip() so the
1272  // event can be processed either in the base wxWindows class
1273  // or the native control.
1274 
1275  event.Skip();
1276  }
1277 }
1278 
1279 
Display Part of a a2dDrawing, in which a2dCanvasObjects are shown.
Definition: drawer.h:470
(In) Visible property that can be added to Docview Objects.
Definition: gen.h:1785
#define wxDynamicCast(obj, className)
Define wxDynamicCast so that it will give a compiler error for unrelated types.
Definition: gen.h:75
Base class for all types of strokes, understood by a2dDrawer2D classes.
Definition: stylebase.h:378
wxUint16 GetLayer() const
layer set for new objects.
Definition: canglob.h:930
static const a2dSignal sm_changedProperty
Definition: gen.h:381
void SetSelectable(bool status)
set layer selectable
Definition: layerinf.cpp:366
a2dSmrtPtr< a2dLayers > m_controlslayersetup
changed local setup which is shown in dialog and compared with the controlled external setup ...
Definition: layerdlg.h:87
void SetLayer(wxUint16 layer, bool setStyleOfLayer=false)
Definition: canglob.cpp:1076
const wxString & GetFeature() const
this layer is part of a group of layers to present a feature ( metalized via etc. )...
Definition: layerinf.h:136
wxColour GetColour2() const
return colour 2
Definition: stylebase.cpp:4969
choose a fill pattern
Definition: strucdlg.h:299
void CmLoadFromFile(wxCommandEvent &event)
load layers settings in dialog from file
Definition: layerdlg.cpp:775
bool GetAvailable()
are there objects on this layer
Definition: layerinf.h:108
dialog for defining style on an a2dCanvasObject
void SignalChange()
sent a sig_changedLayerInfo to a2dDrawing
Definition: layerinf.cpp:437
Ref Counted base object.
Definition: gen.h:1045
a2dDrawing * GetRoot() const
get a2dCanvasDocument of the object.
Definition: canobj.h:952
#define EVT_DO(func)
event sent from a2DocumentCommandProcessor when a command is initially done
Definition: comevt.h:795
a2dObject * Clone(CloneOptions options, a2dRefMap *refs=NULL) const
create an exact copy of this property
Definition: gen.cpp:1199
void ConnectEvent(wxEventType type, wxEvtHandler *eventSink)
Definition: gen.cpp:876
virtual void SetName(const wxString &name)
Set name for layer.
Definition: layerinf.cpp:253
void SetDrawerStroke(const a2dStroke &stroke)
Used to set the current stroke.
Definition: drawer2d.cpp:565
wxColour GetStrokeColour() const
get first colour of stroke
Definition: canobj.cpp:2952
void Update(unsigned int how=(a2dCANVIEW_UPDATE_ALL|a2dCANVIEW_UPDATE_BLIT), wxObject *hintObject=NULL)
see OnUpdate
Definition: drawer.cpp:1744
This class implements drawing functions for wxDC based drawing.
Definition: dcdrawer.h:203
void StoreControls(unsigned int start, unsigned int nrLayers=10)
get the values from the controls and store them
Definition: layerdlg.cpp:587
void CmSort(wxCommandEvent &)
sort order
Definition: layerdlg.cpp:835
wxColour GetColour() const
return colour 1
Definition: stylebase.cpp:6131
std::vector< a2dLayerInfoPtr > & GetLayerIndex()
return array index on Layer
Definition: layerinf.cpp:555
wxBitmap GetBuffer() const
return buffer as a bitmap
Definition: dcdrawer.h:220
a2dLayers * GetLayerSetup()
Get the layersettings for the canvas.
Definition: drawing.h:506
bool GetVisible()
is the layer visible
Definition: layerinf.cpp:341
static const a2dSignal sig_layersetupChanged
layer info changed id sent around when m_layersetup is changed.
Definition: drawing.h:771
a2dDrawingPart * GetActiveDrawingPart()
return the currently/last active drawing part.
Definition: canglob.h:1262
int GetOutMapping()
mapping of internal layer index to external layer index
Definition: layerinf.cpp:386
void SetDrawerFill(const a2dFill &fill)
Used to set the current fill.
Definition: drawer2d.cpp:621
a2dFillStyle
Filling styles for a2dFill.
Definition: stylebase.h:91
static const a2dSignal sig_changedLayer
when an object is removed from a layer,
Definition: drawing.h:774
layer dialog for changing layer settings.
void SetVisible(bool status)
set layer visible
Definition: layerinf.cpp:361
void SetRead(bool status)
read this layer from input files
Definition: layerinf.cpp:376
bool GetSelectable()
can objects on this layer be selected
Definition: layerinf.cpp:346
virtual wxString GetName() const
Get name for layer.
Definition: layerinf.cpp:248
int GetInMapping()
mapping of external file layer to internal layer index
Definition: layerinf.cpp:381
static const a2dSignal sig_changedActiveDrawing
when active drawing is set, this signal is send to the drawing.
Definition: canglob.h:1292
#define EVT_COM_EVENT(func)
static wxEvtHandler for communication event
Definition: gen.h:564
#define wxStaticCast(obj, className)
The wxWindows 2.4.2 wxStaticCast is buggy. It evaluates its argument twice.
Definition: gen.h:123
wxColour GetFillColour() const
get first colour of fill
Definition: canobj.cpp:2902
void SetStrokeColour(const wxColour &colour)
set first colour of stroke
Definition: canobj.cpp:2963
void SetPending(bool pending)
next to base sets m_indexed false
Definition: layerinf.cpp:545
a2dCanvasObject * GetShowObject() const
return pointer of then currently shown object on the drawer.
Definition: drawer.h:680
void CmSaveToFile(wxCommandEvent &event)
save layers settings in dialog to file
Definition: layerdlg.cpp:742
A2DGENERALDLLEXP a2dSmrtPtr< a2dGeneralGlobal > a2dGeneralGlobals
a global pointer to get to global instance of important classes.
Definition: comevt.cpp:1148
wxUint16 GetLayer() const
Returns the layer index where this object is drawn upon.
Definition: canobj.h:2368
void SetColour(const wxColour &col)
set colour used for gradient and wxSTIPPLE_MASK_OPAQUE filling.
Definition: stylebase.cpp:4988
contains the layer properties for one layer,
Definition: layerinf.h:41
void SetInMapping(wxUint16 layer)
read this layer from the given layer in input files
Definition: layerinf.cpp:391
defines common settinsg for a habitat for a set of a2dCameleons.
Definition: canglob.h:439
void SetFillColour(const wxColour &colour)
set first colour of fill
Definition: canobj.cpp:2917
bool LoadLayers(const wxString &filename)
save layers to a file
Definition: layerinf.cpp:576
Dialog for displaying/editing layers and properties of layers.
Definition: layerdlg.h:30
bool GetFilling() const
if true, filling is on else filling is transparent.
Definition: stylebase.cpp:5069
static const a2dSignal sig_changedLayers
when more layers changed ( rerendering view is needed).
Definition: drawer.h:1505
virtual void BeginDraw()
start to draw on this context (used to initialize a specific drawer)
Definition: dcdrawer.cpp:2438
void SetStroke(const wxColour &strokecolor, double width=0, a2dStrokeStyle style=a2dSTROKE_SOLID)
Set a stroke for the object which will be used instead of the layer stroke.
Definition: canobj.cpp:2924
void SetOutMapping(wxUint16 layer)
write this layer from the given layer to output files
Definition: layerinf.cpp:395
property to hold a a2dStroke type variable to be associated with a a2dObject
Definition: styleprop.h:98
wxColour GetColour() const
return colour
Definition: stylebase.cpp:5012
Event sent to a2dCommandProcessor.
Definition: comevt.h:701
see a2dComEvent
Definition: gen.h:371
std::vector< a2dLayerInfoPtr > & GetOrderIndex()
return array index on Order
Definition: layerinf.cpp:562
void SetLayerSetup(a2dLayers *layersetup)
set the layersettings for the canvas.
Definition: drawing.cpp:280
void DrawRoundedRectangle(double x, double y, double width, double height, double radius, bool pixelsize=false)
Draw RoundedRectangle in world coordinates.
Definition: dcdrawer.cpp:1730
a2dDrawing * GetDrawing() const
get drawing via top object
Definition: drawer.cpp:726
void SetFilling(bool OnOff)
Definition: stylebase.cpp:5060
int m_patterns[10]
the choosen pattern.
Definition: layerdlg.h:239
a2dCanvasGlobal * a2dCanvasGlobals
global a2dCanvasGlobal to have easy access to global settings
Definition: canglob.cpp:1234
all headers of the canvas module
virtual void SetLayer(wxUint16 layer)
set layer index where this object is drawn upon.
Definition: canobj.cpp:5920
property to hold a a2dFill type variable to be associated with a a2dObject
Definition: styleprop.h:44
void SetColour2(const wxColour &col)
set colour 2 used for gradient and wxSTIPPLE_MASK_OPAQUE filling.
Definition: stylebase.cpp:4949
bool DisconnectEvent(wxEventType type, wxEvtHandler *eventSink)
Definition: gen.cpp:902
void SetFill(const a2dFill &fill)
Set a fill for the object which will be used instead of the layer fill.
Definition: canobj.cpp:2874
virtual void EndDraw()
end drawing on this context (used to reset a specific drawer)
Definition: dcdrawer.cpp:2475
bool GetRead()
does this layer need to be read in from a file.
Definition: layerinf.cpp:356
layerdlg.cpp Source File -- Sun Oct 12 2014 17:04:21 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation