App-GUI-Harmonograph

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

    stands still over a widgets. Also helpful are messages in the status bar
    at the bottom - on bottom left regarding current state of the image and
    bottom right about state of the settings. Settings are all the
    parameters that guide the drawing. You change them via widgets controls
    on the right side. They can be saved and loaded from a file via the
    settings menu. Configuration are the general settings of this program,
    which are mostly saved colors and paths were to store images and
    settings.

    When browsing the main menu, help texts about the highlighted item also
    appears in the status bar. The Menu can be completely navigated with the
    keyboard. Just hold Alt and use the direction keys (up, down, left and
    right) or the highlighted letters. When holding the Alt key you can also
    see which Alt + letter combinations trigger which button.

  Pendulum
    Each of the first three tabs contains the settings of two pendula. The
    first tab holds the lateral or linear pendula: X (left right movement)
    and Y (up and down). The second tab shows settings of the epicycle
    pendula E (left right) and F (up down). They also just move in x or y
    direction, but they swing not around the center of the image but around

README  view on Meta::CPAN

    menu. Lets say your directory is "/home/user/images/h" and the base file
    name is beauty. If there is already a file
    "/home/user/images/h/beauty_4.png" - the program will detect that and
    set the counter to 5. You can play with the settings and than (no matter
    if there is currently a complete drawing or not) push the *Save* button
    to produce a complete drawing into "/home/user/images/h/beauty_5.png".
    If you push the *INI* button you safe the current settings into
    "/home/user/images/h/beauty_5.ini". This file can later be loaded via
    settings menu to restore the current state of all buttons in the tabs.

  Menu
    The upmost menu bar has only three very simple menus. Please not that
    each menu shows which key combination triggers the same command and
    while hovering over an menu item you see a short help text the left
    status bar field.

    The first menu is for loading and storing setting files with arbitrary
    names. I recommend giving them the file ending ".ini" for transparency
    reasons. A submenu allows a quick load of the recently used files. The
    first entry lets you reset the whole program to the starting state and
    the last is just to exit (safely with saving the configs).

lib/App/GUI/Harmonograph.pm  view on Meta::CPAN

Please mind the tool tips - short help texts which appear if the mouse
stands still over a widgets. Also helpful are messages in the
status bar at the bottom - on bottom left regarding current state of the image
and bottom right about state of the settings. Settings are all the
parameters that guide the drawing. You change them via widgets controls
on the right side. They can be saved and loaded from a file via the
settings menu. Configuration are the general settings of this program,
which are mostly saved colors and paths were to store images and settings.

When browsing the main menu, help texts about the highlighted item
also appears in the status bar. The Menu can be completely navigated with
the keyboard. Just hold Alt and use the direction keys (up, down, left
and right) or the highlighted letters. When holding the Alt key you can
also see which Alt + letter combinations trigger which button.


=head2 Pendulum

=for HTML <p>
<img src="https://raw.githubusercontent.com/lichtkind/App-GUI-Harmonograph/main/examples/POD/Tab_Pendulum.png"    alt=""  width="85%" height="85%">
</p>

lib/App/GUI/Harmonograph.pm  view on Meta::CPAN

"/home/user/images/h" and the base file name is beauty. If there is already
a file "/home/user/images/h/beauty_4.png" - the program will detect that
and set the counter to 5. You can play with the settings and than (no matter
if there is currently a complete drawing or not) push the I<Save> button
to produce a complete drawing into "/home/user/images/h/beauty_5.png".
If you push the I<INI> button you safe the current settings into
"/home/user/images/h/beauty_5.ini". This file can later be loaded via
settings menu to restore the current state of all buttons in the tabs.


=head2 Menu

The upmost menu bar has only three very simple menus.
Please not that each menu shows which key combination triggers the same
command and while hovering over an menu item you see a short help text
the left status bar field.

The first menu is for loading and storing setting files with arbitrary
names. I recommend giving them the file ending C<.ini> for transparency
reasons. A submenu allows a quick load of the recently used files.
The first entry lets you reset the whole program to the starting state

