view Framework/Layers/IVolumeSlicer.h @ 421:f87f28624b96 cache-in-radiography

tentative to make SmartLoader and RadiographyScene work together (not really working)
author am@osimis.io
date Tue, 20 Nov 2018 16:35:29 +0100
parents 885e1ebd315c
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/>.
 **/


#pragma once

#include "ILayerRenderer.h"
#include "../Toolbox/Slice.h"
#include "../../Framework/Messages/IObservable.h"
#include "../../Framework/Messages/IMessage.h"
#include "Core/Images/Image.h"
#include <Plugins/Samples/Common/FullOrthancDataset.h>
#include <boost/shared_ptr.hpp>

namespace OrthancStone
{

  class IVolumeSlicer : public IObservable
  {
  public:
    typedef OriginMessage<MessageType_VolumeSlicer_GeometryReady, IVolumeSlicer>  GeometryReadyMessage;
    typedef OriginMessage<MessageType_VolumeSlicer_GeometryError, IVolumeSlicer>  GeometryErrorMessage;
    typedef OriginMessage<MessageType_VolumeSlicer_ContentChanged, IVolumeSlicer> ContentChangedMessage;

    class TagsReadyMessage : public OriginMessage<MessageType_VolumeSlicer_TagsReady, IVolumeSlicer>
    {
    private:
      const OrthancPlugins::FullOrthancDataset& dicomTags_;
    public:
      TagsReadyMessage(IVolumeSlicer& origin,
                       const OrthancPlugins::FullOrthancDataset& dicomTags) :
        OriginMessage(origin),
        dicomTags_(dicomTags)
      {
      }

      const OrthancPlugins::FullOrthancDataset& GetDicomTags() const
      {
        return dicomTags_;
      }
    };

    class FrameReadyMessage : public OriginMessage<MessageType_VolumeSlicer_FrameReady, IVolumeSlicer>
    {
    private:
      boost::shared_ptr<Orthanc::ImageAccessor> image_;
    public:
      FrameReadyMessage(IVolumeSlicer& origin, boost::shared_ptr<Orthanc::ImageAccessor> image) :
        OriginMessage(origin),
        image_(image)
      {
      }

      boost::shared_ptr<Orthanc::ImageAccessor> GetImage() const
      {
        return image_;
      }
    };

    class SliceContentChangedMessage : public OriginMessage<MessageType_VolumeSlicer_SliceChanged, IVolumeSlicer>
    {
    private:
      const Slice& slice_;

    public:
      SliceContentChangedMessage(IVolumeSlicer& origin,
                                 const Slice& slice) :
        OriginMessage(origin),
        slice_(slice)
      {
      }

      const Slice& GetSlice() const
      {
        return slice_;
      }
    };
    

    class LayerReadyMessage : public OriginMessage<MessageType_VolumeSlicer_LayerReady, IVolumeSlicer>
    {
    public:
      class IRendererFactory : public boost::noncopyable
      {
      public:
        virtual ~IRendererFactory()
        {
        }

        virtual ILayerRenderer* CreateRenderer() const = 0;
      };

    private:
      const IRendererFactory&    factory_;
      const CoordinateSystem3D&  slice_;

    public:
      LayerReadyMessage(IVolumeSlicer& origin,
                        const IRendererFactory& rendererFactory,
                        const CoordinateSystem3D& slice) :
        OriginMessage(origin),
        factory_(rendererFactory),
        slice_(slice)
      {
      }

      ILayerRenderer* CreateRenderer() const
      {
        return factory_.CreateRenderer();
      }

      const CoordinateSystem3D& GetSlice() const
      {
        return slice_;
      }
    };


    class LayerErrorMessage : public OriginMessage<MessageType_VolumeSlicer_LayerError, IVolumeSlicer>
    {
    private:
      const CoordinateSystem3D&  slice_;

    public:
      LayerErrorMessage(IVolumeSlicer& origin,
                        const CoordinateSystem3D& slice) :
        OriginMessage(origin),
        slice_(slice)
      {
      }

      const CoordinateSystem3D& GetSlice() const
      {
        return slice_;
      }
    };


    IVolumeSlicer(MessageBroker& broker) :
      IObservable(broker)
    {
    }
    
    virtual ~IVolumeSlicer()
    {
    }

    virtual bool GetExtent(std::vector<Vector>& points,
                           const CoordinateSystem3D& viewportSlice) = 0;

    virtual void ScheduleLayerCreation(const CoordinateSystem3D& viewportSlice) = 0;
  };
}