Package qubx :: Module toolspace
[hide private]
[frames] | no frames]

Module toolspace

source code

Widget with switchable mouse controllers (Tools) and transparent overlays and layers.

Colors are given as a pair: COLORREF=(name_for_prefs, (r,g,b,a)). (r,g,b,a) is the initial default. Each time it draws, a ToolSpace looks up its colors (and font) in self.appearance (type TS_Appearance):

>>> r,g,b,a = self.appearance.color(COLORREF)

You can change the color:

>>> self.appearance.colors[COLORREF].set( (r,g,b,a) )

Or swap in a different TS_Appearance, e.g. for black and white printing:

>>> set_aside, self.appearance = self.appearance, black_and_white_appearance

Appearance prefs are saved by qubx.util_panels.SettingsFace.

Layers and sublayers are laid out statically, in multiples of appearance.emsize. Negative coordinates or dimensions indicate distance from the right or bottom edge. When font size or widget dimensions change, it updates the layout.

Copyright 2008-2014 Research Foundation State University of New York This file is part of QUB Express.

QUB Express is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

QUB Express is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License, named LICENSE.txt, in the QUB Express program directory. If not, see <http://www.gnu.org/licenses/>.

Classes [hide private]
  TS_Color
Represents one named color.
  TS_Appearance
Holds color and font preferences.
  TS_ColorsDialog
Modeless window for changing the (r,g,b,a) values in appearance.colors.
  ToolSpace
Base widget with these features:
  ToolSpace_GL
  GLSpace
Base widget with these features:
  LayerSet
  Tool
Receives mouse events from a ToolSpace.
  Layer
A floating, transparent, clickable area in a ToolSpace.
  SubLayer
A specific display element or control on a Layer in a ToolSpace.
  RotRect
Represents a rectangle that has been rotated theta radians about (x0, y0).
  OverlayRgnTool
Base class for a Tool which defines RotRect regions of interest.
  OverlayRgnCaptionedTool
Base class for a Tool which presents a message and highlights regions of interest.
  Spotlight
Demo tool to shine a spotlight on a ToolSpace.
  Layer_Toolbar
Layer containing a row or column of buttons; automatically laid out; spotlighted on rollover with tooltips.
  Overlay_Tooltip
Draws a tool-tip on a ToolSpace.
  SubLayer_Label
Displays a string of text.
  SubLayer_UpDown
The little up and down buttons, such as next to a number.
  SubLayer_Check
A box that is active or not; click to toggle.
  SubLayer_Popup
A circle with inscribed triangle, which shows a menu when clicked.
  Button_Popup
  Button_Popup_PNG
  SubLayer_MenuLines
A collection of horizontal lines, which shows a menu when clicked.
  Button_MenuLines
  SubLayer_DropDown
A combo-box in the style of csDropDownList (enumerated choices only).
  Tool_DropDown
Displays a drop-down menu (from SubLayer_DropDown) and handles mouse clicks.
  SubLayer_Range
A slightly nonstandard scroll bar; grab the left or right edge to resize the thumb.
  SubLayer_Mag
Draws a magnifying glass under the label.
  SubLayer_PNG
  SubLayer_Popup_PNG
  SubLayer_Icon
A little icon suitable for Layer_Toolbar.
  SubLayer_Ruler
A little yellow ruler icon.
  SubLayer_Eraser
An eraser icon.
  SubLayer_Stamp
A rubber stamp icon.
  SubLayer_Arrow
An arrow.
  SubLayer_Progress
Progress bar, from 0 to 100.
  SubLayer_Radio
Label with radio button behavior.
  Palette
  SubLayer_SmoothZoom
  SubLayer_PanIcon
Functions [hide private]
 
EditOneColor(colorref, caption='Pick a color', appearance=None)
Runs a modal dialog so the user can change one color in the prefs.
source code
 
activate_cursor(space, cursor, counter=0) source code
 
ignore_event(*args) source code
 
draw_stamp(context, w, h, appearance) source code
 
COLOR_CLASS(c) source code
 
draw_pan_icon(cr, w, h) source code
 
