# HG changeset patch # User Sebastien Jodogne # Date 1540883466 -3600 # Node ID 100df90bf0eaa1f9b938dbad45c9a71da2298850 # Parent b8eeb49f3e65de8810ca6ffdf3747d62aada6965 preparing to implement Export diff -r b8eeb49f3e65 -r 100df90bf0ea Applications/Samples/SingleFrameEditorApplication.h --- a/Applications/Samples/SingleFrameEditorApplication.h Tue Oct 30 07:55:08 2018 +0100 +++ b/Applications/Samples/SingleFrameEditorApplication.h Tue Oct 30 08:11:06 2018 +0100 @@ -23,18 +23,17 @@ #include "SampleApplicationBase.h" -#include "../../Framework/Toolbox/GeometryToolbox.h" #include "../../Framework/Toolbox/ImageGeometry.h" -#include "../../Framework/Layers/OrthancFrameLayerSource.h" - -#include +#include "../../Framework/Toolbox/OrthancApiClient.h" +#include "../../Framework/Toolbox/DicomFrameConverter.h" + #include +#include #include #include -#include //TODO #include +#include #include -#include #include @@ -2207,6 +2206,7 @@ std::auto_ptr floatBuffer_; std::auto_ptr cairoBuffer_; bool invert_; + ImageInterpolation interpolation_; virtual bool RenderInternal(unsigned int width, unsigned int height, @@ -2240,9 +2240,7 @@ stack_.Render(*floatBuffer_, GetView(), interpolation); - // TODO => rendering quality - - // As in GrayscaleFrameRenderer => TODO MERGE? + // Very similar to GrayscaleFrameRenderer => TODO MERGE? Orthanc::ImageAccessor target; cairoBuffer_->GetAccessor(target); @@ -2269,7 +2267,6 @@ v = static_cast(255.0f * (*p - x0) / (x1 - x0)); // (*) } - // TODO MONOCHROME1 if (invert_) { v = 255 - v; @@ -2296,11 +2293,9 @@ virtual bool RenderScene(CairoContext& context, const ViewportGeometry& view) { - ImageInterpolation interpolation = ImageInterpolation_Nearest; // TODO PARAMETER? - cairo_t* cr = context.GetObject(); - if (RenderInternal(context.GetWidth(), context.GetHeight(), interpolation)) + if (RenderInternal(context.GetWidth(), context.GetHeight(), interpolation_)) { // https://www.cairographics.org/FAQ/#paint_from_a_surface cairo_save(cr); @@ -2329,7 +2324,8 @@ IObservable(broker), IObserver(broker), stack_(stack), - invert_(false) + invert_(false), + interpolation_(ImageInterpolation_Nearest) { stack.RegisterObserverCallback(new Callable(*this, &BitmapStackWidget::OnGeometryChanged)); stack.RegisterObserverCallback(new Callable(*this, &BitmapStackWidget::OnContentChanged)); @@ -2354,8 +2350,11 @@ void SetInvert(bool invert) { - invert_ = invert; - NotifyContentChanged(); + if (invert_ != invert) + { + invert_ = invert; + NotifyContentChanged(); + } } void SwitchInvert() @@ -2368,6 +2367,20 @@ { return invert_; } + + void SetInterpolation(ImageInterpolation interpolation) + { + if (interpolation_ != interpolation) + { + interpolation_ = interpolation; + NotifyContentChanged(); + } + } + + ImageInterpolation GetInterpolation() const + { + return interpolation_; + } }; @@ -2384,8 +2397,9 @@ }; - UndoRedoStack undoRedoStack_; - Tool tool_; + UndoRedoStack undoRedoStack_; + Tool tool_; + OrthancApiClient *orthanc_; static double GetHandleSize() @@ -2408,7 +2422,8 @@ public: BitmapStackInteractor() : - tool_(Tool_Move) + tool_(Tool_Move), + orthanc_(NULL) { } @@ -2582,6 +2597,10 @@ tool_ = Tool_Crop; break; + case 'e': + Export(); + break; + case 'i': dynamic_cast(widget).SwitchInvert(); break; @@ -2590,6 +2609,29 @@ tool_ = Tool_Move; break; + case 'n': + { + BitmapStackWidget& w = dynamic_cast(widget); + + switch (w.GetInterpolation()) + { + case ImageInterpolation_Nearest: + LOG(INFO) << "Switching to bilinear interpolation"; + w.SetInterpolation(ImageInterpolation_Bilinear); + break; + + case ImageInterpolation_Bilinear: + LOG(INFO) << "Switching to nearest neighbor interpolation"; + w.SetInterpolation(ImageInterpolation_Nearest); + break; + + default: + throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); + } + + break; + } + case 'r': tool_ = Tool_Rotate; break; @@ -2622,6 +2664,24 @@ break; } } + + + void SetOrthanc(OrthancApiClient& orthanc) + { + orthanc_ = &orthanc; + } + + + void Export() + { + if (orthanc_ == NULL) + { + return; + } + + // TODO + LOG(WARNING) << "Exporting DICOM"; + } }; @@ -2666,9 +2726,11 @@ statusBar.SetMessage("Use the key \"a\" to reinitialize the layout"); statusBar.SetMessage("Use the key \"c\" to crop"); + statusBar.SetMessage("Use the key \"e\" to export DICOM to the Orthanc server"); statusBar.SetMessage("Use the key \"f\" to switch full screen"); statusBar.SetMessage("Use the key \"i\" to invert contrast"); statusBar.SetMessage("Use the key \"m\" to move objects"); + statusBar.SetMessage("Use the key \"n\" to switch between nearest neighbor and bilinear interpolation"); statusBar.SetMessage("Use the key \"r\" to rotate objects"); statusBar.SetMessage("Use the key \"s\" to resize objects (not applicable to DICOM bitmaps)"); statusBar.SetMessage("Use the key \"w\" to change windowing"); @@ -2686,6 +2748,7 @@ int frame = parameters["frame"].as(); orthancApiClient_.reset(new OrthancApiClient(IObserver::broker_, context_->GetWebService())); + interactor_.SetOrthanc(*orthancApiClient_); Orthanc::FontRegistry fonts; fonts.AddFromResource(Orthanc::EmbeddedResources::FONT_UBUNTU_MONO_BOLD_16); @@ -2695,7 +2758,7 @@ //stack_->LoadFrame("61f3143e-96f34791-ad6bbb8d-62559e75-45943e1b", 0, false); { - BitmapStack::Bitmap& bitmap = stack_->LoadText(fonts.GetFont(0), "Hello\nworld\nBonjour, Alain"); + BitmapStack::Bitmap& bitmap = stack_->LoadText(fonts.GetFont(0), "Hello\nworld"); //dynamic_cast(bitmap).SetForegroundValue(256); dynamic_cast(bitmap).SetResizeable(true); } @@ -2714,24 +2777,6 @@ //stack_->SetWindowing(128, 256); } - - - void Invert() - { - // TODO - } - - void Rotate(int degrees) - { - // TODO - } - - void Export() - { - // TODO: export dicom file to a temporary file - } }; - - } }