void KarbonCalligraphyTool::updateSelectedPath() { KoPathShape *oldSelectedPath = m_selectedPath; // save old value KoSelection *selection = canvas()->shapeManager()->selection(); // null pointer if it the selection isn't a KoPathShape // or if the selection is empty m_selectedPath = dynamic_cast<KoPathShape *>(selection->firstSelectedShape()); // or if it's a KoPathShape but with no or more than one subpaths if (m_selectedPath && m_selectedPath->subpathCount() != 1) { m_selectedPath = 0; } // or if there ora none or more than 1 shapes selected if (selection->count() != 1) { m_selectedPath = 0; } // emit signal it there wasn't a selected path and now there is // or the other way around if ((m_selectedPath != 0) != (oldSelectedPath != 0)) { emit pathSelectedChanged(m_selectedPath != 0); } }
void RoundCornersPlugin::slotRoundCorners() { KoCanvasController* canvasController = KoToolManager::instance()->activeCanvasController(); KoSelection *selection = canvasController->canvas()->shapeManager()->selection(); KoShape * shape = selection->firstSelectedShape(); if (! shape) return; // check if we have a path based shape KoPathShape * path = dynamic_cast<KoPathShape*>(shape); if (! path) return; m_roundCornersDlg->setUnit(canvasController->canvas()->unit()); if (QDialog::Rejected == m_roundCornersDlg->exec()) return; KUndo2Command * cmd = new KUndo2Command(kundo2_i18n("Round Corners")); // convert to path before if we have a parametric shape KoParameterShape * ps = dynamic_cast<KoParameterShape*>(shape); if (ps && ps->isParametricShape()) new KoParameterToPathCommand(ps, cmd); new RoundCornersCommand(path, m_roundCornersDlg->radius(), cmd); canvasController->canvas()->addCommand(cmd); }
void WhirlPinchPlugin::slotWhirlPinch() { KoCanvasController* canvasController = KoToolManager::instance()->activeCanvasController(); KoSelection *selection = canvasController->canvas()->shapeManager()->selection(); KoShape * shape = selection->firstSelectedShape(); if (! shape) return; // check if we have a path based shape KoPathShape * path = dynamic_cast<KoPathShape*>(shape); if (! path) return; // check if it is no parametric shape KoParameterShape * ps = dynamic_cast<KoParameterShape*>(shape); if (ps && ps->isParametricShape()) return; m_whirlPinchDlg->setUnit(canvasController->canvas()->unit()); if (QDialog::Rejected == m_whirlPinchDlg->exec()) return; canvasController->canvas()->addCommand( new KarbonWhirlPinchCommand(path, m_whirlPinchDlg->angle(), m_whirlPinchDlg->pinch(), m_whirlPinchDlg->radius())); }
void StrokeDocker::selectionChanged() { KoCanvasController* canvasController = KoToolManager::instance()->activeCanvasController(); KoSelection *selection = canvasController->canvas()->shapeManager()->selection(); KoShape * shape = selection->firstSelectedShape(); if( shape ) setStroke( shape->border() ); }
void StrokeDocker::applyChanges() { KoCanvasController* canvasController = KoToolManager::instance()->activeCanvasController(); KoSelection *selection = canvasController->canvas()->shapeManager()->selection(); canvasController->canvas()->resourceProvider()->setActiveBorder( d->border ); if( ! selection || ! selection->count() ) return; KoLineBorder * newBorder = new KoLineBorder(d->border); KoLineBorder * oldBorder = dynamic_cast<KoLineBorder*>( selection->firstSelectedShape()->border() ); if( oldBorder ) { newBorder->setColor( oldBorder->color() ); newBorder->setLineBrush( oldBorder->lineBrush() ); } KoShapeBorderCommand *cmd = new KoShapeBorderCommand( selection->selectedShapes(), newBorder ); canvasController->canvas()->addCommand( cmd ); }
void RefinePathPlugin::slotRefinePath() { KoCanvasController* canvasController = KoToolManager::instance()->activeCanvasController(); KoSelection *selection = canvasController->canvas()->shapeManager()->selection(); KoShape * shape = selection->firstSelectedShape(); if (! shape) return; // check if we have a path based shape KoPathShape * path = dynamic_cast<KoPathShape*>(shape); if (! path) return; // check if it is no parametric shape KoParameterShape * ps = dynamic_cast<KoParameterShape*>(shape); if (ps && ps->isParametricShape()) return; if (QDialog::Rejected == m_RefinePathDlg->exec()) return; canvasController->canvas()->addCommand(new KarbonPathRefineCommand(path, m_RefinePathDlg->knots())); }