# HG changeset patch # User Alain Mazy # Date 1562141729 -7200 # Node ID 580dd82e13f5627f3c2f0d9eb7bb630256589eb1 # Parent 200b4e0dddfc790fd20f1d30805644e5ac77d051 added GetApproximateMemoryUsage diff -r 200b4e0dddfc -r 580dd82e13f5 Framework/Radiography/RadiographyDicomLayer.h --- a/Framework/Radiography/RadiographyDicomLayer.h Wed Jul 03 10:12:09 2019 +0200 +++ b/Framework/Radiography/RadiographyDicomLayer.h Wed Jul 03 10:15:29 2019 +0200 @@ -60,6 +60,22 @@ return frame_; } + virtual size_t GetApproximateMemoryUsage() const + { + size_t size = 0; + if (source_.get() != NULL) + { + size += source_->GetPitch() * source_->GetHeight(); + } + if (converted_.get() != NULL) + { + size += converted_->GetPitch() * converted_->GetHeight(); + } + + return size; + } + + void SetDicomTags(const OrthancPlugins::FullOrthancDataset& dataset); void SetSourceImage(Orthanc::ImageAccessor* image); // Takes ownership diff -r 200b4e0dddfc -r 580dd82e13f5 Framework/Radiography/RadiographyLayer.h --- a/Framework/Radiography/RadiographyLayer.h Wed Jul 03 10:12:09 2019 +0200 +++ b/Framework/Radiography/RadiographyLayer.h Wed Jul 03 10:15:29 2019 +0200 @@ -355,5 +355,10 @@ float& maxValue) const = 0; friend class RadiographyMaskLayer; // because it needs to GetTransform on the dicomLayer it relates to + + virtual size_t GetApproximateMemoryUsage() const // this is used to limit the number of scenes loaded in RAM when resources are limited (we actually only count the size used by the images, not the C structs) + { + return 0; + } }; } diff -r 200b4e0dddfc -r 580dd82e13f5 Framework/Radiography/RadiographyMaskLayer.h --- a/Framework/Radiography/RadiographyMaskLayer.h Wed Jul 03 10:12:09 2019 +0200 +++ b/Framework/Radiography/RadiographyMaskLayer.h Wed Jul 03 10:15:29 2019 +0200 @@ -49,6 +49,18 @@ { } + virtual size_t GetApproximateMemoryUsage() const + { + size_t size = 0; + if (mask_.get() != NULL) + { + size += mask_->GetPitch() * mask_->GetHeight(); + } + + return size; + } + + void SetCorners(const std::vector& corners); void SetCorner(const Orthanc::ImageProcessing::ImagePoint& corner, size_t index); diff -r 200b4e0dddfc -r 580dd82e13f5 Framework/Radiography/RadiographyScene.cpp --- a/Framework/Radiography/RadiographyScene.cpp Wed Jul 03 10:12:09 2019 +0200 +++ b/Framework/Radiography/RadiographyScene.cpp Wed Jul 03 10:15:29 2019 +0200 @@ -147,6 +147,16 @@ return *layer; } + size_t RadiographyScene::GetApproximateMemoryUsage() const + { + size_t size = 0; + for (Layers::const_iterator it = layers_.begin(); it != layers_.end(); it++) + { + size += it->second->GetApproximateMemoryUsage(); + } + return size; + } + void RadiographyScene::OnLayerEdited(const RadiographyLayer::LayerEditedMessage& message) { BroadcastMessage(RadiographyScene::LayerEditedMessage(*this, message.GetOrigin())); diff -r 200b4e0dddfc -r 580dd82e13f5 Framework/Radiography/RadiographyScene.h --- a/Framework/Radiography/RadiographyScene.h Wed Jul 03 10:12:09 2019 +0200 +++ b/Framework/Radiography/RadiographyScene.h Wed Jul 03 10:15:29 2019 +0200 @@ -163,6 +163,8 @@ virtual ~RadiographyScene(); + virtual size_t GetApproximateMemoryUsage() const; + bool GetWindowing(float& center, float& width) const;