コード例 #1
0
    def __init__(self, commandSequencer, struct = None):
        """
        Constructor for DnaDuplex_EditCommand
        """

        EditCommand.__init__(self, commandSequencer)        

        #_fallbackDnaGroup stores the DnaSegments created while in 
        #this command. This temporary dnaGroup is created IF AND ONLY IF 
        #DnaDuplex_EditCommand is unable to access the dnaGroup object of the 
        #parent BuildDna_EditCommand. (so if this group gets created, it should
        #be considered as a bug. While exiting the command the list of segments 
        #of this group is given to the BuildDna_EditCommand where they get 
        #their new parent. @see self.restore_gui
        self._fallbackDnaGroup = None

        #_parentDnaGroup is the dnagroup of BuildDna_EditCommand 
        self._parentDnaGroup = None

        #Maintain a list of segments created while this command was running. 
        #Note that the segments , when created will be added directly to the 
        # self._parentDnaGroup (or self._fallbackDnaGroup if there is a bug) 
        # But self._parentDnaGroup (which must be = the dnaGroup of 
        # BuildDna_EditCommand.) may already contain DnaSegments (added earlier)
        # so, we can not use group.steal_members() in case user cancels the 
        #structure creation (segment addition). 
        self._segmentList = []

        self.struct = struct
コード例 #2
0
    def runCommand(self):
        """
        Overrides superclass method. 
        Run this edit command. This method is called when user invokes 
        Insert > Plane command (to create a new plane object) . In addition 
        to creating the Plane object and Property manager, this also updates
        the property manager values with the ones for the new Plane object. 
        
        @see: MWSemantics.createPlane() which calls this while inserting a 
        new Plane
        @see: self.editStructure()
        @see: PlanePropertyManager.setParameters()
        @see: self._updatePropMgrParams()
        @TODO: The code that updates the PropMgr params etc needs to be in the 
        EditCommand API method/
        
        """
        EditCommand.runCommand(self)
        if self.hasValidStructure():             
            self._updatePropMgrParams()

            #Store the previous parameters. Important to set it after you 
            #set attrs in the propMgr. 
            #self.previousParams is used in self._previewStructure and 
            #self._finalizeStructure to check if self.struct changed.
            self.previousParams = self._gatherParameters()
コード例 #3
0
 def restore_gui(self):
     """
     Restore the GUI 
     """
     EditCommand.restore_gui(self)
     if self.flyoutToolbar:
         self.flyoutToolbar.displayProteinStyleAction.setChecked(False)    
コード例 #4
0
 def restore_gui(self):
     """
     Restore the GUI 
     """
     EditCommand.restore_gui(self)
     if self.flyoutToolbar:
         self.flyoutToolbar.editResiduesAction.setChecked(False)    
コード例 #5
0
    def editStructure(self, struct = None):
        """
        Overrides EditCommand.editStructure method. Provides a way to edit an
        existing structure. This implements a topLevel command that the client
        can execute to edit an existing object(i.e. self.struct) that it wants.

        Example: If its a plane edit controller, this method will be used to
                edit an object of class Plane.

        This method also creates a propMgr objects if it doesn't exist and
        shows this property manager

        @see: L{self.createStructure} (another top level command that
              facilitates creation of a model object created by this
              editCommand
        @see: L{Plane.edit} and L{Plane_EditCommand._createPropMgrObject}
        """

        if struct is not None:
            #Should we always unpick the structure while editing it?
            #Makes sense for editing a Dna. If this is problematic, the
            #following should be done in the subclasses that need this.
            if hasattr(struct, 'picked') and struct.picked:
                struct.unpick()

        EditCommand.editStructure(self, struct)
コード例 #6
0
    def model_changed(self):
        #This MAY HAVE BUG. WHEN --
        #debug pref 'call model_changed only when needed' is ON
        #See related bug 2729 for details. 

        #The following code that updates te handle positions and the strand 
        #sequence fixes bugs like 2745 and updating the handle positions
        #updating handle positions in model_changed instead of in 
        #self.graphicsMode._draw_handles() is also a minor optimization
        #This can be further optimized by debug pref 
        #'call model_changed only when needed' but its NOT done because of an 
        # issue menitoned in bug 2729   - Ninad 2008-04-07    

        EditCommand.model_changed(self) #This also calls the 
                                        #propMgr.model_changed 

        if self.grabbedHandle is not None:
            return

        #For Rattlesnake, PAM5 segment resizing  is not supported. 
        #@see: self.hasResizableStructure()        
        if self.hasValidStructure():
            isStructResizable, why_not = self.hasResizableStructure()
            if not isStructResizable:
                self.handles = []
                return
            elif len(self.handles) == 0:
                self._updateHandleList()

            self.updateHandlePositions()
            #NOTE: The following also updates self._previousParams
            self._updateStrandSequence_if_needed()
