You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
511 lines
16 KiB
511 lines
16 KiB
15 years ago
|
// Copyright (C) 2002 Dominique Devriese <devriese@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.
|
||
|
|
||
|
// This program is distributed in the hope that it will be useful,
|
||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
// GNU General Public License for more details.
|
||
|
|
||
|
// You should have received a copy of the GNU General Public License
|
||
|
// along with this program; if not, write to the Free Software
|
||
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||
|
// 02110-1301, USA.
|
||
|
|
||
|
#include "object_imp_factory.h"
|
||
|
|
||
|
#include "object_imp.h"
|
||
|
#include "bogus_imp.h"
|
||
|
#include "circle_imp.h"
|
||
|
#include "conic_imp.h"
|
||
|
#include "cubic_imp.h"
|
||
|
#include "line_imp.h"
|
||
|
#include "locus_imp.h"
|
||
|
#include "other_imp.h"
|
||
|
#include "point_imp.h"
|
||
|
#include "text_imp.h"
|
||
|
|
||
|
#include "../misc/coordinate.h"
|
||
|
|
||
15 years ago
|
#include <tqdom.h>
|
||
15 years ago
|
|
||
12 years ago
|
#include <tdelocale.h>
|
||
15 years ago
|
|
||
|
const ObjectImpFactory* ObjectImpFactory::instance()
|
||
|
{
|
||
|
static const ObjectImpFactory t;
|
||
|
return &t;
|
||
|
}
|
||
|
|
||
|
ObjectImpFactory::ObjectImpFactory()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
ObjectImpFactory::~ObjectImpFactory()
|
||
|
{
|
||
|
}
|
||
|
|
||
13 years ago
|
static void addXYElements( const Coordinate& c, TQDomElement& parent, TQDomDocument& doc )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQDomElement xe = doc.createElement( "x" );
|
||
15 years ago
|
xe.appendChild(
|
||
|
doc.createTextNode(
|
||
15 years ago
|
TQString::number( c.x ) ) );
|
||
13 years ago
|
parent.appendChild( xe );
|
||
15 years ago
|
TQDomElement ye = doc.createElement( "y" );
|
||
15 years ago
|
ye.appendChild(
|
||
|
doc.createTextNode(
|
||
15 years ago
|
TQString::number( c.y ) ) );
|
||
13 years ago
|
parent.appendChild( ye );
|
||
15 years ago
|
}
|
||
|
|
||
13 years ago
|
static void addDoubleElement( const char* name, double d, TQDomElement& parent, TQDomDocument& doc )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQDomElement e = doc.createElement( name );
|
||
|
e.appendChild( doc.createTextNode( TQString::number( d ) ) );
|
||
13 years ago
|
parent.appendChild( e );
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
static void addCoordinateElement( const char* name, const Coordinate& d, TQDomElement& p, TQDomDocument& doc )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQDomElement e = doc.createElement( name );
|
||
15 years ago
|
addXYElements( d, e, doc );
|
||
|
p.appendChild( e );
|
||
|
}
|
||
|
|
||
13 years ago
|
TQString ObjectImpFactory::serialize( const ObjectImp& d, TQDomElement& parent,
|
||
15 years ago
|
TQDomDocument& doc ) const
|
||
15 years ago
|
{
|
||
|
if( d.inherits( IntImp::stype() ) )
|
||
|
{
|
||
13 years ago
|
parent.appendChild(
|
||
15 years ago
|
doc.createTextNode(
|
||
15 years ago
|
TQString::number( static_cast<const IntImp&>( d ).data() ) ) );
|
||
13 years ago
|
return TQString::fromLatin1( "int" );
|
||
15 years ago
|
}
|
||
|
else if ( d.inherits( DoubleImp::stype() ) )
|
||
|
{
|
||
13 years ago
|
parent.appendChild(
|
||
15 years ago
|
doc.createTextNode(
|
||
15 years ago
|
TQString::number( static_cast<const DoubleImp&>( d ).data() ) ) );
|
||
13 years ago
|
return TQString::fromLatin1( "double" );
|
||
15 years ago
|
}
|
||
|
else if( d.inherits( StringImp::stype() ) )
|
||
|
{
|
||
13 years ago
|
parent.appendChild(
|
||
15 years ago
|
doc.createTextNode(
|
||
|
static_cast<const StringImp&>( d ).data() ) );
|
||
13 years ago
|
return TQString::fromLatin1( "string" );
|
||
15 years ago
|
}
|
||
|
else if ( d.inherits( TestResultImp::stype() ) )
|
||
|
{
|
||
13 years ago
|
parent.appendChild(
|
||
15 years ago
|
doc.createTextNode(
|
||
|
static_cast<const TestResultImp&>( d ).data() ) );
|
||
13 years ago
|
return TQString::fromLatin1( "testresult" );
|
||
15 years ago
|
}
|
||
|
else if( d.inherits( HierarchyImp::stype() ) )
|
||
|
{
|
||
13 years ago
|
static_cast<const HierarchyImp&>( d ).data().serialize( parent, doc );
|
||
13 years ago
|
return TQString::fromLatin1( "hierarchy" );
|
||
15 years ago
|
}
|
||
|
else if ( d.inherits( TransformationImp::stype() ) )
|
||
|
{
|
||
|
const Transformation& trans = static_cast<const TransformationImp&>( d ).data();
|
||
|
|
||
15 years ago
|
TQDomElement matrixe = doc.createElement( "matrix" );
|
||
15 years ago
|
for ( int i = 0; i < 3; ++i )
|
||
|
{
|
||
|
for ( int j = 0; j < 3; ++j )
|
||
|
{
|
||
15 years ago
|
TQDomElement elel = doc.createElement( "element" );
|
||
|
elel.setAttribute( "row", TQString::number( i ) );
|
||
|
elel.setAttribute( "column", TQString::number( j ) );
|
||
|
elel.appendChild( doc.createTextNode( TQString::number( trans.data( i, j ) ) ) );
|
||
15 years ago
|
matrixe.appendChild( elel );
|
||
|
};
|
||
|
}
|
||
13 years ago
|
parent.appendChild( matrixe );
|
||
15 years ago
|
|
||
15 years ago
|
TQDomElement homothetye = doc.createElement( "homothetic" );
|
||
15 years ago
|
const char* ishomothety = trans.isHomothetic() ? "true" : "false";
|
||
|
homothetye.appendChild( doc.createTextNode( ishomothety ) );
|
||
13 years ago
|
parent.appendChild( homothetye );
|
||
15 years ago
|
|
||
13 years ago
|
return TQString::fromLatin1( "transformation" );
|
||
15 years ago
|
}
|
||
|
else if( d.inherits( AbstractLineImp::stype() ) )
|
||
|
{
|
||
|
LineData l = static_cast<const AbstractLineImp&>( d ).data();
|
||
13 years ago
|
addCoordinateElement( "a", l.a, parent, doc );
|
||
|
addCoordinateElement( "b", l.b, parent, doc );
|
||
15 years ago
|
if( d.inherits( SegmentImp::stype() ) )
|
||
13 years ago
|
return TQString::fromLatin1( "segment" );
|
||
15 years ago
|
else if( d.inherits( RayImp::stype() ) )
|
||
13 years ago
|
return TQString::fromLatin1( "ray" );
|
||
|
else return TQString::fromLatin1( "line" );
|
||
15 years ago
|
}
|
||
|
else if( d.inherits( PointImp::stype() ) )
|
||
|
{
|
||
|
addXYElements( static_cast<const PointImp&>( d ).coordinate(),
|
||
13 years ago
|
parent, doc );
|
||
13 years ago
|
return TQString::fromLatin1( "point" );
|
||
15 years ago
|
}
|
||
|
else if( d.inherits( TextImp::stype() ) )
|
||
|
{
|
||
15 years ago
|
TQString text = static_cast<const TextImp&>( d ).text();
|
||
13 years ago
|
parent.appendChild(
|
||
15 years ago
|
doc.createTextNode( text ) );
|
||
13 years ago
|
return TQString::fromLatin1( "text" );
|
||
15 years ago
|
}
|
||
|
else if( d.inherits( AngleImp::stype() ) )
|
||
|
{
|
||
13 years ago
|
addDoubleElement( "size", static_cast<const AngleImp&>( d ).size(), parent, doc );
|
||
13 years ago
|
return TQString::fromLatin1( "angle" );
|
||
15 years ago
|
}
|
||
|
else if ( d.inherits( ArcImp::stype() ) )
|
||
|
{
|
||
|
const ArcImp& a = static_cast<const ArcImp&>( d );
|
||
13 years ago
|
addCoordinateElement( "center", a.center(), parent, doc );
|
||
|
addDoubleElement( "radius", a.radius(), parent, doc );
|
||
|
addDoubleElement( "startangle", a.startAngle(), parent, doc );
|
||
|
addDoubleElement( "angle", a.angle(), parent, doc );
|
||
13 years ago
|
return TQString::fromLatin1( "arc" );
|
||
15 years ago
|
}
|
||
|
else if( d.inherits( VectorImp::stype() ) )
|
||
|
{
|
||
|
Coordinate dir = static_cast<const VectorImp&>( d ).dir();
|
||
13 years ago
|
addXYElements( dir, parent, doc );
|
||
13 years ago
|
return TQString::fromLatin1( "vector" );
|
||
15 years ago
|
}
|
||
|
else if( d.inherits( LocusImp::stype() ) )
|
||
|
{
|
||
|
const LocusImp& locus = static_cast<const LocusImp&>( d );
|
||
|
|
||
|
// serialize the curve..
|
||
15 years ago
|
TQDomElement curve = doc.createElement( "curve" );
|
||
15 years ago
|
const CurveImp& curveimp = *locus.curve();
|
||
15 years ago
|
TQString type = serialize( curveimp, curve, doc );
|
||
15 years ago
|
curve.setAttribute( "type", type );
|
||
13 years ago
|
parent.appendChild( curve );
|
||
15 years ago
|
|
||
|
// serialize the hierarchy..
|
||
15 years ago
|
TQDomElement hier = doc.createElement( "calculation" );
|
||
15 years ago
|
locus.hierarchy().serialize( hier, doc );
|
||
13 years ago
|
parent.appendChild( hier );
|
||
15 years ago
|
|
||
13 years ago
|
return TQString::fromLatin1( "locus" );
|
||
15 years ago
|
}
|
||
|
else if( d.inherits( CircleImp::stype() ) )
|
||
|
{
|
||
|
const CircleImp& c = static_cast<const CircleImp&>( d );
|
||
13 years ago
|
addCoordinateElement( "center", c.center(), parent, doc );
|
||
|
addDoubleElement( "radius", c.radius(), parent, doc );
|
||
13 years ago
|
return TQString::fromLatin1( "circle" );
|
||
15 years ago
|
}
|
||
|
else if( d.inherits( ConicImp::stype() ) )
|
||
|
{
|
||
|
const ConicPolarData data = static_cast<const ConicImp&>( d ).polarData();
|
||
13 years ago
|
addCoordinateElement( "focus1", data.focus1, parent, doc );
|
||
|
addDoubleElement( "pdimen", data.pdimen, parent, doc );
|
||
|
addDoubleElement( "ecostheta0", data.ecostheta0, parent, doc );
|
||
|
addDoubleElement( "esintheta0", data.esintheta0, parent, doc );
|
||
13 years ago
|
return TQString::fromLatin1( "conic" );
|
||
15 years ago
|
}
|
||
|
else if( d.inherits( CubicImp::stype() ) )
|
||
|
{
|
||
|
const CubicCartesianData data = static_cast<const CubicImp&>( d ).data();
|
||
15 years ago
|
TQDomElement coeffs = doc.createElement( "coefficients" );
|
||
15 years ago
|
addDoubleElement( "a000", data.coeffs[0], coeffs, doc );
|
||
|
addDoubleElement( "a001", data.coeffs[1], coeffs, doc );
|
||
|
addDoubleElement( "a002", data.coeffs[2], coeffs, doc );
|
||
|
addDoubleElement( "a011", data.coeffs[3], coeffs, doc );
|
||
|
addDoubleElement( "a012", data.coeffs[4], coeffs, doc );
|
||
|
addDoubleElement( "a022", data.coeffs[5], coeffs, doc );
|
||
|
addDoubleElement( "a111", data.coeffs[6], coeffs, doc );
|
||
|
addDoubleElement( "a112", data.coeffs[7], coeffs, doc );
|
||
|
addDoubleElement( "a122", data.coeffs[8], coeffs, doc );
|
||
|
addDoubleElement( "a222", data.coeffs[9], coeffs, doc );
|
||
13 years ago
|
parent.appendChild( coeffs );
|
||
13 years ago
|
return TQString::fromLatin1( "cubic" );
|
||
15 years ago
|
}
|
||
|
assert( false );
|
||
14 years ago
|
return TQString();
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
static Coordinate readXYElements( const TQDomElement& e, bool& ok )
|
||
15 years ago
|
{
|
||
|
double x, y;
|
||
|
ok = true;
|
||
15 years ago
|
TQDomElement xe = e.firstChild().toElement();
|
||
15 years ago
|
if ( xe.isNull() || xe.tagName() != "x" )
|
||
|
{
|
||
|
ok = false;
|
||
|
return Coordinate();
|
||
|
}
|
||
|
else x = xe.text().toDouble( &ok );
|
||
|
|
||
15 years ago
|
TQDomElement ye = xe.nextSibling().toElement();
|
||
15 years ago
|
if ( ye.isNull() || ye.tagName() != "y" )
|
||
|
{
|
||
|
ok = false;
|
||
|
return Coordinate();
|
||
|
}
|
||
|
else y = ye.text().toDouble( &ok );
|
||
|
|
||
|
return Coordinate( x, y );
|
||
|
}
|
||
|
|
||
15 years ago
|
static Coordinate readCoordinateElement( TQDomNode n, bool& ok,
|
||
15 years ago
|
const char* tagname )
|
||
|
{
|
||
15 years ago
|
TQDomElement e = n.toElement();
|
||
15 years ago
|
if ( e.isNull() || e.tagName() != tagname )
|
||
|
{
|
||
|
ok = false;
|
||
|
Coordinate ret;
|
||
|
return ret;
|
||
|
}
|
||
|
return readXYElements( e, ok );
|
||
|
}
|
||
|
|
||
15 years ago
|
static double readDoubleElement( TQDomNode n, bool& ok,
|
||
15 years ago
|
const char* tagname )
|
||
|
{
|
||
15 years ago
|
TQDomElement e = n.toElement();
|
||
15 years ago
|
if ( e.isNull() || e.tagName() != tagname )
|
||
|
{
|
||
|
ok = false;
|
||
|
return 0.;
|
||
|
};
|
||
|
return e.text().toDouble( &ok );
|
||
|
}
|
||
|
|
||
15 years ago
|
ObjectImp* ObjectImpFactory::deserialize( const TQString& type,
|
||
13 years ago
|
const TQDomElement& parent,
|
||
15 years ago
|
TQString& error ) const
|
||
15 years ago
|
{
|
||
|
#define KIG_GENERIC_PARSE_ERROR \
|
||
|
{ \
|
||
|
error = i18n( "An error was encountered at line %1 in file %2." ) \
|
||
13 years ago
|
.arg( __LINE__ ).arg( __FILE__ ); \
|
||
15 years ago
|
return 0; \
|
||
|
}
|
||
|
|
||
|
bool ok = true;
|
||
|
if ( type == "int" )
|
||
|
{
|
||
13 years ago
|
int ret = parent.text().toInt( &ok );
|
||
15 years ago
|
if ( ! ok ) KIG_GENERIC_PARSE_ERROR;
|
||
|
return new IntImp( ret );
|
||
|
}
|
||
|
else if ( type == "double" )
|
||
|
{
|
||
13 years ago
|
double ret = parent.text().toDouble( &ok );
|
||
15 years ago
|
if ( ! ok ) KIG_GENERIC_PARSE_ERROR;
|
||
|
return new DoubleImp( ret );
|
||
|
}
|
||
|
else if ( type == "string" )
|
||
|
{
|
||
13 years ago
|
return new StringImp( parent.text() );
|
||
15 years ago
|
}
|
||
|
else if ( type == "testresult" )
|
||
|
{
|
||
13 years ago
|
return new TestResultImp( parent.text() );
|
||
15 years ago
|
}
|
||
|
else if ( type == "hierarchy" )
|
||
|
{
|
||
13 years ago
|
ObjectHierarchy* hier = ObjectHierarchy::buildSafeObjectHierarchy( parent, error );
|
||
15 years ago
|
if ( ! hier ) return 0;
|
||
|
HierarchyImp* imp = new HierarchyImp( *hier );
|
||
|
delete hier;
|
||
|
return imp;
|
||
|
}
|
||
|
else if ( type == "transformation" )
|
||
|
{
|
||
|
double data[3][3];
|
||
|
bool homothetic = false;
|
||
13 years ago
|
for ( TQDomElement childe = parent.firstChild().toElement();
|
||
15 years ago
|
! childe.isNull(); childe = childe.nextSibling().toElement() )
|
||
|
{
|
||
|
if ( childe.tagName() == "matrix" )
|
||
|
{
|
||
15 years ago
|
for ( TQDomElement elel = childe.firstChild().toElement();
|
||
15 years ago
|
! elel.isNull(); elel = elel.nextSibling().toElement() )
|
||
|
{
|
||
|
if ( elel.tagName() != "element" ) KIG_GENERIC_PARSE_ERROR;
|
||
|
bool ok = true;
|
||
|
int row = elel.attribute( "row" ).toInt( &ok );
|
||
|
if ( ! ok ) KIG_GENERIC_PARSE_ERROR;
|
||
|
int column = elel.attribute( "column" ).toInt( &ok );
|
||
|
if ( ! ok ) KIG_GENERIC_PARSE_ERROR;
|
||
|
data[row][column] = elel.text().toDouble( &ok );
|
||
|
if ( ! ok ) KIG_GENERIC_PARSE_ERROR;
|
||
|
};
|
||
|
}
|
||
|
else if ( childe.tagName() == "homothetic" )
|
||
|
{
|
||
|
homothetic = childe.text() == "true";
|
||
|
}
|
||
|
else continue;
|
||
|
};
|
||
|
Transformation trans( data, homothetic );
|
||
|
return new TransformationImp( trans );
|
||
|
}
|
||
|
else if ( type == "point" )
|
||
|
{
|
||
13 years ago
|
Coordinate ret = readXYElements( parent, ok );
|
||
15 years ago
|
if ( ! ok ) KIG_GENERIC_PARSE_ERROR;
|
||
|
return new PointImp( ret );
|
||
|
}
|
||
|
else if ( type == "line" || type == "segment" || type == "ray" )
|
||
|
{
|
||
13 years ago
|
TQDomNode n = parent.firstChild();
|
||
15 years ago
|
Coordinate a = readCoordinateElement( n, ok, "a" );
|
||
|
if ( !ok ) KIG_GENERIC_PARSE_ERROR;
|
||
|
n = n.nextSibling();
|
||
|
Coordinate b = readCoordinateElement( n, ok, "b" );
|
||
|
if ( ! ok ) KIG_GENERIC_PARSE_ERROR;
|
||
|
if ( type == "line" ) return new LineImp( a, b );
|
||
|
else if ( type == "segment" ) return new SegmentImp( a, b );
|
||
|
else return new RayImp( a, b );
|
||
|
}
|
||
|
else if( type == "angle" )
|
||
|
{
|
||
13 years ago
|
double size = readDoubleElement( parent.firstChild(), ok, "size" );
|
||
15 years ago
|
if ( ! ok ) KIG_GENERIC_PARSE_ERROR;
|
||
|
return new AngleImp( Coordinate(), 0, size );
|
||
|
}
|
||
|
else if ( type == "arc" )
|
||
|
{
|
||
13 years ago
|
TQDomNode n = parent.firstChild();
|
||
15 years ago
|
Coordinate center = readCoordinateElement( n, ok, "center" );
|
||
|
if ( ! ok ) KIG_GENERIC_PARSE_ERROR;
|
||
|
n = n.nextSibling();
|
||
|
double radius = readDoubleElement( n, ok, "radius" );
|
||
|
if ( ! ok ) KIG_GENERIC_PARSE_ERROR;
|
||
|
n = n.nextSibling();
|
||
|
double startangle = readDoubleElement( n, ok, "startangle" );
|
||
|
if ( ! ok ) KIG_GENERIC_PARSE_ERROR;
|
||
|
n = n.nextSibling();
|
||
|
double angle = readDoubleElement( n, ok, "angle" );
|
||
|
if ( ! ok ) KIG_GENERIC_PARSE_ERROR;
|
||
|
return new ArcImp( center, radius, startangle, angle );
|
||
|
}
|
||
|
else if( type == "vector" )
|
||
|
{
|
||
13 years ago
|
Coordinate dir = readXYElements( parent, ok );
|
||
15 years ago
|
if ( ! ok ) KIG_GENERIC_PARSE_ERROR;
|
||
|
return new VectorImp( Coordinate(), dir );
|
||
|
}
|
||
|
else if( type == "locus" )
|
||
|
{
|
||
13 years ago
|
TQDomElement curvee = parent.firstChild().toElement();
|
||
15 years ago
|
if ( curvee.isNull() || curvee.tagName() != "curve" ) KIG_GENERIC_PARSE_ERROR;
|
||
15 years ago
|
TQString type = curvee.attribute( "type" );
|
||
15 years ago
|
ObjectImp* oi = deserialize( type, curvee, error );
|
||
|
if ( ! oi || ! oi->inherits( CurveImp::stype() ) ) KIG_GENERIC_PARSE_ERROR;
|
||
|
//CurveImp* curvei = static_cast<CurveImp*>( oi );
|
||
|
|
||
15 years ago
|
TQDomElement hiere = curvee.nextSibling().toElement();
|
||
15 years ago
|
if ( hiere.isNull() || hiere.tagName() != "calculation" ) KIG_GENERIC_PARSE_ERROR;
|
||
|
assert( false ); // TODO
|
||
|
// return new LocusImp( curvei, hier );
|
||
|
}
|
||
|
else if( type == "circle" )
|
||
|
{
|
||
13 years ago
|
TQDomNode n = parent.firstChild();
|
||
15 years ago
|
Coordinate center = readCoordinateElement( n, ok, "center" );
|
||
|
if ( ! ok ) KIG_GENERIC_PARSE_ERROR;
|
||
|
|
||
|
n = n.nextSibling();
|
||
|
double radius = readDoubleElement( n, ok, "radius" );
|
||
|
if ( ! ok ) KIG_GENERIC_PARSE_ERROR;
|
||
|
|
||
|
return new CircleImp( center, radius );
|
||
|
}
|
||
|
else if( type == "conic" )
|
||
|
{
|
||
13 years ago
|
TQDomNode n = parent.firstChild();
|
||
15 years ago
|
Coordinate focus1 = readCoordinateElement( n, ok, "focus1" );
|
||
|
if ( ! ok ) KIG_GENERIC_PARSE_ERROR;
|
||
|
|
||
|
n = n.nextSibling();
|
||
|
double pdimen = readDoubleElement( n, ok, "pdimen" );
|
||
|
if ( ! ok ) KIG_GENERIC_PARSE_ERROR;
|
||
|
|
||
|
n = n.nextSibling();
|
||
|
double ecostheta0 = readDoubleElement( n, ok, "ecostheta0" );
|
||
|
if ( ! ok ) KIG_GENERIC_PARSE_ERROR;
|
||
|
|
||
|
n = n.nextSibling();
|
||
|
double esintheta0 = readDoubleElement( n, ok, "esintheta0" );
|
||
|
if ( ! ok ) KIG_GENERIC_PARSE_ERROR;
|
||
|
|
||
|
return new ConicImpPolar(
|
||
|
ConicPolarData( focus1, pdimen, ecostheta0, esintheta0 ) );
|
||
|
}
|
||
|
else if( type == "cubic" )
|
||
|
{
|
||
13 years ago
|
TQDomElement coeffse = parent.firstChild().toElement();
|
||
15 years ago
|
if ( coeffse.isNull() || coeffse.tagName() != "coefficients" )
|
||
|
KIG_GENERIC_PARSE_ERROR;
|
||
|
|
||
15 years ago
|
TQDomNode n = coeffse.firstChild();
|
||
15 years ago
|
double a000 = readDoubleElement( n, ok, "a000" );
|
||
|
if ( ! ok ) KIG_GENERIC_PARSE_ERROR;
|
||
|
|
||
|
n = n.nextSibling();
|
||
|
double a001 = readDoubleElement( n, ok, "a001" );
|
||
|
if ( ! ok ) KIG_GENERIC_PARSE_ERROR;
|
||
|
|
||
|
n = n.nextSibling();
|
||
|
double a002 = readDoubleElement( n, ok, "a002" );
|
||
|
if ( ! ok ) KIG_GENERIC_PARSE_ERROR;
|
||
|
|
||
|
n = n.nextSibling();
|
||
|
double a011 = readDoubleElement( n, ok, "a011" );
|
||
|
if ( ! ok ) KIG_GENERIC_PARSE_ERROR;
|
||
|
|
||
|
n = n.nextSibling();
|
||
|
double a012 = readDoubleElement( n, ok, "a012" );
|
||
|
if ( ! ok ) KIG_GENERIC_PARSE_ERROR;
|
||
|
|
||
|
n = n.nextSibling();
|
||
|
double a022 = readDoubleElement( n, ok, "a022" );
|
||
|
if ( ! ok ) KIG_GENERIC_PARSE_ERROR;
|
||
|
|
||
|
n = n.nextSibling();
|
||
|
double a111 = readDoubleElement( n, ok, "a111" );
|
||
|
if ( ! ok ) KIG_GENERIC_PARSE_ERROR;
|
||
|
|
||
|
n = n.nextSibling();
|
||
|
double a112 = readDoubleElement( n, ok, "a112" );
|
||
|
if ( ! ok ) KIG_GENERIC_PARSE_ERROR;
|
||
|
|
||
|
n = n.nextSibling();
|
||
|
double a122 = readDoubleElement( n, ok, "a112" );
|
||
|
if ( ! ok ) KIG_GENERIC_PARSE_ERROR;
|
||
|
|
||
|
n = n.nextSibling();
|
||
|
double a222 = readDoubleElement( n, ok, "a222" );
|
||
|
if ( ! ok ) KIG_GENERIC_PARSE_ERROR;
|
||
|
|
||
|
return new CubicImp( CubicCartesianData( a000, a001, a002,
|
||
|
a011, a012, a022,
|
||
|
a111, a112, a122,
|
||
|
a222 ) );
|
||
|
}
|
||
|
|
||
|
error = i18n( "This Kig file uses an object of type \"%1\", "
|
||
|
"which this Kig version does not support."
|
||
|
"Perhaps you have compiled Kig without support "
|
||
|
"for this object type,"
|
||
13 years ago
|
"or perhaps you are using an older Kig version." ).arg( type );
|
||
15 years ago
|
return 0;
|
||
|
}
|
||
|
|