| 35 | } |
| 36 | |
| 37 | void mitk::InteractionTestHelper::Initialize(const std::string &interactionXmlFilePath) |
| 38 | { |
| 39 | tinyxml2::XMLDocument document; |
| 40 | if (tinyxml2::XML_SUCCESS == document.LoadFile(interactionXmlFilePath.c_str())) |
| 41 | { |
| 42 | // create data storage |
| 43 | m_DataStorage = mitk::StandaloneDataStorage::New(); |
| 44 | |
| 45 | // for each renderer found create a render window and configure |
| 46 | for (auto *element = document.FirstChildElement(mitk::InteractionEventConst::xmlTagInteractions().c_str()) |
| 47 | ->FirstChildElement(mitk::InteractionEventConst::xmlTagConfigRoot().c_str()) |
| 48 | ->FirstChildElement(mitk::InteractionEventConst::xmlTagRenderer().c_str()); |
| 49 | element != nullptr; |
| 50 | element = element->NextSiblingElement(mitk::InteractionEventConst::xmlTagRenderer().c_str())) |
| 51 | { |
| 52 | // get name of renderer |
| 53 | const char *rendererName = |
| 54 | element->Attribute(mitk::InteractionEventConst::xmlEventPropertyRendererName().c_str()); |
| 55 | |
| 56 | // get view direction |
| 57 | mitk::AnatomicalPlane viewDirection = mitk::AnatomicalPlane::Axial; |
| 58 | if (element->Attribute(mitk::InteractionEventConst::xmlEventPropertyViewDirection().c_str()) != nullptr) |
| 59 | { |
| 60 | int viewDirectionNum = |
| 61 | std::atoi(element->Attribute(mitk::InteractionEventConst::xmlEventPropertyViewDirection().c_str())); |
| 62 | viewDirection = static_cast<mitk::AnatomicalPlane>(viewDirectionNum); |
| 63 | } |
| 64 | |
| 65 | // get mapper slot id |
| 66 | MapperSlotId mapperID = mitk::BaseRenderer::Standard2D; |
| 67 | if (element->Attribute(mitk::InteractionEventConst::xmlEventPropertyMapperID().c_str()) != nullptr) |
| 68 | { |
| 69 | int mapperIDNum = |
| 70 | std::atoi(element->Attribute(mitk::InteractionEventConst::xmlEventPropertyMapperID().c_str())); |
| 71 | mapperID = static_cast<MapperSlotId>(mapperIDNum); |
| 72 | } |
| 73 | |
| 74 | // Get Size of Render Windows |
| 75 | int size[3]; |
| 76 | size[0] = size[1] = size[2] = 0; |
| 77 | if (element->Attribute(mitk::InteractionEventConst::xmlRenderSizeX().c_str()) != nullptr) |
| 78 | { |
| 79 | size[0] = std::atoi(element->Attribute(mitk::InteractionEventConst::xmlRenderSizeX().c_str())); |
| 80 | } |
| 81 | if (element->Attribute(mitk::InteractionEventConst::xmlRenderSizeY().c_str()) != nullptr) |
| 82 | { |
| 83 | size[1] = std::atoi(element->Attribute(mitk::InteractionEventConst::xmlRenderSizeY().c_str())); |
| 84 | } |
| 85 | if (element->Attribute(mitk::InteractionEventConst::xmlRenderSizeZ().c_str()) != nullptr) |
| 86 | { |
| 87 | size[2] = std::atoi(element->Attribute(mitk::InteractionEventConst::xmlRenderSizeZ().c_str())); |
| 88 | } |
| 89 | |
| 90 | // create renderWindow, renderer and dispatcher |
| 91 | auto rw = RenderWindow::New(nullptr, rendererName); // VtkRenderWindow is created within constructor if nullptr |
| 92 | |
| 93 | if (size[0] != 0 && size[1] != 0) |
| 94 | { |
no test coverage detected