コード例 #7
0
    def __init__(self, commandSequencer, struct = None):
        """
        Constructor for BuildDna_EditCommand
        """

        EditCommand.__init__(self, commandSequencer)
        self.struct = struct
コード例 #8
0
    def editStructure(self, struct = None):
        EditCommand.editStructure(self, struct)        
        if self.hasValidStructure():         
            #When the structure (segment) is finalized (after the  modifications)
            #it will be added to the original NanotubeGroup to which it belonged 
            #before we began editing (modifying) it. 
            self._parentNanotubeGroup = self.struct.getNanotubeGroup() 
            #Set the endpoints
            #@ DOES THIS DO ANYTHING? I don't think so. --Mark 2008-04-01
            #@endPoint1, endPoint2 = self.struct.nanotube.getEndPoints()
            #@params_for_propMgr = (endPoint1, endPoint2)

            #TODO 2008-03-25: better to get all parameters from self.struct and
            #set it in propMgr?  This will mostly work except that reverse is 
            #not true. i.e. we can not specify same set of params for 
            #self.struct.setProps ...because endPoint1 and endPoint2 are derived.
            #by the structure when needed. Commenting out following line of code
            self.propMgr.setParameters(self.struct.getProps())

            #Store the previous parameters. Important to set it after you 
            #set nanotube attrs in the propMgr. 
            #self.previousParams is used in self._previewStructure and 
            #self._finalizeStructure to check if self.struct changed.
            self.previousParams = self._gatherParameters()
            self._updateHandleList()
            self.updateHandlePositions()
        return
コード例 #9
0
 def cancelStructure(self):
     """
     Overrides Editcommand.cancelStructure ..calls _removeSegments which 
     deletes all the segments created while this command was running
     @see: B{EditCommand.cancelStructure}
     """
     EditCommand.cancelStructure(self)
     self._removeSegments()
コード例 #10
0
 def cancelStructure(self):
     """
     Cancel the structure
     """
     EditCommand.cancelStructure(self)
     if self.struct is not None:
         if self.struct.isEmpty():
             self._removeStructure()
コード例 #11
0
 def restore_gui(self):
     """
     @see: EditCommand.restore_gui
     """
     EditCommand.restore_gui(self)
     #Following call doesn't update the struct with steps similar to 
     #ones in bug 2699. Instead calling struct.updateCosmeticProps directly
     ##self.propMgr.update_props_if_needed_before_closing()
     if self.hasValidStructure():
         self.struct.updateCosmeticProps() 
コード例 #12
0
    def init_gui(self):
        """
        Do changes to the GUI while entering this command. This includes opening 
        the property manager, updating the command toolbar , connecting widget 
        slots (if any) etc. Note: The slot connection in property manager and 
        command toolbar is handled in those classes. 

        Called once each time the command is entered; should be called only 
        by code in modes.py

        @see: L{self.restore_gui}
        """
        EditCommand.init_gui(self)        


        if isinstance(self.graphicsMode, DnaDuplex_GraphicsMode):
            self._setParamsForDnaLineGraphicsMode()
            self.mouseClickPoints = []

        #Clear the segmentList as it may still be maintaining a list of segments
        #from the previous run of the command. 
        self._segmentList = []

        prevMode = self.commandSequencer.prevMode 
        if prevMode.commandName == 'BUILD_DNA':
            params = prevMode.provideParamsForTemporaryMode(self.commandName)
            self.callback_addSegments, self._parentDnaGroup = params

            #@TODO: self.callback_addSegments is not used as of 2008-02-24 
            #due to change in implementation. Not removing it for now as the 
            #new implementation (which uses the dnaGroup object of 
            #BuildDna_EditCommand is still being tested) -- Ninad 2008-02-24

            #Following won't be necessary after Command Toolbar is 
            #properly integrated into the Command/CommandSequencer API
            try:
                self.flyoutToolbar = prevMode.flyoutToolbar
                #Need a better way to deal with changing state of the 
                #corresponding action in the flyout toolbar. To be revised 
                #during command toolbar cleanup 
                self.flyoutToolbar.dnaDuplexAction.setChecked(True)
            except AttributeError:
                self.flyoutToolbar = None


            if self.flyoutToolbar:
                if not self.flyoutToolbar.dnaDuplexAction.isChecked():
                    self.flyoutToolbar.dnaDuplexAction.setChecked(True)
        else:
            #Should this be an assertion? Should we always kill _parentDnaGroup
            #if its not None? ..not a good idea. Lets just make it to None. 
            self._parentDnaGroup = None             
            self._createFallbackDnaGroup()
            
        self.updateDrawingPlane(plane = None)
