Ejemplo n.º 1
0
void RGBPickerTool::pickRect() {
  TImageP image = TImageP(getImage(false));

  TTool::Application *app = TTool::getApplication();
  TPaletteHandle *ph      = app->getPaletteController()->getCurrentPalette();
  int styleId             = ph->getStyleIndex();
  TPalette *palette       = ph->getPalette();
  TRectD area             = m_selectingRect;
  if (!palette) return;
  if (m_selectingRect.x0 > m_selectingRect.x1) {
    area.x1 = m_selectingRect.x0;
    area.x0 = m_selectingRect.x1;
  }
  if (m_selectingRect.y0 > m_selectingRect.y1) {
    area.y1 = m_selectingRect.y0;
    area.y0 = m_selectingRect.y1;
  }
  m_selectingRect.empty();
  if (area.getLx() <= 1 || area.getLy() <= 1) return;
  StylePicker picker(image, palette);

  // iwsw commented out temporarily
  // if (m_viewer->get3DLutUtil() &&
  // Preferences::instance()->isDoColorCorrectionByUsing3DLutEnabled())
  //	m_viewer->get3DLutUtil()->bindFBO();

  m_currentValue = picker.pickColor(area);

  // iwsw commented out temporarily
  // if (m_viewer->get3DLutUtil() &&
  // Preferences::instance()->isDoColorCorrectionByUsing3DLutEnabled())
  //	m_viewer->get3DLutUtil()->releaseFBO();
}
Ejemplo n.º 2
0
void RGBPickerTool::leftButtonDown(const TPointD &pos, const TMouseEvent &e) {
  TTool::Application *app   = TTool::getApplication();
  TPaletteHandle *pltHandle = app->getPaletteController()->getCurrentPalette();
  m_currentStyleId          = pltHandle->getStyleIndex();
  if (m_currentStyleId == 0) return;

  TColorStyle *colorStyle = pltHandle->getStyle();

  if (colorStyle) m_oldValue = colorStyle->getMainColor();

  if (m_pickType.getValue() == RECT_PICK) {
    m_selectingRect.x0 = e.m_pos.x;
    m_selectingRect.y0 = e.m_pos.y;
    m_selectingRect.x1 = e.m_pos.x;
    m_selectingRect.y1 = e.m_pos.y;
    m_drawingRect.x0   = pos.x;
    m_drawingRect.y0   = pos.y;
    m_drawingRect.x1   = pos.x;
    m_drawingRect.y1   = pos.y;
    invalidate();
    return;
  } else if (m_pickType.getValue() == FREEHAND_PICK) {
    startFreehand(pos, convert(e.m_pos));
    return;
  } else if (m_pickType.getValue() == POLYLINE_PICK) {
    addPointPolyline(pos, convert(e.m_pos));
    return;
  } else {
    pick(e.m_pos);
  }
}
Ejemplo n.º 3
0
void setCurrentColorWithUndo(const TPixel32 &color) {
  TTool::Application *app = TTool::getApplication();
  TPaletteHandle *ph      = app->getPaletteController()->getCurrentPalette();
  int styleId             = ph->getStyleIndex();
  TPalette *palette       = ph->getPalette();
  TXshSimpleLevel *level  = app->getCurrentLevel()->getSimpleLevel();
  if (palette)
    TUndoManager::manager()->add(
        new UndoPickRGBM(palette, styleId, color, level));

  setCurrentColor(color);

  if (level) {
    std::vector<TFrameId> fids;
    level->getFids(fids);
    invalidateIcons(level, fids);
  }
}
Ejemplo n.º 4
0
void RGBPickerTool::onImageChanged() {
  if (m_currentStyleId != 0 && m_makePick &&
      (m_pickType.getValue() == POLYLINE_PICK ||
       m_pickType.getValue() == RECT_PICK)) {
    TTool::Application *app = TTool::getApplication();
    TPaletteHandle *ph      = app->getPaletteController()->getCurrentPalette();
    int styleId             = ph->getStyleIndex();
    TPalette *palette       = ph->getPalette();
    TXshSimpleLevel *level  = app->getCurrentLevel()->getSimpleLevel();
    if (palette)
      TUndoManager::manager()->add(
          new UndoPickRGBM(palette, styleId, m_currentValue, level));
    setCurrentColor(m_currentValue);
    if (level) {
      std::vector<TFrameId> fids;
      level->getFids(fids);
      invalidateIcons(level, fids);
    }
  }
  m_makePick = false;
}
Ejemplo n.º 5
0
void RGBPickerTool::pick(TPoint pos) {
  TImageP image = TImageP(getImage(false));

  TTool::Application *app = TTool::getApplication();
  TPaletteHandle *ph      = app->getPaletteController()->getCurrentPalette();
  int styleId             = ph->getStyleIndex();
  TPalette *palette       = ph->getPalette();
  if (!palette) return;

  TRectD area = TRectD(pos.x - 1, pos.y - 1, pos.x + 1, pos.y + 1);
  StylePicker picker(image, palette);

  // iwsw commented out temporarily
  // if (m_viewer->get3DLutUtil() &&
  // Preferences::instance()->isDoColorCorrectionByUsing3DLutEnabled())
  //	m_viewer->get3DLutUtil()->bindFBO();

  m_currentValue = picker.pickColor(area);

  // iwsw commented out temporarily
  // if (m_viewer->get3DLutUtil() &&
  // Preferences::instance()->isDoColorCorrectionByUsing3DLutEnabled())
  //	m_viewer->get3DLutUtil()->releaseFBO();

  TXshSimpleLevel *level = app->getCurrentLevel()->getSimpleLevel();
  UndoPickRGBM *cmd = new UndoPickRGBM(palette, styleId, m_currentValue, level);
  TUndoManager::manager()->add(cmd);
  cmd->redo();
  /*
setCurrentColor(m_currentValue);
if(level)
{
vector<TFrameId> fids;
level->getFids(fids);
invalidateIcons(level,fids);
}
*/
}
Ejemplo n.º 6
0
void RGBPickerTool::pickStroke() {
  TImageP image = TImageP(getImage(false));

  TTool::Application *app = TTool::getApplication();
  TPaletteHandle *ph      = app->getPaletteController()->getCurrentPalette();
  int styleId             = ph->getStyleIndex();
  TPalette *palette       = ph->getPalette();
  if (!palette) return;

  StylePicker picker(image, palette);
  TStroke *stroke = new TStroke(*m_stroke);

  // iwsw commented out temporarily
  // if (m_viewer->get3DLutUtil() &&
  // Preferences::instance()->isDoColorCorrectionByUsing3DLutEnabled())
  //	m_viewer->get3DLutUtil()->bindFBO();

  m_currentValue = picker.pickColor(stroke);

  // iwsw commented out temporarily
  // if (m_viewer->get3DLutUtil() &&
  // Preferences::instance()->isDoColorCorrectionByUsing3DLutEnabled())
  //	m_viewer->get3DLutUtil()->releaseFBO();

  if (!(m_pickType.getValue() == POLYLINE_PICK)) {
    TXshSimpleLevel *level = app->getCurrentLevel()->getSimpleLevel();
    TUndoManager::manager()->add(
        new UndoPickRGBM(palette, styleId, m_currentValue, level));
    setCurrentColor(m_currentValue);
    if (level) {
      std::vector<TFrameId> fids;
      level->getFids(fids);
      invalidateIcons(level, fids);
    }
  }
}