21#include <tqgroupbox.h>
25#include "KoUnitWidgets.h"
30#include <karbon_view.h>
31#include <karbon_part.h>
32#include <shapes/vellipse.h>
33#include "vellipsetool.h"
37VEllipseOptionsWidget::VEllipseOptionsWidget(
KarbonPart *part, TQWidget *parent,
const char *name )
38 : KDialogBase( parent, name, true, i18n(
"Insert Ellipse" ), Ok | Cancel ), m_part( part )
40 TQGroupBox *group =
new TQGroupBox( 2, TQt::Horizontal, i18n(
"Properties" ),
this );
41 new TQLabel( i18n(
"Type:" ), group );
42 m_type =
new KComboBox(
false, group );
43 m_type->insertItem( i18n(
"Full" ), VEllipse::full );
44 m_type->insertItem( i18n(
"Section" ), VEllipse::section );
45 m_type->insertItem( i18n(
"Pie" ), VEllipse::cut );
46 m_type->insertItem( i18n(
"Arc" ), VEllipse::arc );
47 connect( m_type, TQ_SIGNAL( activated(
int ) ),
this, TQ_SLOT( typeChanged(
int ) ) );
50 m_widthLabel =
new TQLabel( i18n(
"object width",
"Width:" ), group );
51 m_width =
new KoUnitDoubleSpinBox( group, 0.0, 1000.0, 0.5, 100.0, KoUnit::U_MM );
52 m_heightLabel =
new TQLabel( i18n(
"Height:" ), group );
53 m_height =
new KoUnitDoubleSpinBox( group, 0.0, 1000.0, 0.5, 100.0, KoUnit::U_MM );
55 new TQLabel( i18n(
"Start angle:" ), group );
56 m_startAngle =
new KIntSpinBox( group );
57 m_startAngle->setMinValue( 0 );
58 m_startAngle->setMaxValue( 360 );
60 new TQLabel( i18n(
"End angle:" ), group );
61 m_endAngle =
new KIntSpinBox( group );
62 m_endAngle->setMinValue( 0 );
63 m_endAngle->setMaxValue( 360 );
65 typeChanged( VEllipse::full );
69 group->setInsideMargin( 4 );
70 group->setInsideSpacing( 2 );
72 setMainWidget( group );
73 setFixedSize( baseSize() );
77VEllipseOptionsWidget::typeChanged(
int type )
79 m_startAngle->setEnabled( type != VEllipse::full );
80 m_endAngle->setEnabled( type != VEllipse::full );
84VEllipseOptionsWidget::type()
const
86 return m_type->currentItem();
90VEllipseOptionsWidget::startAngle()
const
92 return m_startAngle->value();
96VEllipseOptionsWidget::endAngle()
const
98 return m_endAngle->value();
102VEllipseOptionsWidget::width()
const
104 return m_width->value();
108VEllipseOptionsWidget::height()
const
110 return m_height->value();
114VEllipseOptionsWidget::setWidth(
double value )
116 m_width->changeValue( value );
120VEllipseOptionsWidget::setHeight(
double value )
122 m_height->changeValue( value );
126VEllipseOptionsWidget::refreshUnit ()
128 m_width->setUnit( m_part->unit() );
129 m_height->setUnit( m_part->unit() );
132VEllipseTool::VEllipseTool( KarbonView *view )
133 : VShapeTool( view,
"tool_ellipse" )
136 m_optionsWidget =
new VEllipseOptionsWidget( view->part() );
137 registerTool(
this );
139 m_startAngle = m_endAngle = 0;
143VEllipseTool::~VEllipseTool()
145 delete( m_optionsWidget );
149VEllipseTool::refreshUnit()
151 m_optionsWidget->refreshUnit();
155VEllipseTool::shape(
bool interactive )
const
159 double d1 = m_optionsWidget->width() / 2.0;
160 double d2 = m_optionsWidget->height() / 2.0;
164 KoPoint( m_center.x() - d1, m_center.y() - d2 ),
166 (VEllipse::VEllipseType)m_optionsWidget->type(),
167 m_optionsWidget->startAngle(),
168 m_optionsWidget->endAngle() );
174 KoPoint( m_center.x() - m_d1, m_center.y() - m_d2 ),
177 (VEllipse::VEllipseType)m_optionsWidget->type(),
178 m_startAngle, m_endAngle );
182VEllipseTool::mouseMove()
184 if( m_state == normal )
191 if( m_state == startangle )
193 m_startAngle = atan2( last().y() - m_center.y(), last().x() - m_center.x() );
194 m_startAngle = ( m_startAngle / VGlobal::pi_2 ) * 90.0;
195 if( m_startAngle < 0 )
196 m_startAngle += 360.0;
200 m_endAngle = atan2( last().y() - m_center.y(), last().x() - m_center.x() );
201 m_endAngle = ( m_endAngle / VGlobal::pi_2 ) * 90.0;
210VEllipseTool::mouseDragRelease()
212 if( m_optionsWidget->type() == VEllipse::full )
213 VShapeTool::mouseDragRelease();
215 if( m_state == normal )
216 if( m_optionsWidget->type() != VEllipse::full )
217 m_state = startangle;
221VEllipseTool::mouseButtonPress()
223 if( m_state == normal )
225 VShapeTool::mouseButtonPress();
231VEllipseTool::mouseButtonRelease()
233 if( m_optionsWidget->type() == VEllipse::full || m_state == normal )
234 VShapeTool::mouseButtonRelease();
236 if( m_state == startangle )
238 else if( m_state == endangle )
240 VShapeTool::mouseDragRelease();
241 m_startAngle = m_endAngle = 0;
247VEllipseTool::cancel()
250 VShapeTool::cancel();
254 m_startAngle = m_endAngle = 0;
259VEllipseTool::showDialog()
const
261 return m_optionsWidget->exec() == TQDialog::Accepted;
265VEllipseTool::setup( TDEActionCollection *collection )
267 m_action =
static_cast<TDERadioAction *
>(collection -> action( name() ) );
271 m_action =
new TDERadioAction( i18n(
"Ellipse Tool" ),
"14_ellipse", TQt::SHIFT+TQt::Key_H,
this, TQ_SLOT( activate() ), collection, name() );
272 m_action->setToolTip( i18n(
"Ellipse" ) );
273 m_action->setExclusiveGroup(
"shapes" );
278#include "vellipsetool.moc"
Keeps track of visual per document properties.
A composite path consists of one or many subpaths.