MCPcopy Create free account
hub / github.com/Kitware/VTK / WritePatterns

Method WritePatterns

IO/Export/vtkSVGContextDevice2D.cxx:2440–2477  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

2438
2439//------------------------------------------------------------------------------
2440void vtkSVGContextDevice2D::WritePatterns()
2441{
2442 for (const PatternInfo& info : this->Impl->PatternSet)
2443 {
2444 vtkNew<vtkXMLDataElement> pattern;
2445 this->DefinitionNode->AddNestedElement(pattern);
2446 pattern->SetName("pattern");
2447 pattern->SetAttribute("id", info.PatternId.c_str());
2448
2449 // We only care about Repeat and Stretch, since SVG doesn't allow control
2450 // over Nearest/Linear interpolation.
2451 const bool isTiled = ((info.TextureProperty & vtkBrush::Repeat) != 0);
2452 if (isTiled)
2453 {
2454 pattern->SetIntAttribute("width", info.ImageSize[0]);
2455 pattern->SetIntAttribute("height", info.ImageSize[1]);
2456 pattern->SetAttribute("patternUnits", "userSpaceOnUse");
2457 }
2458 else // Stretched
2459 {
2460 std::ostringstream viewBox;
2461 viewBox << "0,0," << info.ImageSize[0] << "," << info.ImageSize[1];
2462 pattern->SetIntAttribute("width", 1);
2463 pattern->SetIntAttribute("height", 1);
2464 pattern->SetAttribute("viewBox", viewBox.str().c_str());
2465 pattern->SetAttribute("preserveAspectRatio", "none");
2466 }
2467
2468 vtkNew<vtkXMLDataElement> use;
2469 pattern->AddNestedElement(use);
2470 use->SetName("use");
2471 use->SetFloatAttribute("x", 0);
2472 use->SetFloatAttribute("y", 0);
2473 use->SetIntAttribute("width", info.ImageSize[0]);
2474 use->SetIntAttribute("height", info.ImageSize[1]);
2475 use->SetAttribute("xlink:href", (std::string("#") + info.ImageId).c_str());
2476 }
2477}
2478
2479//------------------------------------------------------------------------------
2480void vtkSVGContextDevice2D::WriteClipRects()

Callers 1

GenerateDefinitionsMethod · 0.95

Calls 8

AddNestedElementMethod · 0.80
SetIntAttributeMethod · 0.80
SetFloatAttributeMethod · 0.80
stringClass · 0.50
SetNameMethod · 0.45
SetAttributeMethod · 0.45
c_strMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected