Qt-interest Archive, July 2005
RE: Drawing an arrow
Message 1 in thread
try something like this
void EdgeItem::drawArrow( const doublePoint& pt, const doublePoint& ppt, double sze, const QPen& pen )
{
doublePoint pd, pa, pb;
double tangent;
/* in order to get the arrowhead the correct way round,
* we reverse the gradient.
* This is equivalent to reversing the geometry below...
*/
pd.x = ppt.x - pt.x, pd.y = ppt.y - pt.y;
if (pd.x == 0 && pd.y == 0)
return;
tangent = atan2 ((double) pd.y, (double) pd.x);
pa.x = sze * cos (tangent + M_PI / 7) + pt.x;
pa.y = sze * sin (tangent + M_PI / 7) + pt.y;
pb.x = sze * cos (tangent - M_PI / 7) + pt.x;
pb.y = sze * sin (tangent - M_PI / 7) + pt.y;
//-- connect the dots...
CanvasLine* lhs = new CanvasLine( canvas );
lhs->setPoints( pa.x, pa.y, pt.x, pt.y );
lhs->setPen( pen );
lhs->setZ( 1 );
lhs->show();
SimpleCanvasLine* rhs = new SimpleCanvasLine( canvas, this );
rhs->setPoints( pb.x, pb.y, pt.x, pt.y );
rhs->setPen( pen );
lhs->setZ( 1 );
rhs->show();
}
-----Original Message-----
From: François-Xavier Payet [mailto:mailing-lists@xxxxxxxx]
Sent: 06 July 2005 08:56
To: qt-interest@xxxxxxxxxxxxx
Subject: Drawing an arrow
Hi,
Has anyone got a source code for drawing an arrow?
Thanks,
FX
_____________________________________________________________________
This incoming message has been checked for all known viruses by Star Internet, on behalf of Celoxica, delivered through the MessageLabs Virus Scanning Service.
_____________________________________________________________________
This message has been checked for all known viruses by Star Internet
delivered on behalf of Celoxica Ltd through the MessageLabs Virus Scanning Service.
This email and any files transmitted with it are confidential and
may be legally privileged. It is intended solely for the use of the
individual or entity to whom it is addressed. If you have received
this in error, please contact the sender and delete the material
immediately. Whilst this email has been swept for viruses, you
should carry out your own virus check before opening any
attachment. Celoxica Ltd accepts no liability for any loss or
damage which may be caused by software viruses or interception
or interruption of this email.
Message 2 in thread
On Mer 6 juillet 2005 9:54, Alistair MacArthur a écrit :
> try something like this
> void EdgeItem::drawArrow( const doublePoint& pt, const doublePoint& ppt,
> double sze, const QPen& pen )
> {
> doublePoint pd, pa, pb;
> double tangent;
> /* in order to get the arrowhead the correct way round,
> * we reverse the gradient.
> * This is equivalent to reversing the geometry below...
> */
> pd.x = ppt.x - pt.x, pd.y = ppt.y - pt.y;
> if (pd.x == 0 && pd.y == 0)
> return;
> tangent = atan2 ((double) pd.y, (double) pd.x);
> pa.x = sze * cos (tangent + M_PI / 7) + pt.x;
> pa.y = sze * sin (tangent + M_PI / 7) + pt.y;
> pb.x = sze * cos (tangent - M_PI / 7) + pt.x;
> pb.y = sze * sin (tangent - M_PI / 7) + pt.y;
> //-- connect the dots...
> CanvasLine* lhs = new CanvasLine( canvas );
> lhs->setPoints( pa.x, pa.y, pt.x, pt.y );
> lhs->setPen( pen );
> lhs->setZ( 1 );
> lhs->show();
> SimpleCanvasLine* rhs = new SimpleCanvasLine( canvas, this );
> rhs->setPoints( pb.x, pb.y, pt.x, pt.y );
> rhs->setPen( pen );
> lhs->setZ( 1 );
> rhs->show();
> }
>
It worked great. Thanks a lot
FX
> -----Original Message-----
> From: François-Xavier Payet [mailto:mailing-lists@xxxxxxxx]
> Sent: 06 July 2005 08:56
> To: qt-interest@xxxxxxxxxxxxx
> Subject: Drawing an arrow
>
>
> Hi,
>
> Has anyone got a source code for drawing an arrow?
>
> Thanks,
>
> FX
>
>
> _____________________________________________________________________
> This incoming message has been checked for all known viruses by Star
> Internet, on behalf of Celoxica, delivered through the MessageLabs Virus
> Scanning Service.
>
> _____________________________________________________________________
> This message has been checked for all known viruses by Star Internet
> delivered on behalf of Celoxica Ltd through the MessageLabs Virus Scanning
> Service.
>
> This email and any files transmitted with it are confidential and
> may be legally privileged. It is intended solely for the use of the
> individual or entity to whom it is addressed. If you have received
> this in error, please contact the sender and delete the material
> immediately. Whilst this email has been swept for viruses, you
> should carry out your own virus check before opening any
> attachment. Celoxica Ltd accepts no liability for any loss or
> damage which may be caused by software viruses or interception
> or interruption of this email.
>
>
Message 3 in thread
Hi,
Has anyone got a source code for drawing an arrow?
Thanks,
FX