21#include "insertknotsplugin.h"
22#include <karbon_view.h>
23#include <karbon_part.h>
24#include <core/vpath.h>
25#include <core/vsegment.h>
26#include <kgenericfactory.h>
28#include <tqgroupbox.h>
33typedef KGenericFactory<InsertKnotsPlugin, KarbonView> InsertKnotsPluginFactory;
34K_EXPORT_COMPONENT_FACTORY( karbon_insertknotsplugin, InsertKnotsPluginFactory(
"karboninsertknotsplugin" ) )
36InsertKnotsPlugin::InsertKnotsPlugin( KarbonView *parent, const
char* name, const TQStringList & ) : Plugin( parent, name )
39 i18n(
"&Insert Knots..." ),
"14_insertknots", 0,
this,
40 TQ_SLOT( slotInsertKnots() ), actionCollection(),
"path_insert_knots" );
42 m_insertKnotsDlg =
new VInsertKnotsDlg();
46InsertKnotsPlugin::slotInsertKnots()
48 KarbonPart *part = ((KarbonView *)parent())->part();
49 if( part && m_insertKnotsDlg->exec() )
50 part->
addCommand(
new VInsertKnotsCmd( &part->document(), m_insertKnotsDlg->knots() ),
true );
53VInsertKnotsDlg::VInsertKnotsDlg( TQWidget* parent,
const char* name )
54 : KDialogBase( parent, name, true, i18n(
"Insert Knots" ), Ok | Cancel )
57 TQGroupBox* group =
new TQGroupBox( 2, TQt::Horizontal, i18n(
"Properties" ),
this );
59 new TQLabel( i18n(
"Knots:" ), group );
60 m_knots =
new KIntSpinBox( group );
61 m_knots->setMinValue( 1 );
62 group->setMinimumWidth( 300 );
65 connect(
this, TQ_SIGNAL( okClicked() ),
this, TQ_SLOT( accept() ) );
66 connect(
this, TQ_SIGNAL( cancelClicked() ),
this, TQ_SLOT( reject() ) );
68 setMainWidget( group );
69 setFixedSize( baseSize() );
73VInsertKnotsDlg::knots()
const
75 return m_knots->value();
79VInsertKnotsDlg::setKnots( uint value )
81 m_knots->setValue( value );
85VInsertKnotsCmd::VInsertKnotsCmd(
VDocument* doc, uint knots )
88 m_knots = knots > 0 ? knots : 1;
92VInsertKnotsCmd::visitVSubpath(
VSubpath& path )
101 length = path.current()->
length();
103 for( uint i = m_knots; i > 0; --i )
107 path.current()->
lengthParam( length / ( m_knots + 1.0 ) ) ) );
117#include "insertknotsplugin.moc"
void addCommand(VCommand *cmd, bool repaint=false)
insert a command into the undo/redo-history:
All non-visual, static doc info is in here.
VReplacingCmd is a generic command.
double length(double t=1.0) const
Calculates the arclength from p0 to the point parametrized by 0 <= t <= 1.
double lengthParam(double len) const
Calculates the parameter of a point located at arclength len.
VSegment * splitAt(double t)
Splits the segment at parameter 0 <= t <= 1.
VSubpath provides a sophisticated list of VSegment.
bool success() const
Return if the operation was a success or not.
void setSuccess(bool success=true)
Set the success property.