21#include <tqgroupbox.h>
27#include <karbon_view.h>
28#include <karbon_part.h>
29#include <shapes/vstar.h>
31#include "KoUnitWidgets.h"
34VStarOptionsWidget::VStarOptionsWidget(
KarbonPart *part, TQWidget* parent,
const char* name )
35 : KDialogBase( parent, name, true, i18n(
"Insert Star" ), Ok | Cancel ), m_part( part )
37 TQGroupBox *group =
new TQGroupBox( 2, TQt::Horizontal, i18n(
"Properties" ),
this );
38 new TQLabel( i18n(
"Type:" ), group );
39 m_type =
new KComboBox(
false, group );
40 m_type->insertItem( i18n(
"Star Outline" ), VStar::star_outline );
41 m_type->insertItem( i18n(
"Spoke" ), VStar::spoke );
42 m_type->insertItem( i18n(
"Wheel" ), VStar::wheel );
43 m_type->insertItem( i18n(
"Polygon" ), VStar::polygon );
44 m_type->insertItem( i18n(
"Framed Star" ), VStar::framed_star);
45 m_type->insertItem( i18n(
"Star" ), VStar::star );
46 m_type->insertItem( i18n(
"Gear" ), VStar::gear );
47 connect( m_type, TQ_SIGNAL( activated(
int ) ),
this, TQ_SLOT( typeChanged(
int ) ) );
50 m_outerRLabel =
new TQLabel( i18n(
"Outer radius:" ), group );
51 m_outerR =
new KoUnitDoubleSpinBox( group, 0.0, 1000.0, 0.5, 50.0, KoUnit::U_MM );
52 connect( m_outerR, TQ_SIGNAL( valueChanged(
double ) ),
this, TQ_SLOT( setOuterRadius(
double ) ) );
54 m_innerRLabel =
new TQLabel( i18n(
"Inner radius:" ), group );
55 m_innerR =
new KoUnitDoubleSpinBox( group, 0.0, 1000.0, 0.5, 25.0, KoUnit::U_MM );
59 new TQLabel( i18n(
"Edges:" ), group );
60 m_edges =
new KIntSpinBox( group );
61 m_edges->setMinValue( 3 );
62 connect( m_edges, TQ_SIGNAL( valueChanged(
int ) ),
this, TQ_SLOT( setEdges(
int ) ) );
64 new TQLabel( i18n(
"Inner angle:" ), group );
65 m_innerAngle =
new KIntSpinBox( group );
66 m_innerAngle->setMinValue( 0 );
67 m_innerAngle->setMaxValue( 360 );
69 new TQLabel( i18n(
"Roundness:" ), group );
70 m_roundness =
new KDoubleNumInput( group );
71 m_roundness->setRange( 0.0, 1.0, 0.05 );
73 typeChanged( VStar::star_outline );
75 group->setInsideMargin( 4 );
76 group->setInsideSpacing( 2 );
78 setMainWidget( group );
79 setFixedSize( baseSize() );
83VStarOptionsWidget::refreshUnit()
85 m_outerR->setUnit( m_part->unit() );
86 m_innerR->setUnit( m_part->unit() );
90VStarOptionsWidget::setEdges(
int v )
92 m_edges->setValue( v );
95 if( type() == VStar::star )
96 m_innerR->setValue( VStar::getOptimalInnerRadius( edges(), outerRadius(), innerAngle() ) );
100VStarOptionsWidget::setInnerRadius(
double v )
102 m_innerR->changeValue( v );
106VStarOptionsWidget::setOuterRadius(
double v )
108 m_outerR->setValue( v );
111 if( type() == VStar::star )
112 m_innerR->setValue( VStar::getOptimalInnerRadius( edges(), outerRadius(), innerAngle() ) );
116VStarOptionsWidget::roundness()
const
118 return m_roundness->value();
122VStarOptionsWidget::edges()
const
124 return m_edges->value();
128VStarOptionsWidget::innerRadius()
const
130 return m_innerR->value();
134VStarOptionsWidget::outerRadius()
const
136 return m_outerR->value();
140VStarOptionsWidget::type()
const
142 return m_type->currentItem();
146VStarOptionsWidget::innerAngle()
const
148 return m_innerAngle->value();
152VStarOptionsWidget::typeChanged(
int type )
154 m_innerR->setEnabled( type == VStar::star || type == VStar::star_outline || type == VStar::framed_star || type == VStar::gear );
155 m_innerAngle->setEnabled( type == VStar::star || type == VStar::star_outline || type == VStar::framed_star || type == VStar::gear );
158 if( type == VStar::star )
159 m_innerR->changeValue( VStar::getOptimalInnerRadius( edges(), outerRadius(), innerAngle() ) );
162VStarTool::VStarTool( KarbonView *view )
163 : VShapeTool( view,
"tool_star", true )
166 m_optionsWidget =
new VStarOptionsWidget( view->part() );
167 m_optionsWidget->setEdges( 5 );
168 registerTool(
this );
171void VStarTool::refreshUnit()
173 m_optionsWidget->refreshUnit();
176VStarTool::~VStarTool()
178 delete( m_optionsWidget );
182VStarTool::arrowKeyReleased( TQt::Key key )
185 if( key == TQt::Key_Up )
187 else if( key == TQt::Key_Down )
194 m_optionsWidget->setEdges( m_optionsWidget->edges() + change );
201VStarTool::shape(
bool interactive )
const
209 m_optionsWidget->outerRadius(),
210 m_optionsWidget->innerRadius(),
211 m_optionsWidget->edges(), 0.0, m_optionsWidget->innerAngle(),
212 m_optionsWidget->roundness(), (VStar::VStarType)m_optionsWidget->type() );
220 m_optionsWidget->innerRadius() * m_d1 /
221 m_optionsWidget->outerRadius(),
222 m_optionsWidget->edges(),
223 m_d2, m_optionsWidget->innerAngle(),
224 m_optionsWidget->roundness(), (VStar::VStarType)m_optionsWidget->type() );
228VStarTool::showDialog()
const
230 return m_optionsWidget->exec() == TQDialog::Accepted;
234VStarTool::setup( TDEActionCollection *collection )
236 m_action =
static_cast<TDERadioAction *
>(collection -> action( name() ) );
240 TDEShortcut shortcut( TQt::Key_Plus );
241 shortcut.append(TDEShortcut( TQt::Key_F9 ) );
242 m_action =
new TDERadioAction( i18n(
"Star Tool" ),
"14_star", shortcut,
this, TQ_SLOT( activate() ), collection, name() );
243 m_action->setToolTip( i18n(
"Draw a star" ) );
244 m_action->setExclusiveGroup(
"shapes" );
249#include "vstartool.moc"
Keeps track of visual per document properties.
A composite path consists of one or many subpaths.
This shape offers star-like shapes with a lot of parameters :