コード例 #13
0
 def restore_gui(self):
     """
     Do changes to the GUI while exiting this command. This includes closing 
     this mode's property manager, updating the command toolbar ,
     Note: The slot connection/disconnection in property manager and 
     command toolbar is handled in those classes.
     @see: L{self.init_gui}
     """
     EditCommand.restore_gui(self)
     if self.flyoutToolbar:
         self.flyoutToolbar.deActivateFlyoutToolbar()
コード例 #14
0
    def __init__(self, commandSequencer, struct = None):
        """
        Constructor for InsertNanotube_EditCommand
        """

        EditCommand.__init__(self, commandSequencer)        

        #Maintain a list of segments created while this command was running. 
        self._segmentList = []

        self.struct = struct
コード例 #15
0
    def editStructure(self, struct = None):
        """
        """
        EditCommand.editStructure(self, struct)        
        if self.hasValidStructure():             
            self._updatePropMgrParams()

            #Store the previous parameters. Important to set it after you 
            #set attrs in the propMgr. 
            #self.previousParams is used in self._previewStructure and 
            #self._finalizeStructure to check if self.struct changed.
            self.previousParams = self._gatherParameters()
コード例 #16
0
    def __init__(self, commandSequencer, struct = None):
        """
        Constructor for DnaDuplex_EditCommand
        """

        glpane = commandSequencer
        State_preMixin.__init__(self, glpane)        
        EditCommand.__init__(self, commandSequencer)
        self.struct = struct

        #Graphics handles for editing the structure . 
        self.handles = []        
        self.grabbedHandle = None
コード例 #17
0
    def __init__(self, commandSequencer):
        """
        Constructor for InsertDna_EditCommand
        """
        # used by self.command_update_internal_state()
        self._previous_model_change_indicator = None

        glpane = commandSequencer.assy.glpane
        State_preMixin.__init__(self, glpane)
        EditCommand.__init__(self, commandSequencer)

        # Graphics handles for editing the structure .
        self.handles = []
        self.grabbedHandle = None
コード例 #18
0
    def create_and_or_show_PM_if_wanted(self, showPropMgr = True):
        """
        Create the property manager object if one doesn't already exist 
        and then show the propMgr if wanted by the user. 
        @param showPropMgr: If True, show the property manager 
        @type showPropMgr: boolean
        """
        EditCommand.create_and_or_show_PM_if_wanted(
            self,
            showPropMgr = showPropMgr)

        self.propMgr.updateMessage("Specify two points in the 3D Graphics " \
                                   "Area to define the endpoints of the "\
                                   "DNA duplex."
                               )
コード例 #19
0
    def __init__(self, commandSequencer):
        """
        Constructor for InsertDna_EditCommand
        """
        glpane = commandSequencer.assy.glpane
        State_preMixin.__init__(self, glpane)        
        EditCommand.__init__(self, commandSequencer)
        
        #Graphics handles for editing the structure . 
        self.handles = []        
        self.grabbedHandle = None

        #Initialize DEBUG preference
        pref_nt_segment_resize_by_recreating_nanotube()
        return
コード例 #20
0
 def create_and_or_show_PM_if_wanted(self, showPropMgr = True):
     """
     Create the property manager object if one doesn't already exist
     and then show the propMgr if wanted by the user.
     @param showPropMgr: If True, show the property manager
     @type showPropMgr: boolean
     """
     EditCommand.create_and_or_show_PM_if_wanted(
         self,
         showPropMgr = showPropMgr)
     
     self.propMgr.updateMessage("Use appropriate command in the command "\
                                "toolbar to create or modify a Protein Object"\
                                "<br>"
                            )
