void PMDistanceControlPoint::snapToGrid( ) { double d = moveGrid( ); if( !approxZero( d ) ) m_distance = rint( m_distance / d ) * d; setChanged( ); }
void PMCone::createPoints( PMPointArray& points, const PMVector& end1, const PMVector& end2, double radius1, double radius2, int steps ) { double angle = ( 2.0 * M_PI ) / (double) steps; PMVector pointAt = end2 - end1; double pl = pointAt.abs( ); if( approxZero( pl ) ) pointAt = PMVector( 0.0, 1.0, 0.0 ); else pointAt /= pl; PMMatrix rotation = PMMatrix::rotation( pointAt, angle ); PMVector endPoint1 = pointAt.orthogonal( ); endPoint1 *= radius1; PMVector endPoint2 = pointAt.orthogonal( ); endPoint2 *= radius2; int i; for( i = 0; i < steps; i++ ) { points[i] = PMPoint( endPoint1 + end1 ); points[i + steps] = PMPoint( endPoint2 + end2 ); endPoint1 = rotation * endPoint1; endPoint2 = rotation * endPoint2; } }
void PMDistanceControlPoint::graphicalChange( const PMVector& startPoint, const PMVector& /*viewNormal*/, const PMVector& endPoint ) { if( !approxZero( m_directionLength ) ) m_distance = m_originalDistance + PMVector::dot( endPoint - startPoint, m_direction ) / ( m_directionLength * m_directionLength ); }
void PMCone::controlPoints( PMControlPointList & list ) { PMVector center, angle1, angle2; center = m_end1 - m_end2; double pl = center.abs( ); if( approxZero( pl ) ) center = PMVector( 0.0, 1.0, 0.0 ); else center /= pl; angle1 = center.orthogonal( ); angle2 = PMVector::cross( center, angle1 ); PM3DControlPoint* pb1 = new PM3DControlPoint( m_end1, PMEnd1ID, i18n( "End 1" ) ); list.append( pb1 ); PM3DControlPoint* pb2 = new PM3DControlPoint( m_end2, PMEnd2ID, i18n( "End 2" ) ); list.append( pb2 ); list.append( new PMDistanceControlPoint( pb1, angle1, m_radius1, PMRadius1ID, i18n( "Radius 1 (1)" ) ) ); list.append( new PMDistanceControlPoint( pb1, angle2, m_radius1, PMRadius1ID, i18n( "Radius 1 (2)" ) ) ); list.append( new PMDistanceControlPoint( pb2, angle1, m_radius2, PMRadius2ID, i18n( "Radius 2 (1)" ) ) ); list.append( new PMDistanceControlPoint( pb2, angle2, m_radius2, PMRadius2ID, i18n( "Radius 2 (2)" ) ) ); }
void PMCone::controlPointsChanged( PMControlPointList & list ) { PMControlPoint* p; bool pointChanged = false; bool radiusChanged = false; for( p = list.first( ); p; p = list.next( ) ) { if( p->changed( ) ) { switch( p->id( ) ) { case PMEnd1ID: setEnd1( ( ( PM3DControlPoint *) p)->point( ) ); pointChanged = true; break; case PMEnd2ID: setEnd2( ( ( PM3DControlPoint *) p)->point( ) ); pointChanged = true; break; case PMRadius1ID: setRadius1( ( ( PMDistanceControlPoint *) p)->distance( ) ); radiusChanged = true; break; case PMRadius2ID: setRadius2( ( ( PMDistanceControlPoint *) p)->distance( ) ); radiusChanged = true; break; default: kdError (PMArea) << "Wrong ID in PMCone::controlPointsChanged\n"; break; } } } if( pointChanged ) { PMVector center, angle1, angle2; bool firstPoint1 = true; bool firstPoint2 = true; center = m_end1 - m_end2; double pl = center.abs( ); if( approxZero( pl ) ) center = PMVector( 0.0, 1.0, 0.0 ); else center /= pl; angle1 = center.orthogonal( ); angle2 = PMVector::cross( center, angle1 ); for( p = list.first( ); p; p = list.next( ) ) { if( p->id( ) == PMRadius1ID ) { if( firstPoint1 ) { ( ( PMDistanceControlPoint *) p)->setDirection( angle1 ); firstPoint1 = false; } else ( ( PMDistanceControlPoint *) p)->setDirection( angle2 ); }else if( p->id( ) == PMRadius2ID ) { if( firstPoint2 ) { ( ( PMDistanceControlPoint *) p)->setDirection( angle1 ); firstPoint2 = false; } else ( ( PMDistanceControlPoint *) p)->setDirection( angle2 ); } } } if( radiusChanged ) for( p = list.first( ); p; p = list.next( ) ) if( p->id( ) == PMRadius1ID ) ( ( PMDistanceControlPoint *) p)->setDistance( m_radius1 ); else if( p->id( ) == PMRadius2ID ) ( ( PMDistanceControlPoint *) p)->setDistance( m_radius2 ); }