<commit_before>/*
 * ImageRenderer.cpp
 *
 * Copyright (C) 2010 by VISUS (Universitaet Stuttgart)
 * Alle Rechte vorbehalten.
 */

#include "stdafx.h"
#include "imageviewer2/ImageRenderer.h"
#include "imageviewer2/JpegBitmapCodec.h"
#include "mmcore/misc/PngBitmapCodec.h"
#include "vislib/graphics/BitmapCodecCollection.h"
#include "vislib/graphics/gl/IncludeAllGL.h"

//#define _USE_MATH_DEFINES
#include "image_calls/Image2DCall_2.h"
#include "mmcore/CoreInstance.h"
#include "mmcore/cluster/mpi/MpiCall.h"
#include "mmcore/param/ButtonParam.h"
#include "mmcore/param/EnumParam.h"
#include "mmcore/param/FilePathParam.h"
#include "mmcore/param/IntParam.h"
#include "mmcore/param/StringParam.h"
#include "mmcore/view/AbstractRenderingView.h"
#include "mmcore/view/CallRender3D_2.h"
#include "vislib/sys/Log.h"
#include "vislib/sys/SystemInformation.h"
//#include <cmath>

using namespace megamol::core;
using namespace megamol;

const unsigned int TILE_SIZE = 2 * 1024;

/*
 * misc::ImageRenderer::ImageRenderer
 */