lib/App/GUI/Harmonograph/Frame.pm  view on Meta::CPAN

        $self->write_image( $path );
    });
    Wx::Event::EVT_BUTTON( $self, $self->{'btn'}{'draw'},  sub { draw( $self ) });
    Wx::Event::EVT_CLOSE( $self, sub {
        $self->{'tab'}{'color'}->update_config;
        $self->{'config'}->save();
        $self->{'dialog'}{'about'}->Destroy();
        $_[1]->Skip(1)
    });

    # Menu
    my $settings_menu = $self->{'setting_menu'} = Wx::Menu->new();
    $settings_menu->Append( 11100, "&Init\tCtrl+I", "put all settings to default" );
    $settings_menu->Append( 11200, "&Open\tCtrl+O", "load settings from an INI file" );
    $settings_menu->Append( 11400, "&Write\tCtrl+W", "store curent settings into an INI file" );
    $settings_menu->AppendSeparator();
    $settings_menu->Append( 11500, "&Quit\tAlt+Q", "save configs and close program" );

    my $image_size_menu = Wx::Menu->new();
    for (1 .. 20) {
        my $size = $_ * 100;
        $image_size_menu->AppendRadioItem(12100 + $_, $size, "set image size to $size x $size");
        Wx::Event::EVT_MENU( $self, 12100 + $_, sub {
            my $size = 100 * ($_[1]->GetId - 12100);
            $self->{'config'}->set_value('image_size', $size);
        });
    }
    $image_size_menu->Check( 12100 +($self->{'config'}->get_value('image_size') / 100), 1);

    my $image_format_menu = Wx::Menu->new();
    $image_format_menu->AppendRadioItem(12201, 'PNG', "set default image format to PNG");
    $image_format_menu->AppendRadioItem(12202, 'JPEG', "set default image format to JPEG");
    $image_format_menu->AppendRadioItem(12203, 'SVG', "set default image format to SVG");

    Wx::Event::EVT_MENU( $self, 12201, sub { $self->{'config'}->set_value('file_base_ending', 'png') });
    Wx::Event::EVT_MENU( $self, 12202, sub { $self->{'config'}->set_value('file_base_ending', 'jpg') });
    Wx::Event::EVT_MENU( $self, 12203, sub { $self->{'config'}->set_value('file_base_ending', 'svg') });

    $image_format_menu->Check( 12201, 1 ) if $self->{'config'}->get_value('file_base_ending') eq 'png';
    $image_format_menu->Check( 12202, 1 ) if $self->{'config'}->get_value('file_base_ending') eq 'jpg';
    $image_format_menu->Check( 12203, 1 ) if $self->{'config'}->get_value('file_base_ending') eq 'svg';

    my $image_menu = Wx::Menu->new();
    $image_menu->Append( 12300, "&Draw\tCtrl+D", "complete a sketch drawing" );
    $image_menu->Append( 12100, "S&ize",  $image_size_menu,   "set image size" );
    $image_menu->Append( 12200, "&Format",  $image_format_menu, "set default image formate" );
    $image_menu->Append( 12400, "&Save\tCtrl+S", "save currently displayed image" );

    my $help_menu = Wx::Menu->new();
    $help_menu->Append( 13300, "&About\tAlt+A", "Dialog with general information about the program" );

    my $menu_bar = Wx::MenuBar->new();
    $menu_bar->Append( $settings_menu, '&Settings' );
    $menu_bar->Append( $image_menu,    '&Image' );
    $menu_bar->Append( $help_menu,     '&Help' );
    $self->SetMenuBar($menu_bar);

    Wx::Event::EVT_MENU( $self, 11100, sub { $self->init });
    Wx::Event::EVT_MENU( $self, 11200, sub { $self->open_settings_dialog });
    Wx::Event::EVT_MENU( $self, 11400, sub { $self->write_settings_dialog });
    Wx::Event::EVT_MENU( $self, 11500, sub { $self->Close });
    Wx::Event::EVT_MENU( $self, 12300, sub { $self->draw });
    Wx::Event::EVT_MENU( $self, 12400, sub { $self->save_image_dialog });
    Wx::Event::EVT_MENU( $self, 13300, sub { $self->{'dialog'}{'about'}->ShowModal });

    # GUI layout assembly

lib/App/GUI/Harmonograph/Frame.pm  view on Meta::CPAN

    $self;
}

sub update_recent_settings_menu {
    my ($self) = @_;
    my $recent = $self->{'config'}->get_value('last_settings');
    return unless ref $recent eq 'ARRAY';
    my $set_menu_ID = 11300;
    $self->{'setting_menu'}->Destroy( $set_menu_ID );
    my $Recent_ID = $set_menu_ID + 1;
    $self->{'recent_menu'} = Wx::Menu->new();
    for (reverse @$recent){
        my $path = $_;
        $self->{'recent_menu'}->Append($Recent_ID, $path);
        Wx::Event::EVT_MENU( $self, $Recent_ID++, sub { $self->open_setting_file( $path ) });
    }
    $self->{'setting_menu'}->Insert( 2, $set_menu_ID, '&Recent', $self->{'recent_menu'}, 'recently saved settings' );

}

sub init {



( run in 0.543 second using v1.01-cache-2.11-cpan-49f99fa48dc )