summaryrefslogtreecommitdiffstats
path: root/kpovmodeler/pmpovraymatrixedit.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kpovmodeler/pmpovraymatrixedit.cpp')
-rw-r--r--kpovmodeler/pmpovraymatrixedit.cpp102
1 files changed, 102 insertions, 0 deletions
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
+**************************************************************************
+
+**************************************************************************
+* *
+* 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 <qlayout.h>
+#include <qlabel.h>
+#include <klocale.h>
+
+
+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"