Skip to content

Commit

Permalink
add data-rotation dialog functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias47n9e committed May 1, 2015
1 parent 903aa5d commit 9176138
Show file tree
Hide file tree
Showing 4 changed files with 857 additions and 1 deletion.
282 changes: 282 additions & 0 deletions innstereo/gui_layout.glade
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,268 @@ equatorial aspect</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment_rotation_angle">
<property name="upper">360</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment_rotation_dip">
<property name="upper">90</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment_rotation_dipdir">
<property name="upper">360</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkDialog" id="dialog_rotation">
<property name="can_focus">False</property>
<property name="border_width">3</property>
<property name="title" translatable="yes">Rotate Layers</property>
<property name="default_width">800</property>
<property name="default_height">500</property>
<property name="type_hint">dialog</property>
<signal name="destroy" handler="on_dialog_rotation_destroy" swapped="no"/>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox6">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox" id="dialog-action_area6">
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="button_cancel_rotation">
<property name="label" translatable="yes">Cancel</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="on_button_cancel_rotation_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button_apply_rotate">
<property name="label" translatable="yes">Add Rotated Data</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="on_button_apply_rotate_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box9">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow_rotate">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="shadow_type">in</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkGrid" id="grid2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">3</property>
<child>
<object class="GtkLabel" id="label67">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="margin_top">10</property>
<property name="margin_bottom">10</property>
<property name="hexpand">False</property>
<property name="label" translatable="yes">Rotation Settings</property>
<property name="ellipsize">start</property>
<attributes>
<attribute name="weight" value="bold"/>
<attribute name="scale" value="1.5"/>
</attributes>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="width">5</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label68">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="margin_left">5</property>
<property name="margin_right">5</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<property name="label" translatable="yes">Rotation Axis</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="spinbutton_rotation_dipdir">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">center</property>
<property name="margin_left">5</property>
<property name="margin_right">5</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<property name="adjustment">adjustment_rotation_dipdir</property>
<signal name="value-changed" handler="on_spinbutton_rotation_dipdir_value_changed" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="spinbutton_rotation_dip">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="margin_left">5</property>
<property name="margin_right">5</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<property name="adjustment">adjustment_rotation_dip</property>
<signal name="value-changed" handler="on_spinbutton_rotation_dip_value_changed" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label69">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="margin_left">5</property>
<property name="margin_right">5</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<property name="label" translatable="yes">Dip Direction</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label70">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<property name="label" translatable="yes">Dip</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label71">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="margin_left">25</property>
<property name="margin_right">5</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<property name="label" translatable="yes">Rotation Angle</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
<packing>
<property name="left_attach">3</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="spinbutton_rotation_angle">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="margin_left">5</property>
<property name="margin_right">5</property>
<property name="adjustment">adjustment_rotation_angle</property>
<signal name="value-changed" handler="on_spinbutton_rotation_angle_value_changed" swapped="no"/>
</object>
<packing>
<property name="left_attach">4</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
<object class="GtkAdjustment" id="adjustment_steps">
<property name="upper">100</property>
<property name="step_increment">1</property>
Expand Down Expand Up @@ -1082,6 +1344,11 @@ equatorial aspect</property>
<property name="can_focus">False</property>
<property name="pixbuf">calculate_plane_intersect.svg</property>
</object>
<object class="GtkImage" id="image_rotate">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixbuf">rotate.svg</property>
</object>
<object class="GtkListStore" id="liststore_assign_columns">
<columns>
<!-- column-name gint1 -->
Expand Down Expand Up @@ -3871,6 +4138,21 @@ equatorial aspect</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="toolbutton_rotate_layer">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Rotates the currently selected layers. The rotation settings are set in a dialog.</property>
<property name="label" translatable="yes">Rotate Layer</property>
<property name="use_underline">True</property>
<property name="icon_widget">image_rotate</property>
<signal name="clicked" handler="on_toolbutton_rotate_layer_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkSeparatorToolItem" id="toolbutton2">
<property name="visible">True</property>
Expand Down
48 changes: 47 additions & 1 deletion innstereo/main_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from .plot_control import PlotSettings
from .polar_axes import NorthPolarAxes
from .file_parser import FileParseDialog
from .rotation_dialog import RotationDialog


class MainWindow(object):
Expand Down Expand Up @@ -236,6 +237,35 @@ def evaluate_lines():
self.add_eigenvector_feature(store, dipdir[2], dip[2], values[2])
self.redraw_plot()

def on_toolbutton_rotate_layer_clicked(self, toolbutton):
# pylint: disable=unused-argument
"""
Open the data rotation dialog.
If one or more layers are selected a instance of the data-rotation
dialog is initialized and the selected rows are passed to it.
"""
selection = self.layer_view.get_selection()
model, row_list = selection.get_selected_rows()

if len(row_list) == 0:
self.statbar.push(1, ("Please select layers to rotate!"))
return

def parse_layers(model, path, itr, data, key):
line = model[path]
data[key][3].append([line[0], line[1], line[2]])

data_rows = []
for row in row_list:
layer_obj = model[row][3]
data_rows.append(layer_obj)

rotate_dialog = RotationDialog(self.main_window, self.settings,
data_rows, self.add_layer_dataset,
self.add_feature, self.redraw_plot)
rotate_dialog.run()

def on_toolbutton_new_project_clicked(self, widget):
# pylint: disable=unused-argument
"""
Expand Down Expand Up @@ -1442,6 +1472,22 @@ def add_smallcircle_feature(self, datastore, dip_direct=0, dip=0,
"""
datastore.append([dip_direct, dip, angle])

def add_feature(self, layer_type, store, *args):
"""
Adds a feature to a layer.
Exepects a layer-type and a datastore. Additional arguments are passed
to the specific function (e.g. dipdirection or dip)
"""
if layer_type == "plane":
self.add_planar_feature(store, *args)
if layer_type == "line":
self.add_linear_feature(store, *args)
if layer_type == "faultplane":
self.add_faultplane_feature(store, *args)
if layer_type == "smallcircle":
self.add_smallcircle_feature(store, *args)

def on_toolbutton_add_feature_clicked(self, widget):
"""
Adds an empty row to the currently selected data layer.
Expand Down Expand Up @@ -1708,7 +1754,7 @@ def startup():
"image_new_line", "image_new_fold", "image_plane_intersect",
"image_best_fitting_plane", "layer_right_click_menu",
"image_create_small_circle", "menu_plot_views", "image_eigenvector",
"poles_to_lines", "image_linears_to_planes"))
"poles_to_lines", "image_linears_to_planes", "image_rotate"))

gui_instance = MainWindow(builder)
builder.connect_signals(gui_instance)
Expand Down

0 comments on commit 9176138

Please sign in to comment.