App-SeismicUnixGui
view release on metacpan or search on metacpan
lib/App/SeismicUnixGui/misc/blue_flow.pm view on Meta::CPAN
1. Find widget you have selected
if widget_name= frame then we have flow
$var->{_flow}
if widget_name= menubutton we have superflow
$var->{_tool}
2. Set the new program name
3. Make widget states active for:
run_button
save_button
4. Disable the following widgets:
delete_from_flow_button
(sunix) flow_listbox
sunix_listbox -choice of listed sunix modules in a listbox
gui_history records updates to GUI selections
but color_flow_href points to the changed has reference and senses
the change as well.
=head4 Examples
=head3 SEISMIC UNIX NOTES
=head2 CHANGES and their DATES
refactoring of 2017 version of L_SU.pl
V 0.0.2 removed unused methods in comments
V 0.0.3 2021 allows for better color listbox control
V 0.0.4 7.10.21 allows control to handle non-numeric
names for input files
=cut
=head2 Notes
sub sunix_select (subroutine is only active in neutral_flow.pm)
=cut
use Moose;
our $VERSION = '0.0.4';
use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants';
use aliased 'App::SeismicUnixGui::configs::big_streams::Project_config';
extends 'App::SeismicUnixGui::misc::gui_history' => { -version => 0.0.2 };
use aliased 'App::SeismicUnixGui::misc::gui_history';
use App::SeismicUnixGui::misc::param_widgets_blue '0.0.2';
use aliased 'App::SeismicUnixGui::misc::param_widgets_blue';
use App::SeismicUnixGui::misc::param_flow_blue '0.0.5';
use aliased 'App::SeismicUnixGui::misc::param_flow_blue';
use aliased 'App::SeismicUnixGui::misc::binding';
use App::SeismicUnixGui::misc::control '0.0.3';
use aliased 'App::SeismicUnixGui::misc::control';
use App::SeismicUnixGui::misc::decisions '1.0.0';
use aliased 'App::SeismicUnixGui::misc::decisions';
use aliased 'App::SeismicUnixGui::misc::dirs';
use aliased 'App::SeismicUnixGui::misc::file_dialog';
use aliased 'App::SeismicUnixGui::misc::files_LSU';
use aliased 'App::SeismicUnixGui::misc::flow_widgets';
use aliased 'App::SeismicUnixGui::misc::help';
use aliased 'App::SeismicUnixGui::misc::manage_files_by2';
use aliased 'App::SeismicUnixGui::messages::message_director';
use aliased 'App::SeismicUnixGui::misc::perl_flow';
use aliased 'App::SeismicUnixGui::misc::param_sunix';
use Carp;
use Clone 'clone';
=head2 Instantiation
=cut
my $Project = Project_config->new();
my $L_SU_global_constants = L_SU_global_constants->new();
my $control = control->new();
my $decisions = decisions->new();
my $dirs = dirs->new();
my $file_dialog = file_dialog->new();
my $flow_widgets = flow_widgets->new();
my $gui_history = gui_history->new();
my $manage_files_by2 = manage_files_by2->new();
my $message_director = message_director->new();
my $param_flow_color_pkg = param_flow_blue->new();
my $param_widgets = param_widgets_blue->new();
my $flow_type = $L_SU_global_constants->flow_type_href();
my $var = $L_SU_global_constants->var();
my $empty_string = $var->{_empty_string};
my $this_color = 'blue';
my $color_flow_href = $gui_history->get_defaults();
my $neutral = $var->{_neutral};
my $sunix_select = $var->{_sunix_select};
my $number_from_color = $L_SU_global_constants->number_from_color_href();
my $_is_last_parameter_index_touched_color =
'_is_last_parameter_index_touched_' . $this_color;
my $_flow_listbox_color_w = '_flow_listbox_' . $this_color . '_w';
my $_flow_name_color_w = '_flow_name_' . $this_color . '_w';
my $_number_from_color = $number_from_color->{ ( '_' . $this_color ) };
my $_flow_name_in_color = '_flow_name_in_' . $this_color;
my $_flow_name_out_color = '_flow_name_out_' . $this_color;
=head2
share the following parameters in same name
space
=cut
lib/App/SeismicUnixGui/misc/blue_flow.pm view on Meta::CPAN
# switch between the correct index of the last parameter that was touched
# as a function of the flow's color
# These data are encapsulated
$color_flow_href->{_last_parameter_index_touched_color} = 0; # initialize
$color_flow_href->{$_is_last_parameter_index_touched_color} = $true;
$param_widgets->set_check_buttons(
$color_flow_href->{_check_buttons_settings_aref} );
# print(
#" 2. color_flow, END _add2flow, color_flow_href->{_values_aref}=@{$color_flow_href->{_values_aref}}\n"
# );
# print(" 2. color_flow, END _add2flow, widget values =@{$param_widgets->get_values_aref()} \n");
_flow_select_director('_add2flow');
$param_widgets->set_entry_change_status($false);
return ();
}
=head2 sub _clear_color_flow
wipe out color-flow list box with programs
wipe out param_widgets_color
wipe out parameters stored for color flow
=cut
sub _clear_color_flow {
my ($self) = @_;
# my $number = $param_flow_color_pkg->get_num_items();
#clear all stored parameters and versions in the param_flow
$param_flow_color_pkg->clear();
my $number = $param_flow_color_pkg->get_num_items();
my $test = $color_flow_href->{_check_buttons_settings_aref};
# clear the parameter values and labels belonging to the gui
# strange memory leak inside param_widgets
my $save = clone( $color_flow_href->{_check_buttons_settings_aref} );
$param_widgets->gui_full_clear();
# print("color_flow,_clear_color_flow: print gui_history.txt \n");
# $gui_history->view();
@{ $color_flow_href->{_check_buttons_settings_aref} } = @$save;
# remove all sunix program names from the flow listbox
# in "color"_flow namespace
my $_flow_listbox_color_w = _get_flow_listbox_color_w();
$flow_widgets->clear($_flow_listbox_color_w);
}
=head2 sub _FileDialog_button
Only cases with MB binding use this private ('_') subroutine
e.g., sunix programs displayed in the parameter boxes during
flow construction.
sub binding is responsible
Other cases that select the GUI file buttons directly (user click) use: FileDialog_button instead.
Once the file name is selected the parameter value is updated in the GUI
foreach my $key (sort keys %$color_flow) {
print (" color_flowkey is $key, value is $color_flow->{$key}\n");
}
print ("color_flow,_FileDialog_button(binding), _is_flow_listbox_color_w: $color_flow_href->{_is_flow_listbox_color_w} \n");
=cut
sub _FileDialog_button {
my ( $self, $flow_dialog_type_sref ) = @_;
if ($flow_dialog_type_sref) {
# flow dialog type can be
# 'Open' or Data_PL_SEISMIC
# provide values in the current widget
$color_flow_href->{_values_aref} = $param_widgets->get_values_aref();
my $most_recent_flow_index_touched =
( $color_flow_href->{_flow_select_index_href} )->{_most_recent};
# establish which program is active in the flow
$color_flow_href->{_prog_names_aref} =
$param_flow_color_pkg->get_flow_prog_names_aref();
$control->set_flow_prog_names_aref(
$color_flow_href->{_prog_names_aref} );
$control->set_flow_prog_name_index($most_recent_flow_index_touched);
# clean all quotes upon input
$color_flow_href->{_values_aref} =
$control->get_no_quotes4array( $color_flow_href->{_values_aref} );
# restore string quotes to values that need them
# e.g., character strings as well as fnumeric file names
$color_flow_href->{_values_aref} = $control->get_string_or_number4aref(
$color_flow_href->{_values_aref} );
# dereference scalar
$color_flow_href->{_dialog_type} = $$flow_dialog_type_sref;
$file_dialog->set_flow_color( $color_flow_href->{_flow_color} );
$file_dialog->set_hash_ref($color_flow_href);
$file_dialog->set_dialog_type($$flow_dialog_type_sref);
$file_dialog->FileDialog_director();
# updates to parameter values
# changed within file_dialog are retrieved
$color_flow_href->{_values_aref} = $file_dialog->get_values_aref();
# print("color flow, _FileDialog_button: color_flow_href->{_values_aref}=@{$color_flow_href->{_values_aref}}\n");
# assume that after selection to open of a data file, while using file-dialog button, the
# GUI has been updated
# Assume we are still dealing with the current flow item selected
# Update the value of the Entry widget (in GUI) with the selected file name
# Also update the parameter_widgets with the updated value
my $current_index = $file_dialog->get_current_index();
my $selected_Entry_widget = $file_dialog->get_selected_Entry_widget();
@{ $param_widgets->{_values_aref} }[$current_index] =
$file_dialog->get_selected_file_name();
@{ $color_flow_href->{_values_aref} }[$current_index] =
$file_dialog->get_selected_file_name();
$param_widgets->redisplay_values();
# Make sure to place focus again on the updated widget so other modules can find the selection
$selected_Entry_widget->focus; # from above
#print("13 color_flow, _FileDialog_button,color_flow selected_file_name: @{ $param_widgets->{_values_aref} }[$current_index]\n");
#print("13 color_flow, _FileDialog_button,color_flow values: @{ $color_flow_href->{_values_aref} }\n");
# print("9. color_flow, _FileDialog_button, last_flow_color:$color_flow_href->{_last_flow_color}\n");
# print("1. color_flow, _FileDialog_button, last_flow_index_touched $color_flow_href->{_last_flow_index_touched}\n");
# set up this flow listbox item as the last item touched
# user-built_flow in current use
my $_flow_listbox_color_w = _get_flow_listbox_color_w();
my $current_flow_listbox_index =
$flow_widgets->get_flow_selection($_flow_listbox_color_w);
# print("2. color_flow, _FileDialog_button, last_flow_index_touched $color_flow_href->{_last_flow_index_touched}\n");
# print("10. color_flow, _FileDialog_button, last_flow_color:$color_flow_href->{_last_flow_color}\n");
# Changes made with another instance of param_widgets (in file_dialog) will require
# that we update the namespace of the current param_flow
# We make this change inside _save_most_recent_param_flow
_save_most_recent_param_flow();
}
else {
print("color_flow,_FileDialog_button (binding),option type missing ");
}
return ();
}
=head2 sub _clear_items_version_aref
clear items_versions_aref
used when last item is removed from the listbox
=cut
sub _clear_items_version_aref {
my ($self) = @_;
if ($color_flow_href) {
$color_flow_href->{_items_versions_aref} = '';
return ();
}
else {
print("color_flow, _clear_items_version_aref, missing color_flow \n");
return ();
}
}
=head2 sub _clear_stack_versions
clear items_versions_aref
when last flow item is deleted
in the listbox
=cut
sub _clear_stack_versions {
my $_flow_listbox_color_w = _get_flow_listbox_color_w();
$flow_widgets->clear_flow_item($_flow_listbox_color_w);
$flow_widgets->clear_items_versions_aref();
# with hash value = ''
_clear_items_version_aref();
$param_flow_color_pkg->clear_flow_items_version_aref();
}
=head2 sub _flow_select_director
Private alias for flow_select
both color and button are set as
per the flow_select called by an active click
from Main, in_L_SU_flow_bindings
=cut
sub _flow_select_director {
my ($type) = @_;
if ( defined $type ) {
$gui_history->set_flow_select_color($this_color);
if (
$type eq '_add2flow' # when perl flow is read
or $type eq '_perl_flow'
or $type eq 'delete_from_flow_button'
or $type eq 'delete_whole_flow_button'
or $type eq 'flow_item_down_arrow_button'
or $type eq 'flow_item_up_arrow_button'
)
{
# update most recent flow
# print(
#" 3. color_flow,_flow_select_director,END OF LOADING INTO GUI for type=$type\n"
# );
# print(
#" 3. color_flow,_flow_select_director,color_flow_href->{_values_aref}=@{$color_flow_href->{_values_aref}}\n"
# );
_flow_select2save_most_recent_param_flow();
# print(" 3. color_flow,_flow_select_director, widget values=@{$param_widgets->get_values_aref()} \n");
if ( $type eq '_add2flow' ) {
# CASE of opening a perl flow
# the last set of param_widgets opened
@save_last_param_widget_values =
@{ $param_widgets->get_values_aref() };
$save_last_param_widget_value = $save_last_param_widget_values[-1];
$save_last_param_widget_index = $#save_last_param_widget_values;
}
# flow loading and display is complete
# print("1. color_flow, _flow_select_director, print out gui_history\n");
# $gui_history->view();
}
elsif ( $type eq 'add2flow_button' ) {
_flow_select2save_most_recent_param_flow();
# update prior flow
# flow_select();
}
else {
print("color_flow,_flow_select_director, unexpected\n");
}
return ();
}
}
=head2 sub flow_select2save_most_recent_param_flow
select a program from the flow
when add2flow_button is directly selected by the user
archive the index
and update any changed parameter flows
consider prior flow-color changes
unticked strings from GUI are corrected here
uses _updateNsave_most_recent_param_flow();
=cut
sub flow_select2save_most_recent_param_flow {
my ($self) = @_;
$color_flow_href->{_flow_type} = $flow_type->{_user_built};
_local_set_flow_listbox_color_w($flow_color);
my $message = $message_director->null_button(0);
$message_w->delete( "1.0", 'end' );
$message_w->insert( 'end', $message );
$gui_history->set_hash_ref($color_flow_href);
$gui_history->set_defaults_4start_of_flow_select($flow_color);
$color_flow_href = $gui_history->get_hash_ref();
# update the flow color as per add2flow_select2save_most_recent_param_flow
my $_flow_listbox_color_w = _get_flow_listbox_color_w();
$color_flow_href->{_prog_name_sref} =
$flow_widgets->get_current_program( \$_flow_listbox_color_w );
$decisions->set_hash_ref($color_flow_href);
# print("color_flow, flow_select2save_most_recent_param_flow, view stored flow parameters BEFORE update\n");
# $param_flow_color_pkg->view_data();
my $pre_req_ok = $decisions->get4flow_select();
if ($pre_req_ok) {
my $binding = binding->new();
my $here;
# consider previous flow-color changes
# unticked strings from GUI are corrected within
_updateNsave_most_recent_param_flow();
# print("color_flow, flow_select2save_most_recent_param_flow, view stored flow parameters AFTER update\n");
# $param_flow_color_pkg->view_data();
# print(
# "4. color_flow, flow_select2save_most_recent_param_flow: writing gui_history.txt\n"
# );
# $gui_history->view();
# for just-selected program name
# get its flow parameters from storage
# and redisplay the widgets with parameters
# Update the flow item index to the program that is currently being used, instead
# of prior program
# Warning: Flow selection gets reset if user double-clicks on a parameter value
# in another window
$gui_history->set_button('flow_select');
my $index = $flow_widgets->get_flow_selection($_flow_listbox_color_w);
if ( defined($index)
and $index >= 0 )
{
# print("10 color_flow, flow_select2save_most_recent_param_flow index=$index \n");
# print("3. color_flow, flow_select2save_most_recent_param_flow: writing gui_history.txt\n");
# $gui_history->view();
# CASE MOST COMMON
$param_flow_color_pkg->set_flow_index($index);
$color_flow_href->{_names_aref} =
$param_flow_color_pkg->get_names_aref();
$color_flow_href->{_values_aref} =
$param_flow_color_pkg->get_values_aref();
$color_flow_href->{_check_buttons_settings_aref} =
$param_flow_color_pkg->get_check_buttons_settings();
# print("10 flow_select2save_most_recent_param_flow,check_buttons_settings_aref: @{color_flow_href->{_check_buttons_settings_aref}}\n");
# get stored first index and num of items
$color_flow_href->{_param_flow_first_idx} =
$param_flow_color_pkg->first_idx();
$color_flow_href->{_param_flow_length} =
$param_flow_color_pkg->length();
$param_widgets->set_current_program(
$color_flow_href->{_prog_name_sref} );
# widgets were initialized in super class
$param_widgets->set_labels_w_aref(
$color_flow_href->{_labels_w_aref} );
$param_widgets->set_values_w_aref(
$color_flow_href->{_values_w_aref} );
$param_widgets->set_check_buttons_w_aref(
$color_flow_href->{_check_buttons_w_aref} );
$color_flow_href->{_prog_name_sref} =
$flow_widgets->get_current_program( \$_flow_listbox_color_w );
$param_widgets->range($color_flow_href);
# strange memory leak inside param_widgets
my $save1 =
clone( $color_flow_href->{_check_buttons_settings_aref} );
$param_widgets->gui_full_clear();
@{ $color_flow_href->{_check_buttons_settings_aref} } = @$save1;
$param_widgets->set_labels( $color_flow_href->{_names_aref} );
# test next 4 lines
# my $save2 =
# clone( $color_flow_href->{_values_aref} );
# $param_widgets->gui_full_clear();
# @{ $color_flow_href->{_values_aref} } = @$save2;
# $param_widgets->set_values( $color_flow_href->{_values_aref} );
$param_widgets->set_check_buttons(
$color_flow_href->{_check_buttons_settings_aref} );
$param_widgets->redisplay_labels();
$param_widgets->redisplay_values();
$param_widgets->redisplay_check_buttons();
$param_widgets->set_entry_change_status($false);
# unxpectedly Entry focus is delayed until the end of this method before
# completion;
# that is we get to gui_history->view before we can update the focus
# mysterious!!!!!
$param_widgets->set_focus_on_Entry_w(0)
; # put focus on first entry widget, index=0
# Here is where you rebind the different buttons depending on the
# program name that is selected (i.e., through spec.pm)
$binding->set_prog_name_sref( $color_flow_href->{_prog_name_sref} );
$binding->set_values_w_aref( $param_widgets->get_values_w_aref );
# reference to local subroutine that will be run when MB3 is pressed
$binding->setFileDialog_button_sub_ref( \&_FileDialog_button );
$binding->set();
$gui_history->set_hash_ref($color_flow_href);
$gui_history->set4end_of_flow_select($flow_color);
$gui_history->set_flow_index_last_touched($index);
$color_flow_href = $gui_history->get_hash_ref()
; # now color_flow= 0; flow_type=user_built
# Update the entry button value that displays the currently active
# flow or superflow name, by using the currently selected program name from the flow list
# e.g. data_in, suximage, suxgraph etc.
( $color_flow_href->{_flowNsuperflow_name_w} )
->configure( -text => ${ $color_flow_href->{_prog_name_sref} } );
# needed in possible export via get_hash_ref to help
my $prog_name_sref = $color_flow_href->{_prog_name_sref};
}
elsif ( defined $index ) {
# if ( $index eq $empty_string
# or $index < 0 ) {
#
# print("color_flow,flow_select2save_most_recent_param_flow, NADA probably deleted last of flow\n");
# }
}
else {
# print("color_flow,flow_select2save_most_recent_param_flow, no index, - NADA\n");
}
} # end pre_ok
# print("color_flow,flow_select2save_most_recent_param_flow, end\n");
return ();
} # end sub
=head2 sub _flow_select2save_most_recent_param_flow
select a program from the flow
archive the index
and update any changed parameter flows
=cut
sub _flow_select2save_most_recent_param_flow {
my ($self) = @_;
$color_flow_href->{_flow_type} = $flow_type->{_user_built};
# print("1. color_flow,_flow_select2save_most_recent_param_flow, last_flow_index_touched:$color_flow_href->{_last_flow_index_touched}\n");
# print("color_flow,_flow_select2save_most_recent_param_flow, last_flow_color:$color_flow_href->{_last_flow_color}\n");
# reset residual flow_listbox_color_w of another color
# flow_color exists in current (color_flow) namespace
_local_set_flow_listbox_color_w($flow_color);
$gui_history->set_flow_select_color($flow_color);
# print("1. color_flow, _flow_select2save_most_recent_param_flow, show stored flow parameters\n");
# $param_flow_color_pkg->view_data();
my $message = $message_director->null_button(0);
$message_w->delete( "1.0", 'end' );
$message_w->insert( 'end', $message );
$gui_history->set_hash_ref($color_flow_href);
$gui_history->set_defaults_4start_of_flow_select($flow_color);
$color_flow_href = $gui_history->get_hash_ref();
# update the flow color as per add2_flow_select2save_most_recent_param_flow
my $_flow_listbox_color_w = _get_flow_listbox_color_w();
$color_flow_href->{_prog_name_sref} =
$flow_widgets->get_current_program( \$_flow_listbox_color_w );
$decisions->set_hash_ref($color_flow_href);
# print("3. color_flow, _flow_select2save_most_recent_param_flow: writing gui_history.txt\n");
# $gui_history->view();
# print("3. color_flow,_flow_select2save_most_recent_param_flow, last_flow_index_touched:$color_flow_href->{_last_flow_index_touched}\n");
#$param_flow_color_pkg->view_data();
my $pre_req_ok = $decisions->get4flow_select();
if ($pre_req_ok) {
my $binding = binding->new();
my $here;
$gui_history->set_button('flow_select');
# consider prior flow-color changes
# unticked strings from GUI are corrected here
# print(" 8, color_flow, before _updatenNsave_most_recent_param_flow\n");
# $param_flow_color_pkg->view_data();
# print(
#"8B. color_flow, _flow_select2save_most_recent_param_flow, values@{$color_flow_href->{_values_aref}}\n"
# );
_updateNsave_most_recent_param_flow();
# print("after 117 _updateNsave_most_recent_param_flow\n");
# print(
# "after 118 _color_flow, _flow_select2save_most_recent_param_flow, values@{$color_flow_href->{_values_aref}}\n"
# );
# for just-selected program name
# get its flow parameters from storage
# and redisplay the widgets with parameters
# Update the flow item index to the program that is currently being used, instead
# of prior program
# Warning: Flow selection gets reset if user double-clicks on a parameter value
# in another window
my $index = $flow_widgets->get_flow_selection($_flow_listbox_color_w);
$param_flow_color_pkg->set_flow_index($index);
$color_flow_href->{_names_aref} =
$param_flow_color_pkg->get_names_aref();
# print("9 _flow_select2save_most_recent_param_flow,index=$index\n");
# $param_flow_color_pkg->view_data();
# print("9B. color_flow, _flow_select2save_most_recent_param_flow, values@{$color_flow_href->{_values_aref}}\n");
$color_flow_href->{_values_aref} =
$param_flow_color_pkg->get_values_aref();
$color_flow_href->{_check_buttons_settings_aref} =
$param_flow_color_pkg->get_check_buttons_settings();
# print("10 _flow_select2save_most_recent_param_flow,index=$index\n");
# $param_flow_color_pkg->view_data();
# print("10 _flow_select2save_most_recent_param_flow,check_buttons_settings_aref: @{color_flow_href->{_check_buttons_settings_aref}}\n");
# get stored first index and num of items
$color_flow_href->{_param_flow_first_idx} =
$param_flow_color_pkg->first_idx();
$color_flow_href->{_param_flow_length} =
$param_flow_color_pkg->length();
$param_widgets->set_current_program(
$color_flow_href->{_prog_name_sref} );
# print("4. color_flow, _flow_select2save_most_recent_param_flow: writing gui_history.txt\n");
# $gui_history->view();
# widgets were initialized in super class
$param_widgets->set_labels_w_aref( $color_flow_href->{_labels_w_aref} );
$param_widgets->set_values_w_aref( $color_flow_href->{_values_w_aref} );
$param_widgets->set_check_buttons_w_aref(
$color_flow_href->{_check_buttons_w_aref} );
$color_flow_href->{_prog_name_sref} =
$flow_widgets->get_current_program( \$_flow_listbox_color_w );
# wipes out values labels and checkbuttons from the gui
$param_widgets->range($color_flow_href);
# print(
#"119 color_flow, END _flow_select2save_most_recent_param_flow,color_flow_href->{_values_aref} =@{$color_flow_href->{_values_aref}}\n"
# );
# strange memory leak inside param_widgets
# my @save1 = clone( @{$color_flow_href->{_check_buttons_settings_aref}} );
# $color_flow_href->{_check_buttons_settings_aref} = \@save1;
# my @save2 = clone( @{$color_flow_href->{_values_aref}} );
# $color_flow_href->{_values_aref} = \@save2;
# my @save3 = clone( @{$color_flow_href->{_names_aref}} );
# $color_flow_href->{_names_aref} = \@save3;
# print("120 color_flow, END _flow_select2save_most_recent_param_flow,color_flow_href->{_values_aref} =@{$color_flow_href->{_values_aref}}\n");
#
$param_widgets->gui_full_clear();
$param_widgets->set_labels( $color_flow_href->{_names_aref} );
$param_widgets->set_values( $color_flow_href->{_values_aref} );
$param_widgets->set_check_buttons(
$color_flow_href->{_check_buttons_settings_aref} );
# print(
#"121 color_flow, END _flow_select2save_most_recent_param_flow,color_flow_href->{_values_aref} =@{$color_flow_href->{_values_aref}}\n"
# );
$param_widgets->redisplay_labels();
$param_widgets->redisplay_values();
$param_widgets->redisplay_check_buttons();
$param_widgets->set_entry_change_status($false);
# mysterious!!!!!
# We need to get gui_istory->view before we can update the focus
# Unxpectedly, Entry focus is delayed until the end of this method before
# completion;
# put focus on first entry widget, index=0
$param_widgets->set_focus_on_Entry_w(0);
# print(
#"122 color_flow, END _flow_select2save_most_recent_param_flow,color_flow_href->{_values_aref} =@{$color_flow_href->{_values_aref}}\n"
# );
# $color_flow_href->{_last_parameter_index_touched_color} = 0;
# the changed parameter value in the Entry widget should force an update of stored values
# in the current flow item (not the last flow item touched)
# _save_most_recent_param_flow(); # is only active if
# $color_flow_href->{_last_parameter_index_touched_color} >= 0
# Here is where you rebind the different buttons depending on the
# program name that is selected (i.e., through *_spec.pm)
$binding->set_prog_name_sref( $color_flow_href->{_prog_name_sref} );
$binding->set_values_w_aref( $param_widgets->get_values_w_aref );
# reference to local subroutine that will be run when MB3 is pressed
$binding->setFileDialog_button_sub_ref( \&_FileDialog_button );
$binding->set();
$gui_history->set_hash_ref($color_flow_href);
$gui_history->set4end_of_flow_select($flow_color);
$gui_history->set_flow_index_last_touched($index);
$color_flow_href = $gui_history->get_hash_ref();
# Update the entry button value that displays the currently active
# flow or superflow name, by using the currently selected program name from the flow list
# e.g. data_in, suximage, suxgraph etc.
( $color_flow_href->{_flowNsuperflow_name_w} )
->configure( -text => ${ $color_flow_href->{_prog_name_sref} } );
# needed in possible export via get_hash_ref to help
my $prog_name_sref = $color_flow_href->{_prog_name_sref};
# will not reflect the Entry focus change
# print("color_flow_href _flow_select2save_most_recent_param_flow, log view is on\n");
# $gui_history->view();
# print("11, color_flow, END of _flow_select2save_most_recent_param_flow \n");
# $param_flow_color_pkg->view_data();
# print("14.color_flow,_flow_select2save_most_recent_param_flow,widget values =@{$param_widgets->get_values_aref()} \n");
} # end pre_ok
return ();
}
=head2 sub _get_flow_color
get a private hash value
=cut
sub _get_flow_color {
my ($self) = @_;
if ( $color_flow_href->{_flow_color} ) {
my $color;
$color = $color_flow_href->{_flow_color};
return ($color);
}
else {
print("color_flow, missing flow color\n");
}
}
=head2 sub _get_flow_listbox_color_w
=cut
sub _get_flow_listbox_color_w {
my ($self) = @_;
my $this_flow_listbox_color_w;
if ( defined $this_color
and $this_color ne $empty_string )
lib/App/SeismicUnixGui/misc/blue_flow.pm view on Meta::CPAN
# Place names of the programs at the top of the color listbox
$flow_name_color_w->configure(
-text => $color_flow_href->{$_flow_name_in_color} );
# Place names of the programs at the head of the GUI
$color_flow_href->{_flowNsuperflow_name_w}->configure(
-text => $color_flow_href->{_big_stream_name_in} );
# populate gui, and bot param_flow and param_widgets namespaces
_perl_flow();
}
else {
# print(" color_flow,FileDialog_button, perl flow parse errors\n");
# print("3 color_flow,FileDialog_button, Warning: missing file. \"Cancel\" clicked by user? NADA\n");
}
}
elsif ( $topic eq $file_dialog_type->{_Data} ) {
# print("color_flow, FileDialog_button,option_sref $topic\n");
# assume that after selection to open of a data file in file-dialog the
# GUI has been updated
# See if the last parameter index has been touched (>= 0)
# Assume we are still dealing with the current flow item selected
$color_flow_href->{_last_parameter_index_touched_color} =
$file_dialog->get_last_parameter_index_touched_color();
$color_flow_href->{$_is_last_parameter_index_touched_color} = $true;
# set the current listbox as the last color listbox
$color_flow_href->{_last_flow_listbox_color_w} =
$color_flow_href->{_flow_listbox_color_w};
# provide values in the current widget
$color_flow_href->{_values_aref} =
$param_widgets->get_values_aref();
my $most_recent_flow_index_touched =
( $color_flow_href->{_flow_select_index_href} )->{_most_recent};
# restore terminal ticks to strings
# establish which program is active in the flow
$color_flow_href->{_prog_names_aref} =
$param_flow_color_pkg->get_flow_prog_names_aref();
$control->set_flow_prog_names_aref(
$color_flow_href->{_prog_names_aref} );
$control->set_flow_prog_name_index($most_recent_flow_index_touched);
# restore strings to have terminal strings
# remove quotes upon input
$color_flow_href->{_values_aref} =
$control->get_no_quotes4array( $color_flow_href->{_values_aref} );
# in case parameter values have been displayed stringless
$color_flow_href->{_values_aref} =
$control->get_string_or_number4aref(
$color_flow_href->{_values_aref} );
# print(
# "color_flow,FileDialog_button(binding), flow_listbox_color_w: $color_flow_href->{_flow_listbox_color_w} \n"
# );
$file_dialog->set_flow_color( $color_flow_href->{_flow_color} );
$file_dialog->set_hash_ref($color_flow_href);
$file_dialog->FileDialog_director();
# print(
# "color_flow,FileDialog_button(binding), last_parameter_index_touched_color: $color_flow_href->{_last_parameter_index_touched_color} \n"
# );
# update to parameter values occurs in file_dialog
$color_flow_href->{_values_aref} = $file_dialog->get_values_aref();
# set up this flow listbox item as the last item touched
my $_flow_listbox_color_w =
_get_flow_listbox_color_w(); # user-built_flow in current use
my $current_flow_listbox_index =
$flow_widgets->get_flow_selection($_flow_listbox_color_w);
# $color_flow_href->{_last_flow_index_touched} =
# $current_flow_listbox_index; # for next time
# $color_flow_href->{$_is_last_flow_index_touched_color} = $true;
# print("color_flow,FileDialog_button(binding), last_flow_index_touched:$color_flow_href->{_last_flow_index_touched} \n");
# Changes made with another instance of param_widgets (in file_dialog) will require
# that we also update the namespace of the current param_flow
# We make this change inside _save_most_recent_param_flow
_save_most_recent_param_flow();
}
else {
print("1. color_flow, FileDialog_button, missing topic \n");
# Ends opt_ref
}
}
else {
print("color_flow,FileDialog_button ,option type missing\n");
}
return ();
}
=head2 sub add2flow_button
When build a first-time perl flow
Incorporate new prorgam parameter values and labels into the gui
and save the values, labels and checkbuttons setting in the param_flow
namespace
foreach my $key (sort keys %$color_flow_href) {
print (" color_flow key is $key, value is $color_flow_href->{$key}\n");
}
$ans= $color_flow_href->{_param_sunix_length};
print("1b. color_flow, add2flow_button, _param_sunix_length= $ans\n");
=cut
sub add2flow_button {
my ( $self, $value ) = @_;
# $color_flow_href->{_names_aref} = $param_widgets->get_labels_aref();
# print("start add2flow_button all label0 = @{$color_flow_href->{_names_aref}}[0]\n");
# print("start add2flow_buttonall label1 = @{$color_flow_href->{_names_aref}}[1]\n");
# $color_flow_href->{_values_aref} = $param_widgets->get_values_aref();
# print("start add2flow_buttonall value0 = @{$color_flow_href->{_values_aref}}[0]\n");
# print("start add2flow_buttonall value1 = @{$color_flow_href->{_values_aref}}[1]\n");
# There is a case when a flow is used for the first time, when
# a parameter value has been added or
# modified and the flow item
# is not selected manually after a change (using select_flow_button)
# If a previous flow item has not been updated
# we must force an update to save these first-time, new, parameter values
# by using _flow_select (which calls flow_select).
# When we are coming from selecting an sunix program
# the flow listbox has been cleared of selections
# The last flow listbox selection was stored in the gui history
# We can not set flow_select button index
# We will increment the number of clicks
# (TODO) and that you have not changed color
lib/App/SeismicUnixGui/misc/blue_flow.pm view on Meta::CPAN
print(
"1 color_flow, flow_select, num_items_in_flow =$num_items_in_flow\n"
);
print(
"1 color_flow, flow_select, max_index_in_flow =$max_index_in_flow\n"
);
print(
"1 color_flow, flow_select, most_recent_flow_index =$most_recent_flow_index\n"
);
print(
"1 color_flow, flow_select, last_flow_color=$last_flow_color\n");
print(
"2 color_flow, flow_select, num_items_in_flow =$num_items_in_flow\n"
);
print(
"2 color_flow, flow_select, max_index_in_flow =$max_index_in_flow\n"
);
print(
"2 color_flow, flow_select, most_recent_flow_index =$most_recent_flow_index\n"
);
=cut
sub flow_select {
my ($self) = @_;
my $ans;
# print("1. color_flow, flow_select, print out gui_history\n");
# $gui_history->view();
$color_flow_href->{_flow_type} = $flow_type->{_user_built};
# reset residual flow_listbox_color_w of another color
# flow_color exists in current (color_flow) namespace
_local_set_flow_listbox_color_w($flow_color);
$gui_history->set_flow_select_color($flow_color);
my $message = $message_director->null_button(0);
$message_w->delete( "1.0", 'end' );
$message_w->insert( 'end', $message );
$gui_history->set_hash_ref($color_flow_href);
$gui_history->set_defaults_4start_of_flow_select($flow_color);
$color_flow_href = $gui_history->get_hash_ref();
# update the flow color as per add2flow_select
my $_flow_listbox_color_w = _get_flow_listbox_color_w();
$color_flow_href->{_prog_name_sref} =
$flow_widgets->get_current_program( \$_flow_listbox_color_w );
$decisions->set_hash_ref($color_flow_href);
my $pre_req_ok = $decisions->get4flow_select();
if ($pre_req_ok) {
my $binding = binding->new();
my ( $ans, $ans1 );
$gui_history->set_button('flow_select');
my $prior_flow_type =
( ( $gui_history->get_defaults )->{_flow_type_href} )->{_prior};
my $prior_flow_select_color =
( ( $gui_history->get_defaults )->{_flow_select_color_href} )
->{_prior};
my $most_recent_flow_select_color =
( ( $gui_history->get_defaults )->{_flow_select_color_href} )
->{_most_recent};
my $most_recent_flow_index_touched =
( $color_flow_href->{_flow_select_index_href} )->{_most_recent};
my $max_saved_widget_index = scalar @save_last_param_widget_values;
if ( $prior_flow_type eq $flow_type->{_user_built}
and $most_recent_flow_select_color eq $prior_flow_select_color )
{
# CASE 1 last click was inside this same colored flow
# consider prior flow-color changes
# that have been made to param_widgets but not updated
# unticked strings from GUI are corrected here
_update_prior_param_flow();
# find which flow index is selected
my $num_items_in_flow = $param_flow_color_pkg->get_num_items();
my $max_index_in_flow = $num_items_in_flow - 1;
$last_flow_color = $color_flow_href->{_last_flow_color};
# $gui_history->set_file_status($num_items_in_flow);
# my $file_status = $gui_history->get_file_status();
# print(
# "3 start.color_flow,flow_select, file_status,num_items_in_flow: $file_status,$num_items_in_flow\n"
# );
if ( not $memory_leak4flow_select_fixed ) {
if ( ( $this_color eq $last_flow_color )
&& $most_recent_flow_index_touched == $max_index_in_flow )
{
# CASE 1A- NO memory correction needed
# last selected index was last in program
# list and last color flow is the same as this color flow
# e.g., just loaded a new flow and user clicks on last program
# in flow
$param_widgets->set_values(
\@save_last_param_widget_values );
$param_flow_color_pkg->set_flow_index(
$most_recent_flow_index_touched);
$param_flow_color_pkg->set_values_aref(
\@save_last_param_widget_values );
}
elsif (
( $this_color eq $last_flow_color )
lib/App/SeismicUnixGui/misc/blue_flow.pm view on Meta::CPAN
# $aref = $param_flow_color_pkg->get_values_aref();
# print("11a.color_flow,flow_select, values:@{$aref}\n");
$color_flow_href->{_check_buttons_settings_aref} =
$param_flow_color_pkg->get_check_buttons_settings();
# get stored first index and num of items
$color_flow_href->{_param_flow_first_idx} =
$param_flow_color_pkg->first_idx();
$color_flow_href->{_param_flow_length} =
$param_flow_color_pkg->length();
$param_widgets->set_current_program(
$color_flow_href->{_prog_name_sref} );
# print(
# "11.color_flow,flow_select, names:@{$color_flow_href->{_names_aref}}\n"
# );
# widgets were initialized in super class
# 1. prepare to update gui by assigning widgets
# TODO are the next 3 lines needed now that we share gui_history?
$param_widgets->set_labels_w_aref( $color_flow_href->{_labels_w_aref} );
$param_widgets->set_values_w_aref( $color_flow_href->{_values_w_aref} );
$param_widgets->set_check_buttons_w_aref(
$color_flow_href->{_check_buttons_w_aref} );
$color_flow_href->{_prog_name_sref} =
$flow_widgets->get_current_program( \$_flow_listbox_color_w );
# wipes out values labels and checkbuttons from the gui
$param_widgets->range($color_flow_href);
# strange memory leak inside param_widgets
my $save = clone( $color_flow_href->{_check_buttons_settings_aref} );
$param_widgets->gui_full_clear();
@{ $color_flow_href->{_check_buttons_settings_aref} } = @$save;
$param_widgets->set_labels( $color_flow_href->{_names_aref} );
$param_widgets->set_values( $color_flow_href->{_values_aref} );
$param_widgets->set_check_buttons(
$color_flow_href->{_check_buttons_settings_aref} );
$param_widgets->redisplay_labels();
$param_widgets->redisplay_values();
$param_widgets->redisplay_check_buttons();
$param_widgets->set_entry_change_status($false);
# unxpectedly Entry focus is delayed until the end of this method becore
# completion;
# that is we get to gui_history->view before we can update the focus
# mysterious!!!!!
$param_widgets->set_focus_on_Entry_w(0)
; # put focus on first entry widget, index=0
# $color_flow_href->{_last_parameter_index_touched_color} = 0;
# the changed parameter value in the Entry widget should force an update of stored values
# in the current flow item (not the last flow item touched)
# _save_most_recent_param_flow(); # is only active if
# $color_flow_href->{_last_parameter_index_touched_color} >= 0
# Here is where you rebind the different buttons depending on the
# program name that is selected (i.e., through spec.pm)
$binding->set_prog_name_sref( $color_flow_href->{_prog_name_sref} );
$binding->set_values_w_aref( $param_widgets->get_values_w_aref );
# reference to local subroutine that will be run when MB3 is pressed
$binding->setFileDialog_button_sub_ref( \&_FileDialog_button );
$binding->set();
$gui_history->set_hash_ref($color_flow_href);
$gui_history->set4end_of_flow_select($flow_color);
$gui_history->set_flow_index_last_touched($index);
$color_flow_href = $gui_history->get_hash_ref();
# Update thre entry button value that displays the currently active
# flow or superflow name, by using the currently selected program name from the flow list
# e.g. data_in, suximage, suxgraph etc.
( $color_flow_href->{_flowNsuperflow_name_w} )
->configure( -text => ${ $color_flow_href->{_prog_name_sref} } );
# needed in possible export via get_hash_ref to help
my $prog_name_sref = $color_flow_href->{_prog_name_sref};
} # end pre_ok
# $ans = ( ( $gui_history->get_defaults )->{_flow_select_color_href} )
# ->{_most_recent};
# print("7. color_flow,flow_select,most recent color: $ans\n");
#
# $ans = ( ( $gui_history->get_defaults )->{_flow_select_color_href} )
# ->{_prior};
# print("8. color_flow,flow_select,prior color: $ans\n");
# print("1. color_flow,flow_select, post _update_prior_param_flow: \n");
# print("1. color_flow,flow_select, view stored param flow values: \n");
# $param_flow_color_pkg->view_data();
# print("color_flow, END of flow_select: writing gui_history.txt\n");
# $gui_history->view();
return ();
}
=head2 sub get_Flow_file_exists
=cut
sub get_Flow_file_exists {
my ($self) = @_;
my $result = $empty_string;
if ( length $color_flow->{_Flow_file_exists} ) {
$result = $color_flow->{_Flow_file_exists};
return ($result);
}
else {
print(" color_flow, get_Flow_file_exists, missing variable value\n");
return ($result);
}
}
=head2 sub get_hash_ref
exports private hash
46
=cut
sub get_hash_ref {
( run in 0.844 second using v1.01-cache-2.11-cpan-2398b32b56e )