Пример #1
0
void PMTranslate::controlPointsChanged( PMControlPointList& list )
{
   PMControlPoint* p;

   for( p = list.first( ); p; p = list.next( ) )
   {
      if( p->changed( ) )
      {
         switch( p->id( ) )
         {
            case PMTranslationID:
               setTranslation( ( ( PMTranslateControlPoint* ) p )->translation( ) );
               break;
            default:
               kdError( PMArea ) << "Wrong ID in PMTranslate::controlPointsChanged\n";
               break;
         }
      }
   }
}
Пример #2
0
void PMTorus::controlPointsChanged( PMControlPointList& list )
{
   bool majorChanged = false, minorChanged = false;
   PMControlPoint* p;
   for( p = list.first( ); p; p = list.next( ) )
   {
      if( p->changed( ) )
      {
         switch( p->id( ) )
         {
            case PMMinorRadiusID:
               setMinorRadius( ( ( PMDistanceControlPoint* ) p )->distance( ) );
               ( ( PMDistanceControlPoint* ) p )->setDistance( m_minorRadius );
               minorChanged = true;
               break;
            case PMMajorRadiusID:
               setMajorRadius( ( ( PMDistanceControlPoint* ) p )->distance( ) );
               ( ( PMDistanceControlPoint* ) p )->setDistance( m_majorRadius );
               majorChanged = true;
               break;
            default:
               kdError( PMArea ) << "Wrong ID in PMTorus::controlPointsChanged\n";
               break;
         }
      }
   }

   if( majorChanged )
      for( p = list.first( ); p; p = list.next( ) )
         if( p->id( ) == PMMajorRadiusID )
            ( ( PMDistanceControlPoint* ) p )->setDistance( m_majorRadius );
   if( minorChanged )
      for( p = list.first( ); p; p = list.next( ) )
         if( p->id( ) == PMMinorRadiusID )
            ( ( PMDistanceControlPoint* ) p )->setDistance( m_minorRadius );
}
Пример #3
0
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 );
}