Mercurial > hg > orthanc-stone
changeset 1573:32e0c007789d
cppcheck
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 21 Sep 2020 18:28:34 +0200 |
parents | 1b3039384972 |
children | fb5e620430ae |
files | Applications/Samples/Common/RtViewerApp.cpp Applications/Samples/Common/RtViewerView.cpp Applications/Samples/Common/RtViewerView.h Applications/Samples/Sdl/RtViewer/RtViewerSdl.cpp Applications/Samples/WebAssembly/SingleFrameViewer/SingleFrameViewerApplication.h Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp OrthancStone/Resources/RunCppCheck.sh |
diffstat | 7 files changed, 50 insertions(+), 36 deletions(-) [+] |
line wrap: on
line diff
--- a/Applications/Samples/Common/RtViewerApp.cpp Mon Sep 21 18:13:52 2020 +0200 +++ b/Applications/Samples/Common/RtViewerApp.cpp Mon Sep 21 18:28:34 2020 +0200 @@ -74,12 +74,12 @@ return geometry; } - RtViewerApp::RtViewerApp() - : undoStack_(new UndoStack) + RtViewerApp::RtViewerApp() : + undoStack_(new UndoStack), + // Create the volumes that will be filled later on + ctVolume_(boost::make_shared<DicomVolumeImage>()), + doseVolume_(boost::make_shared<DicomVolumeImage>()) { - // Create the volumes that will be filled later on - ctVolume_ = boost::make_shared<DicomVolumeImage>(); - doseVolume_ = boost::make_shared<DicomVolumeImage>(); } boost::shared_ptr<RtViewerApp> RtViewerApp::Create()
--- a/Applications/Samples/Common/RtViewerView.cpp Mon Sep 21 18:13:52 2020 +0200 +++ b/Applications/Samples/Common/RtViewerView.cpp Mon Sep 21 18:28:34 2020 +0200 @@ -74,7 +74,7 @@ Scene2D& scene = controller.GetScene(); // do not try to use stuff too early! - OrthancStone::ICompositor& compositor = lock->GetCompositor(); + const OrthancStone::ICompositor& compositor = lock->GetCompositor(); std::stringstream msg; @@ -262,8 +262,8 @@ compositor.SetFont(1, ttf, FONT_SIZE_1, Orthanc::Encoding_Latin1); } - void RtViewerView::SetInfoDisplayMessage( - std::string key, std::string value) + void RtViewerView::SetInfoDisplayMessage(const std::string& key, + const std::string& value) { if (value == "") infoTextMap_.erase(key);
--- a/Applications/Samples/Common/RtViewerView.h Mon Sep 21 18:13:52 2020 +0200 +++ b/Applications/Samples/Common/RtViewerView.h Mon Sep 21 18:28:34 2020 +0200 @@ -108,7 +108,8 @@ } private: - void SetInfoDisplayMessage(std::string key, std::string value); + void SetInfoDisplayMessage(const std::string& key, + const std::string& value); boost::shared_ptr<RtViewerApp> GetApp(); boost::shared_ptr<IViewport> CreateViewport(const std::string& canvasId); void DisplayInfoText();
--- a/Applications/Samples/Sdl/RtViewer/RtViewerSdl.cpp Mon Sep 21 18:13:52 2020 +0200 +++ b/Applications/Samples/Sdl/RtViewer/RtViewerSdl.cpp Mon Sep 21 18:28:34 2020 +0200 @@ -208,7 +208,7 @@ { std::unique_ptr<IViewport::ILock> lock(viewport_->Lock()); ViewportController& controller = lock->GetController(); - Scene2D& scene = controller.GetScene(); + const Scene2D& scene = controller.GetScene(); std::string ttf; Orthanc::EmbeddedResources::GetFileResource(ttf, Orthanc::EmbeddedResources::UBUNTU_FONT); @@ -269,28 +269,33 @@ { std::vector<SDL_Event> sdlEvents; std::map<Uint32,SDL_Event> userEventsMap; - SDL_Event sdlEvent; - // FIRST: collect all pending events - while (SDL_PollEvent(&sdlEvent) != 0) { - if ( (sdlEvent.type >= SDL_USEREVENT) && - (sdlEvent.type < SDL_LASTEVENT) ) + SDL_Event sdlEvent; + + // FIRST: collect all pending events + while (SDL_PollEvent(&sdlEvent) != 0) { - // we don't want to have multiple refresh events , - // and since every refresh event is a user event with a special type, - // we use a map - userEventsMap[sdlEvent.type] = sdlEvent; - } - else - { - sdlEvents.push_back(sdlEvent); + if ( (sdlEvent.type >= SDL_USEREVENT) && + (sdlEvent.type < SDL_LASTEVENT) ) + { + // we don't want to have multiple refresh events , + // and since every refresh event is a user event with a special type, + // we use a map + userEventsMap[sdlEvent.type] = sdlEvent; + } + else + { + sdlEvents.push_back(sdlEvent); + } } } // SECOND: add all user events to sdlEvents for (std::map<Uint32,SDL_Event>::const_iterator it = userEventsMap.begin(); it != userEventsMap.end(); ++it) + { sdlEvents.push_back(it->second); + } // now process the events for (std::vector<SDL_Event>::const_iterator it = sdlEvents.begin(); it != sdlEvents.end(); ++it)
--- a/Applications/Samples/WebAssembly/SingleFrameViewer/SingleFrameViewerApplication.h Mon Sep 21 18:13:52 2020 +0200 +++ b/Applications/Samples/WebAssembly/SingleFrameViewer/SingleFrameViewerApplication.h Mon Sep 21 18:28:34 2020 +0200 @@ -191,10 +191,10 @@ IWebViewerLoadersObserver* observer) : context_(context), observer_(observer), - loadThumbnails_(false) + loadThumbnails_(false), + loadedSeries_(boost::make_shared<LoadedDicomResources>(Orthanc::DICOM_TAG_SERIES_INSTANCE_UID)), + loadedStudies_(boost::make_shared<LoadedDicomResources>(Orthanc::DICOM_TAG_STUDY_INSTANCE_UID)) { - loadedSeries_ = boost::make_shared<LoadedDicomResources>(Orthanc::DICOM_TAG_SERIES_INSTANCE_UID); - loadedStudies_ = boost::make_shared<LoadedDicomResources>(Orthanc::DICOM_TAG_STUDY_INSTANCE_UID); } static Orthanc::IDynamicObject* CreatePayload(Type type)
--- a/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp Mon Sep 21 18:13:52 2020 +0200 +++ b/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp Mon Sep 21 18:28:34 2020 +0200 @@ -151,7 +151,7 @@ boost::shared_ptr<OrthancStone::SeriesThumbnailsLoader> thumbnailsLoader_; boost::shared_ptr<OrthancStone::SeriesMetadataLoader> metadataLoader_; - ResourcesLoader(const OrthancStone::DicomSource& source) : + explicit ResourcesLoader(const OrthancStone::DicomSource& source) : source_(source), pending_(0), studies_(new OrthancStone::LoadedDicomResources(Orthanc::DICOM_TAG_STUDY_INSTANCE_UID)), @@ -385,7 +385,7 @@ assert(image != NULL); } - virtual size_t GetMemoryUsage() const + virtual size_t GetMemoryUsage() const ORTHANC_OVERRIDE { assert(image_.get() != NULL); return (image_->GetBytesPerPixel() * image_->GetPitch() * image_->GetHeight()); @@ -705,7 +705,7 @@ } public: - SeriesCursor(size_t framesCount) : + explicit SeriesCursor(size_t framesCount) : framesCount_(framesCount), currentFrame_(framesCount / 2), // Start at the middle frame isCircular_(false), @@ -792,12 +792,14 @@ OrthancStone::Extent2D extent_; public: - FrameGeometry() : - isValid_(false) + explicit FrameGeometry() : + isValid_(false), + pixelSpacingX_(1), + pixelSpacingY_(1) { } - FrameGeometry(const Orthanc::DicomMap& tags) : + explicit FrameGeometry(const Orthanc::DicomMap& tags) : isValid_(false), coordinates_(tags) { @@ -945,7 +947,7 @@ boost::shared_ptr<ViewerViewport> viewport_; public: - ICommand(boost::shared_ptr<ViewerViewport> viewport) : + explicit ICommand(boost::shared_ptr<ViewerViewport> viewport) : viewport_(viewport) { if (viewport == NULL) @@ -983,7 +985,7 @@ class SetDefaultWindowingCommand : public ICommand { public: - SetDefaultWindowingCommand(boost::shared_ptr<ViewerViewport> viewport) : + explicit SetDefaultWindowingCommand(boost::shared_ptr<ViewerViewport> viewport) : ICommand(viewport) { }
--- a/OrthancStone/Resources/RunCppCheck.sh Mon Sep 21 18:13:52 2020 +0200 +++ b/OrthancStone/Resources/RunCppCheck.sh Mon Sep 21 18:28:34 2020 +0200 @@ -9,16 +9,19 @@ fi cat <<EOF > /tmp/cppcheck-suppressions.txt +stlFindInsert:../../Applications/Samples/WebAssembly/SingleFrameViewer/SingleFrameViewerApplication.h +stlFindInsert:../../Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp:658 unpreciseMathCall:../../OrthancStone/Sources/Scene2D/Internals/CairoFloatTextureRenderer.cpp unpreciseMathCall:../../OrthancStone/Sources/Scene2D/LookupTableTextureSceneLayer.cpp +unreadVariable:../../OrthancStone/Sources/Viewport/SdlViewport.cpp:135 +unreadVariable:../../OrthancStone/Sources/Viewport/SdlViewport.cpp:193 unusedFunction useInitializationList:../../OrthancStone/Sources/OpenGL/OpenGLProgram.cpp:36 -unreadVariable:../../OrthancStone/Sources/Viewport/SdlViewport.cpp:135 -unreadVariable:../../OrthancStone/Sources/Viewport/SdlViewport.cpp:193 EOF ${CPPCHECK} --enable=all --quiet --std=c++11 \ --suppressions-list=/tmp/cppcheck-suppressions.txt \ + -DHAS_ORTHANC_EXCEPTION=1 \ -DORTHANC_BUILDING_FRAMEWORK_LIBRARY=1 \ -DORTHANC_ENABLE_BASE64=1 \ -DORTHANC_ENABLE_CIVETWEB=0 \ @@ -46,9 +49,12 @@ -D__GNUC__ \ -D__cplusplus=201103 \ -D__linux__ \ + -DEM_ASM \ -UNDEBUG \ -I/home/jodogne/Subversion/orthanc/OrthancFramework/Sources \ \ ../../OrthancStone/Sources \ + ../../Applications/Samples \ + ../../Applications/StoneWebViewer \ \ 2>&1