measure_string(cr, points, s) source code
Variables [hide private]
  gtkHas2Click = False
  DBL_CLICK_MS = 250
  ColorInfo = defaultdict(<function <lambda> at 0x7fd123474500>,...
  LAYER_BG = ('toolspace.layer.bg', (0.12, 0.12, 0.12, 0.85))
  LAYER_FG = ('toolspace.layer.fg', (0.1, 1, 0.1, 0.9))
  LAYER_BORDER = ('toolspace.layer.border', (0.5, 0.5, 0.5, 0.5))
  COLOR_CLEAR = ('toolspace.clear', (0, 0, 0, 0))
  COLOR_BLACK = ('toolspace.black', (0, 0, 0, 1))
  COLOR_WHITE = ('toolspace.white', (1, 1, 1, 1))
  COLOR_LABEL = ('toolspace.label', (0.1, 1, 0.1, 0.9))
  COLOR_HOVER = ('toolspace.label.hover', (0.1, 1, 0.1, 0.9))
  COLOR_POPUP = ('toolspace.popup', (0, 0, 1, 1))
  COLOR_DROPDOWN = ('toolspace.dropdown', (0.1, 1, 0.1, 0.9))
  COLOR_RANGE = ('toolspace.range', (0.1, 0.5, 0.7, 0.5))
  COLOR_RANGE_HOVER = ('toolspace.range.hover', (0.2, 0.7, 1, 0.6))
  COLOR_RANGE_EXPAND = ('toolspace.range.expand', (1, 0.2, 0.8, ...
  COLOR_TOOLTIP_BG = ('toolspace.tooltip.bg', (1, 1, 0.3, 0.8))
  COLOR_TOOLTIP_FG = ('toolspace.tooltip.fg', (0, 0, 0, 0.85))
  COLOR_CHECK = ('toolspace.check', (1, 0.5, 0, 0.8))
  COLOR_PALETTE_TEXT = ('toolspace.palette.text', (1, 1, 1, 1))
  COLOR_PALETTE_MORE = ('toolspace.palette.more', (0.1, 0.1, 0.1...
  COLOR_RADIO_FILL = ('toolspace.radio.fill', (1, 0.5, 0, 0.8))
  COLOR_FOCUSED = ('toolspace.focused', (0.75, 0.45, 1, 0.5))
  COLOR_MAG_RIM = ('toolspace.mag.rim', (1, 1, 1, 0.8))
  COLOR_MAG_LENS = ('toolspace.mag.lens', (1, 1, 1, 0.35))
  PALETTE_H_EMS = 2.3
  TOOLBAR_PAD = 0.5
  Appearance = <qubx.toolspace.TS_Appearance object>
  glprefs_path = os.path.join(__main__.QUBX_HOME_PATH, 'Presets'...
  wanted = True
  HAVE_OPENGL = False
  COLOR = defaultdict(<function <lambda> at 0x7fd12349c2a8>, {0:...
  offset = 7
  ZOOM_FACTOR = 1.02
  ZOOM_FACTOR_PER_PIXEL = 0.001
  ZOOM_DELAY_MS = 20
  COLOR_ZOOM = ('qubx.toolspace.zoom', (0, 0, 0, 1))
  COLOR_ZOOM_HOVER = ('qubx.toolspace.zoom.hover', (0.5, 0, 0, 1))
  __package__ = 'qubx'
  c = (1, 0, 1)
  e = 2.71828182846
  i = 19
  pi = 3.14159265359
  rdbk = 'Expired.'
  rdbreak = 'supporting'
  rdname = 'qubfast.txt'
Variables Details [hide private]

ColorInfo

Value:
defaultdict(<function <lambda> at 0x7fd123474500>, {'qubx.cube.other.m\
enu': {'label': 'Other panel menu'}, 'scope.signal.bg': {'label': 'Dat\
a signal background'}, 'scope.mean.line': {'label': 'Data center line'\
}, 'toolspace.layer.bg': {'label': 'Default layer background'}, 'list_\
figure.fit': {'label': 'ListFigure fit curves'}, 'data_fit.button': {'\
label': 'Data curvefit buttons'}, 'toolspace.focused': {'label': 'Pane\
l border focused'}, 'modelGTK.state.label': {'label': 'Model state lab\
el'}, 'scope.units.hover': {'label': 'Data units mouseover'}, 'dataGTK\
...

COLOR_RANGE_EXPAND

Value:
('toolspace.range.expand', (1, 0.2, 0.8, 0.9))

COLOR_PALETTE_MORE

Value:
('toolspace.palette.more', (0.1, 0.1, 0.1, 1))

glprefs_path

Value:
os.path.join(__main__.QUBX_HOME_PATH, 'Presets', 'Appearance', '__acti\
ve.qpr')

COLOR

Value:
defaultdict(<function <lambda> at 0x7fd12349c2a8>, {0: (0, 0, 0), 1: (\
1, 0, 0), 2: (0, 0, 1), 3: (0, 1, 0), 4: (0, 1, 1), 5: (1, 1, 0), 6: (\
1, 0, 1), 7: (0.5, 0.0, 0.0), 8: (0.525, 0.32025, 0.013125000000000012\
), 9: (0.44550000000000006, 0.55, 0.027500000000000028), 10: (0.149499\
99999999994, 0.575, 0.04312499999999997), 11: (0.059999999999999984, 0\
.6, 0.2759999999999999), 12: (0.078125, 0.625, 0.625), 13: (0.09750000\
000000002, 0.3185, 0.65), 14: (0.22949999999999962, 0.1181250000000000\
4, 0.675), 15: (0.5879999999999999, 0.13999999999999996, 0.7), 16: (0.\
...