コード例 #21
0
    def keep_empty_group(self, group):
        """
        Returns True if the empty group should not be automatically deleted. 
        otherwise returns False. The default implementation always returns 
        False. Subclasses should override this method if it needs to keep the
        empty group for some reasons. Note that this method will only get called
        when a group has a class constant autdelete_when_empty set to True. 
        (and as of 2008-03-06, it is proposed that dna_updater calls this method
        when needed. 
        @see: Command.keep_empty_group() which is overridden here. 
        @see: BreakStrands_Command.keep_empty_group
        @see: Group.autodelete_when_empty.. a class constant used by the 
              dna_updater (the dna updater then decides whether to call this 
              method to see which empty groups need to be deleted)
        """

        bool_keep = EditCommand.keep_empty_group(self, group)

        if not bool_keep:
            if self.hasValidStructure():
                if group is self.struct:
                    bool_keep = True
                elif group is self.struct.parent_node_of_class(self.assy.DnaGroup):
                    bool_keep = True
            # If this command doesn't have a valid structure, as a fall back,
            # lets instruct it to keep ALL the DnaGroup objects even when empty
            # Reason? ..see explanation in BreakStrands_Command.keep_empty_group
            elif isinstance(group, self.assy.DnaGroup):
                bool_keep = True

        return bool_keep
コード例 #22
0
    def keep_empty_group(self, group):
        """
        Returns True if the empty group should not be automatically deleted.
        otherwise returns False. The default implementation always returns
        False. Subclasses should override this method if it needs to keep the
        empty group for some reasons. Note that this method will only get called
        when a group has a class constant autdelete_when_empty set to True.
        (and as of 2008-03-06, it is proposed that dna_updater calls this method
        when needed.
        @see: Command.keep_empty_group() which is overridden here.
        """

        bool_keep = EditCommand.keep_empty_group(self, group)

        if not bool_keep:
            #Lets just not delete *ANY* DnaGroup while in DnaDisplayStyle_Command
            #Although DnaDisplayStyle command can only be accessed through
            #BuildDna_EditCommand, it could happen (due to a bug) that the
            #previous command is not BuildDna_Editcommand. So bool_keep
            #in that case will return False propmting dna updater to even delete
            #the empty DnaGroup (if it becomes empty for some reasons) of the
            #BuildDna command. To avoid this ,this method will instruct
            # to keep all instances of DnaGroup even when they might be empty.
            if isinstance(group, self.assy.DnaGroup):
                bool_keep = True
            #Commented out code that shows what I was planning to implement
            #earlier.
            ##previousCommand = self.commandSequencer.prevMode # keep_empty_group: .struct
            ##if previousCommand.commandName == 'BUILD_DNA':
                ##if group is previousCommand.struct:
                    ##bool_keep = True

        return bool_keep
コード例 #23
0
    def keep_empty_group(self, group):
        """
        Returns True if the empty group should not be automatically deleted. 
        otherwise returns False. The default implementation always returns 
        False. Subclasses should override this method if it needs to keep the
        empty group for some reasons. Note that this method will only get called
        when a group has a class constant autdelete_when_empty set to True. 
        (and as of 2008-03-06, it is proposed that dna_updater calls this method
        when needed. 
        @see: Command.keep_empty_group() which is overridden here. 
        """

        bool_keep = EditCommand.keep_empty_group(self, group)

        if not bool_keep: 
            #Don't delete any DnaSegements or DnaGroups at all while 
            #in DnaDuplex_EditCommand. 
            #Reason: See BreakStrand_Command.keep_empty_group. In addition to 
            #this, this command can create multiple DnaSegments Although those 
            #won't be empty, it doesn't hurt in waiting for this temporary 
            #command to exit before deleting any empty groups.             
            if isinstance(group, self.assy.DnaSegment) or \
               isinstance(group, self.assy.DnaGroup):
                bool_keep = True

        return bool_keep
コード例 #24
0
    def init_gui(self):
        """
        Do changes to the GUI while entering this command. This includes opening
        the property manager, updating the command toolbar , connecting widget
        slots (if any) etc. Note: The slot connection in property manager and
        command toolbar is handled in those classes.

        Called once each time the command is entered; should be called only
        by code in modes.py

        @see: L{self.restore_gui}
        """
        EditCommand.init_gui(self)
        if self.flyoutToolbar is None:
            self.flyoutToolbar = ProteinFlyout(self.win, self.propMgr)

        self.flyoutToolbar.activateFlyoutToolbar()
コード例 #25
0
 def editStructure(self, struct = None):
     """
     Edit the structure
     @param struct: structure to be edited (in this case its a strand chunk)
     @type struct: chunk or None (this will change post dna data model)
     """
     EditCommand.editStructure(self, struct)
     if self.hasValidStructure():
         self._updatePropMgrParams()
         #For Rattlesnake, we do not support resizing of PAM5 model.
         #So don't append the exprs handles to the handle list (and thus
         #don't draw those handles. See self.model_changed()
         isStructResizable, why_not = self.hasResizableStructure()
         if not isStructResizable:
             self.handles = []
         else:
             self._updateHandleList()
             self.updateHandlePositions()
