rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
c = tk.Checkbutton(right_frame,text=str(44),variable=option12)
c = tk.Checkbutton(right_frame,text=str(44),variable=option13)
def validedChanges(): """Check for a least one selected kana portion (display of a message if not the case), catch parameters, then close the window.""" if not 1 in temp_list: tkMessageBox.showinfo(str(65),str(66))
label = tk.Label(right_frame,text=str(45)) label.pack(fill="both",expand=1)
frame2 = tk.Frame(right_frame) label = tk.Label(frame2,text=str(45)) label.pack(side="left",expand=1)
def validedChanges(): """Check for a least one selected kana portion (display of a message if not the case), catch parameters, then close the window.""" if not 1 in temp_list: tkMessageBox.showinfo(str(65),str(66))
o = tk.OptionMenu(right_frame,option14,str(46),str(47),str(70),str(48),str(74),str(49),str(50))
o = tk.OptionMenu(frame2,option14,str(46),str(47),str(70),str(48),str(74),str(49),str(50))
def validedChanges(): """Check for a least one selected kana portion (display of a message if not the case), catch parameters, then close the window.""" if not 1 in temp_list: tkMessageBox.showinfo(str(65),str(66))
o.pack(fill="both",expand=1)
o.pack(side="left",expand=1) frame2.pack(fill="both",expand=1)
def validedChanges(): """Check for a least one selected kana portion (display of a message if not the case), catch parameters, then close the window.""" if not 1 in temp_list: tkMessageBox.showinfo(str(65),str(66))
print self.used_kana_list
def randomKana(self,*args): """Randomly choose a kana, respecting many parameters, which will be the right answer."""
opt_lang = {str(46):'en',str(47):'fr',str(48):'pt_BR',str(49):'sv',str(50):'sr','en':str(46),'fr':str(47),'pt_BR':str(48),'sv':str(49),'sr':str(50)}
opt_lang = {str(46):'en',str(47):'fr',str(48):'pt_BR',str(49):'sr',str(50):'sv','en':str(46),'fr':str(47),'pt_BR':str(48),'sr':str(49),'sv':str(50)}
def options(self): #Dicts for integrer to string options convertion and vice-versa... opt_boolean = {0:'false',1:'true','false':0,'true':1} opt_romanization_system = {str(62):"hepburn",str(63):"kunrei-shiki",str(64):"nihon-shiki",'hepburn':str(62),'kunrei-shiki':str(63),'nihon-shiki':str(64)} opt_answer_mode = {str(39)...
if num==0 or num==3: return self.default_kana_list[0] elif num==1 or num==4: return self.default_kana_list[1] elif num==2 or num==5: return self.default_kana_list[2] else: return self.default_kana_list[3]
return self.default_kana_list[num]
def getASet(self,num): """Return a set from its number.""" if num==0 or num==3: return self.default_kana_list[0] elif num==1 or num==4: return self.default_kana_list[1] elif num==2 or num==5: return self.default_kana_list[2] else: return self.default_kana_list[3]
"kwa":"ква", "kwo":"квн","гва",
"kwa":"ква", "kwo":"квн",
def HepburnToOtherSysConvert(kana,outputsys): #Kunrei-shiki/Nihon-shiki common kana values. if outputsys in ("kunrei-shiki","nihon-shiki"): convert = { "shi":"si", "sha":"sya", "shu":"syu", "sho":"syo", "ji":"zi", "ja":"zya", "ju":"zyu", "jo":"zyo", "tsu":"tu", "chi":"ti", "cha":"tya", "chu":"tyu", "cho":"tyo", "fu":"h...
self.checkAnswer(self.answerButt[event.keyval-49]) def main(self,oldbox=None): if self.currentlang!=self.param.val('lang'):
self.check_answer(self.answerButt[event.keyval-49]) def main(self, oldbox=None): if self.currentlang != self.param.val('lang'):
def keypress(self, source, event): widgetNumber = event.keyval - 49 if ((widgetNumber >= 0 and widgetNumber <= self.param.val('list_size')) and self.__dict__.has_key('answerButt') and self.answerButt[widgetNumber]): self.checkAnswer(self.answerButt[event.keyval-49])
self.setKanaImage(self.kanaEngine.getKanaKind(),self.kana)
self.set_kana_image(self.kanaEngine.getKanaKind(), self.kana)
def quiz(self,oldbox): #Defining kana selection parameters. self.kanaEngine.kanaSelectParams( (self.param.val('basic_hiragana'), self.param.val('modified_hiragana'), self.param.val('contracted_hiragana'), self.param.val('basic_katakana'), self.param.val('modified_katakana'), self.param.val('contracted_katakana'), self....
if x[-2:]=="-2": x = x[:-2] self.answerButt[i] = gtk.Button(str(i+1) + ": " + x.upper()) self.answerButt[i].connect("clicked",self.checkAnswer)
if x[-2:] == "-2": x = x[:-2] self.answerButt[i] = gtk.Button("%s: %s" % (str(i + 1), x.upper())) self.answerButt[i].connect("clicked", self.check_answer)
def quiz(self,oldbox): #Defining kana selection parameters. self.kanaEngine.kanaSelectParams( (self.param.val('basic_hiragana'), self.param.val('modified_hiragana'), self.param.val('contracted_hiragana'), self.param.val('basic_katakana'), self.param.val('modified_katakana'), self.param.val('contracted_katakana'), self....
self.newQuestion)
self.new_question)
def quiz(self,oldbox): #Defining kana selection parameters. self.kanaEngine.kanaSelectParams( (self.param.val('basic_hiragana'), self.param.val('modified_hiragana'), self.param.val('contracted_hiragana'), self.param.val('basic_katakana'), self.param.val('modified_katakana'), self.param.val('contracted_katakana'), self....
"clicked",self.checkAnswer,entry) entry.connect("activate",lambda widget: self.nextButton.clicked())
"clicked", self.check_answer,entry) entry.connect("activate", lambda widget: self.nextButton.clicked())
def quiz(self,oldbox): #Defining kana selection parameters. self.kanaEngine.kanaSelectParams( (self.param.val('basic_hiragana'), self.param.val('modified_hiragana'), self.param.val('contracted_hiragana'), self.param.val('basic_katakana'), self.param.val('modified_katakana'), self.param.val('contracted_katakana'), self....
def checkAnswer(self,widget):
def check_answer(self,widget):
def checkAnswer(self,widget): """Check the given answer, update the score and display the result. """
"clicked",self.newQuestion,widget) self.nextButton.grab_focus()
"clicked", self.new_question,widget) self.nextButton.grab_focus()
def checkAnswer(self,widget): """Check the given answer, update the score and display the result. """
def newQuestion(self, widget):
def new_question(self, widget):
def newQuestion(self, widget): #Randomly get a kana. self.kana = self.kanaEngine.randomKana()
self.setKanaImage(self.kanaEngine.getKanaKind(),self.kana)
self.set_kana_image(self.kanaEngine.getKanaKind(), self.kana)
def newQuestion(self, widget): #Randomly get a kana. self.kana = self.kanaEngine.randomKana()
if x[-2:]=="-2": x = x[:-2] self.answerButt[i].set_label(str(i+1) + ": " + x.upper()) self.answerButt[i].show() i+=1 else:
if x[-2:] == "-2": x = x[:-2] self.answerButt[i].set_label("%s: %s" % (str(i + 1), x.upper())) i += 1 else:
def newQuestion(self, widget): #Randomly get a kana. self.kana = self.kanaEngine.randomKana()
"clicked",self.checkAnswer,widget) self.quizWidget['stop'].hide()
"clicked", self.check_answer, widget) self.quizWidget['stop'].hide()
def newQuestion(self, widget): #Randomly get a kana. self.kana = self.kanaEngine.randomKana()
text = "<big>%s</big>\n\n%s\n%s\n%s" % (msg(16),msg(17) % results[0], msg(18) % results[1],msg(19) % results[2]) def getUnrecmsg(kind):
text = "<big>%s</big>\n\n%s\n%s\n%s" % (msg(16), msg(17) % results[0], msg(18) % results[1], msg(19) % results[2]) def get_unrec_msg(kind):
def results(self,data): results = self.score.getResults() #Displaying results. text = "<big>%s</big>\n\n%s\n%s\n%s" % (msg(16),msg(17) % results[0], msg(18) % results[1],msg(19) % results[2])
if len(results[3][0])>0: text += getUnrecmsg(0) if len(results[3][1])>0: text += getUnrecmsg(1)
if len(results[3][0]) > 0: text += get_unrec_msg(0) if len(results[3][1]) > 0: text += get_unrec_msg(1)
def getUnrecmsg(kind): """Return a ready-to-display string which indicates the unrecognized kana (by kind) during the quiz. """ plop = "" for key,val in results[3][kind].items(): for x in val: if key!=1: plop += "%s (%s), " % (x.upper(),key) else: plop += "%s, " % x.upper() return "\n%s" % msg(72+kind) % plop[:-2]
self.main(box) def portions_popup(widget,kanaset): temp_list = list(kanaPortions[kanaset]) def newValue(widget,num): temp_list[num] = (0,1)[widget.get_active()] def selectAll(widget):
self.main(da_box) def portions_popup(widget, kanaset): temp_list = list(kanaPortions[kanaset]) def new_value(widget, num): """Update the emporary variable value.""" temp_list[num] = (0, 1)[widget.get_active()] def select_all(widget):
def callback(widget,special=None): if special=="save": #Update the configuration. self.param.write({ 'basic_hiragana':opt_conv["boolean"][option1.get_active()], 'basic_hiragana_portions':kanaPortions[0], 'modified_hiragana':opt_conv["boolean"][option2.get_active()], 'modified_hiragana_portions':kanaPortions[1], 'contra...
def validedChanges(*args):
def valided_changes(*args):
def validedChanges(*args): """Check for a least one selected kana portion (display of a message if not the case), catch parameters, then close the window.
check.connect("toggled",newValue,i) if temp_list[i]==1: check.set_active(True) if j: table.attach(check,0,1,k,k+1); j=0 else: table.attach(check,1,2,k,k+1); j=1; k+=1
check.connect("toggled", new_value, i) if temp_list[i] == 1: check.set_active(True) if j: table.attach(check, 0, 1, k, k + 1) j=0 else: table.attach(check, 1, 2, k, k + 1) j=1 k+=1
def validedChanges(*args): """Check for a least one selected kana portion (display of a message if not the case), catch parameters, then close the window.
button.connect_object("clicked",selectAll,table)
button.connect_object("clicked", select_all,table)
def validedChanges(*args): """Check for a least one selected kana portion (display of a message if not the case), catch parameters, then close the window.
button = gtk.Button(stock=gtk.STOCK_OK) button.connect("clicked",validedChanges)
button = gtk.Button(stock = gtk.STOCK_OK) button.connect("clicked", valided_changes)
def validedChanges(*args): """Check for a least one selected kana portion (display of a message if not the case), catch parameters, then close the window.
toolbar.insert_item(msg(83), None, None, None, None, None, -1) toolbar.insert_item(msg(84), None, None, None, None, None, -1) toolbar.insert_item(msg(85), None, None, None, None, None, -1) toolbar.insert_item(msg(86), None, None, None, None, None, -1)
for i in range(83, 87): button = gtk.Button(msg(i)) item = gtk.ToolItem() item.add(button) item.set_expand(True) item.set_homogeneous(True) toolbar.insert(item,i - 83)
def validedChanges(*args): """Check for a least one selected kana portion (display of a message if not the case), catch parameters, then close the window.
for val in (msg(76),msg(77),msg(78)): option11.append_text(val)
for x in (76, 77, 78): option11.append_text(msg(x))
def validedChanges(*args): """Check for a least one selected kana portion (display of a message if not the case), catch parameters, then close the window.
for val in (msg(46),msg(47),msg(70),msg(48),msg(74),msg(49),msg(50)): option14.append_text(val)
for x in (46, 47, 70, 48, 74, 49, 50): option14.append_text(msg(x))
def bouyaka(widget,targets): """Set list size widgets sensitive state according to answer mode widget selected param. """ for x in targets: x.set_sensitive(not widget.get_active())
def setKanaImage(self,kind,kana):
def set_kana_image(self,kind,kana):
def setKanaImage(self,kind,kana): """Updating kana image.""" self.kanaImage.set_from_file(os.path.join(self.datarootpath,"img","kana", "%s_%s.gif" % (("k","h")[kind],kana)))
if not self.parts[self.set_num]:
if self.parts[self.set_num]==0:
def randomKana(self,*args): if "true" in args[0]: ok = 0 while not ok: sets = list(args[0]) self.parts = args[1] self.no_repeat = args[2]
self.part = self.used_kana_list[self.set_num][self.part_num]
def randomKana(self,*args): if "true" in args[0]: ok = 0 while not ok: sets = list(args[0]) self.parts = args[1] self.no_repeat = args[2]
if self.no_repeat=="false" and self.previous_kana and (self.previous_kana[0],self.previous_kana[1],self.previous_kana[2])==(self.kind,self.set_num,self.part): self.part.remove(self.previous_kana[3])
def randomKana(self,*args): if "true" in args[0]: ok = 0 while not ok: sets = list(args[0]) self.parts = args[1] self.no_repeat = args[2]
if self.previous_kana: self.part.append(self.previous_kana[3])
while self.kana==self.previous_kana: self.kana = random.choice(self.part)
def randomKana(self,*args): if "true" in args[0]: ok = 0 while not ok: sets = list(args[0]) self.parts = args[1] self.no_repeat = args[2]
else: self.previous_kana = (self.kind,self.set_num,self.part,self.kana)
self.previous_kana = self.kana
def randomKana(self,*args): if "true" in args[0]: ok = 0 while not ok: sets = list(args[0]) self.parts = args[1] self.no_repeat = args[2]
if self.no_repeat=="false": templist.remove(self.kana)
templist.remove(self.kana)
def randomAnswers(self,list_size): #Anwsers will be get from this temporary question set, it is the same kana part than the selected kana. templist = self.getKanaList()[self.set_num][self.part_num] answers = [] #Anwsers' list.
i2r = (self.i2r * self.scale) + self.offset i2g = (self.i2g * self.scale) + self.offset i2b = (self.i2b * self.scale) + self.offset
cm = self.colormap[self.lutName] i2r = (cm[0] * self.scale) + self.offset i2g = (cm[1] * self.scale) + self.offset i2b = (cm[2] * self.scale) + self.offset
def mouseDragged_ (self, event): """ Implement color stretching by modifying the LUT """ (x, y) = event.locationInWindow () visibleRect = self.convertRect_toView_ (self.superview ().bounds (), self) (w, h) = visibleRect.size self.offset = x / w self.scale = (y - h / 2.) / h * MAX_CONTRAST * 2. # Modify a copy of the ...
zoom = self.frameBuffers[frame].zoom
def drawRect_ (self, rect): """ Draw the content of the PyOpenGLView instance on screen. We override this method in order to draw on screen using Quartz 2D directly. """ # glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) frame = self.mapping[self.frameNo] if (not self.frameBuffers[frame] or not self.frameBuffers[f...
x = int (rect.origin.x) y = int (rect.origin.y) w = int (rect.size.width) h = int (rect.size.height) x0 = x + 0 y0 = int (y - int (h))
x = int (rect.origin.x / zoom) y = int (rect.origin.y / zoom) w = int (rect.size.width / zoom) h = int (rect.size.height / zoom) glViewport (x, y, w, h)
def drawRect_ (self, rect): """ Draw the content of the PyOpenGLView instance on screen. We override this method in order to draw on screen using Quartz 2D directly. """ # glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) frame = self.mapping[self.frameNo] if (not self.frameBuffers[frame] or not self.frameBuffers[f...
raw = self.frameBuffers[frame].buffer[y:y+h,x:x+w].tostring () glViewport (x, y, w, h)
endX = int (x + w) endY = int (y + h) raw = self.frameBuffers[frame].buffer[y:endY,x:endX].tostring () glPixelZoom (zoom, zoom)
def drawRect_ (self, rect): """ Draw the content of the PyOpenGLView instance on screen. We override this method in order to draw on screen using Quartz 2D directly. """ # glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) frame = self.mapping[self.frameNo] if (not self.frameBuffers[frame] or not self.frameBuffers[f...
self.setNeedsDisplay_ (True) self.frameNo = newFrameNo
def prev (self): """ Display the image associated with the previous IRAF framebuffer, if any. We need to update self.frameBuffers appropriately! """ newFrameNo = self.frameNo - 1 if (self.mapping.has_key (newFrameNo)): imageID = self.mapping[newFrameNo] if (self.images[imageID]): self.setImage_ (self.images[imageID]...
self.setNeedsDisplay_ (True) self.frameNo = newFrameNo
def next (self): """ Display the image associated with the next IRAF framebuffer, if any. We need to update self.frameBuffers appropriately! """ newFrameNo = self.frameNo + 1 if (self.mapping.has_key (newFrameNo)): imageID = self.mapping[newFrameNo] if (self.images[imageID]): self.setImage_ (self.images[imageID]) se...
def __init__ (self, request, clientAddress, server):
def __init__ (self, request, clientAddress, server, verbose=False):
def __init__ (self, request, clientAddress, server): """ This is the class constructor. It is the Python constructor since we are actually instantiating this object ourselves. """ self.needsUpdate = 0 # these NEED to be set automatically from the client # interaction self.width = None self.height = None self.frameNo = ...
def returnCursor (self, dataout, sx, sy, frame, wcs, key, strval=''): """ writes the cursor position to dataout. input: dataout: the output stream sx: x coordinate sy: y coordinate wcs: nonzero if we want WCS translation frame: frame buffer index key: keystroke used as trigger strv...
def returnCursor (self, dataout, sx, sy, frame, wcs, key, strval=''): """ writes the cursor position to dataout. input: dataout: the output stream sx: x coordinate sy: y coordinate wcs: nonzero if we want WCS translation frame: frame buffer index key: keystroke used as trigger strv...
line = pkt.datain.read (pkt.nbytes)
line = pkt.fromClient (pkt.nbytes)
def handleLut (self, pkt): self.server.controller.updateProgressInfo ('Choosing current frame...', -1) if (pkt.subunit & COMMAND): dataType = str (pkt.nbytes / 2) + 'h' size = struct.calcsize (dataType) line = pkt.datain.read (pkt.nbytes) n = len (line) if (n < pkt.nbytes): return try: x = struct.unpack (dataType, line...
for exctn in sys.exc_info(): sys.stderr.write (exctn)
sys.stderr.write ('Error unpacking the dataType struct.\n') return
def handleLut (self, pkt): self.server.controller.updateProgressInfo ('Choosing current frame...', -1) if (pkt.subunit & COMMAND): dataType = str (pkt.nbytes / 2) + 'h' size = struct.calcsize (dataType) line = pkt.datain.read (pkt.nbytes) n = len (line) if (n < pkt.nbytes): return try: x = struct.unpack (dataType, line...
if (frame < 0 or not fb or not len (fb.buffer)):
if (frame < 0 or not fb or not fb.buffer):
def handleWCS (self, pkt): if (pkt.tid & IIS_READ): self.server.controller.updateProgressInfo ('Writing WCS to client...', -1) # Return the WCS for the referenced frame. if ((pkt.x & 017777) and (pkt.y & 017777)): # return IIS version number text = "version=" + str (IIS_VERSION) text = rightPad (text, SZ_OLD_WCSBUF) el...
pkt.dataout.write (text)
pkt.toClient (text)
def handleWCS (self, pkt): if (pkt.tid & IIS_READ): self.server.controller.updateProgressInfo ('Writing WCS to client...', -1) # Return the WCS for the referenced frame. if ((pkt.x & 017777) and (pkt.y & 017777)): # return IIS version number text = "version=" + str (IIS_VERSION) text = rightPad (text, SZ_OLD_WCSBUF) el...
line = pkt.datain.read (pkt.nbytes)
line = pkt.fromClient (pkt.nbytes)
def handleWCS (self, pkt): if (pkt.tid & IIS_READ): self.server.controller.updateProgressInfo ('Writing WCS to client...', -1) # Return the WCS for the referenced frame. if ((pkt.x & 017777) and (pkt.y & 017777)): # return IIS version number text = "version=" + str (IIS_VERSION) text = rightPad (text, SZ_OLD_WCSBUF) el...
fb.buffer[start:end] = array.array ('B', pkt.datain.read (pkt.nbytes))
fb.buffer[start:end] = array.array ('B', pkt.fromClient (pkt.nbytes))
def handleMemory (self, pkt): if (pkt.tid & IIS_READ): pass else: # get the frame number, we start from 0 self.frameNo = self.decodeFrameNo (pkt.z & 07777) - 1 try: fb = self.server.controller.getFrame (self.frameNo) except: # the selected frame does not exist, create it fb = self.server.controller.initFrame (self.fram...
fb.buffer.fromstring (pkt.datain.read (pkt.nbytes))
fb.buffer.fromstring (pkt.fromClient (pkt.nbytes))
def handleMemory (self, pkt): if (pkt.tid & IIS_READ): pass else: # get the frame number, we start from 0 self.frameNo = self.decodeFrameNo (pkt.z & 07777) - 1 try: fb = self.server.controller.getFrame (self.frameNo) except: # the selected frame does not exist, create it fb = self.server.controller.initFrame (self.fram...
data = array.array ('B', pkt.datain.read (pkt.nbytes))
data = array.array ('B', pkt.fromClient (pkt.nbytes))
def handleMemory (self, pkt): if (pkt.tid & IIS_READ): pass else: # get the frame number, we start from 0 self.frameNo = self.decodeFrameNo (pkt.z & 07777) - 1 try: fb = self.server.controller.getFrame (self.frameNo) except: # the selected frame does not exist, create it fb = self.server.controller.initFrame (self.fram...
self.returnCursor (pkt.dataout, sx, sy, frame, 1, key, '')
self.returnCursor (pkt, sx, sy, frame, 1, key, '')
def handleImcursor (self, pkt): if (pkt.tid & IIS_READ): self.server.controller.updateProgressInfo ('Cursor mode ON', 2) if (pkt.tid & IMC_SAMPLE): # return the cursor position # wcs = int (pkt.z) # (sx, sy, key, frame) = self.server.controller.imageView.getCursor () # frame -= 1 # # self.returnCursor (pkt.dataout, sx...
line = packet.datain.read (size)
line = packet.fromClient (size)
def handle (self): """ This is where the action starts. """ self.server.controller.updateProgressInfo ('Idle.', 2) # create a packet structure packet = IIS () packet.datain = self.rfile packet.dataout = self.wfile # decode the header size = struct.calcsize ('8h') line = packet.datain.read (size) n = len (line) if (n ...
sys.stderr.write ('PYIMTOOL: error unpacking the data.\n') for exctn in sys.exc_info(): sys.stderr.write (exctn)
sys.stderr.write ('PYIMTOOL: error unpacking incoming data.\n') return
def handle (self): """ This is where the action starts. """ self.server.controller.updateProgressInfo ('Idle.', 2) # create a packet structure packet = IIS () packet.datain = self.rfile packet.dataout = self.wfile # decode the header size = struct.calcsize ('8h') line = packet.datain.read (size) n = len (line) if (n ...
line = packet.datain.read (size)
if (self.verbose): print ('Next packet') line = packet.fromClient (size)
def handle (self): """ This is where the action starts. """ self.server.controller.updateProgressInfo ('Idle.', 2) # create a packet structure packet = IIS () packet.datain = self.rfile packet.dataout = self.wfile # decode the header size = struct.calcsize ('8h') line = packet.datain.read (size) n = len (line) if (n ...
line = packet.datain.read (size) n = len (line) continue
return
def handle (self): """ This is where the action starts. """ self.server.controller.updateProgressInfo ('Idle.', 2) # create a packet structure packet = IIS () packet.datain = self.rfile packet.dataout = self.wfile # decode the header size = struct.calcsize ('8h') line = packet.datain.read (size) n = len (line) if (n ...
if (self.verbose): print ('NO-OP')
def handle (self): """ This is where the action starts. """ self.server.controller.updateProgressInfo ('Idle.', 2) # create a packet structure packet = IIS () packet.datain = self.rfile packet.dataout = self.wfile # decode the header size = struct.calcsize ('8h') line = packet.datain.read (size) n = len (line) if (n ...
m = self.rfile.read (n)
m = packet.fromClient (n)
def handle (self): """ This is where the action starts. """ self.server.controller.updateProgressInfo ('Idle.', 2) # create a packet structure packet = IIS () packet.datain = self.rfile packet.dataout = self.wfile # decode the header size = struct.calcsize ('8h') line = packet.datain.read (size) n = len (line) if (n ...
line = packet.datain.read (size)
if (self.verbose): print ('Next packet (last chance)') line = packet.fromClient (size)
def handle (self): """ This is where the action starts. """ self.server.controller.updateProgressInfo ('Idle.', 2) # create a packet structure packet = IIS () packet.datain = self.rfile packet.dataout = self.wfile # decode the header size = struct.calcsize ('8h') line = packet.datain.read (size) n = len (line) if (n ...
def returnCursor (self, dataout, sx, sy, frame, wcs, key, strval=''): """ writes the cursor position to dataout. input: dataout: the output stream
def returnCursor (self, packet, sx, sy, frame, wcs, key, strval=''): """ Write the cursor position to the client. Input: packet: the IIS packet (therefore the output stream)
def returnCursor (self, dataout, sx, sy, frame, wcs, key, strval=''): """ writes the cursor position to dataout. input: dataout: the output stream sx: x coordinate sy: y coordinate wcs: nonzero if we want WCS translation frame: frame buffer index key: keystroke used as trigger strv...
dataout.write (rightPad (curval, SZ_IMCURVAL)) return ()
packet.toClient (rightPad (curval, SZ_IMCURVAL)) if (self.verbose): print ('returnCursor: done') return
def returnCursor (self, dataout, sx, sy, frame, wcs, key, strval=''): """ writes the cursor position to dataout. input: dataout: the output stream sx: x coordinate sy: y coordinate wcs: nonzero if we want WCS translation frame: frame buffer index key: keystroke used as trigger strv...
lutData = file ('/Users/fpierfed/Desktop/heat.lut').readlines ()
lutData = file ('%s/heat.lut' % (RESOURCES_PATH)).readlines ()
def prepareOpenGL (self): """ OpenGL initialization routine """ # setup the LUT lutData = file ('/Users/fpierfed/Desktop/heat.lut').readlines () self.i2r = numarray.zeros (shape=(256), type='Float32') self.i2g = numarray.zeros (shape=(256), type='Float32') self.i2b = numarray.zeros (shape=(256), type='Float32') for i i...
clipView = self.superview () scrollView = self.superview ().superview () frame = self.convertRect_fromView_ (clipView.frame (), scrollView) self.addCursorRect_cursor_ (frame, NSCursor.crosshairCursor ())
visibleRect = self.convertRect_toView_ (self.superview ().bounds (), self) self.addCursorRect_cursor_ (visibleRect, NSCursor.crosshairCursor ())
def resetCursorRects (self): clipView = self.superview () scrollView = self.superview ().superview () frame = self.convertRect_fromView_ (clipView.frame (), scrollView) self.addCursorRect_cursor_ (frame, NSCursor.crosshairCursor ()) return
visibleRect = self.visibleRect ()
visibleRect = self.convertRect_toView_ (self.superview ().bounds (), self)
def reshape (self): """ Sets the receiver's viewport and coordinate system to reflect changes to the visible portion of the view. """ visibleRect = self.visibleRect () superVisibleRect = visibleRect # Conversion captures any scaling in effect superVisibleRect = self.convertRect_toView_ (superVisibleRect, self.supervie...
-1.0, 1.0);
-1.0, 1.0)
def reshape (self): """ Sets the receiver's viewport and coordinate system to reflect changes to the visible portion of the view. """ visibleRect = self.visibleRect () superVisibleRect = visibleRect # Conversion captures any scaling in effect superVisibleRect = self.convertRect_toView_ (superVisibleRect, self.supervie...
print ('zx out of range')
print ('zw out of range')
def drawRect_ (self, rect): """ Draw the content of the PyOpenGLView instance on screen. We override this method in order to draw on screen using Quartz 2D directly. """ frame = self.mapping[self.frameNo] if (not self.frameBuffers[frame] or not self.frameBuffers[frame].raw): return # now = time.time () zoom = self.f...
print ('zy out of range')
print ('zw out of range')
def drawRect_ (self, rect): """ Draw the content of the PyOpenGLView instance on screen. We override this method in order to draw on screen using Quartz 2D directly. """ frame = self.mapping[self.frameNo] if (not self.frameBuffers[frame] or not self.frameBuffers[frame].raw): return # now = time.time () zoom = self.f...
(w, h) = self.visibleRect ().size
visibleRect = self.convertRect_toView_ (self.superview ().bounds (), self) (w, h) = visibleRect.size
def mouseDragged_ (self, event): """ Implement color stretching by modifying the LUT """ (x, y) = event.locationInWindow () (w, h) = self.visibleRect ().size self.offset = x / w self.scale = (y - h / 2.) / h * MAX_CONTRAST * 2. # Modify a copy of the actual color tables i2r = (self.i2r * self.scale) + self.offset i2g...
print (1)
def keyDown_ (self, event): if (not self.reqHandler): print (1) return if (self.sx != None and self.sy != None): mods = event.modifierFlags () if (mods == 256): # remember that the image is flipped vertically imageID = self.mapping[self.frameNo] height = self.frameBuffers[imageID].height key = event.characters ()[0] ...
self.drawRect_ (self.visibleRect ())
self.setNeedsDisplay_ (True)
def setImage_ (self, image): """ Call drawRect_ () ro update the visibleRect of the OpenGL view. """ self.drawRect_ (self.visibleRect ()) return
self.setNeedsDisplay_ (True)
def zoomIn (self): # Get the currently displayed image/frameBuffer imageID = self.mapping[self.frameNo] frameBuffer = self.frameBuffers[imageID] image = self.images[imageID] if (not frameBuffer or not image): return (w0, h0) = (frameBuffer.width, frameBuffer.height) # update the zoom factor frameBuffer.zoom *= 2.0 ...
self.setNeedsDisplay_ (True)
def zoomOut (self): # Get the currently displayed image/frameBuffer imageID = self.mapping[self.frameNo] frameBuffer = self.frameBuffers[imageID] image = self.images[imageID] if (not frameBuffer or not image): return (w0, h0) = (frameBuffer.width, frameBuffer.height) # update the zoom factor frameBuffer.zoom /= 2.0 ...
self.setNeedsDisplay_ (True)
def zoomToFit (self): # Get the currently displayed image/frameBuffer imageID = self.mapping[self.frameNo] frameBuffer = self.frameBuffers[imageID] image = self.images[imageID] if (not frameBuffer or not image): return # get the min between the clip view dimensions (w, h) = self.superview ().frame ()[1] (w0, h0) = (f...
self.setNeedsDisplay_ (True)
def actualSize (self): # Get the currently displayed image/frameBuffer imageID = self.mapping[self.frameNo] frameBuffer = self.frameBuffers[imageID] image = self.images[imageID] if (not frameBuffer or not image): return (w0, h0) = (frameBuffer.width, frameBuffer.height) # update the zoom factor frameBuffer.zoom = 1....
self.colormap = self.initColormaps ()
self.colormap = {} self.initColormaps ()
def awakeFromNib (self): # self.images is the image cache. Every time we are asked to # display an image in a (previously) empty IRAF framebuffer, # we store the image in self.images. This allowes us to switch # between IRAF framebuffers very quickly. self.images = {0: None, 1: None} # Each image in self.images has a ...
cm = {}
def initColormaps (self): cm = {} # scan the colormaps directory for LUTs lutFiles = glob.glob ('%s/colormaps/*.lut' % (RESOURCES_PATH)) for fileName in lutFiles: lutName = os.path.basename (fileName[:-4]) # setup the LUT arrays try: lutData = file (fileName).readlines () except: print ('Cannot read file %s' % (file...
cm[lutName] = [numarray.zeros (shape=(256), type='Float32'),
self.colormap[lutName] = [numarray.zeros (shape=(256), type='Float32'),
def initColormaps (self): cm = {} # scan the colormaps directory for LUTs lutFiles = glob.glob ('%s/colormaps/*.lut' % (RESOURCES_PATH)) for fileName in lutFiles: lutName = os.path.basename (fileName[:-4]) # setup the LUT arrays try: lutData = file (fileName).readlines () except: print ('Cannot read file %s' % (file...
cm[lutName][0][i] = float (r) cm[lutName][1][i] = float (g) cm[lutName][2][i] = float (b)
self.colormap[lutName][0][i] = float (r) self.colormap[lutName][1][i] = float (g) self.colormap[lutName][2][i] = float (b)
def initColormaps (self): cm = {} # scan the colormaps directory for LUTs lutFiles = glob.glob ('%s/colormaps/*.lut' % (RESOURCES_PATH)) for fileName in lutFiles: lutName = os.path.basename (fileName[:-4]) # setup the LUT arrays try: lutData = file (fileName).readlines () except: print ('Cannot read file %s' % (file...
if (cm.has_key (DEFAULT_LUT)):
if (self.colormap.has_key (DEFAULT_LUT)):
def initColormaps (self): cm = {} # scan the colormaps directory for LUTs lutFiles = glob.glob ('%s/colormaps/*.lut' % (RESOURCES_PATH)) for fileName in lutFiles: lutName = os.path.basename (fileName[:-4]) # setup the LUT arrays try: lutData = file (fileName).readlines () except: print ('Cannot read file %s' % (file...
elif (len (cm.keys ())): self.lutName = cm.keys ()[0]
elif (len (self.colormap.keys ())): self.lutName = self.colormap.keys ()[0]
def initColormaps (self): cm = {} # scan the colormaps directory for LUTs lutFiles = glob.glob ('%s/colormaps/*.lut' % (RESOURCES_PATH)) for fileName in lutFiles: lutName = os.path.basename (fileName[:-4]) # setup the LUT arrays try: lutData = file (fileName).readlines () except: print ('Cannot read file %s' % (file...
NSApp ().delegate ().setLuts (lutNames=cm.keys (),
NSApp ().delegate ().setLuts (lutNames=self.colormap.keys (),
def initColormaps (self): cm = {} # scan the colormaps directory for LUTs lutFiles = glob.glob ('%s/colormaps/*.lut' % (RESOURCES_PATH)) for fileName in lutFiles: lutName = os.path.basename (fileName[:-4]) # setup the LUT arrays try: lutData = file (fileName).readlines () except: print ('Cannot read file %s' % (file...
return (cm)
return
def initColormaps (self): cm = {} # scan the colormaps directory for LUTs lutFiles = glob.glob ('%s/colormaps/*.lut' % (RESOURCES_PATH)) for fileName in lutFiles: lutName = os.path.basename (fileName[:-4]) # setup the LUT arrays try: lutData = file (fileName).readlines () except: print ('Cannot read file %s' % (file...
i = int (x) + int (frameBuffer.imgWidth) * int (y)
def mouseMoved_ (self, event): # Get the currently displayed image/frameBuffer imageID = self.mapping[self.frameNo] frameBuffer = self.frameBuffers[imageID] image = self.images[imageID] if (not self.trackMouse or not (frameBuffer and frameBuffer.raw)): return (x, y) = self.convertPoint_fromView_ (event.locationInWind...
v = wcsPixTransform (frameBuffer.ct, frameBuffer.buffer[i])
v = wcsPixTransform (frameBuffer.ct, frameBuffer.buffer[int (x), int (y)])
def mouseMoved_ (self, event): # Get the currently displayed image/frameBuffer imageID = self.mapping[self.frameNo] frameBuffer = self.frameBuffers[imageID] image = self.images[imageID] if (not self.trackMouse or not (frameBuffer and frameBuffer.raw)): return (x, y) = self.convertPoint_fromView_ (event.locationInWind...
self.images = [None, None] self.activeImage = 0 self.frameBuffer = None
self.images = {0: None, 1: None} self.frameBuffers = {0: None, 1: None} self.mapping = {1: 1} self.frameNo = 1 self.hotSpareID = 0 self.reqHandler = None self.sx = None self.sy = None
def awakeFromNib (self): self.images = [None, None] self.activeImage = 0 self.frameBuffer = None self.infoPanel = None self.trackMouse = False self.magnifierActive = False self.transformation = NSAffineTransform.transform () return
def display (self, frameBuffer):
def getHotSpareID (self): return (self.hotSpareID) def setHotSpareID (self, newID): self.hotSpareID = newID return def setReqHandler (self, rh): self.reqHandler = rh self.startTrackingMouse (panel=None) return def display (self, frameBuffer, frameID): """ Build a new image based on the content of frameBuffer. ...
def resetCursorRects (self): clipView = self.superview () scrollView = self.superview ().superview () frame = self.convertRect_fromView_ (clipView.frame (), scrollView) self.addCursorRect_cursor_ (frame, NSCursor.crosshairCursor ()) return
inactive = int (not self.activeImage)
self.frameNo = frameID + 1 self.frameBuffers[self.hotSpareID] = frameBuffer
def display (self, frameBuffer): pool = NSAutoreleasePool.alloc().init() inactive = int (not self.activeImage) try: bitmap = NSBitmapImageRep.alloc () bitmap.initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bytesPerRow_bitsPerPixel_ ( (frameBuffer.buffer, N...
(frameBuffer.buffer, None, None, None, None), frameBuffer.width, frameBuffer.height, frameBuffer.bitsPerSample, frameBuffer.samplesPerPixel, frameBuffer.hasAlpha, frameBuffer.isPlanar, frameBuffer.colorSpaceName, frameBuffer.width, frameBuffer.bitsPerSample * frameBuffer.samplesPerPixel)
(self.frameBuffers[self.hotSpareID].buffer, None, None, None, None), self.frameBuffers[self.hotSpareID].width, self.frameBuffers[self.hotSpareID].height, self.frameBuffers[self.hotSpareID].bitsPerSample, self.frameBuffers[self.hotSpareID].samplesPerPixel, self.frameBuffers[self.hotSpareID].hasAlpha, self.frameBuffers[s...
def display (self, frameBuffer): pool = NSAutoreleasePool.alloc().init() inactive = int (not self.activeImage) try: bitmap = NSBitmapImageRep.alloc () bitmap.initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bytesPerRow_bitsPerPixel_ ( (frameBuffer.buffer, N...
self.images[inactive] = NSImage.alloc ().init () self.images[inactive].addRepresentation_ (bitmap)
self.images[self.hotSpareID] = NSImage.alloc ().init () self.images[self.hotSpareID].addRepresentation_ (bitmap)
def display (self, frameBuffer): pool = NSAutoreleasePool.alloc().init() inactive = int (not self.activeImage) try: bitmap = NSBitmapImageRep.alloc () bitmap.initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bytesPerRow_bitsPerPixel_ ( (frameBuffer.buffer, N...
self.setFrameSize_ ((frameBuffer.width, frameBuffer.height)) self.setImage_ (self.images[inactive]) self.frameBuffer = frameBuffer
self.setFrameSize_ ((self.frameBuffers[self.hotSpareID].width, self.frameBuffers[self.hotSpareID].height)) self.setImage_ (self.images[self.hotSpareID])
def display (self, frameBuffer): pool = NSAutoreleasePool.alloc().init() inactive = int (not self.activeImage) try: bitmap = NSBitmapImageRep.alloc () bitmap.initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bytesPerRow_bitsPerPixel_ ( (frameBuffer.buffer, N...
if (self.images[self.activeImage]): self.images[self.activeImage].autorelease () self.activeImage = inactive
if (self.mapping.has_key (self.frameNo)): oldID = self.mapping[self.frameNo] if (self.images[oldID]): del (self.images[oldID]) if (self.frameBuffers[oldID]): self.frameBuffers[oldID] = None self.mapping[self.frameNo] = self.hotSpareID self.hotSpareID = oldID else: self.mapping[self.frameNo] = self.hotSpareID ...
def display (self, frameBuffer): pool = NSAutoreleasePool.alloc().init() inactive = int (not self.activeImage) try: bitmap = NSBitmapImageRep.alloc () bitmap.initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bytesPerRow_bitsPerPixel_ ( (frameBuffer.buffer, N...
if (not self.trackMouse or not (self.frameBuffer and self.frameBuffer.buffer)):
imageID = self.mapping[self.frameNo] frameBuffer = self.frameBuffers[imageID] image = self.images[imageID] if (not self.trackMouse or not (frameBuffer and frameBuffer.buffer)):
def mouseMoved_ (self, event): if (not self.trackMouse or not (self.frameBuffer and self.frameBuffer.buffer)): return (x, y) = self.convertPoint_fromView_ (event.locationInWindow (), None) frame = self.frame () view_rect = self.superview ().frame () view_rect = self.convertRect_fromView_ (view_rect, self.superview (...
if (not self.magnifierActive):
if (self.infoPanel and not self.magnifierActive):
def mouseMoved_ (self, event): if (not self.trackMouse or not (self.frameBuffer and self.frameBuffer.buffer)): return (x, y) = self.convertPoint_fromView_ (event.locationInWindow (), None) frame = self.frame () view_rect = self.superview ().frame () view_rect = self.convertRect_fromView_ (view_rect, self.superview (...
x /= self.frameBuffer.zoom y /= self.frameBuffer.zoom
x /= frameBuffer.zoom y /= frameBuffer.zoom
def mouseMoved_ (self, event): if (not self.trackMouse or not (self.frameBuffer and self.frameBuffer.buffer)): return (x, y) = self.convertPoint_fromView_ (event.locationInWindow (), None) frame = self.frame () view_rect = self.superview ().frame () view_rect = self.convertRect_fromView_ (view_rect, self.superview (...
(self.sx, self.sy) = wcsCoordTransform (self.frameBuffer.ct, x, y)
(self.sx, self.sy) = wcsCoordTransform (frameBuffer.ct, x, y)
def mouseMoved_ (self, event): if (not self.trackMouse or not (self.frameBuffer and self.frameBuffer.buffer)): return (x, y) = self.convertPoint_fromView_ (event.locationInWindow (), None) frame = self.frame () view_rect = self.superview ().frame () view_rect = self.convertRect_fromView_ (view_rect, self.superview (...
self.infoPanel.setField ('x', self.sx) self.infoPanel.setField ('y', self.sy) except: print ('ops!') pass i = int (x) + int (self.frameBuffer.imgWidth) * int (y) z1 = min (self.frameBuffer.ct.z1, self.frameBuffer.ct.z2) z2 = max (self.frameBuffer.ct.z1, self.frameBuffer.ct.z2) try: v = wcsPixTransform (self.frameBuf...
v = wcsPixTransform (frameBuffer.ct, frameBuffer.buffer[i])
def mouseMoved_ (self, event): if (not self.trackMouse or not (self.frameBuffer and self.frameBuffer.buffer)): return (x, y) = self.convertPoint_fromView_ (event.locationInWindow (), None) frame = self.frame () view_rect = self.superview ().frame () view_rect = self.convertRect_fromView_ (view_rect, self.superview (...
try: if (v >= z2): self.infoPanel.setField ('int', unicode ("\263 %.4f" % (z2), 'mac_roman')) return if (v <= z1): self.infoPanel.setField ('int', unicode ("\262 %.4f" % (z1), 'mac_roman')) return else: self.infoPanel.setField ('int', "%.4f" % (v)) return except: pass
if (self.infoPanel): try: if (v >= z2): self.infoPanel.setField ('int', unicode ("\263 %.4f" % (z2), 'mac_roman')) return if (v <= z1): self.infoPanel.setField ('int', unicode ("\262 %.4f" % (z1), 'mac_roman')) return else: self.infoPanel.setField ('int', "%.4f" % (v)) return except: pass
def mouseMoved_ (self, event): if (not self.trackMouse or not (self.frameBuffer and self.frameBuffer.buffer)): return (x, y) = self.convertPoint_fromView_ (event.locationInWindow (), None) frame = self.frame () view_rect = self.superview ().frame () view_rect = self.convertRect_fromView_ (view_rect, self.superview (...
try: self.infoPanel.setField ('x', '---') self.infoPanel.setField ('y', '---') self.infoPanel.setField ('int', '---') if (self.magnifierActive): self.infoPanel.disableMagnifier () self.magnifierActive = False except: pass
if (self.infoPanel): try: self.infoPanel.setField ('x', '---') self.infoPanel.setField ('y', '---') self.infoPanel.setField ('int', '---') if (self.magnifierActive): self.infoPanel.disableMagnifier () self.magnifierActive = False except: pass
def mouseMoved_ (self, event): if (not self.trackMouse or not (self.frameBuffer and self.frameBuffer.buffer)): return (x, y) = self.convertPoint_fromView_ (event.locationInWindow (), None) frame = self.frame () view_rect = self.superview ().frame () view_rect = self.convertRect_fromView_ (view_rect, self.superview (...
Strats treacking the mouse and updates the cursor fields in
Start treacking the mouse and updates the cursor fields in
def startTrackingMouse (self, panel): """ Strats treacking the mouse and updates the cursor fields in the info window. """ self.infoPanel = panel self.trackMouse = True if (self.frameBuffer and self.frameBuffer.buffer): # set the name, title and extension fields self.infoPanel.setField ('name', self.frameBuffer.ct.ref...