bool SWContact2D::evaluate() { SWManifold mf; bool ret = testFixture2D( mf, fixture1(), fixture2() ); if ( ret ) { manifold = mf; tmat33 mat; SWCollider2D* collider1 = fixture1()->getCollide(); cm1 = collider1->getCenterOfMass(); SWCollider2D* collider2 = fixture2()->getCollide(); cm2 = collider2->getCenterOfMass(); /*for ( tuint i=0;i<mf.count;++i ) { SWLog( "r%d %f, %f", i, mf.points[i].x, mf.points[i].y ); } */ //SWLog( "cm1 %f, %f", cm1.x, cm1.y ); //SWLog( "cm2 %f, %f", cm2.x, cm2.y ); } return ret; }
void VCXYPad_Test::saveXML() { QWidget w; VCXYPad pad(&w, m_doc); pad.show(); w.show(); pad.setCaption("MyPad"); pad.resize(QSize(150, 200)); pad.move(QPoint(10, 20)); pad.m_area->setPosition(QPointF(23, 45)); pad.setInputSource(new QLCInputSource(0, 1), VCXYPad::panInputSourceId); pad.setInputSource(new QLCInputSource(2, 3), VCXYPad::tiltInputSourceId); QCOMPARE(pad.m_area->position(), QPointF(23, 45)); QCOMPARE(pad.m_area->position(), QPointF(23, 45)); VCXYPadFixture fixture1(m_doc); fixture1.setHead(GroupHead(11, 0)); pad.appendFixture(fixture1); VCXYPadFixture fixture2(m_doc); fixture2.setHead(GroupHead(22, 0)); pad.appendFixture(fixture2); QDomDocument xmldoc; QDomElement root = xmldoc.createElement("Root"); xmldoc.appendChild(root); int fixture = 0, position = 0, wstate = 0, appearance = 0, pan = 0, tilt = 0; QVERIFY(pad.saveXML(&xmldoc, &root) == true); QDomNode node = root.firstChild(); QCOMPARE(node.toElement().tagName(), QString("XYPad")); QCOMPARE(node.toElement().attribute("Caption"), QString("MyPad")); node = node.firstChild(); while (node.isNull() == false) { QDomElement tag = node.toElement(); if (tag.tagName() == "Fixture") { fixture++; QVERIFY(tag.attribute("ID") == QString("11") || tag.attribute("ID") == QString("22")); QVERIFY(tag.attribute("Head") == QString("0")); QCOMPARE(tag.childNodes().count(), 2); } else if (tag.tagName() == "Position") { position++; QFAIL("Legacy tag found in saved XML!"); } else if (tag.tagName() == "Pan") { pan++; QCOMPARE(tag.attribute("Position"), QString("23")); QCOMPARE(tag.firstChild().toElement().attribute("Universe"), QString("0")); QCOMPARE(tag.firstChild().toElement().attribute("Channel"), QString("1")); } else if (tag.tagName() == "Tilt") { tilt++; QCOMPARE(tag.attribute("Position"), QString("45")); QCOMPARE(tag.firstChild().toElement().attribute("Universe"), QString("2")); QCOMPARE(tag.firstChild().toElement().attribute("Channel"), QString("3")); } else if (tag.tagName() == "WindowState") { wstate++; } else if (tag.tagName() == "Appearance") { appearance++; } else { QFAIL(QString("Unexpected tag: %1").arg(tag.tagName()).toUtf8().constData()); } node = node.nextSibling(); } QCOMPARE(fixture, 2); QCOMPARE(position, 0); QCOMPARE(pan, 1); QCOMPARE(tilt, 1); QCOMPARE(wstate, 1); QCOMPARE(appearance, 1); }