def _drawDnaRubberbandLine(self): handleType = '' if self.command.grabbedHandle is not None: if self.command.grabbedHandle in [ self.command.rotationHandle1, self.command.rotationHandle2 ]: handleType = 'ROTATION_HANDLE' else: handleType = 'RESIZE_HANDLE' if handleType and handleType == 'RESIZE_HANDLE': params = self.command.getDnaRibbonParams() if params: end1, end2, basesPerTurn, duplexRise, ribbon1_start_point, \ ribbon2_start_point, ribbon1_direction, ribbon2_direction,\ ribbon1Color, ribbon2Color = params #Note: The displayStyle argument for the rubberband line should #really be obtained from self.command.struct. But the struct #is a DnaSegment (a Group) and doesn't have attr 'display' #Should we then obtain this information from one of its strandChunks? #but what if two strand chunks and axis chunk are rendered #in different display styles? since situation may vary, lets #use self.glpane.displayMode for rubberbandline displayMode drawDnaRibbons( self.glpane, end1, end2, basesPerTurn, duplexRise, self.glpane.scale, self.glpane.lineOfSight, self.glpane.displayMode, ribbonThickness=4.0, ribbon1_start_point=ribbon1_start_point, ribbon2_start_point=ribbon2_start_point, ribbon1_direction=ribbon1_direction, ribbon2_direction=ribbon2_direction, ribbon1Color=ribbon1Color, ribbon2Color=ribbon2Color, ) #Draw the text next to the cursor that gives info about #number of base pairs etc self._drawCursorText() return
def _drawDnaRubberbandLine(self): handleType = '' if self.command.grabbedHandle is not None: if self.command.grabbedHandle in [self.command.rotationHandle1, self.command.rotationHandle2]: handleType = 'ROTATION_HANDLE' else: handleType = 'RESIZE_HANDLE' if handleType and handleType == 'RESIZE_HANDLE': params = self.command.getDnaRibbonParams() if params: end1, end2, basesPerTurn, duplexRise, ribbon1_start_point, \ ribbon2_start_point, ribbon1_direction, ribbon2_direction,\ ribbon1Color, ribbon2Color = params #Note: The displayStyle argument for the rubberband line should #really be obtained from self.command.struct. But the struct #is a DnaSegment (a Group) and doesn't have attr 'display' #Should we then obtain this information from one of its strandChunks? #but what if two strand chunks and axis chunk are rendered #in different display styles? since situation may vary, lets #use self.glpane.displayMode for rubberbandline displayMode drawDnaRibbons(self.glpane, end1, end2, basesPerTurn, duplexRise, self.glpane.scale, self.glpane.lineOfSight, self.glpane.displayMode, ribbonThickness = 4.0, ribbon1_start_point = ribbon1_start_point, ribbon2_start_point = ribbon2_start_point, ribbon1_direction = ribbon1_direction, ribbon2_direction = ribbon2_direction, ribbon1Color = ribbon1Color, ribbon2Color = ribbon2Color, ) #Draw the text next to the cursor that gives info about #number of base pairs etc self._drawCursorText() return
def _drawDnaRubberbandLine(self): """ Overrides superclass method. It loops through the segments being resized and draws the rubberband lines for all. NOT this could be SLOW @see: MultipleDnaSegmentResize_EditCommand.getDnaRibbonParams() for comments. @TODO: needs more cleanup """ handleType = '' if self.command.grabbedHandle is not None: if self.command.grabbedHandle in [ self.command.rotationHandle1, self.command.rotationHandle2 ]: handleType = 'ROTATION_HANDLE' else: handleType = 'RESIZE_HANDLE' if handleType and handleType == 'RESIZE_HANDLE': for segment in self.command.getResizeSegmentList(): self.command.currentStruct = segment params_when_adding_bases, params_when_removing_bases = \ self.command.getDnaRibbonParams() self.command.currentStruct = None if params_when_adding_bases: numberOfBasePairs,\ end1, \ end2, \ basesPerTurn,\ duplexRise, \ ribbon1_start_point, \ ribbon2_start_point, \ ribbon1_direction, \ ribbon2_direction, \ ribbon1Color, \ ribbon2Color = params_when_adding_bases #Note: The displayStyle argument for the rubberband line should #really be obtained from self.command.struct. But the struct #is a DnaSegment (a Group) and doesn't have attr 'display' #Should we then obtain this information from one of its strandChunks? #but what if two strand chunks and axis chunk are rendered #in different display styles? since situation may vary, lets #use self.glpane.displayMode for rubberbandline displayMode drawDnaRibbons(self.glpane, end1, end2, basesPerTurn, duplexRise, self.glpane.scale, self.glpane.lineOfSight, self.glpane.displayMode, ribbonThickness=4.0, ribbon1_start_point=ribbon1_start_point, ribbon2_start_point=ribbon2_start_point, ribbon1_direction=ribbon1_direction, ribbon2_direction=ribbon2_direction, ribbon1Color=ribbon1Color, ribbon2Color=ribbon2Color, stepColor=black) #Draw a sphere that indicates the current position of #the resize end of each segment . drawsphere(env.prefs[selectionColor_prefs_key], end2, SPHERE_RADIUS_2, SPHERE_DRAWLEVEL, opacity=SPHERE_OPACITY) numberOfBasePairsString = "+" + str(numberOfBasePairs) self.glpane.renderTextAtPosition(end2, numberOfBasePairsString) elif params_when_removing_bases: numberOfBasePairs, end2 = params_when_removing_bases #Draw a sphere that indicates the current position of #the resize end of each segment. drawsphere(darkred, end2, SPHERE_RADIUS_2, SPHERE_DRAWLEVEL, opacity=SPHERE_OPACITY) numberOfBasePairsString = str(numberOfBasePairs) self.glpane.renderTextAtPosition( end2, textString=numberOfBasePairsString, ) #Draw the text next to the cursor that gives info about #number of base pairs etc self._drawCursorText()
def Draw_other(self): """ Draw the DNA rubberband line (a ladder representation) """ #The rubberband line display needs to be a user preference. #Example: There could be 3 radio buttons in the duplex PM that allows #you to draw the rubberband line as a simple line, a line with points #that indicate duplexrise, a dna ladder with arrow heads. Drawing it as #a ladder with arrow heads for the beams is the current implementation # -Ninad 2007-10-30 #@see: Line_GraphicsMode class definition about this flag. Basically we suppress #cursor text drawing in the superclass and draw later in this method #after everyting is drawn. # [update, bruce 090310. This could use refactoring. Not urgent.] self._ok_to_render_cursor_text = False _superclass_for_GM.Draw_other(self) self._ok_to_render_cursor_text = True #This fixes NFR bug 2803 #Don't draw the Dna rubberband line if the cursor is over the confirmation #corner. But make sure to call superclass.Draw_other method before doing this #check because we need to draw the rest of the model in the graphics #mode!. @see: Line_GraphicsMode.Draw_other # [update, bruce 090310: that superclass call no longer draws the model, # but might still be needed for other reasons. Also, how this is implemented # is questionable; see longer review comment in the superclass.] handler = self.o.mouse_event_handler if handler is not None and handler is self._ccinstance: return if self.endPoint2 is not None and \ self.endPoint1 is not None: #Draw the ladder. #Convention: # The red band(beam) of the # ladder is always the 'leading edge' of the ladder. i.e. the red # band arrow head is always at the moving end of the mouse #(endpoint2). # A General Note/ FYI to keep in mind: # Consider a double stranded DNA and focus on the 'twin peaks' #(say, two consecutive helices in the middle of the dna duplex) # From the "mountain" with twin peaks that is the minor groove, # the DNA flows downhill 5' to 3' # Or in other words, # - For the 'mountain peak' on the right , # the 5' to 3' flows downhill, from left to right. # - For the 'mountain peak' on the left, # the 3' to 5' flows downhill, from right to left # # Thus, the red beam of the ladder, can either become the # 'left mountain' or the 'right mountain' depending on the # orientation while drawing the ladder if self.command.callback_rubberbandLineDisplay() == 'Ladder': # Note: there needs to be a radio button to switch on the # rubberband ladder display for a dna line. At the moment it is # disabled and is superseded by the ribbons ruberband display. drawDnaLadder(self.endPoint1, self.endPoint2, self.command.duplexRise, self.glpane.scale, self.glpane.lineOfSight, beamThickness = 4.0, beam1Color = env.prefs[dnaDefaultStrand1Color_prefs_key], beam2Color = env.prefs[dnaDefaultStrand2Color_prefs_key], ) elif self.command.callback_rubberbandLineDisplay() == 'Ribbons': #Default dna rubberband line display style drawDnaRibbons(self.glpane, self.endPoint1, self.endPoint2, self.command.basesPerTurn, self.command.duplexRise, self.glpane.scale, self.glpane.lineOfSight, self.glpane.displayMode, ribbonThickness = 4.0, ribbon1Color = env.prefs[dnaDefaultStrand1Color_prefs_key], ribbon2Color = env.prefs[dnaDefaultStrand2Color_prefs_key], ) else: pass self._drawCursorText() pass return
def _drawDnaRubberbandLine(self): """ Overrides superclass method. It loops through the segments being resized and draws the rubberband lines for all. NOT this could be SLOW @see: MultipleDnaSegmentResize_EditCommand.getDnaRibbonParams() for comments. @TODO: needs more cleanup """ handleType = '' if self.command.grabbedHandle is not None: if self.command.grabbedHandle in [self.command.rotationHandle1, self.command.rotationHandle2]: handleType = 'ROTATION_HANDLE' else: handleType = 'RESIZE_HANDLE' if handleType and handleType == 'RESIZE_HANDLE': for segment in self.command.getResizeSegmentList(): self.command.currentStruct = segment params_when_adding_bases, params_when_removing_bases = \ self.command.getDnaRibbonParams() self.command.currentStruct = None if params_when_adding_bases: numberOfBasePairs,\ end1, \ end2, \ basesPerTurn,\ duplexRise, \ ribbon1_start_point, \ ribbon2_start_point, \ ribbon1_direction, \ ribbon2_direction, \ ribbon1Color, \ ribbon2Color = params_when_adding_bases #Note: The displayStyle argument for the rubberband line should #really be obtained from self.command.struct. But the struct #is a DnaSegment (a Group) and doesn't have attr 'display' #Should we then obtain this information from one of its strandChunks? #but what if two strand chunks and axis chunk are rendered #in different display styles? since situation may vary, lets #use self.glpane.displayMode for rubberbandline displayMode drawDnaRibbons(self.glpane, end1, end2, basesPerTurn, duplexRise, self.glpane.scale, self.glpane.lineOfSight, self.glpane.displayMode, ribbonThickness = 4.0, ribbon1_start_point = ribbon1_start_point, ribbon2_start_point = ribbon2_start_point, ribbon1_direction = ribbon1_direction, ribbon2_direction = ribbon2_direction, ribbon1Color = ribbon1Color, ribbon2Color = ribbon2Color, stepColor = black ) #Draw a sphere that indicates the current position of #the resize end of each segment . drawsphere(env.prefs[selectionColor_prefs_key], end2, SPHERE_RADIUS_2, SPHERE_DRAWLEVEL, opacity = SPHERE_OPACITY) numberOfBasePairsString = "+" + str(numberOfBasePairs) self.glpane.renderTextAtPosition( end2, numberOfBasePairsString) elif params_when_removing_bases: numberOfBasePairs , end2 = params_when_removing_bases #Draw a sphere that indicates the current position of #the resize end of each segment. drawsphere(darkred, end2, SPHERE_RADIUS_2, SPHERE_DRAWLEVEL, opacity = SPHERE_OPACITY) numberOfBasePairsString = str(numberOfBasePairs) self.glpane.renderTextAtPosition( end2, textString = numberOfBasePairsString, ) #Draw the text next to the cursor that gives info about #number of base pairs etc self._drawCursorText()
def Draw(self): """ Draw the DNA rubberband line (a ladder representation) """ #The rubberband line display needs to be a user preference. #Example: There could be 3 radio buttons in the duplex PM that allows #you to draw the rubberband line as a simple line, a line with points #that indicate duplexrise, a dna ladder with arrow heads. Drawing it as #a ladder with arrow heads for the beams is the current implementation # -Ninad 2007-10-30 #@see: LineMode_GM class definition about this flag. Basically we supress #cursor text drawing in the superclass and draw later in this method #after everyting is drawn. self._ok_to_render_cursor_text = False _superclass_for_GM.Draw(self) self._ok_to_render_cursor_text = True #This fixes NFR bug 2803 #Don't draw the Dna rubberband line if the cursor is over the confirmation #corner. But make sure to call superclass.Draw method before doing this #check because we need to draw the rest of the model in the graphics #mode!. @see: LineMode_GM.Draw handler = self.o.mouse_event_handler if handler is not None and handler is self._ccinstance: return if self.endPoint2 is not None and \ self.endPoint1 is not None: #Draw the ladder. #Convention: # The red band(beam) of the # ladder is always the 'leading edge' of the ladder. i.e. the red # band arrow head is always at the moving end of the mouse #(endpoint2). # A General Note/ FYI to keep in mind: # Consider a double stranded DNA and focus on the 'twin peaks' #(say, two consecutive helices in the middle of the dna duplex) # From the "mountain" with twin peaks that is the minor groove, # the DNA flows downhill 5' to 3' # Or in other words, # - For the 'mountain peak' on the right , # the 5' to 3' flows downhill, from left to right. # - For the 'mountain peak' on the left, # the 3' to 5' flows downhill, from right to left # # Thus, the red beam of the ladder, can either become the # 'left mountain' or the 'right mountain' depending on the # orientation while drawing the ladder if self.command.callback_rubberbandLineDisplay() == 'Ladder': #Note there needs to be a radio button to switch on the # rubberband ladder display for a dna line. At the moment it is # disabled and is superseded by the ribbons ruberband display. drawDnaLadder(self.endPoint1, self.endPoint2, self.command.duplexRise, self.glpane.scale, self.glpane.lineOfSight, beamThickness = 4.0, beam1Color = env.prefs[dnaDefaultStrand1Color_prefs_key], beam2Color = env.prefs[dnaDefaultStrand2Color_prefs_key], ) elif self.command.callback_rubberbandLineDisplay() == 'Ribbons': #Default dna rubberband line display style drawDnaRibbons(self.glpane, self.endPoint1, self.endPoint2, self.command.basesPerTurn, self.command.duplexRise, self.glpane.scale, self.glpane.lineOfSight, self.glpane.displayMode, ribbonThickness = 4.0, ribbon1Color = env.prefs[dnaDefaultStrand1Color_prefs_key], ribbon2Color = env.prefs[dnaDefaultStrand2Color_prefs_key], ) else: pass self._drawCursorText()