def on_shiftZ_button_click(target, bb, gtkentry, bv, gtkimage): memento = bb.get_memento() shiftby = extract_floats(gtkentry.get_text()) if len( shiftby ) != 1: # something is wrong with user input, notify and do nothing else print("on_shiftZ_button_click : bad input provided for shift") return if not shift(bb, bv, gtkimage, (0, 0, shiftby[0])): print("on_shiftZ_button_click : can't shift past bounding box") return reset_projections() undo_push(memento, 'z')
def on_scaleXYZ_button_click(target, bb, gtkentry, bv, gtkimage): memento = bb.get_memento() scaleby = extract_floats(gtkentry.get_text()) if len( scaleby ) != 1: # something is wrong with user input, notify and do nothing else print("on_scaleXYZ_button_click : bad input provided for scale") return if not bb.scale( scaleby[0] ): # .scale also refreshes Observers if successful (success <=> return True) print("on_scaleXYZ_button_click : can't scale into bounding box") return bb.draw(bv) bv.show(gtkimage) reset_projections() undo_push(memento, 's')
maingrid.attach( smallboxgrid, left = 10, top = 0, width = 3, height = 10 ) # TO DO: attach a GtkLabel for communication with user (want to avoid dependence on terminal) mainwin.add( maingrid ) # extract points and description of enclosing box from file bigbox = None f = open( sys.argv[1], "r" ) # sys.argv[1], as in C, is the first parameter passed by the user (should be filename of file containing points) O = L = None for line in f: if "%" in line: # allow MATLAB-style remarks in the header print( "LAUNCH : ignored line '%s'" % line[:-1] ) continue flts = extract_floats( line ) if len( flts ) != 3: print( "LAUNCH : invalid line in file (probably not bad, usually extra newline)" ) continue if bigbox is None: # inefficient to continue checking nature of line after known to be past "header" if "O" in line or "o" in line: # line describes a corner of the box O = ( flts[0], flts[1], flts[2] ) print( "LAUNCH : successfully read 'O' field" ) continue elif "L" in line or "l" in line: # line describes the box's dimensions L = ( flts[0], flts[1], flts[2] ) print( "LAUNCH : successfully read 'L' field" ) continue assert O is not None, "LAUNCH : 'O' field not found?" assert L is not None, "LAUNCH : 'L' field not found?" bigbox = BigBox( O, L ) # if here, header is completely known and current line (should) contains the first point -- initialize outermost box and fall out of this if-statement