summaryrefslogtreecommitdiffstats
path: root/kpovmodeler/pmrotate.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit47d455dd55be855e4cc691c32f687f723d9247ee (patch)
tree52e236aaa2576bdb3840ebede26619692fed6d7d /kpovmodeler/pmrotate.cpp
downloadtdegraphics-47d455dd55be855e4cc691c32f687f723d9247ee.tar.gz
tdegraphics-47d455dd55be855e4cc691c32f687f723d9247ee.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegraphics@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kpovmodeler/pmrotate.cpp')
-rw-r--r--kpovmodeler/pmrotate.cpp164
1 files changed, 164 insertions, 0 deletions
diff --git a/kpovmodeler/pmrotate.cpp b/kpovmodeler/pmrotate.cpp
new file mode 100644
index 00000000..f3e34040
--- /dev/null
+++ b/kpovmodeler/pmrotate.cpp
@@ -0,0 +1,164 @@
+/*
+**************************************************************************
+ description
+ --------------------
+ copyright : (C) 2000-2002 by Andreas Zehender
+ email : zehender@kde.org
+**************************************************************************
+
+**************************************************************************
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+**************************************************************************/
+
+
+#include "pmrotate.h"
+#include "pmrotateedit.h"
+
+#include "pmxmlhelper.h"
+#include "pmmemento.h"
+#include "pmrotatecontrolpoint.h"
+
+#include <klocale.h>
+#include <qdom.h>
+
+const PMVector rotateDefault = PMVector( 0, 0, 0 );
+
+PMDefinePropertyClass( PMRotate, PMRotateProperty );
+
+PMMetaObject* PMRotate::s_pMetaObject = 0;
+PMObject* createNewRotate( PMPart* part )
+{
+ return new PMRotate( part );
+}
+
+PMRotate::PMRotate( PMPart* part )
+ : Base( part )
+{
+}
+
+PMRotate::PMRotate( const PMRotate& r )
+ : Base( r )
+{
+ m_rotate = r.m_rotate;
+}
+
+PMRotate::~PMRotate( )
+{
+}
+
+QString PMRotate::description( ) const
+{
+ return i18n( "rotate" );
+}
+
+void PMRotate::serialize( QDomElement& e, QDomDocument& /*doc*/ ) const
+{
+ e.setAttribute( "value", m_rotate.serializeXML( ) );
+}
+
+void PMRotate::readAttributes( const PMXMLHelper& h )
+{
+ m_rotate = h.vectorAttribute( "value", rotateDefault );
+}
+
+PMMetaObject* PMRotate::metaObject( ) const
+{
+ if( !s_pMetaObject )
+ {
+ s_pMetaObject = new PMMetaObject( "Rotate", Base::metaObject( ),
+ createNewRotate );
+ s_pMetaObject->addProperty(
+ new PMRotateProperty( "rotation", &PMRotate::setRotation, &PMRotate::rotation ) );
+ }
+ return s_pMetaObject;
+}
+
+void PMRotate::cleanUp( ) const
+{
+ if( s_pMetaObject )
+ {
+ delete s_pMetaObject;
+ s_pMetaObject = 0;
+ }
+ Base::cleanUp( );
+}
+
+void PMRotate::setRotation( const PMVector& p )
+{
+ if( p != m_rotate )
+ {
+ if( m_pMemento )
+ {
+ m_pMemento->addData( s_pMetaObject, PMRotationID, m_rotate );
+ m_pMemento->setViewStructureChanged( );
+ }
+ m_rotate = p;
+ m_rotate.resize( 3 );
+ }
+}
+
+PMDialogEditBase* PMRotate::editWidget( QWidget* parent ) const
+{
+ return new PMRotateEdit( parent );
+}
+
+void PMRotate::restoreMemento( PMMemento* s )
+{
+ PMMementoDataIterator it( s );
+ PMMementoData* data;
+
+ for( ; it.current( ); ++it )
+ {
+ data = it.current( );
+ if( data->objectType( ) == s_pMetaObject )
+ {
+ switch( data->valueID( ) )
+ {
+ case PMRotationID:
+ setRotation( data->vectorData( ) );
+ break;
+ default:
+ kdError( PMArea ) << "Wrong ID in PMRotate::restoreMemento\n";
+ break;
+ }
+ }
+ }
+ Base::restoreMemento( s );
+}
+
+PMMatrix PMRotate::transformationMatrix( ) const
+{
+ return PMMatrix::rotation( deg2Rad( m_rotate[0] ), deg2Rad( m_rotate[1] ),
+ deg2Rad( m_rotate[2] ) );
+}
+
+void PMRotate::controlPoints( PMControlPointList& list )
+{
+ list.append( new PMRotateControlPoint( m_rotate, PMRotationID ) );
+}
+
+void PMRotate::controlPointsChanged( PMControlPointList& list )
+{
+ PMControlPoint* p;
+
+ for( p = list.first( ); p; p = list.next( ) )
+ {
+ if( p->changed( ) )
+ {
+ switch( p->id( ) )
+ {
+ case PMRotationID:
+ setRotation( ( ( PMRotateControlPoint* ) p )->rotation( ) );
+ break;
+ default:
+ kdError( PMArea ) << "Wrong ID in PMRotate::controlPointsChanged\n";
+ break;
+ }
+ }
+ }
+}