void updateLevel() { TTool::Application *app = TTool::getApplication(); if (!app->getCurrentLevel()->getLevel()) return; TXshSimpleLevelP xl = app->getCurrentLevel()->getLevel()->getSimpleLevel(); if (app->getCurrentFrame()->getFrameType() != TFrameHandle::LevelFrame) return; TFrameId fid = app->getCurrentFrame()->getFid(); TVectorImageP src = xl->getFrame(fid, true); int count = src->getStrokeCount(); for (int i = 1; i < 10; i++) { ++fid; if (!xl->isFid(fid)) { TVectorImageP vi = new TVectorImage(); xl->setFrame(fid, vi); } TVectorImageP vi = xl->getFrame(fid, true); TVectorImageP dst = src->clone(); deform(dst.getPointer(), src.getPointer(), (double)i / (double)9); count = dst->getStrokeCount(); vi->mergeImage(dst, TAffine()); app->getCurrentTool()->getTool()->notifyImageChanged(fid); } }
void onImageChanged() override { if (!m_multi.getValue()) return; TTool::Application *app = TTool::getApplication(); TXshSimpleLevel *xshl = 0; if (app->getCurrentLevel()->getLevel()) xshl = app->getCurrentLevel()->getSimpleLevel(); if (!xshl || m_level.getPointer() != xshl || (m_closeType.getValue() == RECT_CLOSE && m_selectingRect.isEmpty()) || ((m_closeType.getValue() == FREEHAND_CLOSE || m_closeType.getValue() == POLYLINE_CLOSE) && !m_firstStroke)) resetMulti(); else if (m_firstFrameId == getFrameId()) m_firstFrameSelected = false; // nel caso sono passato allo stato 1 e // torno all'immagine iniziale, torno allo // stato iniziale else { // cambio stato. m_firstFrameSelected = true; if (m_closeType.getValue() == RECT_CLOSE) { assert(!m_selectingRect.isEmpty()); m_firstRect = m_selectingRect; } } }
void resetMulti() { m_firstFrameSelected = false; m_firstRect.empty(); m_firstPoint = TPointD(); m_selectingRect.empty(); TTool::Application *app = TTool::getApplication(); m_level = app->getCurrentLevel()->getLevel() ? app->getCurrentLevel()->getSimpleLevel() : 0; m_firstFrameId = m_veryFirstFrameId = getFrameId(); m_firstStroke = 0; }
void FullColorBrushTool::leftButtonUp(const TPointD &pos, const TMouseEvent &e) { m_brushPos = m_mousePos = pos; TRasterImageP ri = (TRasterImageP)getImage(true); if (!ri) return; if (m_points.size() != 1) { double maxThickness = m_thickness.getValue().second; double thickness = m_pressure.getValue() ? computeThickness(e.m_pressure, m_thickness) : maxThickness; double opacity = (m_pressure.getValue() ? computeThickness(e.m_pressure, m_opacity) : m_opacity.getValue().second) * 0.01; TPointD rasCenter = ri->getRaster()->getCenterD(); TThickPoint point(pos + rasCenter, thickness); m_points.push_back(point); int m = m_points.size(); vector<TThickPoint> points; points.push_back(m_points[m - 3]); points.push_back(m_points[m - 2]); points.push_back(m_points[m - 1]); TRect bbox = m_brush->getBoundFromPoints(points); updateWorkAndBackupRasters(bbox); m_tileSaver->save(bbox); m_brush->addArc(points[0], points[1], points[2], m_oldOpacity, opacity); m_brush->updateDrawing(ri->getRaster(), m_backUpRas, m_currentColor, bbox, m_opacity.getValue().second * 0.01); TRectD invalidateRect = ToolUtils::getBounds(points, maxThickness); invalidate(invalidateRect.enlarge(2) - rasCenter); m_strokeRect += bbox; m_lastRect.empty(); } if (m_brush) { delete m_brush; m_brush = 0; } m_workRaster->unlock(); if (m_tileSet->getTileCount() > 0) { delete m_tileSaver; TTool::Application *app = TTool::getApplication(); TXshLevel *level = app->getCurrentLevel()->getLevel(); TXshSimpleLevelP simLevel = level->getSimpleLevel(); TFrameId frameId = getCurrentFid(); TRasterP ras = ri->getRaster()->extract(m_strokeRect)->clone(); TUndoManager::manager()->add(new FullColorBrushUndo(m_tileSet, simLevel.getPointer(), frameId, m_isFrameCreated, ras, m_strokeRect.getP00())); } notifyImageChanged(); m_strokeRect.empty(); }
FullColorBrushToolNotifier::FullColorBrushToolNotifier(FullColorBrushTool *tool) : m_tool(tool) { TTool::Application *app = m_tool->getApplication(); TXshLevelHandle *levelHandle; if (app) levelHandle = app->getCurrentLevel(); bool ret = false; if (levelHandle) { bool ret = connect(levelHandle, SIGNAL(xshCanvasSizeChanged()), this, SLOT(onCanvasSizeChanged())); assert(ret); } }
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); } }
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; }
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); } */ }
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); } } }