Mercurial > hg > orthanc-stone
view Framework/Layers/OrthancFrameLayerSource.cpp @ 247:3d523c9a8f0d am
trying to use boost::signals2 even more.
author | am@osimis.io |
---|---|
date | Mon, 02 Jul 2018 12:32:02 +0200 |
parents | 5412adf19980 |
children |
line wrap: on
line source
/** * Stone of Orthanc * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics * Department, University Hospital of Liege, Belgium * Copyright (C) 2017-2018 Osimis S.A., Belgium * * This program is free software: you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation, either version 3 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. **/ #include "OrthancFrameLayerSource.h" #include "FrameRenderer.h" #include "../Toolbox/DicomFrameConverter.h" #include <Core/Logging.h> #include <Core/OrthancException.h> #include <boost/lexical_cast.hpp> namespace OrthancStone { void OrthancFrameLayerSource::NotifyGeometryReady(const OrthancSlicesLoader& loader) { if (loader.GetSliceCount() > 0) { LayerSourceBase::NotifyGeometryReady(); } else { LayerSourceBase::NotifyGeometryError(); } } void OrthancFrameLayerSource::NotifyGeometryError(const OrthancSlicesLoader& loader) { LayerSourceBase::NotifyGeometryError(); } void OrthancFrameLayerSource::NotifySliceImageReady(const OrthancSlicesLoader& loader, unsigned int sliceIndex, const Slice& slice, std::auto_ptr<Orthanc::ImageAccessor>& image, SliceImageQuality quality) { bool isFull = (quality == SliceImageQuality_Full); LayerSourceBase::NotifyLayerReady(boost::shared_ptr<ILayerRenderer>(FrameRenderer::CreateRenderer(image.release(), slice, isFull)), slice.GetGeometry(), false); } void OrthancFrameLayerSource::NotifySliceImageError(const OrthancSlicesLoader& loader, unsigned int sliceIndex, const Slice& slice, SliceImageQuality quality) { LayerSourceBase::NotifyLayerReady(NULL, slice.GetGeometry(), true); } OrthancFrameLayerSource::OrthancFrameLayerSource() : quality_(SliceImageQuality_Full) { } void OrthancFrameLayerSource::Init(IWebService& orthanc) { // note: there must have been a shared_ptr created on this object before calling shared_from_this() loader_.reset(new OrthancSlicesLoader(shared_from_this(), orthanc)); } void OrthancFrameLayerSource::LoadSeries(const std::string& seriesId) { loader_->ScheduleLoadSeries(loader_, seriesId); } void OrthancFrameLayerSource::LoadInstance(const std::string& instanceId) { loader_->ScheduleLoadInstance(loader_, instanceId); } void OrthancFrameLayerSource::LoadFrame(const std::string& instanceId, unsigned int frame) { loader_->ScheduleLoadFrame(loader_, instanceId, frame); } bool OrthancFrameLayerSource::GetExtent(std::vector<Vector>& points, const CoordinateSystem3D& viewportSlice) { size_t index; if (loader_->IsGeometryReady() && loader_->LookupSlice(index, viewportSlice)) { loader_->GetSlice(index).GetExtent(points); return true; } else { return false; } } void OrthancFrameLayerSource::ScheduleLayerCreation(const CoordinateSystem3D& viewportSlice) { size_t index; if (loader_->IsGeometryReady()) { if (loader_->LookupSlice(index, viewportSlice)) { loader_->ScheduleLoadSliceImage(loader_, index, quality_); } else { Slice slice; LayerSourceBase::NotifyLayerReady(NULL, slice.GetGeometry(), true); } } } }