Ejemplo n.º 1
0
void MenuUIObject::Init()
{
    m_closeButton->SetPosition(0.5, SUBWINDOW_DISTANCE, 0.5);
    float w = 10, h = 10;
    m_closeButton->Resize(w, h);
    m_closeButton->SetScale(PMVector(0.1, 1, 0.1));
    m_closeButton->SetButtonDisplay(TEXTURE_CLOSE_NORMAL, TEXTURE_CLOSE_HOVER, TEXTURE_CLOSE_PRESS, TEXTURE_CLOSE_DISABLE);
    m_closeButton->ReleaseEvent.AddCallBack(this, &MenuUIObject::CloseButton);
    m_subWindows.push_back(m_closeButton);

    m_startButton->SetPosition(0, SUBWINDOW_DISTANCE, 0.2);
    w = 80; h = 20;
    m_startButton->Resize(w, h);
    m_startButton->SetScale(PMVector(0.6, 1, 0.15));
    m_startButton->SetButtonDisplay(TEXTURE_START_NORMAL, TEXTURE_START_HOVER, TEXTURE_START_PRESS, TEXTURE_CLOSE_DISABLE);
    m_startButton->ReleaseEvent.AddCallBack(this, &MenuUIObject::Game);
    m_subWindows.push_back(m_startButton);

    m_comicButton->SetPosition(0, SUBWINDOW_DISTANCE, -0.2);
    w = 80; h = 20;
    m_comicButton->Resize(w, h);
    m_comicButton->SetScale(PMVector(0.6, 1, 0.15));
    m_comicButton->SetButtonDisplay(TEXTURE_COMIC_NORMAL, TEXTURE_COMIC_HOVER, TEXTURE_COMIC_PRESS, TEXTURE_CLOSE_DISABLE);
    m_comicButton->ReleaseEvent.AddCallBack(this, &MenuUIObject::Comic);
    m_subWindows.push_back(m_comicButton);
}
Ejemplo n.º 2
0
void ComicUIObject::Resize( float &a_width, float &a_height )
{
    m_scale = a_width / m_oriWidth;
    a_height = m_oriHeight * m_scale;

    m_width = a_width;
    m_height = a_height;

    m_object->SetScale(PMVector(m_width, 0, m_height));

    float w = 10.0f / m_width, h = 10.0f / m_height;
    m_closeButton->SetScale(PMVector(w, 1, h));
    m_upButton->SetScale(PMVector(w, 1, h));
    m_downButton->SetScale(PMVector(w, 1, h));
}
Ejemplo n.º 3
0
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;
   }
}
Ejemplo n.º 4
0
PMVector PMSplineSegment::gradient( double t ) const
{
   double t2 = t * t;

   return PMVector( 3*m_a[0]*t2 + 2*m_b[0]*t + m_c[0],
                    3*m_a[1]*t2 + 2*m_b[1]*t + m_c[1] );
}
Ejemplo n.º 5
0
void ComicUIObject::Init()
{
    DIR *dp;
    struct dirent *dirp;
    if(dp = opendir("Comic"))
    {
        while((dirp = readdir(dp)) != NULL)
        {
            std::string file = "Comic/";
            file += dirp->d_name;
            if (file == "Comic/." || file == "Comic/..")
            {
                continue;
            }

            m_comicList.push_back(file);
        }
        closedir(dp);    
    }

    m_closeButton->SetPosition(0.5, SUBWINDOW_DISTANCE, 0.5);
    float w = 10, h = 10;
    m_closeButton->Resize(w, h);
    m_closeButton->SetScale(PMVector(0.1, 1, 0.1));
    m_closeButton->SetButtonDisplay(TEXTURE_CLOSE_NORMAL, TEXTURE_CLOSE_HOVER, TEXTURE_CLOSE_PRESS, TEXTURE_CLOSE_DISABLE);
    m_closeButton->ReleaseEvent.AddCallBack(this, &ComicUIObject::Close);
    m_subWindows.push_back(m_closeButton);

    m_upButton->SetPosition(-0.5, SUBWINDOW_DISTANCE, 0);
    w = 10; h = 10;
    m_upButton->Resize(w, h);
    m_upButton->SetScale(PMVector(0.1, 1, 0.1));
    m_upButton->SetButtonDisplay(TEXTURE_LAST_NORMAL, TEXTURE_LAST_HOVER, TEXTURE_LAST_PRESS, TEXTURE_LAST_DISABLE);
    m_upButton->ReleaseEvent.AddCallBack(this, &ComicUIObject::PageUp);
    m_subWindows.push_back(m_upButton);

    m_downButton->SetPosition(0.5, SUBWINDOW_DISTANCE, 0);
    w = 10; h = 10;
    m_downButton->Resize(w, h);
    m_downButton->SetScale(PMVector(0.1, 1, 0.1));
    m_downButton->SetButtonDisplay(TEXTURE_NEXT_NORMAL, TEXTURE_NEXT_HOVER, TEXTURE_NEXT_PRESS, TEXTURE_NEXT_DISABLE);
    m_downButton->ReleaseEvent.AddCallBack(this, &ComicUIObject::PageDown);
    m_subWindows.push_back(m_downButton);

    UpdatePage();
}
Ejemplo n.º 6
0
PMVector WindowInterface::GetProjectionPoint( PMVector a_point )
{
    PMVector position = m_object->GetAbsolutePosition();

    float k = (m_normal.x * (position.x - a_point.x) + m_normal.y * (position.y - a_point.y) + m_normal.z * (position.z - a_point.z)) / (m_normal.MagnitudeSquared());

    return PMVector(a_point.x + m_normal.x * k, a_point.y + m_normal.y * k, a_point.z + m_normal.z * k);
}
Ejemplo n.º 7
0
PMVector PMSplineSegment::point( double t ) const
{
   double t2 = t * t;
   double t3 = t2 * t;

   return PMVector( m_a[0]*t3 + m_b[0]*t2 + m_c[0]*t + m_d[0],
                    m_a[1]*t3 + m_b[1]*t2 + m_c[1]*t + m_d[1] );
}
Ejemplo n.º 8
0
void WindowInterface::Resize( float &a_width, float &a_height )
{
    m_object->SetScale(PMVector(a_width, 0, a_height));

    PMVector scale = m_object->GetScale();

    m_width = scale.x;
    m_height = scale.y;
}
Ejemplo n.º 9
0
void PMTorus::controlPoints( PMControlPointList& list )
{
   PMVector majorCenter( 0, 0, 0 );
   /** control points of the major radius */
   list.append( new PMDistanceControlPoint( majorCenter, PMVector( 1.0, 0.0, 0.0 ),
                                            m_majorRadius, PMMajorRadiusID,
                                            i18n( "Major radius (x)" ) ) );
   PMDistanceControlPoint* rcp =
      new PMDistanceControlPoint( majorCenter, PMVector( 0.0, 0.0, 1.0 ),
                                  m_majorRadius, PMMajorRadiusID,
                                  i18n( "Major radius (z)" ) );
   list.append( rcp );

   PMVector minorCenter( 0.0, 0.0, m_majorRadius );
   list.append( new PMDistanceControlPoint( rcp, PMVector( 0.0, 1.0, 0.0 ),
                                            m_minorRadius, PMMinorRadiusID,
                                            i18n( "Minor radius (y)" ) ) );
   list.append( new PMDistanceControlPoint( rcp, PMVector( 0.0, 0.0, 1.0 ),
                                            m_minorRadius, PMMinorRadiusID,
                                            i18n( "Minor radius (z)" ) ) );
}
Ejemplo n.º 10
0
PMVector WindowInterface::TransformByCoordinateSqure( PMVector a_point )
{
    PMVector position = m_object->GetAbsolutePosition();
    float normalRate = (m_normal.x * (position.x - a_point.x) + m_normal.y * (position.y - a_point.y) + m_normal.z * (position.z - a_point.z)) / (m_normal.MagnitudeSquared());
    float vectorXRate = (m_planeVectorX.x * (position.x - a_point.x) + m_planeVectorX.y * (position.y - a_point.y) + m_planeVectorX.z * (position.z - a_point.z)) / (m_planeVectorX.MagnitudeSquared());
    float vectorYRate = (m_planeVectorY.x * (position.x - a_point.x) + m_planeVectorY.y * (position.y - a_point.y) + m_planeVectorY.z * (position.z - a_point.z)) / (m_planeVectorY.MagnitudeSquared());

    float distanceSqureX = (m_planeVectorX.MagnitudeSquared()) * vectorXRate * vectorXRate;
    float distanceSqureY = (m_planeVectorY.MagnitudeSquared()) * vectorYRate * vectorYRate;
    float distanceSqureZ = (m_normal.MagnitudeSquared()) * normalRate * normalRate;

    return PMVector(distanceSqureX, distanceSqureY, distanceSqureZ);
}
Ejemplo n.º 11
0
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)" ) ) );
}
Ejemplo n.º 12
0
*  the Free Software Foundation; either version 2 of the License, or     *
*  (at your option) any later version.                                   *
*                                                                        *
**************************************************************************/


