summaryrefslogtreecommitdiffstats
path: root/kpovmodeler/pmsqeedit.cpp
blob: 1cb02f891a0688dba6c6ae52ce96ec30af6297a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
**************************************************************************
                                 description
                             --------------------
    copyright            : (C) 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 "pmsqeedit.h"
#include "pmsqe.h"
#include "pmlineedits.h"

#include <tqlayout.h>
#include <tqlabel.h>
#include <klocale.h>

PMSuperquadricEllipsoidEdit::PMSuperquadricEllipsoidEdit( TQWidget* tqparent, const char* name )
      : Base( tqparent, name )
{
   m_pDisplayedObject = 0;
}

void PMSuperquadricEllipsoidEdit::createTopWidgets( )
{
   Base::createTopWidgets( );
   
   m_pValueE = new PMFloatEdit( this );
   m_pValueE->setValidation( true, 0.01, false, 1.0 );
   m_pValueN = new PMFloatEdit( this );
   m_pValueN->setValidation( true, 0.01, false, 1.0 );
   
   topLayout( )->addWidget( new TQLabel( i18n( "Exponents:" ), this ) );
   
   TQHBoxLayout* hl = new TQHBoxLayout( topLayout( ) );
   TQGridLayout* gl = new TQGridLayout( hl, 2, 2 );
   gl->addWidget( new TQLabel( i18n( "East-west:" ), this ), 0, 0 );
   gl->addWidget( m_pValueE, 0, 1 );
   gl->addWidget( new TQLabel( i18n( "North-south:" ), this ), 1, 0 );
   gl->addWidget( m_pValueN, 1, 1 );
   hl->addStretch( 1 );

   connect( m_pValueE, TQT_SIGNAL( dataChanged( ) ), TQT_SIGNAL( dataChanged( ) ) );
   connect( m_pValueN, TQT_SIGNAL( dataChanged( ) ), TQT_SIGNAL( dataChanged( ) ) );
}

void PMSuperquadricEllipsoidEdit::displayObject( PMObject* o )
{
   if( o->isA( "SuperquadricEllipsoid" ) )
   {
      bool readOnly = o->isReadOnly( );
      m_pDisplayedObject = ( PMSuperquadricEllipsoid* ) o;

      m_pValueE->setValue( m_pDisplayedObject->eastWestExponent( ) );
      m_pValueN->setValue( m_pDisplayedObject->northSouthExponent( ) );

      m_pValueE->setReadOnly( readOnly );
      m_pValueN->setReadOnly( readOnly );
      
      Base::displayObject( o );
   }
   else
      kdError( PMArea ) << "PMSuperquadricEllipsoidEdit: Can't display object\n";
}

void PMSuperquadricEllipsoidEdit::saveContents( )
{
   if( m_pDisplayedObject )
   {
      Base::saveContents( );
      m_pDisplayedObject->setEastWestExponent( m_pValueE->value( ) );
      m_pDisplayedObject->setNorthSouthExponent( m_pValueN->value( ) );
   }
}

bool PMSuperquadricEllipsoidEdit::isDataValid( )
{
   if( m_pValueE->isDataValid( ) )
      if( m_pValueN->isDataValid( ) )
         return Base::isDataValid( );
   return false;
}

#include "pmsqeedit.moc"