Esempio n. 1
0
    def change_chunk_color(self):
        """
        Slot method to change the chunk's color.
        """
        color = QColorDialog.getColor(self.chunk_QColor, self)

        if color.isValid():
            plt = QtGui.QPalette()
            plt.setColor(QtGui.QPalette.Active, QtGui.QPalette.Window, color)
            plt.setColor(QtGui.QPalette.Inactive, QtGui.QPalette.Window, color)
            plt.setColor(QtGui.QPalette.Disabled, QtGui.QPalette.Window, color)
            self.chunk_color_frame.setPalette(plt)

            self.chunk_QColor = color
            self.chunk.color = QColor_to_RGBf(color)
            self.chunk.setcolor(self.chunk.color)
            if self.chunk.hidden:  # A hidden chunk has no glpane attr.
                return
            #Ninad 070321:
            #Note:
            #The chunk is NOT unpicked immediately after changing the color via
            #chunk property dialog, This is intentional.
            #BTW I don't know why it deselects the chunk  after hitting OK or Cancel!
            #(looks like an old Qt4 transition bug)
            self.glpane.gl_update()
Esempio n. 2
0
    def change_jig_color(self):
        '''Slot method to change the jig's color.'''
        color = QColorDialog.getColor(self.jig_QColor, self)

        if color.isValid():
            self.jig_QColor = color
            self.jig_color_pixmap = get_widget_with_color_palette(
                self.jig_color_pixmap, self.jig_QColor)
            self.jig.color = self.jig.normcolor = QColor_to_RGBf(color)
            self.glpane.gl_update()
Esempio n. 3
0
    def change_grid_color(self):
        '''Slot method to change grid color.'''
        color = QColorDialog.getColor(self.grid_color, self)

        if color.isValid():
            self.grid_color = color
            self.grid_color_pixmap = get_widget_with_color_palette(
                self.grid_color_pixmap, self.grid_color)
            self.grid_plane.grid_color = QColor_to_RGBf(color)
            self.glpane.gl_update()
Esempio n. 4
0
    def change_border_color(self):
        '''Slot method change border color.'''
        color = QColorDialog.getColor(self.border_color, self)

        if color.isValid():
            self.border_color = color
            self.border_color_pixmap = get_widget_with_color_palette(
                self.border_color_pixmap, self.border_color)
            self.grid_plane.color = self.grid_plane.normcolor = QColor_to_RGBf(
                color)
            self.glpane.gl_update()
 def chooseCustomBackgroundColor(self):
     """
     Choose a custom background color.
     """
     c = QColorDialog.getColor(RGBf_to_QColor(self.win.glpane.getBackgroundColor()), self)
     if c.isValid():
         self.win.glpane.setBackgroundColor(QColor_to_RGBf(c))
         self.updateCustomColorItemIcon(c)
     else:
         # User cancelled. Need to reset combobox to correct index.
         self._updateBackgroundColorComboBoxIndex()
     return
Esempio n. 6
0
 def openColorChooserDialog(self):
     """
     Prompts the user to choose a color and then updates colorFrame with
     the selected color.
     """
     qcolor = RGBf_to_QColor(self.color)
     if not self.color in self.standardColorList:
         QColorDialog.setCustomColor(self.customColorCount, qcolor.rgb())
         self.customColorCount += 1
     c = QColorDialog.getColor(qcolor, self)
     if c.isValid():
         self.setColor(QColor_to_RGBf(c))
         self.colorFrame.emit(SIGNAL("editingFinished()"))
Esempio n. 7
0
    def change_fill_color(self):
        """
        Slot method to change fill color.
        """
        color = QColorDialog.getColor(self.fill_QColor, self)

        if color.isValid():            
            self.fill_QColor = color
            self.fill_color_pixmap = get_widget_with_color_palette(
                self.fill_color_pixmap, self.fill_QColor)
            
            self.jig.fill_color = QColor_to_RGBf(color)
            self.glpane.gl_update()
Esempio n. 8
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()