#include "pmtranslate.h"
#include "pmtranslateedit.h"

#include "pmxmlhelper.h"
#include "pmmemento.h"
#include "pmtranslatecontrolpoint.h"

#include <klocale.h>

const PMVector moveDefault = PMVector( 0.0, 0.0, 0.0 );

PMDefinePropertyClass( PMTranslate, PMTranslateProperty );

PMMetaObject* PMTranslate::s_pMetaObject = 0;
PMObject* createNewTranslate( PMPart* part )
{
   return new PMTranslate( part );
}

PMTranslate::PMTranslate( PMPart* part )
      : Base( part )
{
}

PMTranslate::PMTranslate( const PMTranslate& t )
Ejemplo n.º 13
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 );
}
Ejemplo n.º 14
0
*                                                                        *
**************************************************************************/


#include "pmjuliafractal.h"

#include "pmxmlhelper.h"
#include "pmjuliafractaledit.h"
#include "pmmemento.h"
#include "pmviewstructure.h"
#include "pm3dcontrolpoint.h"
#include "pmenumproperty.h"

#include <klocale.h>

const PMVector c_defaultJuliaParameter = PMVector( -0.083, 0.0, -0.83, -0.025 );
const PMVector c_defaultSliceNormal = PMVector( 0.0, 0.0, 0.0, 1.0 );
const double c_defaultSliceDistance = 0.0;
const int c_defaultMaxIterations = 20;
const PMJuliaFractal::AlgebraType c_defaultAlgebraType = PMJuliaFractal::Quaternion;
const QString c_defaultAlgebraString = "quaternion";
const PMJuliaFractal::FunctionType c_defaultFunctionType = PMJuliaFractal::FTsqr;
const QString c_defaultFunctionString = "sqr";
const PMVector c_defaultExponent = PMVector( 0.0, 0.0 );
const double c_defaultPrecision = 20.0;


