comparison ViewerPlugin/Plugin.cpp @ 61:147bd6dc28db

refactoring using new items in the plugin toolbox of Orthanc
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 25 Nov 2016 17:15:55 +0100
parents 7a3853d51c45
children d529d9ce3c7e
comparison
equal deleted inserted replaced
60:a59fdb848a7b 61:147bd6dc28db
19 19
20 20
21 #include "../Framework/PrecompiledHeadersWSI.h" 21 #include "../Framework/PrecompiledHeadersWSI.h"
22 #include "../Framework/Inputs/DicomPyramid.h" 22 #include "../Framework/Inputs/DicomPyramid.h"
23 #include "../Framework/Jpeg2000Reader.h" 23 #include "../Framework/Jpeg2000Reader.h"
24 #include "../Framework/Messaging/PluginOrthancConnection.h"
25 24
26 #include "../Resources/Orthanc/Core/Images/ImageProcessing.h" 25 #include "../Resources/Orthanc/Core/Images/ImageProcessing.h"
27 #include "../Resources/Orthanc/Core/Images/PngWriter.h" 26 #include "../Resources/Orthanc/Core/Images/PngWriter.h"
28 #include "../Resources/Orthanc/Core/MultiThreading/Semaphore.h" 27 #include "../Resources/Orthanc/Core/MultiThreading/Semaphore.h"
29 #include "../Resources/Orthanc/Core/OrthancException.h" 28 #include "../Resources/Orthanc/Core/OrthancException.h"
30 #include "../Resources/Orthanc/Plugins/Samples/Common/OrthancPluginCppWrapper.h" 29 #include "../Resources/Orthanc/Plugins/Samples/Common/OrthancPluginCppWrapper.h"
30 #include "../Resources/Orthanc/Plugins/Samples/Common/OrthancPluginConnection.h"
31 31
32 #include <EmbeddedResources.h> 32 #include <EmbeddedResources.h>
33 33
34 #include <cassert> 34 #include <cassert>
35 35
39 { 39 {
40 // TODO Add LRU recycling policy 40 // TODO Add LRU recycling policy
41 class DicomPyramidCache : public boost::noncopyable 41 class DicomPyramidCache : public boost::noncopyable
42 { 42 {
43 private: 43 private:
44 boost::mutex mutex_; 44 boost::mutex mutex_;
45 IOrthancConnection& orthanc_; 45 OrthancPlugins::IOrthancConnection& orthanc_;
46 std::auto_ptr<DicomPyramid> pyramid_; 46 std::auto_ptr<DicomPyramid> pyramid_;
47 47
48 DicomPyramid& GetPyramid(const std::string& seriesId) 48 DicomPyramid& GetPyramid(const std::string& seriesId)
49 { 49 {
50 // Mutex is assumed to be locked 50 // Mutex is assumed to be locked
51 51
62 62
63 return *pyramid_; 63 return *pyramid_;
64 } 64 }
65 65
66 public: 66 public:
67 DicomPyramidCache(IOrthancConnection& orthanc) : 67 DicomPyramidCache(OrthancPlugins::IOrthancConnection& orthanc) :
68 orthanc_(orthanc) 68 orthanc_(orthanc)
69 { 69 {
70 } 70 }
71 71
72 void Invalidate(const std::string& seriesId) 72 void Invalidate(const std::string& seriesId)
103 } 103 }
104 104
105 105
106 OrthancPluginContext* context_ = NULL; 106 OrthancPluginContext* context_ = NULL;
107 107
108 std::auto_ptr<OrthancWSI::PluginOrthancConnection> orthanc_; 108 std::auto_ptr<OrthancPlugins::OrthancPluginConnection> orthanc_;
109 std::auto_ptr<OrthancWSI::DicomPyramidCache> cache_; 109 std::auto_ptr<OrthancWSI::DicomPyramidCache> cache_;
110 std::auto_ptr<Orthanc::Semaphore> transcoderSemaphore_; 110 std::auto_ptr<Orthanc::Semaphore> transcoderSemaphore_;
111 std::string sparseTile_;
112 111
113 112
114 static void AnswerSparseTile(OrthancPluginRestOutput* output, 113 static void AnswerSparseTile(OrthancPluginRestOutput* output,
115 unsigned int tileWidth, 114 unsigned int tileWidth,
116 unsigned int tileHeight) 115 unsigned int tileHeight)
376 sprintf(info, "The whole-slide imaging plugin will use at most %d threads to transcode the tiles", threads); 375 sprintf(info, "The whole-slide imaging plugin will use at most %d threads to transcode the tiles", threads);
377 OrthancPluginLogWarning(context_, info); 376 OrthancPluginLogWarning(context_, info);
378 377
379 OrthancPluginSetDescription(context, "Provides a Web viewer of whole-slide microscopic images within Orthanc."); 378 OrthancPluginSetDescription(context, "Provides a Web viewer of whole-slide microscopic images within Orthanc.");
380 379
381 orthanc_.reset(new OrthancWSI::PluginOrthancConnection(context)); 380 orthanc_.reset(new OrthancPlugins::OrthancPluginConnection(context));
382 cache_.reset(new OrthancWSI::DicomPyramidCache(*orthanc_)); 381 cache_.reset(new OrthancWSI::DicomPyramidCache(*orthanc_));
383 382
384 OrthancPluginRegisterOnChangeCallback(context_, OnChangeCallback); 383 OrthancPluginRegisterOnChangeCallback(context_, OnChangeCallback);
385 384
386 OrthancPlugins::RegisterRestCallback<ServeFile>(context, "/wsi/app/(ol.css)", true); 385 OrthancPlugins::RegisterRestCallback<ServeFile>(context, "/wsi/app/(ol.css)", true);