Mercurial > hg > orthanc-stone
comparison Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp @ 1611:787db80a5a1b
new class MacroLayerRenderer
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 29 Oct 2020 18:02:03 +0100 |
parents | 2df998314507 |
children | ad9b425f27ae |
comparison
equal
deleted
inserted
replaced
1610:b7630b1a0253 | 1611:787db80a5a1b |
---|---|
70 #include <Messages/ObserverBase.h> | 70 #include <Messages/ObserverBase.h> |
71 #include <Oracle/ParseDicomFromWadoCommand.h> | 71 #include <Oracle/ParseDicomFromWadoCommand.h> |
72 #include <Oracle/ParseDicomSuccessMessage.h> | 72 #include <Oracle/ParseDicomSuccessMessage.h> |
73 #include <Scene2D/ColorTextureSceneLayer.h> | 73 #include <Scene2D/ColorTextureSceneLayer.h> |
74 #include <Scene2D/FloatTextureSceneLayer.h> | 74 #include <Scene2D/FloatTextureSceneLayer.h> |
75 #include <Scene2D/MacroSceneLayer.h> | |
75 #include <Scene2D/PolylineSceneLayer.h> | 76 #include <Scene2D/PolylineSceneLayer.h> |
76 #include <Scene2D/TextSceneLayer.h> | 77 #include <Scene2D/TextSceneLayer.h> |
77 #include <Scene2DViewport/ViewportController.h> | 78 #include <Scene2DViewport/ViewportController.h> |
78 #include <StoneException.h> | 79 #include <StoneException.h> |
79 #include <Toolbox/DicomInstanceParameters.h> | 80 #include <Toolbox/DicomInstanceParameters.h> |
990 | 991 |
991 private: | 992 private: |
992 static const int LAYER_TEXTURE = 0; | 993 static const int LAYER_TEXTURE = 0; |
993 static const int LAYER_REFERENCE_LINES = 1; | 994 static const int LAYER_REFERENCE_LINES = 1; |
994 static const int LAYER_ANNOTATIONS = 2; | 995 static const int LAYER_ANNOTATIONS = 2; |
995 static const int LAYER_TEMP = 3; // TODO - REMOVE | 996 |
996 | |
997 | 997 |
998 class ICommand : public Orthanc::IDynamicObject | 998 class ICommand : public Orthanc::IDynamicObject |
999 { | 999 { |
1000 private: | 1000 private: |
1001 boost::shared_ptr<ViewerViewport> viewport_; | 1001 boost::shared_ptr<ViewerViewport> viewport_; |
1516 pixelSpacingX, pixelSpacingY, frames_->GetFrameTags(index)); | 1516 pixelSpacingX, pixelSpacingY, frames_->GetFrameTags(index)); |
1517 layer->SetPixelSpacing(pixelSpacingX, pixelSpacingY); | 1517 layer->SetPixelSpacing(pixelSpacingX, pixelSpacingY); |
1518 | 1518 |
1519 | 1519 |
1520 /**** | 1520 /**** |
1521 * BEGINNING OF EXPERIMENTAL CODE | 1521 * BEGINNING OF EXPERIMENTAL CODE => TODO => Move this to class |
1522 * "CollectionOfAnnotations"? | |
1522 ****/ | 1523 ****/ |
1523 | 1524 |
1524 std::unique_ptr<OrthancStone::ISceneLayer> annotationsLayer; // TODO - Macro layer | 1525 std::unique_ptr<OrthancStone::MacroSceneLayer> annotationsLayer; |
1525 std::unique_ptr<OrthancStone::ISceneLayer> tempLayer; // TODO - Macro layer | |
1526 | 1526 |
1527 if (annotations_) | 1527 if (annotations_) |
1528 { | 1528 { |
1529 std::set<size_t> a; | 1529 std::set<size_t> a; |
1530 annotations_->LookupSopInstanceUid(a, sopInstanceUid); | 1530 annotations_->LookupSopInstanceUid(a, sopInstanceUid); |
1531 if (!a.empty()) | 1531 if (!a.empty()) |
1532 { | 1532 { |
1533 annotationsLayer.reset(new OrthancStone::MacroSceneLayer); | |
1534 annotationsLayer->Reserve(a.size()); | |
1535 | |
1533 using namespace OrthancStone::OsiriX; | 1536 using namespace OrthancStone::OsiriX; |
1534 | |
1535 std::unique_ptr<OrthancStone::PolylineSceneLayer> layer(new OrthancStone::PolylineSceneLayer); | |
1536 | 1537 |
1537 for (std::set<size_t>::const_iterator it = a.begin(); it != a.end(); ++it) | 1538 for (std::set<size_t>::const_iterator it = a.begin(); it != a.end(); ++it) |
1538 { | 1539 { |
1539 const Annotation& annotation = annotations_->GetAnnotation(*it); | 1540 const Annotation& annotation = annotations_->GetAnnotation(*it); |
1540 | 1541 |
1545 const LineAnnotation& line = dynamic_cast<const LineAnnotation&>(annotation); | 1546 const LineAnnotation& line = dynamic_cast<const LineAnnotation&>(annotation); |
1546 double x1, y1, x2, y2; | 1547 double x1, y1, x2, y2; |
1547 if (GetCurrentFrameGeometry().ProjectPoint(x1, y1, line.GetPoint1()) && | 1548 if (GetCurrentFrameGeometry().ProjectPoint(x1, y1, line.GetPoint1()) && |
1548 GetCurrentFrameGeometry().ProjectPoint(x2, y2, line.GetPoint2())) | 1549 GetCurrentFrameGeometry().ProjectPoint(x2, y2, line.GetPoint2())) |
1549 { | 1550 { |
1551 std::unique_ptr<OrthancStone::PolylineSceneLayer> layer(new OrthancStone::PolylineSceneLayer); | |
1550 OrthancStone::PolylineSceneLayer::Chain chain; | 1552 OrthancStone::PolylineSceneLayer::Chain chain; |
1551 chain.push_back(OrthancStone::ScenePoint2D(x1, y1)); | 1553 chain.push_back(OrthancStone::ScenePoint2D(x1, y1)); |
1552 chain.push_back(OrthancStone::ScenePoint2D(x2, y2)); | 1554 chain.push_back(OrthancStone::ScenePoint2D(x2, y2)); |
1553 | 1555 |
1554 // TODO - IsArrow | 1556 // TODO - IsArrow |
1555 | 1557 |
1556 layer->AddChain(chain, false, 0, 255, 0); | 1558 layer->AddChain(chain, false, 0, 255, 0); |
1559 annotationsLayer->AddLayer(layer.release()); | |
1557 } | 1560 } |
1558 break; | 1561 break; |
1559 } | 1562 } |
1560 | 1563 |
1561 case Annotation::Type_Angle: | 1564 case Annotation::Type_Angle: |
1564 double x1, y1, x2, y2, x3, y3; | 1567 double x1, y1, x2, y2, x3, y3; |
1565 if (GetCurrentFrameGeometry().ProjectPoint(x1, y1, angle.GetA()) && | 1568 if (GetCurrentFrameGeometry().ProjectPoint(x1, y1, angle.GetA()) && |
1566 GetCurrentFrameGeometry().ProjectPoint(x2, y2, angle.GetCenter()) && | 1569 GetCurrentFrameGeometry().ProjectPoint(x2, y2, angle.GetCenter()) && |
1567 GetCurrentFrameGeometry().ProjectPoint(x3, y3, angle.GetB())) | 1570 GetCurrentFrameGeometry().ProjectPoint(x3, y3, angle.GetB())) |
1568 { | 1571 { |
1572 std::unique_ptr<OrthancStone::PolylineSceneLayer> layer(new OrthancStone::PolylineSceneLayer); | |
1569 OrthancStone::PolylineSceneLayer::Chain chain; | 1573 OrthancStone::PolylineSceneLayer::Chain chain; |
1570 chain.push_back(OrthancStone::ScenePoint2D(x1, y1)); | 1574 chain.push_back(OrthancStone::ScenePoint2D(x1, y1)); |
1571 chain.push_back(OrthancStone::ScenePoint2D(x2, y2)); | 1575 chain.push_back(OrthancStone::ScenePoint2D(x2, y2)); |
1572 chain.push_back(OrthancStone::ScenePoint2D(x3, y3)); | 1576 chain.push_back(OrthancStone::ScenePoint2D(x3, y3)); |
1573 layer->AddChain(chain, false, 0, 255, 0); | 1577 layer->AddChain(chain, false, 0, 255, 0); |
1578 annotationsLayer->AddLayer(layer.release()); | |
1574 } | 1579 } |
1575 break; | 1580 break; |
1576 } | 1581 } |
1577 | 1582 |
1578 case Annotation::Type_Text: | 1583 case Annotation::Type_Text: |
1579 { | 1584 { |
1580 const TextAnnotation& text = dynamic_cast<const TextAnnotation&>(annotation); | 1585 const TextAnnotation& text = dynamic_cast<const TextAnnotation&>(annotation); |
1581 double x, y; | 1586 double x, y; |
1582 if (GetCurrentFrameGeometry().ProjectPoint(x, y, text.GetCenter())) | 1587 if (GetCurrentFrameGeometry().ProjectPoint(x, y, text.GetCenter())) |
1583 { | 1588 { |
1584 std::unique_ptr<OrthancStone::TextSceneLayer> layer2(new OrthancStone::TextSceneLayer()); | 1589 std::unique_ptr<OrthancStone::TextSceneLayer> layer(new OrthancStone::TextSceneLayer()); |
1585 layer2->SetPosition(x, y); | 1590 layer->SetPosition(x, y); |
1586 layer2->SetText(text.GetText()); | 1591 layer->SetText(text.GetText()); |
1587 layer2->SetAnchor(OrthancStone::BitmapAnchor_Center); | 1592 layer->SetAnchor(OrthancStone::BitmapAnchor_Center); |
1588 layer2->SetColor(255, 0, 0); | 1593 layer->SetColor(255, 0, 0); |
1589 tempLayer.reset(layer2.release()); | 1594 annotationsLayer->AddLayer(layer.release()); |
1590 } | 1595 } |
1591 break; | 1596 break; |
1592 } | 1597 } |
1593 | 1598 |
1594 default: | 1599 default: |
1595 LOG(ERROR) << "Annotation type not implemented: " << annotation.GetType(); | 1600 LOG(ERROR) << "Annotation type not implemented: " << annotation.GetType(); |
1596 } | 1601 } |
1597 } | 1602 } |
1598 | |
1599 annotationsLayer.reset(layer.release()); | |
1600 } | 1603 } |
1601 } | 1604 } |
1602 | 1605 |
1603 /**** | 1606 /**** |
1604 * END OF EXPERIMENTAL CODE | 1607 * END OF EXPERIMENTAL CODE |
1622 scene.SetLayer(LAYER_ANNOTATIONS, annotationsLayer.release()); | 1625 scene.SetLayer(LAYER_ANNOTATIONS, annotationsLayer.release()); |
1623 } | 1626 } |
1624 else | 1627 else |
1625 { | 1628 { |
1626 scene.DeleteLayer(LAYER_ANNOTATIONS); | 1629 scene.DeleteLayer(LAYER_ANNOTATIONS); |
1627 } | |
1628 | |
1629 if (tempLayer.get() != NULL) // TODO - REMOVE | |
1630 { | |
1631 scene.SetLayer(LAYER_TEMP, tempLayer.release()); | |
1632 } | |
1633 else | |
1634 { | |
1635 scene.DeleteLayer(LAYER_TEMP); | |
1636 } | 1630 } |
1637 | 1631 |
1638 if (fitNextContent_) | 1632 if (fitNextContent_) |
1639 { | 1633 { |
1640 lock->RefreshCanvasSize(); | 1634 lock->RefreshCanvasSize(); |