Geoinformatica  0.90
Properties.pm
Go to the documentation of this file.
1 package Geo::Vector::Layer::Dialogs::Properties;
2 # @brief
3 
4 use strict;
5 use warnings;
6 use Carp;
7 use Glib qw/TRUE FALSE/;
8 use Geo::Vector;
11 
12 ## @ignore
13 sub open {
14  my($self, $gui) = @_;
15 
16  # bootstrap:
17  my($dialog, $boot) = $self->bootstrap_dialog
18  ($gui, 'properties_dialog', "Properties of ".$self->name,
19  {
20  properties_dialog => [delete_event => \&cancel_properties, [$self, $gui]],
21  properties_dialog => [delete_event => \&cancel_properties, [$self, $gui]],
22  properties_apply_button => [clicked => \&apply_properties, [$self, $gui, 0]],
23  properties_cancel_button => [clicked => \&cancel_properties, [$self, $gui]],
24  properties_ok_button => [clicked => \&apply_properties, [$self, $gui, 1]],
25  });
26 
27  if ($boot) {
29  $dialog->get_widget('properties_render_as_combobox') );
30  }
31  $dialog->get_widget('properties_dialog')->set_title("Properties of ".$self->name);
32 
33  $self->{backup}->{name} = $self->name;
34  $self->{backup}->{render_as} = $self->render_as;
35  $self->{backup}->{alpha} = $self->alpha;
36 
37  $dialog->get_widget('properties_geometry_type_label')
38  ->set_text($self->geometry_type or 'unknown type');
39 
40  my $a = $self->render_as;
41  $a = defined $a ? $Geo::Vector::RENDER_AS{$a} : 0;
42  $dialog->get_widget('properties_render_as_combobox')->set_active($a);
43 
44  my $count = $self->feature_count;
45  $dialog->get_widget('properties_feature_count_label')->set_text($count);
46 
47  my $ds = $self->data_source;
48  if ($ds =~ /https?:\/\/\w+:.+?\@/) { # remove authentication
49  $ds =~ s/(https?:\/\/)\w+:.+?\@/$1/;
50  }
51  my $driver = $self->driver;
52  $dialog->get_widget('properties_driver_label')->set_text($driver ? $driver : 'unknown');
53  $dialog->get_widget('properties_data_source_label')->set_text(Glib->filename_to_unicode($ds));
54  $dialog->get_widget('properties_SQL_label')->set_text($self->{SQL});
55 
56  $dialog->get_widget('properties_name_entry')->set_text($self->name);
57  $dialog->get_widget('properties_transparency_spinbutton')->set_value($self->alpha);
58 
59  my $t = $dialog->get_widget('properties_schema_treeview');
60  Geo::Vector::Layer::Dialogs::New::schema_to_treeview(undef, $t, 0, $self->schema);
61 
62 }
63 
64 ##@ignore
65 sub apply_properties {
66  my($self, $gui, $close) = @{$_[1]};
67  my $dialog = $self->{properties_dialog};
68  my $alpha = $dialog->get_widget('properties_transparency_spinbutton')->get_value_as_int;
69  $self->alpha($alpha);
70  my $name = $dialog->get_widget('properties_name_entry')->get_text;
71  $self->name($name);
72  my $combo = $dialog->get_widget('properties_render_as_combobox');
73  my $model = $combo->get_model;
74  my $iter = $model->get_iter_from_string($combo->get_active());
75  $self->render_as($model->get_value($iter));
76  $self->hide_dialog('properties_dialog') if $close;
77  $gui->set_layer($self);
78  $gui->{overlay}->render;
79 }
80 
81 ##@ignore
82 sub cancel_properties {
83  my($self, $gui);
84  for (@_) {
85  next unless ref eq 'ARRAY';
86  ($self, $gui) = @{$_};
87  }
88  $self->alpha($self->{backup}->{alpha});
89  $self->name($self->{backup}->{name});
90  $self->render_as($self->{backup}->{render_as});
91  $self->hide_dialog('properties_dialog');
92  $gui->set_layer($self);
93  $gui->{overlay}->render;
94  1;
95 }
96 
97 1;
public method fill_render_as_combobox()
Upgrade Geo::Vector, feature and geometry objects to Geo::Vector::Layers.
Definition: Layer.pm:72
A geospatial layer that consists of Geo::OGR::Features.
Definition: Vector.pm:176