コード例 #26
0
    def restore_gui(self):
        """
        Do changes to the GUI while exiting this command. This includes closing 
        this mode's property manager, updating the command toolbar ,
        Note: The slot connection/disconnection in property manager and 
        command toolbar is handled in those classes.
        @see: L{self.init_gui}
        """                    
        EditCommand.restore_gui(self)

        if isinstance(self.graphicsMode, NanotubeLine_GM):
            self.mouseClickPoints = []

        self.graphicsMode.resetVariables()   

        if self.flyoutToolbar:
            self.flyoutToolbar.insertNanotubeAction.setChecked(False)

        self._segmentList = []
コード例 #27
0
    def editStructure(self, struct = None):
        EditCommand.editStructure(self, struct)        
        if self.hasValidStructure():

            #TODO 2008-03-25: better to get all parameters from self.struct and
            #set it in propMgr?  This will mostly work except that reverse is 
            #not true. i.e. we can not specify same set of params for 
            #self.struct.setProps ...because endPoint1 and endPoint2 are derived.
            #by the structure when needed.
            self.propMgr.setParameters(self.struct.getProps())

            #Store the previous parameters. Important to set it after you 
            #set nanotube attrs in the propMgr. 
            #self.previousParams is used in self._previewStructure and 
            #self._finalizeStructure to check if self.struct changed.
            self.previousParams = self._gatherParameters()
            self._updateHandleList()
            self.updateHandlePositions()
        return
コード例 #28
0
    def __init__(self, commandSequencer, struct = None):
        """
        Constructs an Edit Controller Object. The editCommand, 
        depending on what client code needs it to do, may create a new 
        Linear motor or it may be used for an existing linear motor. 

        @param win: The NE1 main window.
        @type  win: QMainWindow

        @param struct: The model object (in this case a 'linear motor') that the
                       this EditCommand may create and/or edit
                       If struct object is specified, it means this 
                       editCommand will be used to edit that struct. 
        @type  struct: L{LinearMotor} or None

        @see: L{LinearMotor.__init__}
        """ 
        EditCommand.__init__(self, commandSequencer)
        self.struct = struct
コード例 #29
0
 def _finalizeStructure(self):
     """
     Overrides EditCommand._finalizeStructure. 
     @see: EditCommand.preview_or_finalize_structure
     """     
     if self.struct is not None:
         #@TODO 2008-03-19:Should we always do this even when strand sequence
         #is not changed?? Should it waste time in comparing the current 
         #sequence with a previous one? Assigning sequence while leaving the 
         #command will be slow for large files.Need to be optimized if 
         #problematic.
         #What if a flag is set in self.propMgr.updateSequence() when it 
         #updates the seq for the second time and we check that here. 
         #Thats  not good if the method gets called multiple times for some 
         #reason other than the user entered sequence. So not doing here. 
         #Better fix would be to check if sequence gets changed (textChanged)
         #in DnaSequence editor class .... Need to be revised
         EditCommand._finalizeStructure(self) 
         self._updateStrandSequence_if_needed()
         self.assignStrandSequence()
コード例 #30
0
    def editStructure(self, struct=None):
        EditCommand.editStructure(self, struct)
        if self.hasValidStructure():
            self._updatePropMgrParams()

            # Store the previous parameters. Important to set it after you
            # set duplexRise and basesPerTurn attrs in the propMgr.
            # self.previousParams is used in self._previewStructure and
            # self._finalizeStructure to check if self.struct changed.
            self.previousParams = self._gatherParameters()

            # For Rattlesnake, we do not support resizing of PAM5 model.
            # So don't append the exprs handles to the handle list (and thus
            # don't draw those handles. See self.model_changed()
            isStructResizable, why_not = self.hasResizableStructure()
            if not isStructResizable:
                self.handles = []
            else:
                self._updateHandleList()
                self.updateHandlePositions()
コード例 #31
0
    def keep_empty_group(self, group):
        """
        Returns True if the empty group should not be automatically deleted.
        otherwise returns False. The default implementation always returns
        False. Subclasses should override this method if it needs to keep the
        empty group for some reasons. Note that this method will only get called
        when a group has a class constant autdelete_when_empty set to True.
        (and as of 2008-03-06, it is proposed that dna_updater calls this method
        when needed.
        @see: Command.keep_empty_group() which is overridden here.
        """

        bool_keep = EditCommand.keep_empty_group(self, group)

        if not bool_keep:
            if group is self.struct:
                bool_keep = True

        return bool_keep
コード例 #32
0
 def _previewStructure(self):        
     EditCommand._previewStructure(self)
     self.updateHandlePositions()
     self._updateStrandSequence_if_needed()