Ignore:
Timestamp:
Jun 11, 2005 9:56:37 PM (19 years ago)
Author:
mmc
Message:

Added a capability to MainWin? to syncCutBuffer with the
application. The VNC Java client uses the cutbuffer
instead of the selection for Copy/Paste? to desktop, and
this mechanism keeps the two in sync so Copy/Paste? works
properly. Also, added Cut/Copy/Paste? menus to the right
mouse button of various widgets.

Fixed 3D plotting to work with the vtkCutter so it works
better. Also, added support for 3D meshes in addition
to clouds. Meshes store connectivity, so they are better
at representing holes in data. Fixed the 3D plotter so
that rotate is more intuitive, and added lights so you can
see your data better at any angle.

Fixed the loader so that it can load elements with the ""
value, and so that it doesn't duplicate entries found
more than once by *.xml pattern matching.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/mainwin.tcl

    r13 r17  
    1313# ======================================================================
    1414package require Itk
     15package require BLT
    1516
    1617option add *MainWin.mode desktop widgetDefault
     
    3132
    3233    public method draw {option args}
     34    public method syncCutBuffer {option args}
    3335
    3436    protected method _redraw {}
    3537
    3638    private variable _contents ""  ;# frame containing app
     39    private variable _sync         ;# to sync current selection and cut buffer
    3740    private variable _bgscript ""  ;# script of background drawing cmds
    3841    private variable _bgparser ""  ;# parser for bgscript
     
    9699    set btags [bindtags $itk_component(hull)]
    97100    bindtags $itk_component(hull) [lappend btags RapptureMainWin]
     101
     102    set _sync(cutbuffer) ""
     103    set _sync(selection) ""
     104    syncCutBuffer ifneeded
     105}
     106
     107# ----------------------------------------------------------------------
     108# USAGE: syncCutBuffer ifneeded
     109# USAGE: syncCutBuffer transfer <offset> <maxchars>
     110# USAGE: syncCutBuffer lostselection
     111#
     112# Invoked automatically whenever the mouse pointer enters or leaves
     113# a main window to sync the cut buffer with the primary selection.
     114# This helps applications work properly with the "Copy/Paste with
     115# Desktop" option on the VNC applet for the nanoHUB.
     116#
     117# The "ifneeded" option syncs the cutbuffer and the primary selection
     118# if either one has new data.
     119#
     120# The "fromselection" option syncs from the primary selection to the
     121# cut buffer.  If there's a primary selection, it gets copied to the
     122# cut buffer.
     123# ----------------------------------------------------------------------
     124itcl::body Rappture::MainWin::syncCutBuffer {option args} {
     125    set mainwin $itk_component(hull)
     126    switch -- $option {
     127        ifneeded {
     128            #
     129            # See if the incoming cut buffer has changed.
     130            # If so, then sync the new input to the primary selection.
     131            #
     132            set s [blt::cutbuffer get]
     133            if {"" != $s && ![string equal $s $_sync(cutbuffer)]} {
     134                set _sync(cutbuffer) $s
     135
     136                if {![string equal $s $_sync(selection)]
     137                      && [selection own -selection PRIMARY] != $mainwin} {
     138                    set _sync(selection) $s
     139
     140                    clipboard clear
     141                    clipboard append -- $s
     142                    selection handle -selection PRIMARY $mainwin \
     143                        [itcl::code $this syncCutBuffer transfer]
     144                    selection own -selection PRIMARY -command \
     145                        [itcl::code $this syncCutBuffer lostselection] \
     146                        $mainwin
     147                }
     148            }
     149
     150            #
     151            # See if the selection has changed.  If so, then sync
     152            # the new input to the cut buffer, so it's available
     153            # outside the VNC client.
     154            #
     155            set s ""
     156            if {[catch {selection get -selection PRIMARY} s] || "" == $s} {
     157                if {[catch {clipboard get} s]} {
     158                    set s ""
     159                }
     160            }
     161            if {"" != $s && ![string equal $s $_sync(selection)]} {
     162                set _sync(selection) $s
     163                blt::cutbuffer set $s
     164            }
     165
     166            # do this again soon
     167            after 1000 [itcl::code $this syncCutBuffer ifneeded]
     168        }
     169        transfer {
     170            if {[llength $args] != 2} {
     171                error "wrong # args: should be \"syncCutBuffer transfer offset max\""
     172            }
     173            set offset [lindex $args 0]
     174            set maxchars [lindex $args 1]
     175            return [string range $_currseln $offset [expr {$offset+$maxchars-1}]]
     176        }
     177        lostselection {
     178            # nothing to do
     179        }
     180        default {
     181            error "bad option \"$option\": should be ifneeded, transfer, or lostselection"
     182        }
     183    }
    98184}
    99185
     
    127213        }
    128214
     215        set bd 0  ;# optional border
    129216        set sw [winfo width $itk_component(area)]
    130217        set sh [winfo height $itk_component(area)]
     
    133220        set w [winfo reqwidth $itk_component(app)]
    134221        set h [winfo reqheight $itk_component(app)]
    135         if {$w > $sw} {
    136             set $w $sw
     222        if {$w > $sw-2*$bd} {
     223            set $w [expr {$sw-2*$bd}]
    137224            set clip 1
    138225        }
     
    141228            n {
    142229                set x [expr {$sw/2}]
    143                 set y 0
     230                set y $bd
    144231            }
    145232            s {
    146233                set x [expr {$sw/2}]
    147                 set y $sh
     234                set y [expr {$sh-$bd}]
    148235            }
    149236            center {
     
    152239            }
    153240            w {
    154                 set x 0
     241                set x $bd
    155242                set y [expr {$sh/2}]
    156243            }
    157244            e {
    158                 set x $sw
     245                set x [expr {$sw-$bd}]
    159246                set y [expr {$sh/2}]
    160247            }
    161248            nw {
    162                 set x 0
    163                 set y 0
     249                set x $bd
     250                set y $bd
    164251            }
    165252            ne {
    166                 set x $sw
    167                 set y 0
     253                set x [expr {$sw-$bd}]
     254                set y $bd
    168255            }
    169256            sw {
    170                 set x 0
    171                 set y $sh
     257                set x $bd
     258                set y [expr {$sh-$bd}]
    172259            }
    173260            se {
    174                 set x $sw
    175                 set y $sh
     261                set x [expr {$sw-$bd}]
     262                set y [expr {$sh-$bd}]
    176263            }
    177264        }
Note: See TracChangeset for help on using the changeset viewer.