diff Framework/Layers/FrameRenderer.cpp @ 77:f5f54ed8d307 wasm

refactoring
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 24 May 2017 21:13:29 +0200
parents 298f375dcb68
children bd48431ac285
line wrap: on
line diff
--- a/Framework/Layers/FrameRenderer.cpp	Wed May 24 12:42:08 2017 +0200
+++ b/Framework/Layers/FrameRenderer.cpp	Wed May 24 21:13:29 2017 +0200
@@ -76,12 +76,10 @@
   }
 
 
-  FrameRenderer::FrameRenderer(const SliceGeometry& viewportSlice,
-                               const SliceGeometry& frameSlice,
+  FrameRenderer::FrameRenderer(const SliceGeometry& frameSlice,
                                double pixelSpacingX,
                                double pixelSpacingY,
                                bool isFullQuality) :
-    viewportSlice_(viewportSlice),
     frameSlice_(frameSlice),
     pixelSpacingX_(pixelSpacingX),
     pixelSpacingY_(pixelSpacingY),
@@ -138,7 +136,8 @@
 
 
   bool FrameRenderer::RenderLayer(CairoContext& context,
-                                  const ViewportGeometry& view)
+                                  const ViewportGeometry& view,
+                                  const SliceGeometry& viewportSlice)
   {
     if (!style_.visible_)
     {
@@ -147,7 +146,7 @@
 
     if (display_.get() == NULL)
     {
-      if (!ComputePixelTransform(transform_, viewportSlice_, frameSlice_,
+      if (!ComputePixelTransform(transform_, viewportSlice, frameSlice_,
                                  pixelSpacingX_, pixelSpacingY_))
       {
         return true;
@@ -216,7 +215,6 @@
 
 
   ILayerRenderer* FrameRenderer::CreateRenderer(Orthanc::ImageAccessor* frame,
-                                                const SliceGeometry& viewportSlice,
                                                 const SliceGeometry& frameSlice,
                                                 const OrthancPlugins::IDicomDataset& dicom,
                                                 double pixelSpacingX,
@@ -227,15 +225,34 @@
 
     if (frame->GetFormat() == Orthanc::PixelFormat_RGB24)
     {
-      return new ColorFrameRenderer(protect.release(), viewportSlice, frameSlice, 
+      return new ColorFrameRenderer(protect.release(), frameSlice, 
                                     pixelSpacingX, pixelSpacingY, isFullQuality);
     }
     else
     {
       DicomFrameConverter converter;
       converter.ReadParameters(dicom);
-      return new GrayscaleFrameRenderer(protect.release(), converter, viewportSlice, frameSlice, 
+      return new GrayscaleFrameRenderer(protect.release(), converter, frameSlice, 
                                         pixelSpacingX, pixelSpacingY, isFullQuality);
     }
   }
+
+
+  ILayerRenderer* FrameRenderer::CreateRenderer(Orthanc::ImageAccessor* frame,
+                                                const Slice& slice,
+                                                bool isFullQuality)
+  {
+    std::auto_ptr<Orthanc::ImageAccessor> protect(frame);
+
+    if (frame->GetFormat() == Orthanc::PixelFormat_RGB24)
+    {
+      return new ColorFrameRenderer(protect.release(), slice.GetGeometry(), 
+                                    slice.GetPixelSpacingX(), slice.GetPixelSpacingY(), isFullQuality);
+    }
+    else
+    {
+      return new GrayscaleFrameRenderer(protect.release(), slice.GetConverter(), slice.GetGeometry(), 
+                                        slice.GetPixelSpacingX(), slice.GetPixelSpacingY(), isFullQuality);
+    }
+  }
 }