Mercurial > hg > orthanc-stone
comparison Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp @ 1615:f5d4bd7b5593
new class: OsiriXLayerFactory
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 30 Oct 2020 17:26:44 +0100 |
parents | ad9b425f27ae |
children | 49ba862d3454 |
comparison
equal
deleted
inserted
replaced
1614:ad9b425f27ae | 1615:f5d4bd7b5593 |
---|---|
72 #include <Oracle/ParseDicomSuccessMessage.h> | 72 #include <Oracle/ParseDicomSuccessMessage.h> |
73 #include <Scene2D/ArrowSceneLayer.h> | 73 #include <Scene2D/ArrowSceneLayer.h> |
74 #include <Scene2D/ColorTextureSceneLayer.h> | 74 #include <Scene2D/ColorTextureSceneLayer.h> |
75 #include <Scene2D/FloatTextureSceneLayer.h> | 75 #include <Scene2D/FloatTextureSceneLayer.h> |
76 #include <Scene2D/MacroSceneLayer.h> | 76 #include <Scene2D/MacroSceneLayer.h> |
77 #include <Scene2D/OsiriXLayerFactory.h> | |
77 #include <Scene2D/PolylineSceneLayer.h> | 78 #include <Scene2D/PolylineSceneLayer.h> |
78 #include <Scene2D/TextSceneLayer.h> | 79 #include <Scene2D/TextSceneLayer.h> |
79 #include <Scene2DViewport/ViewportController.h> | 80 #include <Scene2DViewport/ViewportController.h> |
80 #include <StoneException.h> | 81 #include <StoneException.h> |
81 #include <Toolbox/DicomInstanceParameters.h> | 82 #include <Toolbox/DicomInstanceParameters.h> |
1516 OrthancStone::GeometryToolbox::GetPixelSpacing( | 1517 OrthancStone::GeometryToolbox::GetPixelSpacing( |
1517 pixelSpacingX, pixelSpacingY, frames_->GetFrameTags(index)); | 1518 pixelSpacingX, pixelSpacingY, frames_->GetFrameTags(index)); |
1518 layer->SetPixelSpacing(pixelSpacingX, pixelSpacingY); | 1519 layer->SetPixelSpacing(pixelSpacingX, pixelSpacingY); |
1519 | 1520 |
1520 | 1521 |
1521 /**** | |
1522 * BEGINNING OF EXPERIMENTAL CODE => TODO => Move this to class | |
1523 * "CollectionOfAnnotations"? | |
1524 ****/ | |
1525 | |
1526 std::unique_ptr<OrthancStone::MacroSceneLayer> annotationsLayer; | 1522 std::unique_ptr<OrthancStone::MacroSceneLayer> annotationsLayer; |
1527 | 1523 |
1528 if (annotations_) | 1524 if (annotations_) |
1529 { | 1525 { |
1526 const FrameGeometry& geometry = GetCurrentFrameGeometry(); | |
1527 | |
1530 std::set<size_t> a; | 1528 std::set<size_t> a; |
1531 annotations_->LookupSopInstanceUid(a, sopInstanceUid); | 1529 annotations_->LookupSopInstanceUid(a, sopInstanceUid); |
1532 if (!a.empty()) | 1530 if (geometry.IsValid() && |
1531 !a.empty()) | |
1533 { | 1532 { |
1534 annotationsLayer.reset(new OrthancStone::MacroSceneLayer); | 1533 annotationsLayer.reset(new OrthancStone::MacroSceneLayer); |
1535 annotationsLayer->Reserve(a.size()); | 1534 annotationsLayer->Reserve(a.size()); |
1536 | 1535 |
1537 using namespace OrthancStone::OsiriX; | 1536 OrthancStone::OsiriXLayerFactory factory; |
1537 factory.SetColor(0, 255, 0); | |
1538 factory.SetArrowLength(100); | |
1539 factory.SetArrowAngle(3.14159/4.0); | |
1538 | 1540 |
1539 for (std::set<size_t>::const_iterator it = a.begin(); it != a.end(); ++it) | 1541 for (std::set<size_t>::const_iterator it = a.begin(); it != a.end(); ++it) |
1540 { | 1542 { |
1541 const Annotation& annotation = annotations_->GetAnnotation(*it); | 1543 const OrthancStone::OsiriX::Annotation& annotation = annotations_->GetAnnotation(*it); |
1542 | 1544 annotationsLayer->AddLayer(factory.Create(annotation, geometry.GetCoordinates())); |
1543 switch (annotation.GetType()) | |
1544 { | |
1545 case Annotation::Type_Line: | |
1546 { | |
1547 const LineAnnotation& line = dynamic_cast<const LineAnnotation&>(annotation); | |
1548 double x1, y1, x2, y2; | |
1549 if (GetCurrentFrameGeometry().ProjectPoint(x1, y1, line.GetPoint1()) && | |
1550 GetCurrentFrameGeometry().ProjectPoint(x2, y2, line.GetPoint2())) | |
1551 { | |
1552 if (line.IsArrow()) | |
1553 { | |
1554 std::unique_ptr<OrthancStone::ArrowSceneLayer> layer( | |
1555 new OrthancStone::ArrowSceneLayer(OrthancStone::ScenePoint2D(x1, y1), | |
1556 OrthancStone::ScenePoint2D(x2, y2))); | |
1557 layer->SetColor(0, 255, 0); | |
1558 annotationsLayer->AddLayer(layer.release()); | |
1559 } | |
1560 else | |
1561 { | |
1562 std::unique_ptr<OrthancStone::PolylineSceneLayer> layer(new OrthancStone::PolylineSceneLayer); | |
1563 OrthancStone::PolylineSceneLayer::Chain chain; | |
1564 chain.push_back(OrthancStone::ScenePoint2D(x1, y1)); | |
1565 chain.push_back(OrthancStone::ScenePoint2D(x2, y2)); | |
1566 layer->AddChain(chain, false, 0, 255, 0); | |
1567 annotationsLayer->AddLayer(layer.release()); | |
1568 } | |
1569 } | |
1570 break; | |
1571 } | |
1572 | |
1573 case Annotation::Type_Angle: | |
1574 { | |
1575 const AngleAnnotation& angle = dynamic_cast<const AngleAnnotation&>(annotation); | |
1576 double x1, y1, x2, y2, x3, y3; | |
1577 if (GetCurrentFrameGeometry().ProjectPoint(x1, y1, angle.GetA()) && | |
1578 GetCurrentFrameGeometry().ProjectPoint(x2, y2, angle.GetCenter()) && | |
1579 GetCurrentFrameGeometry().ProjectPoint(x3, y3, angle.GetB())) | |
1580 { | |
1581 std::unique_ptr<OrthancStone::PolylineSceneLayer> layer(new OrthancStone::PolylineSceneLayer); | |
1582 OrthancStone::PolylineSceneLayer::Chain chain; | |
1583 chain.push_back(OrthancStone::ScenePoint2D(x1, y1)); | |
1584 chain.push_back(OrthancStone::ScenePoint2D(x2, y2)); | |
1585 chain.push_back(OrthancStone::ScenePoint2D(x3, y3)); | |
1586 layer->AddChain(chain, false, 0, 255, 0); | |
1587 annotationsLayer->AddLayer(layer.release()); | |
1588 } | |
1589 break; | |
1590 } | |
1591 | |
1592 case Annotation::Type_Text: | |
1593 { | |
1594 const TextAnnotation& text = dynamic_cast<const TextAnnotation&>(annotation); | |
1595 double x, y; | |
1596 if (GetCurrentFrameGeometry().ProjectPoint(x, y, text.GetCenter())) | |
1597 { | |
1598 std::unique_ptr<OrthancStone::TextSceneLayer> layer(new OrthancStone::TextSceneLayer()); | |
1599 layer->SetPosition(x, y); | |
1600 layer->SetText(text.GetText()); | |
1601 layer->SetAnchor(OrthancStone::BitmapAnchor_Center); | |
1602 layer->SetColor(255, 0, 0); | |
1603 annotationsLayer->AddLayer(layer.release()); | |
1604 } | |
1605 break; | |
1606 } | |
1607 | |
1608 default: | |
1609 LOG(ERROR) << "Annotation type not implemented: " << annotation.GetType(); | |
1610 } | |
1611 } | 1545 } |
1612 } | 1546 } |
1613 } | 1547 } |
1614 | |
1615 /**** | |
1616 * END OF EXPERIMENTAL CODE | |
1617 ****/ | |
1618 | 1548 |
1619 | 1549 |
1620 if (layer.get() == NULL) | 1550 if (layer.get() == NULL) |
1621 { | 1551 { |
1622 return false; | 1552 return false; |