# HG changeset patch # User Sebastien Jodogne # Date 1497448446 -7200 # Node ID 7665ccbf33dbea4ad49511d8fe7dfddfbb969c2a # Parent 53025eecbc95f9d28fccf2bd5c132a5f77d210d4 rename Extent as Extent2D diff -r 53025eecbc95 -r 7665ccbf33db Framework/Toolbox/Extent.cpp --- a/Framework/Toolbox/Extent.cpp Wed Jun 14 15:50:38 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,123 +0,0 @@ -/** - * Stone of Orthanc - * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics - * Department, University Hospital of Liege, Belgium - * Copyright (C) 2017 Osimis, 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 . - **/ - - -#include "Extent.h" - -#include -#include - -namespace OrthancStone -{ - Extent::Extent(double x1, - double y1, - double x2, - double y2) : - empty_(false), - x1_(x1), - y1_(y1), - x2_(x2), - y2_(y2) - { - if (x1_ > x2_) - { - std::swap(x1_, x2_); - } - - if (y1_ > y2_) - { - std::swap(y1_, y2_); - } - } - - - void Extent::Reset() - { - empty_ = true; - x1_ = 0; - y1_ = 0; - x2_ = 0; - y2_ = 0; - } - - void Extent::AddPoint(double x, - double y) - { - if (empty_) - { - x1_ = x; - y1_ = y; - x2_ = x; - y2_ = y; - empty_ = false; - } - else - { - x1_ = std::min(x1_, x); - y1_ = std::min(y1_, y); - x2_ = std::max(x2_, x); - y2_ = std::max(y2_, y); - } - - assert(x1_ <= x2_ && - y1_ <= y2_); // This is the invariant of the structure - } - - - void Extent::Union(const Extent& other) - { - if (other.empty_) - { - return; - } - - if (empty_) - { - *this = other; - return; - } - - assert(!empty_); - - x1_ = std::min(x1_, other.x1_); - y1_ = std::min(y1_, other.y1_); - x2_ = std::max(x2_, other.x2_); - y2_ = std::max(y2_, other.y2_); - - assert(x1_ <= x2_ && - y1_ <= y2_); // This is the invariant of the structure - } - - - bool Extent::IsEmpty() const - { - if (empty_) - { - return true; - } - else - { - assert(x1_ <= x2_ && - y1_ <= y2_); - return (x2_ <= x1_ + 10 * std::numeric_limits::epsilon() || - y2_ <= y1_ + 10 * std::numeric_limits::epsilon()); - } - } -} diff -r 53025eecbc95 -r 7665ccbf33db Framework/Toolbox/Extent.h --- a/Framework/Toolbox/Extent.h Wed Jun 14 15:50:38 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,85 +0,0 @@ -/** - * Stone of Orthanc - * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics - * Department, University Hospital of Liege, Belgium - * Copyright (C) 2017 Osimis, 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 . - **/ - - -#pragma once - -namespace OrthancStone -{ - class Extent - { - private: - bool empty_; - double x1_; - double y1_; - double x2_; - double y2_; - - public: - Extent() - { - Reset(); - } - - Extent(double x1, - double y1, - double x2, - double y2); - - void Reset(); - - void AddPoint(double x, - double y); - - void Union(const Extent& other); - - bool IsEmpty() const; - - double GetX1() const - { - return x1_; - } - - double GetY1() const - { - return y1_; - } - - double GetX2() const - { - return x2_; - } - - double GetY2() const - { - return y2_; - } - - double GetWidth() const - { - return x2_ - x1_; - } - - double GetHeight() const - { - return y2_ - y1_; - } - }; -} diff -r 53025eecbc95 -r 7665ccbf33db Framework/Toolbox/Extent2D.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Framework/Toolbox/Extent2D.cpp Wed Jun 14 15:54:06 2017 +0200 @@ -0,0 +1,123 @@ +/** + * Stone of Orthanc + * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics + * Department, University Hospital of Liege, Belgium + * Copyright (C) 2017 Osimis, 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 . + **/ + + +#include "Extent2D.h" + +#include +#include + +namespace OrthancStone +{ + Extent2D::Extent2D(double x1, + double y1, + double x2, + double y2) : + empty_(false), + x1_(x1), + y1_(y1), + x2_(x2), + y2_(y2) + { + if (x1_ > x2_) + { + std::swap(x1_, x2_); + } + + if (y1_ > y2_) + { + std::swap(y1_, y2_); + } + } + + + void Extent2D::Reset() + { + empty_ = true; + x1_ = 0; + y1_ = 0; + x2_ = 0; + y2_ = 0; + } + + void Extent2D::AddPoint(double x, + double y) + { + if (empty_) + { + x1_ = x; + y1_ = y; + x2_ = x; + y2_ = y; + empty_ = false; + } + else + { + x1_ = std::min(x1_, x); + y1_ = std::min(y1_, y); + x2_ = std::max(x2_, x); + y2_ = std::max(y2_, y); + } + + assert(x1_ <= x2_ && + y1_ <= y2_); // This is the invariant of the structure + } + + + void Extent2D::Union(const Extent2D& other) + { + if (other.empty_) + { + return; + } + + if (empty_) + { + *this = other; + return; + } + + assert(!empty_); + + x1_ = std::min(x1_, other.x1_); + y1_ = std::min(y1_, other.y1_); + x2_ = std::max(x2_, other.x2_); + y2_ = std::max(y2_, other.y2_); + + assert(x1_ <= x2_ && + y1_ <= y2_); // This is the invariant of the structure + } + + + bool Extent2D::IsEmpty() const + { + if (empty_) + { + return true; + } + else + { + assert(x1_ <= x2_ && + y1_ <= y2_); + return (x2_ <= x1_ + 10 * std::numeric_limits::epsilon() || + y2_ <= y1_ + 10 * std::numeric_limits::epsilon()); + } + } +} diff -r 53025eecbc95 -r 7665ccbf33db Framework/Toolbox/Extent2D.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Framework/Toolbox/Extent2D.h Wed Jun 14 15:54:06 2017 +0200 @@ -0,0 +1,85 @@ +/** + * Stone of Orthanc + * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics + * Department, University Hospital of Liege, Belgium + * Copyright (C) 2017 Osimis, 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 . + **/ + + +#pragma once + +namespace OrthancStone +{ + class Extent2D + { + private: + bool empty_; + double x1_; + double y1_; + double x2_; + double y2_; + + public: + Extent2D() + { + Reset(); + } + + Extent2D(double x1, + double y1, + double x2, + double y2); + + void Reset(); + + void AddPoint(double x, + double y); + + void Union(const Extent2D& other); + + bool IsEmpty() const; + + double GetX1() const + { + return x1_; + } + + double GetY1() const + { + return y1_; + } + + double GetX2() const + { + return x2_; + } + + double GetY2() const + { + return y2_; + } + + double GetWidth() const + { + return x2_ - x1_; + } + + double GetHeight() const + { + return y2_ - y1_; + } + }; +} diff -r 53025eecbc95 -r 7665ccbf33db Framework/Toolbox/ViewportGeometry.cpp --- a/Framework/Toolbox/ViewportGeometry.cpp Wed Jun 14 15:50:38 2017 +0200 +++ b/Framework/Toolbox/ViewportGeometry.cpp Wed Jun 14 15:54:06 2017 +0200 @@ -79,7 +79,7 @@ } - void ViewportGeometry::SetSceneExtent(const Extent& extent) + void ViewportGeometry::SetSceneExtent(const Extent2D& extent) { LOG(INFO) << "New scene extent: (" << extent.GetX1() << "," << extent.GetY1() << ") => (" diff -r 53025eecbc95 -r 7665ccbf33db Framework/Toolbox/ViewportGeometry.h --- a/Framework/Toolbox/ViewportGeometry.h Wed Jun 14 15:50:38 2017 +0200 +++ b/Framework/Toolbox/ViewportGeometry.h Wed Jun 14 15:54:06 2017 +0200 @@ -22,7 +22,7 @@ #pragma once #include "../Viewport/CairoContext.h" -#include "../Toolbox/Extent.h" +#include "../Toolbox/Extent2D.h" namespace OrthancStone { @@ -30,7 +30,7 @@ { private: // Extent of the scene (in world units) - Extent sceneExtent_; + Extent2D sceneExtent_; // Size of the display (in pixels) unsigned int width_; @@ -51,9 +51,9 @@ void SetDisplaySize(unsigned int width, unsigned int height); - void SetSceneExtent(const Extent& extent); + void SetSceneExtent(const Extent2D& extent); - const Extent& GetSceneExtent() const + const Extent2D& GetSceneExtent() const { return sceneExtent_; } diff -r 53025eecbc95 -r 7665ccbf33db Framework/Widgets/LayerWidget.cpp --- a/Framework/Widgets/LayerWidget.cpp Wed Jun 14 15:50:38 2017 +0200 +++ b/Framework/Widgets/LayerWidget.cpp Wed Jun 14 15:54:06 2017 +0200 @@ -214,7 +214,7 @@ } - void LayerWidget::GetLayerExtent(Extent& extent, + void LayerWidget::GetLayerExtent(Extent2D& extent, ILayerSource& source) const { extent.Reset(); @@ -232,14 +232,14 @@ } - Extent LayerWidget::GetSceneExtent() + Extent2D LayerWidget::GetSceneExtent() { - Extent sceneExtent; + Extent2D sceneExtent; for (size_t i = 0; i < layers_.size(); i++) { assert(layers_[i] != NULL); - Extent layerExtent; + Extent2D layerExtent; GetLayerExtent(layerExtent, *layers_[i]); sceneExtent.Union(layerExtent); diff -r 53025eecbc95 -r 7665ccbf33db Framework/Widgets/LayerWidget.h --- a/Framework/Widgets/LayerWidget.h Wed Jun 14 15:50:38 2017 +0200 +++ b/Framework/Widgets/LayerWidget.h Wed Jun 14 15:54:06 2017 +0200 @@ -23,7 +23,7 @@ #include "WorldSceneWidget.h" #include "../Layers/ILayerSource.h" -#include "../Toolbox/Extent.h" +#include "../Toolbox/Extent2D.h" #include @@ -50,7 +50,7 @@ bool LookupLayer(size_t& index /* out */, const ILayerSource& layer) const; - void GetLayerExtent(Extent& extent, + void GetLayerExtent(Extent2D& extent, ILayerSource& source) const; virtual void NotifyGeometryReady(const ILayerSource& source); @@ -70,7 +70,7 @@ void ResetChangedLayers(); protected: - virtual Extent GetSceneExtent(); + virtual Extent2D GetSceneExtent(); virtual bool RenderScene(CairoContext& context, const ViewportGeometry& view); diff -r 53025eecbc95 -r 7665ccbf33db Framework/Widgets/TestWorldSceneWidget.cpp --- a/Framework/Widgets/TestWorldSceneWidget.cpp Wed Jun 14 15:50:38 2017 +0200 +++ b/Framework/Widgets/TestWorldSceneWidget.cpp Wed Jun 14 15:54:06 2017 +0200 @@ -119,9 +119,9 @@ } - Extent TestWorldSceneWidget::GetSceneExtent() + Extent2D TestWorldSceneWidget::GetSceneExtent() { - return Extent(-10, -.5, 10, .5); + return Extent2D(-10, -.5, 10, .5); } diff -r 53025eecbc95 -r 7665ccbf33db Framework/Widgets/TestWorldSceneWidget.h --- a/Framework/Widgets/TestWorldSceneWidget.h Wed Jun 14 15:50:38 2017 +0200 +++ b/Framework/Widgets/TestWorldSceneWidget.h Wed Jun 14 15:54:06 2017 +0200 @@ -45,7 +45,7 @@ public: TestWorldSceneWidget(bool animate); - virtual Extent GetSceneExtent(); + virtual Extent2D GetSceneExtent(); virtual bool HasUpdateContent() const { diff -r 53025eecbc95 -r 7665ccbf33db Framework/Widgets/WorldSceneWidget.h --- a/Framework/Widgets/WorldSceneWidget.h Wed Jun 14 15:50:38 2017 +0200 +++ b/Framework/Widgets/WorldSceneWidget.h Wed Jun 14 15:54:06 2017 +0200 @@ -61,7 +61,7 @@ protected: - virtual Extent GetSceneExtent() = 0; + virtual Extent2D GetSceneExtent() = 0; virtual bool RenderScene(CairoContext& context, const ViewportGeometry& view) = 0; diff -r 53025eecbc95 -r 7665ccbf33db Resources/CMake/OrthancStone.cmake --- a/Resources/CMake/OrthancStone.cmake Wed Jun 14 15:50:38 2017 +0200 +++ b/Resources/CMake/OrthancStone.cmake Wed Jun 14 15:54:06 2017 +0200 @@ -203,10 +203,11 @@ ${ORTHANC_STONE_DIR}/Framework/Layers/OrthancFrameLayerSource.cpp ${ORTHANC_STONE_DIR}/Framework/Layers/RenderStyle.cpp ${ORTHANC_STONE_DIR}/Framework/Layers/SliceOutlineRenderer.cpp + ${ORTHANC_STONE_DIR}/Framework/Toolbox/CoordinateSystem3D.cpp ${ORTHANC_STONE_DIR}/Framework/Toolbox/DicomFrameConverter.cpp ${ORTHANC_STONE_DIR}/Framework/Toolbox/DicomStructureSet.cpp ${ORTHANC_STONE_DIR}/Framework/Toolbox/DownloadStack.cpp - ${ORTHANC_STONE_DIR}/Framework/Toolbox/Extent.cpp + ${ORTHANC_STONE_DIR}/Framework/Toolbox/Extent2D.cpp ${ORTHANC_STONE_DIR}/Framework/Toolbox/GeometryToolbox.cpp ${ORTHANC_STONE_DIR}/Framework/Toolbox/MessagingToolbox.cpp ${ORTHANC_STONE_DIR}/Framework/Toolbox/OrthancSeriesLoader.cpp @@ -214,7 +215,6 @@ ${ORTHANC_STONE_DIR}/Framework/Toolbox/ParallelSlices.cpp ${ORTHANC_STONE_DIR}/Framework/Toolbox/ParallelSlicesCursor.cpp ${ORTHANC_STONE_DIR}/Framework/Toolbox/Slice.cpp - ${ORTHANC_STONE_DIR}/Framework/Toolbox/CoordinateSystem3D.cpp ${ORTHANC_STONE_DIR}/Framework/Toolbox/SlicesSorter.cpp ${ORTHANC_STONE_DIR}/Framework/Toolbox/ViewportGeometry.cpp ${ORTHANC_STONE_DIR}/Framework/Viewport/CairoContext.cpp