PMDefinePropertyClass( PMJuliaFractal, PMJuliaFractalProperty );
PMDefineEnumPropertyClass( PMJuliaFractal, PMJuliaFractal::AlgebraType,
                           PMAlgebraTypeProperty );
PMDefineEnumPropertyClass( PMJuliaFractal, PMJuliaFractal::FunctionType,
Ejemplo n.º 15
0
#include "pmlistpattern.h"

#include "pmxmlhelper.h"
#include "pmlistpatternedit.h"
#include "pmcompositeobject.h"
#include "pmmemento.h"
#include "pmenumproperty.h"

#include <klocale.h>

PMDefinePropertyClass( PMListPattern, PMListPatternProperty );
PMDefineEnumPropertyClass( PMListPattern, PMListPattern::PMListType,
                           PMListTypeProperty );

const PMVector brickSizeDefault = PMVector( 8, 6, 4.5 );
const double mortarDefault = 0.5;
const double depthDefault = 0;

PMMetaObject* PMListPattern::s_pMetaObject = 0;
PMMetaObject* PMColorList::s_pMetaObject = 0;
PMObject* createNewColorList( PMPart* part )
{
   return new PMColorList( part );
}
PMMetaObject* PMDensityList::s_pMetaObject = 0;
PMObject* createNewDensityList( PMPart* part )
{
   return new PMDensityList( part );
}
PMMetaObject* PMNormalList::s_pMetaObject = 0;
Ejemplo n.º 16
0
PMVector WindowInterface::GetPlaneScale()
{
    return PMVector(m_width, 1, m_height);
}
Ejemplo n.º 17
0
#include "pmxmlhelper.h"
#include "pmboxedit.h"
#include "pmmemento.h"
#include "pm3dcontrolpoint.h"
#include "pmdefaults.h"
#include "pmdistancecontrolpoint.h"
#include "pmconeedit.h"

#include <klocale.h>


const double defaultConeRadius1 = 0.0;
const double defaultConeRadius2 = 0.5;
const double defaultHalfConeSize = 0.5;
const PMVector defaultEnd1 = PMVector ( 0, defaultHalfConeSize, 0 );
const PMVector defaultEnd2 = PMVector ( 0, -defaultHalfConeSize, 0 );
const bool defaultOpen = false;

/** default cone structure */
PMViewStructure* PMCone::s_pDefaultViewStructure = 0;
int PMCone::s_numSteps = c_defaultConeSteps;
int PMCone::s_parameterKey = 0;

PMDefinePropertyClass( PMCone, PMConeProperty );

PMMetaObject* PMCone::s_pMetaObject = 0;
PMObject* createNewCone( PMPart* part )
{
   return new PMCone( part );
}
Ejemplo n.º 18
0
#include "pmtext.h"

#include "pmxmlhelper.h"
#include "pmtextedit.h"
#include "pmmemento.h"
#include "pmviewstructure.h"
#include "pmresourcelocator.h"
#include "pmtruetypecache.h"
#include "pmdefaults.h"

#include <klocale.h>

const QString c_defaultFont = QString( "" );
const QString c_defaultText = QString( "" );
const double c_defaultThickness = 1.0;
const PMVector c_defaultOffset = PMVector( 0.0, 0.0 );

int PMText::s_parameterKey = 0;
int PMText::s_steps = c_defaultTextSteps;

PMDefinePropertyClass( PMText, PMTextProperty );

PMMetaObject* PMText::s_pMetaObject = 0;
PMObject* createNewText( PMPart* part )
{
   return new PMText( part );
}

PMText::PMText( PMPart* part )
      : Base( part )
{