comparison Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp @ 1633:53d378ef7277

rename FrameGeometry to FrameExtent
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 10 Nov 2020 10:21:10 +0100
parents 9a4c09361f3e
children 4796fb60999e
comparison
equal deleted inserted replaced
1632:9a4c09361f3e 1633:53d378ef7277
824 }; 824 };
825 825
826 826
827 827
828 828
829 class FrameGeometry 829 class FrameExtent
830 { 830 {
831 private: 831 private:
832 bool isValid_; 832 bool isValid_;
833 std::string frameOfReferenceUid_; 833 std::string frameOfReferenceUid_;
834 OrthancStone::CoordinateSystem3D coordinates_; 834 OrthancStone::CoordinateSystem3D coordinates_;
835 double pixelSpacingX_; 835 double pixelSpacingX_;
836 double pixelSpacingY_; 836 double pixelSpacingY_;
837 OrthancStone::Extent2D extent_; 837 OrthancStone::Extent2D extent_;
838 838
839 public: 839 public:
840 explicit FrameGeometry() : 840 explicit FrameExtent() :
841 isValid_(false), 841 isValid_(false),
842 pixelSpacingX_(1), 842 pixelSpacingX_(1),
843 pixelSpacingY_(1) 843 pixelSpacingY_(1)
844 { 844 {
845 } 845 }
846 846
847 explicit FrameGeometry(const Orthanc::DicomMap& tags) : 847 explicit FrameExtent(const Orthanc::DicomMap& tags) :
848 isValid_(false), 848 isValid_(false),
849 coordinates_(tags) 849 coordinates_(tags)
850 { 850 {
851 if (!tags.LookupStringValue( 851 if (!tags.LookupStringValue(
852 frameOfReferenceUid_, Orthanc::DICOM_TAG_FRAME_OF_REFERENCE_UID, false)) 852 frameOfReferenceUid_, Orthanc::DICOM_TAG_FRAME_OF_REFERENCE_UID, false))
927 927
928 bool Intersect(double& x1, // Coordinates of the clipped line (out) 928 bool Intersect(double& x1, // Coordinates of the clipped line (out)
929 double& y1, 929 double& y1,
930 double& x2, 930 double& x2,
931 double& y2, 931 double& y2,
932 const FrameGeometry& other) const 932 const FrameExtent& other) const
933 { 933 {
934 if (this == &other) 934 if (this == &other)
935 { 935 {
936 return false; 936 return false;
937 } 937 }
1310 bool inverted_; 1310 bool inverted_;
1311 bool flipX_; 1311 bool flipX_;
1312 bool flipY_; 1312 bool flipY_;
1313 bool fitNextContent_; 1313 bool fitNextContent_;
1314 bool isCtrlDown_; 1314 bool isCtrlDown_;
1315 FrameGeometry currentFrameGeometry_; 1315 FrameExtent currentFrameExtent_;
1316 std::list<PrefetchItem> prefetchQueue_; 1316 std::list<PrefetchItem> prefetchQueue_;
1317 1317
1318 1318
1319 bool hasFocusOnInstance_; 1319 bool hasFocusOnInstance_;
1320 std::string focusSopInstanceUid_; 1320 std::string focusSopInstanceUid_;
1412 else 1412 else
1413 { 1413 {
1414 quality = DisplayedFrameQuality_High; 1414 quality = DisplayedFrameQuality_High;
1415 } 1415 }
1416 1416
1417 currentFrameGeometry_ = FrameGeometry(frames_->GetFrameTags(index)); 1417 currentFrameExtent_ = FrameExtent(frames_->GetFrameTags(index));
1418 1418
1419 { 1419 {
1420 // Prepare prefetching 1420 // Prepare prefetching
1421 prefetchQueue_.clear(); 1421 prefetchQueue_.clear();
1422 for (size_t i = 0; i < cursor_->GetPrefetchSize() && i < 16; i++) 1422 for (size_t i = 0; i < cursor_->GetPrefetchSize() && i < 16; i++)
1437 frames_->GetFramesCount(), quality); 1437 frames_->GetFramesCount(), quality);
1438 } 1438 }
1439 } 1439 }
1440 else 1440 else
1441 { 1441 {
1442 currentFrameGeometry_ = FrameGeometry(); 1442 currentFrameExtent_ = FrameExtent();
1443 } 1443 }
1444 } 1444 }
1445 1445
1446 1446
1447 void ClearViewport() 1447 void ClearViewport()
1527 1527
1528 std::unique_ptr<OrthancStone::MacroSceneLayer> annotationsLayer; 1528 std::unique_ptr<OrthancStone::MacroSceneLayer> annotationsLayer;
1529 1529
1530 if (annotations_) 1530 if (annotations_)
1531 { 1531 {
1532 const FrameGeometry& geometry = GetCurrentFrameGeometry(); 1532 const FrameExtent& extent = GetCurrentFrameExtent();
1533 1533
1534 std::set<size_t> a; 1534 std::set<size_t> a;
1535 annotations_->LookupSopInstanceUid(a, sopInstanceUid); 1535 annotations_->LookupSopInstanceUid(a, sopInstanceUid);
1536 if (geometry.IsValid() && 1536 if (extent.IsValid() &&
1537 !a.empty()) 1537 !a.empty())
1538 { 1538 {
1539 annotationsLayer.reset(new OrthancStone::MacroSceneLayer); 1539 annotationsLayer.reset(new OrthancStone::MacroSceneLayer);
1540 annotationsLayer->Reserve(a.size()); 1540 annotationsLayer->Reserve(a.size());
1541 1541
1543 factory.SetColor(0, 255, 0); 1543 factory.SetColor(0, 255, 0);
1544 1544
1545 for (std::set<size_t>::const_iterator it = a.begin(); it != a.end(); ++it) 1545 for (std::set<size_t>::const_iterator it = a.begin(); it != a.end(); ++it)
1546 { 1546 {
1547 const OrthancStone::OsiriX::Annotation& annotation = annotations_->GetAnnotation(*it); 1547 const OrthancStone::OsiriX::Annotation& annotation = annotations_->GetAnnotation(*it);
1548 annotationsLayer->AddLayer(factory.Create(annotation, geometry.GetCoordinates())); 1548 annotationsLayer->AddLayer(factory.Create(annotation, extent.GetCoordinates()));
1549 } 1549 }
1550 } 1550 }
1551 } 1551 }
1552 1552
1553 1553
1845 LOG(INFO) << "Number of frames in series: " << frames_->GetFramesCount(); 1845 LOG(INFO) << "Number of frames in series: " << frames_->GetFramesCount();
1846 1846
1847 ResetDefaultWindowing(); 1847 ResetDefaultWindowing();
1848 ClearViewport(); 1848 ClearViewport();
1849 prefetchQueue_.clear(); 1849 prefetchQueue_.clear();
1850 currentFrameGeometry_ = FrameGeometry(); 1850 currentFrameExtent_ = FrameExtent();
1851 1851
1852 if (observer_.get() != NULL) 1852 if (observer_.get() != NULL)
1853 { 1853 {
1854 observer_->SignalFrameUpdated(*this, cursor_->GetCurrentIndex(), 1854 observer_->SignalFrameUpdated(*this, cursor_->GetCurrentIndex(),
1855 frames_->GetFramesCount(), DisplayedFrameQuality_None); 1855 frames_->GetFramesCount(), DisplayedFrameQuality_None);
1925 DisplayCurrentFrame(); 1925 DisplayCurrentFrame();
1926 } 1926 }
1927 } 1927 }
1928 } 1928 }
1929 1929
1930 const FrameGeometry& GetCurrentFrameGeometry() const 1930 const FrameExtent& GetCurrentFrameExtent() const
1931 { 1931 {
1932 return currentFrameGeometry_; 1932 return currentFrameExtent_;
1933 } 1933 }
1934 1934
1935 void UpdateReferenceLines(const std::list<const FrameGeometry*>& planes) 1935 void UpdateReferenceLines(const std::list<const FrameExtent*>& planes)
1936 { 1936 {
1937 std::unique_ptr<OrthancStone::PolylineSceneLayer> layer(new OrthancStone::PolylineSceneLayer); 1937 std::unique_ptr<OrthancStone::PolylineSceneLayer> layer(new OrthancStone::PolylineSceneLayer);
1938 1938
1939 if (GetCurrentFrameGeometry().IsValid()) 1939 if (GetCurrentFrameExtent().IsValid())
1940 { 1940 {
1941 for (std::list<const FrameGeometry*>::const_iterator 1941 for (std::list<const FrameExtent*>::const_iterator
1942 it = planes.begin(); it != planes.end(); ++it) 1942 it = planes.begin(); it != planes.end(); ++it)
1943 { 1943 {
1944 assert(*it != NULL); 1944 assert(*it != NULL);
1945 1945
1946 double x1, y1, x2, y2; 1946 double x1, y1, x2, y2;
1947 if (GetCurrentFrameGeometry().Intersect(x1, y1, x2, y2, **it)) 1947 if (GetCurrentFrameExtent().Intersect(x1, y1, x2, y2, **it))
1948 { 1948 {
1949 OrthancStone::PolylineSceneLayer::Chain chain; 1949 OrthancStone::PolylineSceneLayer::Chain chain;
1950 chain.push_back(OrthancStone::ScenePoint2D(x1, y1)); 1950 chain.push_back(OrthancStone::ScenePoint2D(x1, y1));
1951 chain.push_back(OrthancStone::ScenePoint2D(x2, y2)); 1951 chain.push_back(OrthancStone::ScenePoint2D(x2, y2));
1952 layer->AddChain(chain, false, 0, 255, 0); 1952 layer->AddChain(chain, false, 0, 255, 0);
2155 2155
2156 static void UpdateReferenceLines() 2156 static void UpdateReferenceLines()
2157 { 2157 {
2158 if (showReferenceLines_) 2158 if (showReferenceLines_)
2159 { 2159 {
2160 std::list<const FrameGeometry*> planes; 2160 std::list<const FrameExtent*> planes;
2161 2161
2162 for (Viewports::const_iterator it = allViewports_.begin(); it != allViewports_.end(); ++it) 2162 for (Viewports::const_iterator it = allViewports_.begin(); it != allViewports_.end(); ++it)
2163 { 2163 {
2164 assert(it->second != NULL); 2164 assert(it->second != NULL);
2165 planes.push_back(&it->second->GetCurrentFrameGeometry()); 2165 planes.push_back(&it->second->GetCurrentFrameExtent());
2166 } 2166 }
2167 2167
2168 for (Viewports::iterator it = allViewports_.begin(); it != allViewports_.end(); ++it) 2168 for (Viewports::iterator it = allViewports_.begin(); it != allViewports_.end(); ++it)
2169 { 2169 {
2170 assert(it->second != NULL); 2170 assert(it->second != NULL);