imageviewer2::ImageRenderer::ImageRenderer(void)
    : Renderer3DModule_2()
    , leftFilenameSlot("leftImg", "The image file name")
    , rightFilenameSlot("rightImg", "The image file name")
    , pasteFilenamesSlot("pasteFiles", "Slot to paste both file names at once (semicolon-separated)")
    , pasteSlideshowSlot("pasteShow", "Slot to paste filename pairs (semicolor-separated) on individual lines")
    , firstSlot("first", "go to first image in slideshow")
    , previousSlot("previous", "go to previous image in slideshow")
    , currentSlot("current", "current slideshow image index")
    , nextSlot("next", "go to next image in slideshow")
    , lastSlot("last", "go to last image in slideshow")
    , blankMachine("blankMachine", "semicolon-separated list of machines that do not load image")
    , defaultEye("defaultEye", "where the image goes if the slideshow only has one image per line")
    , shownImage(
          "shownImage", "Index of the shown image. This slot is only used when a ImageLoader module is connected.")
    , callRequestMpi("requestMpi", "Requests initialisation of MPI and the communicator for the view.")
    , callRequestImage{"requestImage", "Requests an image to display"}
    , width(1)
    , height(1)
    , tiles()
    , leftFiles()
    , rightFiles()
    , datahash{std::numeric_limits<size_t>::max()} {

    this->leftFilenameSlot << new param::FilePathParam("");
    this->MakeSlotAvailable(&this->leftFilenameSlot);

    this->rightFilenameSlot << new param::FilePathParam("");
    this->MakeSlotAvailable(&this->rightFilenameSlot);

    this->pasteFilenamesSlot << new param::StringParam("");
    this->pasteFilenamesSlot.SetUpdateCallback(&ImageRenderer::onFilesPasted);
    this->MakeSlotAvailable(&this->pasteFilenamesSlot);

    this->pasteSlideshowSlot << new param::StringParam("");
    this->pasteSlideshowSlot.SetUpdateCallback(&ImageRenderer::onSlideshowPasted);
    this->MakeSlotAvailable(&this->pasteSlideshowSlot);

    this->firstSlot << new param::ButtonParam();
    this->firstSlot.SetUpdateCallback(&ImageRenderer::onFirstPressed);
    this->MakeSlotAvailable(&this->firstSlot);
    this->previousSlot << new param::ButtonParam(core::view::Key::KEY_PAGE_UP);
    this->previousSlot.SetUpdateCallback(&ImageRenderer::onPreviousPressed);
    this->MakeSlotAvailable(&this->previousSlot);

    this->currentSlot << new param::IntParam(0);
    this->currentSlot.SetUpdateCallback(&ImageRenderer::onCurrentSet);
    this->MakeSlotAvailable(&this->currentSlot);

    this->nextSlot << new param::ButtonParam(core::view::Key::KEY_PAGE_DOWN);
    this->nextSlot.SetUpdateCallback(&ImageRenderer::onNextPressed);
    this->MakeSlotAvailable(&this->nextSlot);
    this->lastSlot << new param::ButtonParam();
    this->lastSlot.SetUpdateCallback(&ImageRenderer::onLastPressed);
    this->MakeSlotAvailable(&this->lastSlot);

    param::EnumParam* ep = new param::EnumParam(0);
    ep->SetTypePair(0, "left");
    ep->SetTypePair(1, "right");
    this->defaultEye << ep;
    this->MakeSlotAvailable(&this->defaultEye);

    this->leftFiles.AssertCapacity(20);
    this->rightFiles.AssertCapacity(20);
    this->leftFiles.SetCapacityIncrement(20);
    this->rightFiles.SetCapacityIncrement(20);

    this->blankMachine << new param::StringParam("");
    this->blankMachine.SetUpdateCallback(&ImageRenderer::onBlankMachineSet);
    this->MakeSlotAvailable(&this->blankMachine);

    this->shownImage << new param::IntParam(0, 0);
    this->MakeSlotAvailable(&this->shownImage);

    vislib::sys::SystemInformation::ComputerName(this->machineName);
    this->machineName.ToLowerCase();
<commit_msg>The imageRenderer has now a minimum image index of 0<commit_after>/*
 * ImageRenderer.cpp
 *
 * Copyright (C) 2010 by VISUS (Universitaet Stuttgart)
 * Alle Rechte vorbehalten.
 */

#include "stdafx.h"
#include "imageviewer2/ImageRenderer.h"
#include "imageviewer2/JpegBitmapCodec.h"
#include "mmcore/misc/PngBitmapCodec.h"
#include "vislib/graphics/BitmapCodecCollection.h"
#include "vislib/graphics/gl/IncludeAllGL.h"

//#define _USE_MATH_DEFINES
#include "image_calls/Image2DCall_2.h"
#include "mmcore/CoreInstance.h"
#include "mmcore/cluster/mpi/MpiCall.h"
#include "mmcore/param/ButtonParam.h"
#include "mmcore/param/EnumParam.h"
#include "mmcore/param/FilePathParam.h"
#include "mmcore/param/IntParam.h"
#include "mmcore/param/StringParam.h"
#include "mmcore/view/AbstractRenderingView.h"
#include "mmcore/view/CallRender3D_2.h"
#include "vislib/sys/Log.h"
#include "vislib/sys/SystemInformation.h"
//#include <cmath>

using namespace megamol::core;
using namespace megamol;

const unsigned int TILE_SIZE = 2 * 1024;

/*
 * misc::ImageRenderer::ImageRenderer
 */
imageviewer2::ImageRenderer::ImageRenderer(void)
    : Renderer3DModule_2()
    , leftFilenameSlot("leftImg", "The image file name")
    , rightFilenameSlot("rightImg", "The image file name")
    , pasteFilenamesSlot("pasteFiles", "Slot to paste both file names at once (semicolon-separated)")
    , pasteSlideshowSlot("pasteShow", "Slot to paste filename pairs (semicolor-separated) on individual lines")
    , firstSlot("first", "go to first image in slideshow")
    , previousSlot("previous", "go to previous image in slideshow")
    , currentSlot("current", "current slideshow image index")
    , nextSlot("next", "go to next image in slideshow")
    , lastSlot("last", "go to last image in slideshow")
    , blankMachine("blankMachine", "semicolon-separated list of machines that do not load image")
    , defaultEye("defaultEye", "where the image goes if the slideshow only has one image per line")
    , shownImage(
          "shownImage", "Index of the shown image. This slot is only used when a ImageLoader module is connected.")
    , callRequestMpi("requestMpi", "Requests initialisation of MPI and the communicator for the view.")
    , callRequestImage{"requestImage", "Requests an image to display"}
    , width(1)
    , height(1)
    , tiles()
    , leftFiles()
    , rightFiles()
    , datahash{std::numeric_limits<size_t>::max()} {

    this->leftFilenameSlot << new param::FilePathParam("");
    this->MakeSlotAvailable(&this->leftFilenameSlot);

    this->rightFilenameSlot << new param::FilePathParam("");
    this->MakeSlotAvailable(&this->rightFilenameSlot);

    this->pasteFilenamesSlot << new param::StringParam("");
    this->pasteFilenamesSlot.SetUpdateCallback(&ImageRenderer::onFilesPasted);
    this->MakeSlotAvailable(&this->pasteFilenamesSlot);

    this->pasteSlideshowSlot << new param::StringParam("");
    this->pasteSlideshowSlot.SetUpdateCallback(&ImageRenderer::onSlideshowPasted);
    this->MakeSlotAvailable(&this->pasteSlideshowSlot);

    this->firstSlot << new param::ButtonParam();
    this->firstSlot.SetUpdateCallback(&ImageRenderer::onFirstPressed);
    this->MakeSlotAvailable(&this->firstSlot);
    this->previousSlot << new param::ButtonParam(core::view::Key::KEY_PAGE_UP);
    this->previousSlot.SetUpdateCallback(&ImageRenderer::onPreviousPressed);
    this->MakeSlotAvailable(&this->previousSlot);

    this->currentSlot << new param::IntParam(0, 0);
    this->currentSlot.SetUpdateCallback(&ImageRenderer::onCurrentSet);
    this->MakeSlotAvailable(&this->currentSlot);

    this->nextSlot << new param::ButtonParam(core::view::Key::KEY_PAGE_DOWN);
    this->nextSlot.SetUpdateCallback(&ImageRenderer::onNextPressed);
    this->MakeSlotAvailable(&this->nextSlot);
    this->lastSlot << new param::ButtonParam();
    this->lastSlot.SetUpdateCallback(&ImageRenderer::onLastPressed);
    this->MakeSlotAvailable(&this->lastSlot);

    param::EnumParam* ep = new param::EnumParam(0);
    ep->SetTypePair(0, "left");
    ep->SetTypePair(1, "right");
    this->defaultEye << ep;
    this->MakeSlotAvailable(&this->defaultEye);

    this->leftFiles.AssertCapacity(20);
    this->rightFiles.AssertCapacity(20);
    this->leftFiles.SetCapacityIncrement(20);
    this->rightFiles.SetCapacityIncrement(20);

    this->blankMachine << new param::StringParam("");
    this->blankMachine.SetUpdateCallback(&ImageRenderer::onBlankMachineSet);
    this->MakeSlotAvailable(&this->blankMachine);

    this->shownImage << new param::IntParam(0, 0);
    this->MakeSlotAvailable(&this->shownImage);

    vislib::sys::SystemInformation::ComputerName(this->machineName);
    this->machineName.ToLowerCase();

{'fraction_non_alphanumeric': 0.1417448805460751, 'fraction_numerical': 0.0074658703071672355, 'mean_word_length': 5.435827041866849, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 111, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2223378', 'n_tokens_mistral': 2893, 'n_tokens_neox': 2818, 'n_words': 540}