Example #1
0
// ****************************************************************************
//  Method:  QvisColorGridWidget::emitSelection
//
//  Purpose:
//    Emit any signals associated with making a selection.
//
//  Programmer:  Jeremy Meredith
//  Creation:    August 11, 2006
//
// ****************************************************************************
void
QvisColorGridWidget::emitSelection()
{
    emit selectedColor(paletteColors[currentSelectedItem]);
    emit selectedColor(paletteColors[currentSelectedItem],
                       currentSelectedItem);
    int row, column;
    getRowColumnFromIndex(currentSelectedItem, row, column);
    emit selectedColor(paletteColors[currentSelectedItem], row, column);
}
Example #2
0
void QvisColorGridWidget::mousePressEvent(QMouseEvent* e)
{
  if (e->button() == Qt::RightButton)
  {
    int index = getColorIndex(e->x(), e->y());

    // If a valid color index was returned, select the color.
    if (index != -1)
    {
      // Set the selected color.
      setSelectedColorIndex(index);

      // Emit a signal that allows us to activate a menu.
      int row, column;
      QPoint center(e->x(), e->y());
      getRowColumnFromIndex(currentSelectedColor, row, column);
      emit activateMenu(selectedColor(), row, column, mapToGlobal(center));
    }
  }
}
Example #3
0
void QvisColorGridWidget::setSelectedColorIndex(int index)
{
  if (index >= -1 && index < numPaletteColors)
  {
    QRegion region;

    // If we currently have a selected color, unhighlight it.
    if (currentSelectedColor != -1)
      region = drawUnHighlightedColor(0, currentSelectedColor);

    // Set the new value.
    currentSelectedColor = index;

    // If the selected color that we set is a real color, highlight
    // the new selected color.
    if (currentSelectedColor != -1)
    {
      region = region + drawSelectedColor(0, currentSelectedColor);
    }

    // Update the widget.
    if (isVisible())
      repaint(region);
    else if (drawPixmap)
    {
      delete drawPixmap;
      drawPixmap = 0;
    }

    // emit the selectedColor signal.
    if (currentSelectedColor != -1)
    {
      emit selectedColor(paletteColors[currentSelectedColor]);
      emit selectedColor(paletteColors[currentSelectedColor], currentSelectedColor);
      int row, column;
      getRowColumnFromIndex(currentSelectedColor, row, column);
      emit selectedColor(paletteColors[currentSelectedColor], row, column);
    }
  }
}