Example #1
0
    def updateMessage(self, msg=''):  # Mark 2007-06-23
        """
        Updates the message box with an informative message.
        """
        graphicsModeName = ''
        #Question: should we define a new attr in Graphicsmode classes
        #suchs as graphicsModeName ? (or a method that returns the GM name
        # and which falls backs to graphicsMode.__class__.__name__ if name  is
        # not defined ? -- Ninad 2008-01-25
        if hasattr(self.parentMode, 'graphicsMode'):
            graphicsModeName = self.parentMode.graphicsMode.__class__.__name__

        if msg:
            self.MessageGroupBox.insertHtmlMessage(msg, setAsDefault=True)
            return

        from operations.ops_select import objectSelected
        if objectSelected(self.o.assy):
            msg = ""
        else:
            msg = "Click on an object to select it."

        if graphicsModeName:

            if graphicsModeName == 'TranslateChunks_GraphicsMode':
                currentIndex = self.translateComboBox.currentIndex()
                if currentIndex == 0:
                    msg += "To <b>translate</b> the selection, <b>highlight</b> "\
                        "any of the selected items and <b>drag</b> while holding " \
                        "down the left mouse button. Translate options are "\
                        "available below."
                elif currentIndex == 1:
                    msg += "<b>Translate</b> the selection by specified offset, "\
                        "using the <b>'+Delta'</b> and <b> '-Delta'</b> "\
                        "buttons."
                elif currentIndex == 2:
                    msg += "Use <b>Move Selection</b> button to translate the "\
                        "selection to the specified absolute XYZ coordinate."

            else:
                currentIndex = self.rotateComboBox.currentIndex()
                if currentIndex == 0:
                    msg += "To <b>rotate</b> the selection, <b>highlight</b> "\
                        "any of the selected items and <b>drag</b> while holding " \
                        "down the left mouse button. Rotate options are "\
                        "available below."
                elif currentIndex == 1:
                    msg += "<b> Rotate </b> the selection by the specified "\
                        "angle, around the specified axis, using the "\
                        " <b>'+Theta'</b> and <b> '-Theta'</b> buttons."

        self.MessageGroupBox.insertHtmlMessage(msg, setAsDefault=True)
    def updateMessage(self, msg = ''): # Mark 2007-06-23
        """
        Updates the message box with an informative message.
        """
        graphicsModeName = ''
        #Question: should we define a new attr in Graphicsmode classes 
        #suchs as graphicsModeName ? (or a method that returns the GM name 
        # and which falls backs to graphicsMode.__class__.__name__ if name  is 
        # not defined ? -- Ninad 2008-01-25
        if hasattr(self.parentMode, 'graphicsMode'):
            graphicsModeName = self.parentMode.graphicsMode.__class__.__name__

        if msg:
            self.MessageGroupBox.insertHtmlMessage( msg, setAsDefault  =  True )
            return

        from operations.ops_select import objectSelected
        if objectSelected(self.o.assy):
            msg = ""
        else:
            msg = "Click on an object to select it."
        
        if graphicsModeName:

            if graphicsModeName == 'TranslateChunks_GraphicsMode':
                currentIndex = self.translateComboBox.currentIndex()
                if  currentIndex == 0:
                    msg += "To <b>translate</b> the selection, <b>highlight</b> "\
                        "any of the selected items and <b>drag</b> while holding " \
                        "down the left mouse button. Translate options are "\
                        "available below."
                elif currentIndex == 1:
                    msg += "<b>Translate</b> the selection by specified offset, "\
                        "using the <b>'+Delta'</b> and <b> '-Delta'</b> "\
                        "buttons."
                elif currentIndex == 2:
                    msg += "Use <b>Move Selection</b> button to translate the "\
                        "selection to the specified absolute XYZ coordinate."
                    
            else:
                currentIndex = self.rotateComboBox.currentIndex()
                if  currentIndex == 0:
                    msg += "To <b>rotate</b> the selection, <b>highlight</b> "\
                        "any of the selected items and <b>drag</b> while holding " \
                        "down the left mouse button. Rotate options are "\
                        "available below."
                elif currentIndex == 1:
                    msg += "<b> Rotate </b> the selection by the specified "\
                        "angle, around the specified axis, using the "\
                        " <b>'+Theta'</b> and <b> '-Theta'</b> buttons."

        self.MessageGroupBox.insertHtmlMessage( msg, setAsDefault  =  True )
Example #3
0
    def dispObjectColor(self, initialColor = None):
        """
        Sets the color of the selected chunks and/or jigs to a color the user 
        chooses.

        @param initialColor: the initial color to display in the color chooser
                             dialog, or None or missing to use the default (white).
                             Not used if only one chunk or one jig is selected
                             (in those cases the object's current color is used).
        @type  initialColor: QColor

        @note: Need better method name (i.e. setObjectColor()).
        """        
        if initialColor is None:
            initialColor = Qt.white
        else:
            assert isinstance(initialColor, QColor)
        
        _cmd = greenmsg("Change Color: ")

        from operations.ops_select import objectSelected, ATOMS, CHUNKS, JIGS
        if not objectSelected(self.assy, objectFlags = CHUNKS | JIGS):
            if objectSelected(self.assy, objectFlags = ATOMS):
                _msg = redmsg("Cannot change color of individual atoms.")
            else:
                _msg = redmsg("Nothing selected.")
            env.history.message(_cmd + _msg)
            return

        _numSelectedObjects = self.assy.getNumberOfSelectedChunks() \
                            + self.assy.getNumberOfSelectedJigs()

        if _numSelectedObjects == 1 and self.assy.getNumberOfSelectedChunks() == 1:
            # If only one object is selected, and it's a chunk, 
            # assign initialColor its color.
            _selectedChunkColor = self.assy.selmols[0].color
            if _selectedChunkColor:
                from widgets.widget_helpers import RGBf_to_QColor
                initialColor = RGBf_to_QColor(_selectedChunkColor)

        elif _numSelectedObjects == 1 and self.assy.getNumberOfSelectedJigs() == 1:
            # If only one object is selected, and it's a jig, 
            # assign initialColor its color.
            _selectedJig = self.assy.getSelectedJigs()
            _selectedJigColor = _selectedJig[0].normcolor
            if _selectedJigColor:
                from widgets.widget_helpers import RGBf_to_QColor
                initialColor = RGBf_to_QColor(_selectedJigColor)

        _c = QColorDialog.getColor(initialColor, self)
        if _c.isValid():
            from widgets.widget_helpers import QColor_to_RGBf
            _newColor = QColor_to_RGBf(_c)
            list = []
            for ob in self.assy.selmols:
                ob.setcolor(_newColor)
                list.append(ob)

            for ob in self.assy.getSelectedJigs():
                ob.color = _newColor # Need jig.setColor() method! --mark
                ob.normcolor =  _newColor
                list.append(ob)

            # Ninad 070321: Since the chunk is selected as a colored selection, 
            # it should be unpicked after changing its color. 
            # The user has most likely selected the chunk to change its color 
            # and won't like it still shown 'green'(the selection color) 
            # even after changing the color. so deselect it. 	
            # The chunk is NOT unpicked IF the color is changed via chunk 
            # property dialog. see ChunkProp.change_chunk_color for details.
            # This is intentional.

            for ob in list: 		
                ob.unpick()

            self.win_update()