当前位置: 首页>>代码示例>>C++>>正文


C++ Proxy::removeChild方法代码示例

本文整理汇总了C++中Proxy::removeChild方法的典型用法代码示例。如果您正苦于以下问题:C++ Proxy::removeChild方法的具体用法?C++ Proxy::removeChild怎么用?C++ Proxy::removeChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Proxy的用法示例。


在下文中一共展示了Proxy::removeChild方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: testUndo


//.........这里部分代码省略.........
    // another check that the addProxy() did not change anything
    CPPUNIT_ASSERT_EQUAL(true, checkWorldsAreEqual(&undoWorld, &referenceWorld));
    undoWorld.undoStep();
    CPPUNIT_ASSERT_EQUAL(true, checkWorldsAreEqual(&undoWorld, &referenceWorld));

    //////////////////////////////////////
    // add grand-children to the hierarchy
    //////////////////////////////////////
    Proxy* grandChildUndoWorld = undoWorld.createProxy(new Box(10, 10, 10));
    Proxy* grandChildReferenceWorld = referenceWorld.createProxy(new Box(10, 10, 10));
    grandChildUndoWorld->translate(0, 0, 100);
    grandChildReferenceWorld->translate(0, 0, 100);
    grandChildUndoWorld->rotate(100, 0, 0, 1);
    grandChildReferenceWorld->rotate(100, 0, 0, 1);
    childUndoWorld->addChild(grandChildUndoWorld);
    childReferenceWorld->addChild(grandChildReferenceWorld);
    ////////////////////////////////////////////
    // add grand-children to the hierarchy (end)
    ////////////////////////////////////////////

    // check that grand-children adding did not change anything
    CPPUNIT_ASSERT_EQUAL(true, checkWorldsAreEqual(&undoWorld, &referenceWorld));
    undoWorld.undoStep();
    CPPUNIT_ASSERT_EQUAL(true, checkWorldsAreEqual(&undoWorld, &referenceWorld));

    // check for undo on children
    childUndoWorld->translate(60, 0, 0);
    undoWorld.undoStep();
    CPPUNIT_ASSERT_EQUAL(true, checkWorldsAreEqual(&undoWorld, &referenceWorld));

    // check for undo on grand-children
    grandChildUndoWorld->translate(60, 0, 0);
    undoWorld.undoStep();
    CPPUNIT_ASSERT_EQUAL(true, checkWorldsAreEqual(&undoWorld, &referenceWorld));

    // check for undo on the whole hierarchy
    proxyUndoWorld->translate(5, 5, 5);
    childUndoWorld->rotate(54, 1, 0, 0);
    m = Matrix();
    m.translate(10, 10, 10);
    m.rotate(44, 1, 0, 0);
    grandChildUndoWorld->setTransformation(m);
    grandChildUndoWorld->translate(60, 0, 0);
    undoWorld.undoStep();
    CPPUNIT_ASSERT_EQUAL(true, checkWorldsAreEqual(&undoWorld, &referenceWorld));


    // check that removeProxy() is NOT undone
    undoWorld.removeProxy(dummyUndoProxy);
    referenceWorld.removeProxy(dummyReferenceProxy);
    delete dummyUndoProxy;
    delete dummyReferenceProxy;
    CPPUNIT_ASSERT_EQUAL(true, checkWorldsAreEqual(&undoWorld, &referenceWorld));
    undoWorld.undoStep();
    CPPUNIT_ASSERT_EQUAL(true, checkWorldsAreEqual(&undoWorld, &referenceWorld));


    proxyUndoWorld->translate(10, 10, 10);
    proxyReferenceWorld->translate(10, 10, 10);
    // undo should cause the worlds NOT to be equal
    undoWorld.undoStep();
    CPPUNIT_ASSERT_EQUAL(false, checkWorldsAreEqual(&undoWorld, &referenceWorld));

    proxyUndoWorld->translate(10, 10, 10);
    CPPUNIT_ASSERT_EQUAL(true, checkWorldsAreEqual(&undoWorld, &referenceWorld));

    // check that that startNextStep() actually works as intended, i.e. we undo
    // the things _after_ the startNextStep(), not the ones before
    undoWorld.startNextStep();
    // startNextStep() should not undo anything (except the moveflags)
    CPPUNIT_ASSERT_EQUAL(true, checkWorldsAreEqual(&undoWorld, &referenceWorld));

    // startNextStep() should clear all possible "undo" values, i.e. this
    // should be a noop
    undoWorld.undoStep();
    CPPUNIT_ASSERT_EQUAL(true, checkWorldsAreEqual(&undoWorld, &referenceWorld));

    // things _after_ a startNextStep() should be undone again
    proxyUndoWorld->translate(10, 10, 10);
    undoWorld.undoStep();
    CPPUNIT_ASSERT_EQUAL(true, checkWorldsAreEqual(&undoWorld, &referenceWorld));

    // check that removing of grand-children does not change anything
    childUndoWorld->removeChild(grandChildUndoWorld);
    childReferenceWorld->removeChild(grandChildReferenceWorld);
    delete grandChildUndoWorld;
    delete grandChildReferenceWorld;
    CPPUNIT_ASSERT_EQUAL(true, checkWorldsAreEqual(&undoWorld, &referenceWorld));
    undoWorld.undoStep();
    CPPUNIT_ASSERT_EQUAL(true, checkWorldsAreEqual(&undoWorld, &referenceWorld));

    // check that calls to startNextStep() after removeChild() still works
    undoWorld.startNextStep();
    CPPUNIT_ASSERT_EQUAL(true, checkWorldsAreEqual(&undoWorld, &referenceWorld));
    undoWorld.undoStep();
    CPPUNIT_ASSERT_EQUAL(true, checkWorldsAreEqual(&undoWorld, &referenceWorld));

    // TODO: check that deformations are un-done?
    //       open question: do we want to support un-doing of deformations?
}
开发者ID:ColinGilbert,项目名称:d-collide,代码行数:101,代码来源:undotest.cpp


注:本文中的Proxy::removeChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。