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); } }
void CleanupColorFieldEditorController::edit( DVGui::CleanupColorField *colorField) { if (m_currentColorField && m_currentColorField->isEditing()) m_currentColorField->setIsEditing(false); m_currentColorField = colorField; if (!colorField) return; m_currentColorField->setIsEditing(true); // Setto come stile corrente quello del colorField TColorStyle *fieldStyle = colorField->getStyle(); m_blackColor = dynamic_cast<TBlackCleanupStyle *>(fieldStyle); if (m_blackColor) { m_palette->setStyle(1, new TSolidColorStyle); m_palette->getStyle(1)->setMainColor(fieldStyle->getColorParamValue(1)); } else { m_palette->setStyle(1, new TColorCleanupStyle); TColorStyle *style = m_palette->getStyle(1); style->setMainColor(fieldStyle->getMainColor()); style->setColorParamValue(1, fieldStyle->getColorParamValue(1)); } // Setto m_colorFieldHandle come paletteHandle corrente. TApp::instance()->getPaletteController()->setCurrentPalette( m_colorFieldHandle); connect(m_colorFieldHandle, SIGNAL(colorStyleChanged()), SLOT(onColorStyleChanged())); }
void FullColorBrushTool::onEnter() { TImageP img = getImage(false); TRasterImageP ri(img); if (ri) { m_minThick = m_thickness.getValue().first; m_maxThick = m_thickness.getValue().second; } else { m_minThick = 0; m_maxThick = 0; } Application *app = getApplication(); if (app->getCurrentObject()->isSpline()) { m_currentColor = TPixel32::Red; return; } TPalette *plt = app->getCurrentPalette()->getPalette(); if (!plt) return; int style = app->getCurrentLevelStyleIndex(); TColorStyle *colorStyle = plt->getStyle(style); m_currentColor = colorStyle->getMainColor(); }
void FullColorBrushTool::onActivate() { if (!m_notifier) m_notifier = new FullColorBrushToolNotifier(this); TTool::Application *app = getApplication(); if (app->getCurrentObject()->isSpline()) { m_currentColor = TPixel32::Red; return; } int styleIndex = app->getCurrentLevelStyleIndex(); TPalette *plt = app->getCurrentPalette()->getPalette(); if (plt) { int style = app->getCurrentLevelStyleIndex(); TColorStyle *colorStyle = plt->getStyle(style); m_currentColor = colorStyle->getMainColor(); } if (m_firstTime) { m_firstTime = false; m_thickness.setValue(TIntPairProperty::Value(FullcolorBrushMinSize, FullcolorBrushMaxSize)); m_pressure.setValue(FullcolorPressureSensibility ? 1 : 0); m_opacity.setValue(TDoublePairProperty::Value(FullcolorMinOpacity, FullcolorMaxOpacity)); m_hardness.setValue(FullcolorBrushHardness); } m_brushPad = ToolUtils::getBrushPad(m_thickness.getValue().second, m_hardness.getValue() * 0.01); setWorkAndBackupImages(); }
void CleanupColorFieldEditorController::onColorStyleChanged() { if (!m_currentColorField) return; assert(!!m_palette); TColorStyle *style = m_palette->getStyle(1); if (m_blackColor) { if (m_currentColorField->getOutputColor() == style->getMainColor()) return; m_currentColorField->setOutputColor(style->getMainColor()); } else { if (m_currentColorField->getColor() == style->getMainColor() && m_currentColorField->getOutputColor() == style->getColorParamValue(1)) return; m_currentColorField->setStyle(style); } }
void ColorFieldEditorController::onColorChanged(const TPixel32 &color, bool) { if (!m_currentColorField) return; TColorStyle *style = m_palette->getStyle(1); if (style->getMainColor() == color) return; style->setMainColor(color); TApp::instance() ->getPaletteController() ->getCurrentPalette() ->notifyColorStyleChanged(); }
/*! Update current square colore and, if click event is enable set current StyleSample \b TColorStyle style to \b style. */ void StyleSample::setStyle(TColorStyle &style) { /*-- TSolidColorStyleの場合のみ、単色塗りつぶし --*/ if (style.getTagId() == 3) setColor(style.getMainColor()); else { TRaster32P icon = style.getIcon(qsize2Dimension(m_samplePixmap.rect().size())); m_samplePixmap = rasterToQImage(icon, false); //modified in 6.2 update(); } if (m_clickEnabled) m_style = style.clone(); }
bool TColorStyle::operator==(const TColorStyle &cs) const { if (getTagId() != cs.getTagId()) return false; if (getMainColor() != cs.getMainColor()) return false; int paramCount = getParamCount(); if (paramCount != cs.getParamCount()) return false; int colorParamCount = getColorParamCount(); if (colorParamCount != cs.getColorParamCount()) return false; if (m_name != cs.getName()) return false; if (m_originalName != cs.getOriginalName()) return false; if (m_globalName != cs.getGlobalName()) return false; if (m_isEditedFromOriginal != cs.getIsEditedFlag()) return false; if (m_pickedPosition != cs.getPickedPosition()) return false; if (m_flags != cs.getFlags()) return false; for (int p = 0; p < colorParamCount; ++p) if (getColorParamValue(p) != cs.getColorParamValue(p)) return false; for (int p = 0; p < paramCount; ++p) { switch (getParamType(p)) { case BOOL: if (getParamValue(bool_tag(), p) != cs.getParamValue(bool_tag(), p)) return false; break; case INT: case ENUM: if (getParamValue(int_tag(), p) != cs.getParamValue(int_tag(), p)) return false; break; case DOUBLE: if (getParamValue(double_tag(), p) != cs.getParamValue(double_tag(), p)) return false; break; case FILEPATH: if (getParamValue(TFilePath_tag(), p) != cs.getParamValue(TFilePath_tag(), p)) return false; break; default: assert(false); } } return true; }
UndoPickRGBM(TPalette *palette, int styleId, const TPixel32 newValue, const TXshSimpleLevelP &level) : m_palette(palette) , m_styleId(styleId) , m_newValue(newValue) , m_level(level) , m_colorAutoApplyEnabled(true) { PaletteController *controller = TTool::getApplication()->getPaletteController(); m_colorAutoApplyEnabled = controller->isColorAutoApplyEnabled(); m_styleParamIndex = controller->getCurrentPalette()->getStyleParamIndex(); if (m_colorAutoApplyEnabled) { TColorStyle *cs = m_palette->getStyle(m_styleId); if (0 <= m_styleParamIndex && m_styleParamIndex < cs->getColorParamCount()) m_oldValue = cs->getColorParamValue(m_styleParamIndex); else m_oldValue = cs->getMainColor(); } else { m_oldValue = controller->getColorSample(); } }
TToonzImageP Naa2TlvConverter::makeTlv(bool transparentSyntheticInks) { if (!m_valid || m_colors.empty() || m_regions.empty() || !m_regionRas) return TToonzImageP(); int lx = m_regionRas->getLx(); int ly = m_regionRas->getLy(); TPalette *palette = m_palette; if (!palette) palette = new TPalette(); TRasterCM32P ras(lx, ly); QList<int> styleIds; for (int i = 0; i < m_colors.count() - 1; i++) { TPixel32 color = m_colors.at(i); int styleId = palette->getClosestStyle(color); TColorStyle *cs = styleId < 0 ? 0 : palette->getStyle(styleId); if (cs) { if (cs->getMainColor() != color) cs = 0; } if (cs == 0) { styleId = palette->getPage(0)->addStyle(color); cs = palette->getStyle(styleId); } styleIds.append(styleId); } styleIds.append(0); // syntetic ink // int synteticInkStyleId = palette->getPage(0)->addStyle(TPixel32(0,0,0,0)); // styleIds.append(synteticInkStyleId); for (int y = 0; y < ly; y++) { unsigned short *workScanLine = m_regionRas->pixels(y); TPixelCM32 *outScanLine = ras->pixels(y); for (int x = 0; x < lx; x++) { int c = workScanLine[x]; Q_ASSERT(0 <= c && c < m_regions.count()); int color = m_regions[c].colorIndex; Q_ASSERT(0 <= color && color < styleIds.count()); int styleId = styleIds.at(color); RegionInfo::Type type = m_regions.at(c).type; if (type == RegionInfo::Background) outScanLine[x] = TPixelCM32(); else if (type & RegionInfo::Ink) outScanLine[x] = TPixelCM32(styleId, 0, 0); else if (m_syntheticInkRas->pixels(y)[x] == 1) outScanLine[x] = TPixelCM32(transparentSyntheticInks ? 0 : styleId, styleId, 0); else outScanLine[x] = TPixelCM32(0, styleId, 255); } } TToonzImageP ti = new TToonzImage(ras, ras->getBounds()); ti->setPalette(palette); ti->setDpi(72, 72); return ti; }