summaryrefslogtreecommitdiffstats
path: root/kpovmodeler/pmscene.cpp
blob: cd6593cd7c80c29bf6275a3b16ff214ba9959370 (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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
**************************************************************************
                                 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 "pmscene.h"
#include <klocale.h>
#include <tqdom.h>
#include "pmxmlhelper.h"
#include "pmdocumentformat.h"

const int c_defaultVisibilityLevel = 10;
PMMetaObject* PMScene::s_pMetaObject = 0;
PMObject* createNewScene( PMPart* part )
{
   return new PMScene( part );
}

PMScene::PMScene( PMPart* part )
      : Base( part )
{
   m_visibilityLevel = c_defaultVisibilityLevel;
}

PMScene::PMScene( const PMScene& s )
      : Base( s )
{
   m_visibilityLevel = s.m_visibilityLevel;
}

PMScene::~PMScene( )
{
   m_renderModes.setAutoDelete( true );
   m_renderModes.clear( );
}

TQString PMScene::description( ) const
{
   return i18n( "scene" );
}

PMMetaObject* PMScene::metaObject( ) const
{
   if( !s_pMetaObject )
   {
      s_pMetaObject = new PMMetaObject( "Scene", Base::metaObject( ),
                                        createNewScene );
   }
   return s_pMetaObject;
}

void PMScene::cleanUp( ) const
{
   if( s_pMetaObject )
   {
      delete s_pMetaObject;
      s_pMetaObject = 0;
   }
   Base::cleanUp( );
}

void PMScene::serialize( TQDomElement& e, TQDomDocument& doc ) const
{
   e.setAttribute( "majorFormat", c_majorDocumentFormat );
   e.setAttribute( "minorFormat", c_minorDocumentFormat );
   e.setAttribute( "visibility_level", m_visibilityLevel );
   TQDomElement data = doc.createElement( "extra_data" );
   TQDomElement rm;

   PMRenderModeListIterator it( m_renderModes );
   for( ; it.current( ); ++it )
   {
      rm = doc.createElement( "rendermode" );
      it.current( )->serialize( rm );
      data.appendChild( rm );
   }

   e.appendChild( data );
   Base::serialize( e, doc );
}

void PMScene::readAttributes( const PMXMLHelper& h )
{
   m_visibilityLevel = h.intAttribute( "visibility_level", c_defaultVisibilityLevel );
   TQDomElement e = h.extraData( );
   if( !e.isNull( ) )
   {
      TQDomNode c = e.firstChild( );
      while( !c.isNull( ) )
      {
         if( c.isElement( ) )
         {
            TQDomElement ce = c.toElement( );
            if( ce.tagName( ) == "rendermode" )
               m_renderModes.append( new PMRenderMode( ce ) );
         }
         c = c.nextSibling( );
      }
   }

   if( m_renderModes.count( ) > 0 )
      m_renderModes.at( 0 );

   Base::readAttributes( h );
}