From 47d455dd55be855e4cc691c32f687f723d9247ee Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: 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 --- kpovmodeler/pmpovraymatrixedit.cpp | 102 +++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 kpovmodeler/pmpovraymatrixedit.cpp (limited to 'kpovmodeler/pmpovraymatrixedit.cpp') diff --git a/kpovmodeler/pmpovraymatrixedit.cpp b/kpovmodeler/pmpovraymatrixedit.cpp new file mode 100644 index 00000000..0d78c226 --- /dev/null +++ b/kpovmodeler/pmpovraymatrixedit.cpp @@ -0,0 +1,102 @@ +/* +************************************************************************** + description + -------------------- + copyright : (C) 2001 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 "pmpovraymatrixedit.h" +#include "pmpovraymatrix.h" +#include "pmlineedits.h" + +#include +#include +#include + + +PMPovrayMatrixEdit::PMPovrayMatrixEdit( QWidget* parent, const char* name ) + : Base( parent, name ) +{ + m_pDisplayedObject = 0; +} + +void PMPovrayMatrixEdit::createTopWidgets( ) +{ + Base::createTopWidgets( ); + + int i, r, c; + QGridLayout* gl = new QGridLayout( topLayout( ), 4, 4 ); + + for( i = 0; i < 12; i++ ) + { + m_pValue[i] = new PMFloatEdit( this ); + connect( m_pValue[i], SIGNAL( dataChanged( ) ), SIGNAL( dataChanged( ) ) ); + } + + for( r = 0; r < 4; r++ ) + for( c = 0; c < 3; c++ ) + gl->addWidget( m_pValue[r*3+c], r, c ); + gl->addWidget( new QLabel( "0.0", this ), 0, 3 ); + gl->addWidget( new QLabel( "0.0", this ), 1, 3 ); + gl->addWidget( new QLabel( "0.0", this ), 2, 3 ); + gl->addWidget( new QLabel( "1.0", this ), 3, 3 ); +} + +void PMPovrayMatrixEdit::displayObject( PMObject* o ) +{ + if( o->isA( "PovrayMatrix" ) ) + { + bool readOnly = o->isReadOnly( ); + int i; + m_pDisplayedObject = ( PMPovrayMatrix* ) o; + PMVector v = m_pDisplayedObject->values( ); + + for( i = 0; i < 12; i++ ) + { + m_pValue[i]->setValue( v[i] ); + m_pValue[i]->setReadOnly( readOnly ); + } + + Base::displayObject( o ); + } + else + kdError( PMArea ) << "PMPovrayMatrixEdit: Can't display object\n"; +} + +void PMPovrayMatrixEdit::saveContents( ) +{ + if( m_pDisplayedObject ) + { + Base::saveContents( ); + PMVector v( 12 ); + int i; + + for( i = 0; i < 12; i++ ) + v[i] = m_pValue[i]->value( ); + m_pDisplayedObject->setValues( v ); + } +} + +bool PMPovrayMatrixEdit::isDataValid( ) +{ + int i; + + for( i = 0; i < 12; i++ ) + if( !m_pValue[i]->isDataValid( ) ) + return false; + + return Base::isDataValid( ); +} + +#include "pmpovraymatrixedit.moc" -- cgit v1.2.3