text:
/*
 * widgets.cpp
 *
 *  Created on: Mar 8, 2017
 *      Author: kobus
 */

#include <boost/thread/pthread/thread_data.hpp>
#include "widgets.h"

// ----------------------------------------------------------------------------
// private classes
// ----------------------------------------------------------------------------

TiDspParameters tiDspParams;
TiCameraParameters tiCameraParams;

// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------

// IDs for the controls and the menu commands
enum
{
    // menu items
    Minimal_Quit = wxID_EXIT,

    // it is important for the id corresponding to the "About" command to have
    // this standard value as otherwise it won't be handled properly under Mac
    // (where it is special and put into the "Apple" menu)
    Minimal_About = wxID_ABOUT,
    QUEUE_TIMER
};

// ----------------------------------------------------------------------------
// event tables and other macros for wxWidgets
// ----------------------------------------------------------------------------

// the event tables connect the wxWidgets events with the functions (event
// handlers) which process them. It can be also done at run-time, but for the
// simple menu events like this the static method is much simpler.
wxBEGIN_EVENT_TABLE(MyFrame1, wxFrame)
    EVT_MENU(Minimal_Quit,  MyFrame1::OnQuit)
    EVT_MENU(Minimal_About, MyFrame1::OnAbout)
    EVT_TIMER(QUEUE_TIMER, MyFrame1::OnQueueTimer)
wxEND_EVENT_TABLE()

// Create a new application object: this macro will allow wxWidgets to create
// the application object during program execution (it's better than using a
// static object for many reasons) and also implements the accessor function
// wxGetApp() which will return the reference of the right type (i.e. MyApp and
// not wxApp)
wxIMPLEMENT_APP_NO_MAIN(MyApp);
IMPLEMENT_WX_THEME_SUPPORT;

// ============================================================================
// implementation
// ============================================================================

// ----------------------------------------------------------------------------
// the application class
// ----------------------------------------------------------------------------

// 'Main program' equivalent: the program execution "starts" here
bool MyApp::OnInit()
{
    // call the base class initialization method, currently it only parses a
    // few common command-line options but it could be do more in the future
    if ( !wxApp::OnInit() )
        return false;

    // create the main application window
    myFrame = new MyFrame1("Thermal imager pipeline");

    // and show it (the frames, unlike simple controls, are not shown when
    // created initially)
    myFrame->Show(true);

    // success: wxApp::OnRun() will be called which will enter the main message
    // loop and the application will run. If we returneCannyd false here, the
    // application would exit immediately.
    return true;
}

void MyApp::InitQueues(Queues* qs)
{
	queues = qs;
	myFrame->InitQueues(qs);

    static const int INTERVAL = 1000; // milliseconds
    myFrame->qTimer = new wxTimer(myFrame, QUEUE_TIMER);
    myFrame->qTimer->Start(INTERVAL);
};

// ----------------------------------------------------------------------------
// main frame
// ----------------------------------------------------------------------------

// frame constructor
MyFrame1::MyFrame1(const wxString& title)
       : wxFrame(NULL, wxID_ANY, title)
{
    this->SetSizeHints( wxDefaultSize, wxDefaultSize );

    wxBoxSizer* bSizer1;
    bSizer1 = new wxBoxSizer( wxHORIZONTAL );

    wxBoxSizer* bSizer2;
    bSizer2 = new wxBoxSizer( wxVERTICAL );

    wxGridSizer* gSizer1;
    gSizer1 = new wxGridSizer( 13, 2, 0, 0 );

    m_staticText1 = new wxStaticText( this, wxID_ANY, wxT("Output select"), wxDefaultPosition, wxDefaultSize, 0 );
    m_staticText1->Wrap( -1 );
    m_staticText1->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, true, wxEmptyString ) );

    gSizer1->Add( m_staticText1, 0, wxALL, 5 );

    m_staticText2 = new wxStaticText( this, wxID_ANY, wxT("Active"), wxDefaultPosition, wxDefaultSize, 0 );
    m_staticText2->Wrap( -1 );
    m_staticText2->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, true, wxEmptyString ) );

    gSizer1->Add( m_staticText2, 0, wxALL, 5 );

    m_buttonRaw = new wxButton( this, wxID_ANY, wxT("Raw"), wxDefaultPosition, wxDefaultSize, 0 );
    gSizer1->Add( m_buttonRaw, 0, wxALL, 5 );

    m_checkBoxRaw = new wxCheckBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
    m_checkBoxRaw->SetValue(true);
    m_checkBoxRaw->Enable( false );

    gSizer1->Add( m_checkBoxRaw, 0, wxALL, 5 );

    m_buttonGrayScale = new wxButton( this, wxID_ANY, wxT("Gray scale"), wxDefaultPosition, wxDefaultSize, 0 );
    gSizer1->Add( m_buttonGrayScale, 0, wxALL, 5 );

    m_checkBoxGrayScale = new wxCheckBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
    m_checkBoxGrayScale->SetValue(true);
    gSizer1->Add( m_checkBoxGrayScale, 0, wxALL, 5 );

    m_buttonNonU = new wxButton( this, wxID_ANY, wxT("Non uniformity"), wxDefaultPosition, wxDefaultSize, 0 );
    gSizer1->Add( m_buttonNonU, 0, wxALL, 5 );

    m_checkBoxNonUniformity = new wxCheckBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
    m_checkBoxNonUniformity->SetValue(true);
    gSizer1->Add( m_checkBoxNonUniformity, 0, wxALL, 5 );

    m_buttonFrameAverager = new wxButton( this, wxID_ANY, wxT("Frame averager"), wxDefaultPosition, wxDefaultSize, 0 );
    gSizer1->Add( m_buttonFrameAverager, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5 );

    m_checkBoxFrameAverager = new wxCheckBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
    m_checkBoxFrameAverager->SetValue(true);
    gSizer1->Add( m_checkBoxFrameAverager, 0, wxALL, 5 );

    m_buttonNuc = new wxButton( this, wxID_ANY, wxT("NUC"), wxDefaultPosition, wxDefaultSize, 0 );
    m_buttonNuc->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );

    gSizer1->Add( m_buttonNuc, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5 );

    m_checkBoxNuc = new wxCheckBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
    m_checkBoxNuc->SetValue(true);
    gSizer1->Add( m_checkBoxNuc, 0, wxALL, 5 );

    m_buttonTFilter = new wxButton( this, wxID_ANY, wxT("Temporal filter"), wxDefaultPosition, wxDefaultSize, 0 );
    m_buttonTFilter->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );

    gSizer1->Add( m_buttonTFilter, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5 );

    m_checkBoxTFilter = new wxCheckBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
    m_checkBoxTFilter->SetValue(true);
    gSizer1->Add( m_checkBoxTFilter, 0, wxALL, 5 );

    m_buttonSFilter = new wxButton( this, wxID_ANY, wxT("Spatial filter"), wxDefaultPosition, wxDefaultSize, 0 );
    m_buttonSFilter->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );

    gSizer1->Add( m_buttonSFilter, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5 );

    m_checkBoxSFilter = new wxCheckBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
    m_checkBoxSFilter->SetValue(true);
    gSizer1->Add( m_checkBoxSFilter, 0, wxALL, 5 );

    m_buttonEdgeEnhance = new wxButton( this, wxID_ANY, wxT("Edge enhance"), wxDefaultPosition, wxDefaultSize, 0 );
    gSizer1->Add( m_buttonEdgeEnhance, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5 );

    m_checkBoxEdgeEnhance = new wxCheckBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
    m_checkBoxEdgeEnhance->SetValue(true);
    gSizer1->Add( m_checkBoxEdgeEnhance, 0, wxALL, 5 );

    m_buttonStab = new wxButton( this, wxID_ANY, wxT("Stab"), wxDefaultPosition, wxDefaultSize, 0 );
    m_buttonStab->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );

    gSizer1->Add( m_buttonStab, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5 );

    m_checkBoxAgc = new wxCheckBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
    m_checkBoxAgc->SetValue(true);
    gSizer1->Add( m_checkBoxAgc, 0, wxALL, 5 );

    m_buttonEzoom = new wxButton( this, wxID_ANY, wxT("E-Zoom"), wxDefaultPosition, wxDefaultSize, 0 );
    gSizer1->Add( m_buttonEzoom, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5 );

    m_checkBoxEzoom = new wxCheckBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
    m_checkBoxEzoom->SetValue(true);
    gSizer1->Add( m_checkBoxEzoom, 0, wxALL, 5 );

    m_buttonStretch = new wxButton( this, wxID_ANY, wxT("Stretch"), wxDefaultPosition, wxDefaultSize, 0 );
    gSizer1->Add( m_buttonStretch, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5 );

    m_checkBoxStretch = new wxCheckBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
    m_checkBoxStretch->SetValue(true);
    gSizer1->Add( m_checkBoxStretch, 0, wxALL, 5 );

    m_buttonColorize = new wxButton( this, wxID_ANY, wxT("Colorize"), wxDefaultPosition, wxDefaultSize, 0 );
    m_buttonColorize->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );

    gSizer1->Add( m_buttonColorize, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5 );

    m_checkBoxColorize = new wxCheckBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
    m_checkBoxColorize->SetValue(true);
    gSizer1->Add( m_checkBoxColorize, 0, wxALL, 5 );

    bSizer2->Add( gSizer1, 0, wxALIGN_LEFT|wxFIXED_MINSIZE, 5 );

    bSizer1->Add( bSizer2, 0, 0, 5 );

    wxBoxSizer* bSizer9;
    bSizer9 = new wxBoxSizer( wxVERTICAL );

    m_choicebook2 = new wxChoicebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxCHB_DEFAULT );
    m_panel1 = new wxPanel( m_choicebook2, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
    wxBoxSizer* bSizer16;
    bSizer16 = new wxBoxSizer( wxVERTICAL );

    m_staticText26 = new wxStaticText( m_panel1, wxID_ANY, wxT("Threshold:"), wxDefaultPosition, wxDefaultSize, 0 );
    m_staticText26->Wrap( -1 );
    bSizer16->Add( m_staticText26, 0, wxALL, 5 );

    m_sliderFrameAveragerThreshold = new wxSlider( m_panel1, wxID_ANY, 50, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL );
    bSizer16->Add( m_sliderFrameAveragerThreshold, 0, wxALL|wxEXPAND, 5 );

    m_panel1->SetSizer( bSizer16 );
    m_panel1->Layout();
    bSizer16->Fit( m_panel1 );
    m_choicebook2->AddPage( m_panel1, wxT("Frame averager"), false );
    m_panel2 = new wxPanel( m_choicebook2, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
    wxBoxSizer* bSizer18;
    bSizer18 = new wxBoxSizer( wxVERTICAL );

    m_buttonSample = new wxButton( m_panel2, wxID_ANY, wxT("Sample"), wxDefaultPosition, wxDefaultSize, 0 );
    bSizer18->Add( m_buttonSample, 0, wxALL, 5 );

    m_panel2->SetSizer( bSizer18 );
    m_panel2->Layout();
    bSizer18->Fit( m_panel2 );
    m_choicebook2->AddPage( m_panel2, wxT("NUC"), false );
    m_panel3 = new wxPanel( m_choicebook2, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
    m_choicebook2->AddPage( m_panel3, wxT("Temporal filter"), false );
    m_panel4 = new wxPanel( m_choicebook2, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
    m_choicebook2->AddPage( m_panel4, wxT("Spatial filter"), false );
    m_panel5 = new wxPanel( m_choicebook2, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
    wxBoxSizer* bSizer14;
    bSizer14 = new wxBoxSizer( wxVERTICAL );

    wxBoxSizer* bSizer3;
    bSizer3 = new wxBoxSizer( wxHORIZONTAL );

    m_panelGaussian = new wxPanel( m_panel5, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxRAISED_BORDER|wxTAB_TRAVERSAL );
    m_panelGaussian->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );

    wxBoxSizer* bSizer4;
    bSizer4 = new wxBoxSizer( wxVERTICAL );

    m_buttonGaussian = new wxButton( m_panelGaussian, wxID_ANY, wxT("Gaussian"), wxDefaultPosition, wxDefaultSize, 0 );
    bSizer4->Add( m_buttonGaussian, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );

    m_panelGaussian->SetSizer( bSizer4 );
    m_panelGaussian->Layout();
    bSizer4->Fit( m_panelGaussian );
    bSizer3->Add( m_panelGaussian, 1, wxEXPAND | wxALL, 5 );

    m_panelSharpen = new wxPanel( m_panel5, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxRAISED_BORDER|wxTAB_TRAVERSAL );
    m_panelSharpen->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) );

    wxBoxSizer* bSizer7;
    bSizer7 = new wxBoxSizer( wxVERTICAL );

    m_buttonSharpen = new wxButton( m_panelSharpen, wxID_ANY, wxT("Sharpen"), wxDefaultPosition, wxDefaultSize, 0 );
    bSizer7->Add( m_buttonSharpen, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );

    m_panelSharpen->SetSizer( bSizer7 );
    m_panelSharpen->Layout();
    bSizer7->Fit( m_panelSharpen );
    bSizer3->Add( m_panelSharpen, 1, wxEXPAND | wxALL, 5 );

    m_panelUnsharpMask = new wxPanel( m_panel5, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxRAISED_BORDER|wxTAB_TRAVERSAL );
    m_panelUnsharpMask->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) );

    wxBoxSizer* bSizer8;
    bSizer8 = new wxBoxSizer( wxVERTICAL );

    m_buttonUnsharpMask = new wxButton( m_panelUnsharpMask, wxID_ANY, wxT("Unsharp mask"), wxDefaultPosition, wxDefaultSize, 0 );
    bSizer8->Add( m_buttonUnsharpMask, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );

    m_panelUnsharpMask->SetSizer( bSizer8 );
    m_panelUnsharpMask->Layout();
    bSizer8->Fit( m_panelUnsharpMask );
    bSizer3->Add( m_panelUnsharpMask, 1, wxEXPAND | wxALL, 5 );

    bSizer14->Add( bSizer3, 1, wxEXPAND, 5 );

    m_panel5->SetSizer( bSizer14 );
    m_panel5->Layout();
    bSizer14->Fit( m_panel5 );
    m_choicebook2->AddPage( m_panel5, wxT("Edge enhance"), false );
    m_panel6 = new wxPanel( m_choicebook2, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
    wxBoxSizer* bSizer19;
    bSizer19 = new wxBoxSizer( wxVERTICAL );

    m_buttonStabLock = new wxButton( m_panel6, wxID_ANY, wxT("Lock"), wxDefaultPosition, wxDefaultSize, 0 );
    bSizer19->Add( m_buttonStabLock, 0, wxALL, 5 );

    m_buttonStabLetGo = new wxButton( m_panel6, wxID_ANY, wxT("Let go"), wxDefaultPosition, wxDefaultSize, 0 );
    bSizer19->Add( m_buttonStabLetGo, 0, wxALL, 5 );

    m_panel6->SetSizer( bSizer19 );
    m_panel6->Layout();
    bSizer19->Fit( m_panel6 );
    m_choicebook2->AddPage( m_panel6, wxT("Stab"), true );
    m_panel7 = new wxPanel( m_choicebook2, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
    wxBoxSizer* bSizer161;
    bSizer161 = new wxBoxSizer( wxVERTICAL );

    wxBoxSizer* bSizer17;
    bSizer17 = new wxBoxSizer( wxHORIZONTAL );

    m_radioBtnNoZoom = new wxRadioButton( m_panel7, wxID_ANY, wxT("No Zoom"), wxDefaultPosition, wxDefaultSize, 0 );
    bSizer17->Add( m_radioBtnNoZoom, 0, wxALL, 5 );

    m_radioBtn2xZoom = new wxRadioButton( m_panel7, wxID_ANY, wxT("2x"), wxDefaultPosition, wxDefaultSize, 0 );
    bSizer17->Add( m_radioBtn2xZoom, 0, wxALL, 5 );

    radioBtn4xZoom = new wxRadioButton( m_panel7, wxID_ANY, wxT("4x"), wxDefaultPosition, wxDefaultSize, 0 );
    bSizer17->Add( radioBtn4xZoom, 0, wxALL, 5 );

    radioBtn8xZoom = new wxRadioButton( m_panel7, wxID_ANY, wxT("8x"), wxDefaultPosition, wxDefaultSize, 0 );
    bSizer17->Add( radioBtn8xZoom, 0, wxALL, 5 );

    bSizer161->Add( bSizer17, 0, wxEXPAND, 5 );

    m_staticText181 = new wxStaticText( m_panel7, wxID_ANY, wxT("Vertical offset"), wxDefaultPosition, wxDefaultSize, 0 );
    m_staticText181->Wrap( -1 );
    bSizer161->Add( m_staticText181, 0, wxALL, 5 );

    m_sliderEzoomVerticalOffset = new wxSlider( m_panel7, wxID_ANY, 50, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL );
    bSizer161->Add( m_sliderEzoomVerticalOffset, 0, wxALL|wxEXPAND, 5 );

    m_staticText19 = new wxStaticText( m_panel7, wxID_ANY, wxT("Horisontal offset"), wxDefaultPosition, wxDefaultSize, 0 );
    m_staticText19->Wrap( -1 );
    bSizer161->Add( m_staticText19, 0, wxALL, 5 );

    m_sliderEzoomHorisontalOffset = new wxSlider( m_panel7, wxID_ANY, 50, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL );
    bSizer161->Add( m_sliderEzoomHorisontalOffset, 0, wxALL|wxEXPAND, 5 );

    m_panel7->SetSizer( bSizer161 );
    m_panel7->Layout();
    bSizer161->Fit( m_panel7 );
    m_choicebook2->AddPage( m_panel7, wxT("E-Zoom"), false );
    m_panel8 = new wxPanel( m_choicebook2, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
    m_choicebook2->AddPage( m_panel8, wxT("Stretch"), false );
    m_panel9 = new wxPanel( m_choicebook2, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
    m_choicebook2->AddPage( m_panel9, wxT("Colorize"), false );
    bSizer9->Add( m_choicebook2, 1, wxEXPAND, 5 );

    wxBoxSizer* bSizer10;
    bSizer10 = new wxBoxSizer( wxVERTICAL );

    wxBoxSizer* bSizer11;
    bSizer11 = new wxBoxSizer( wxHORIZONTAL );

    m_staticText16 = new wxStaticText( this, wxID_ANY, wxT("Horisontal pixels:"), wxDefaultPosition, wxDefaultSize, 0 );
    m_staticText16->Wrap( -1 );
    bSizer11->Add( m_staticText16, 0, wxALL, 5 );

    m_staticTextHorisontalPixels = new wxStaticText( this, wxID_ANY, wxT("0"), wxDefaultPosition, wxDefaultSize, 0 );
    m_staticTextHorisontalPixels->Wrap( -1 );
    bSizer11->Add( m_staticTextHorisontalPixels, 0, wxALL, 5 );

    bSizer10->Add( bSizer11, 1, wxEXPAND, 5 );

    wxBoxSizer* bSizer12;
    bSizer12 = new wxBoxSizer( wxHORIZONTAL );

    m_staticText18 = new wxStaticText( this, wxID_ANY, wxT("Vertical pixels:"), wxDefaultPosition, wxDefaultSize, 0 );
    m_staticText18->Wrap( -1 );
    bSizer12->Add( m_staticText18, 0, wxALL, 5 );

    m_staticTextVerticalPixels = new wxStaticText( this, wxID_ANY, wxT("0"), wxDefaultPosition, wxDefaultSize, 0 );
    m_staticTextVerticalPixels->Wrap( -1 );
    bSizer12->Add( m_staticTextVerticalPixels, 0, wxALL, 5 );

    bSizer10->Add( bSizer12, 1, wxEXPAND, 5 );

    wxBoxSizer* bSizer13;
    bSizer13 = new wxBoxSizer( wxHORIZONTAL );

    m_staticText20 = new wxStaticText( this, wxID_ANY, wxT("Framerate"), wxDefaultPosition, wxDefaultSize, 0 );
    m_staticText20->Wrap( -1 );
    bSizer13->Add( m_staticText20, 0, wxALL, 5 );

    m_staticTextFramerate = new wxStaticText( this, wxID_ANY, wxT("0 Hz"), wxDefaultPosition, wxDefaultSize, 0 );
    m_staticTextFramerate->Wrap( -1 );
    bSizer13->Add( m_staticTextFramerate, 0, wxALL, 5 );

    bSizer10->Add( bSizer13, 1, wxEXPAND, 5 );

    wxBoxSizer* bSizer141;
    bSizer141 = new wxBoxSizer( wxHORIZONTAL );

    m_staticText22 = new wxStaticText( this, wxID_ANY, wxT("Pipeline"), wxDefaultPosition, wxDefaultSize, 0 );
    m_staticText22->Wrap( -1 );
    bSizer141->Add( m_staticText22, 0, wxALL, 5 );

    m_staticTextPipeline = new wxStaticText( this, wxID_ANY, wxT("0 Hz"), wxDefaultPosition, wxDefaultSize, 0 );
    m_staticTextPipeline->Wrap( -1 );
    bSizer141->Add( m_staticTextPipeline, 0, wxALL, 5 );

    bSizer10->Add( bSizer141, 1, wxEXPAND, 5 );

    wxBoxSizer* bSizer15;
    bSizer15 = new wxBoxSizer( wxHORIZONTAL );

    m_staticText24 = new wxStaticText( this, wxID_ANY, wxT("Colour space:"), wxDefaultPosition, wxDefaultSize, 0 );
    m_staticText24->Wrap( -1 );
    bSizer15->Add( m_staticText24, 0, wxALL, 5 );

    m_staticTextColourSpace = new wxStaticText( this, wxID_ANY, wxT("0 : 0"), wxDefaultPosition, wxDefaultSize, 0 );
    m_staticTextColourSpace->Wrap( -1 );
    bSizer15->Add( m_staticTextColourSpace, 0, wxALL, 5 );

    bSizer10->Add( bSizer15, 1, wxEXPAND, 5 );

    bSizer9->Add( bSizer10, 0, wxEXPAND, 5 );

    bSizer1->Add( bSizer9, 1, wxEXPAND, 5 );

    this->SetSizer( bSizer1 );
    this->Layout();

    // Connect Events
    m_buttonRaw->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MyFrame1::m_buttonRawOnButtonClick ), NULL, this );
    m_checkBoxRaw->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( MyFrame1::m_checkBox10OnCheckBox ), NULL, this );
    m_buttonGrayScale->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MyFrame1::m_buttonGrayScaleOnButtonClick ), NULL, this );
    m_checkBoxGrayScale->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( MyFrame1::m_checkBoxGrayScaleOnCheckBox ), NULL, this );
    m_buttonNonU->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MyFrame1::m_buttonNonUOnButtonClick ), NULL, this );
    m_checkBoxNonUniformity->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( MyFrame1::m_checkBoxNonUniformityOnCheckBox ), NULL, this );
    m_buttonFrameAverager->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MyFrame1::m_buttonFrameAveragerOnButtonClick ), NULL, this );
    m_checkBoxFrameAverager->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( MyFrame1::m_checkBoxFrameAveragerOnCheckBox ), NULL, this );
    m_buttonNuc->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MyFrame1::m_buttonNucOnButtonClick ), NULL, this );
    m_checkBoxNuc->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( MyFrame1::m_checkBoxNucOnCheckBox ), NULL, this );
    m_buttonTFilter->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MyFrame1::m_buttonTFilterOnButtonClick ), NULL, this );
    m_checkBoxTFilter->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( MyFrame1::m_checkBoxTFilterOnCheckBox ), NULL, this );
    m_buttonSFilter->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MyFrame1::m_buttonSFilterOnButtonClick ), NULL, this );
    m_checkBoxSFilter->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( MyFrame1::m_checkBoxSFilterOnCheckBox ), NULL, this );
    m_buttonEdgeEnhance->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MyFrame1::m_buttonEdgeEnhanceOnButtonClick ), NULL, this );
    m_checkBoxEdgeEnhance->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( MyFrame1::m_checkBoxEdgeEnhanceOnCheckBox ), NULL, this );
    m_buttonStab->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MyFrame1::m_buttonStabOnButtonClick ), NULL, this );
    m_checkBoxAgc->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( MyFrame1::m_checkBoxAgcOnCheckBox ), NULL, this );
    m_buttonEzoom->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MyFrame1::m_buttonEzoomOnButtonClick ), NULL, this );
    m_checkBoxEzoom->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( MyFrame1::m_checkBoxEzoomOnCheckBox ), NULL, this );
    m_buttonStretch->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MyFrame1::m_buttonStretchOnButtonClick ), NULL, this );
    m_checkBoxStretch->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( MyFrame1::m_checkBoxStretchOnCheckBox ), NULL, this );
    m_buttonColorize->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MyFrame1::m_buttonColorizeOnButtonClick ), NULL, this );
    m_checkBoxColorize->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( MyFrame1::m_checkBoxColorizeOnCheckBox ), NULL, this );
    m_sliderFrameAveragerThreshold->Connect( wxEVT_SCROLL_TOP, wxScrollEventHandler( MyFrame1::m_sliderFrameAveragerThresholdOnScroll ), NULL, this );
    m_sliderFrameAveragerThreshold->Connect( wxEVT_SCROLL_BOTTOM, wxScrollEventHandler( MyFrame1::m_sliderFrameAveragerThresholdOnScroll ), NULL, this );
    m_sliderFrameAveragerThreshold->Connect( wxEVT_SCROLL_LINEUP, wxScrollEventHandler( MyFrame1::m_sliderFrameAveragerThresholdOnScroll ), NULL, this );
    m_sliderFrameAveragerThreshold->Connect( wxEVT_SCROLL_LINEDOWN, wxScrollEventHandler( MyFrame1::m_sliderFrameAveragerThresholdOnScroll ), NULL, this );
    m_sliderFrameAveragerThreshold->Connect( wxEVT_SCROLL_PAGEUP, wxScrollEventHandler( MyFrame1::m_sliderFrameAveragerThresholdOnScroll ), NULL, this );
    m_sliderFrameAveragerThreshold->Connect( wxEVT_SCROLL_PAGEDOWN, wxScrollEventHandler( MyFrame1::m_sliderFrameAveragerThresholdOnScroll ), NULL, this );
    m_sliderFrameAveragerThreshold->Connect( wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler( MyFrame1::m_sliderFrameAveragerThresholdOnScroll ), NULL, this );
    m_sliderFrameAveragerThreshold->Connect( wxEVT_SCROLL_THUMBRELEASE, wxScrollEventHandler( MyFrame1::m_sliderFrameAveragerThresholdOnScroll ), NULL, this );
    m_sliderFrameAveragerThreshold->Connect( wxEVT_SCROLL_CHANGED, wxScrollEventHandler( MyFrame1::m_sliderFrameAveragerThresholdOnScroll ), NULL, this );
    m_buttonSample->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MyFrame1::m_buttonSampleOnButtonClick ), NULL, this );
    m_buttonGaussian->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MyFrame1::m_buttonGaussianOnButtonClick ), NULL, this );
    m_buttonSharpen->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MyFrame1::m_buttonSharpenOnButtonClick ), NULL, this );
    m_buttonUnsharpMask->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MyFrame1::m_buttonUnsharpMaskOnButtonClick ), NULL, this );
    m_buttonStabLock->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MyFrame1::m_buttonStabLockOnButtonClick ), NULL, this );
    m_buttonStabLetGo->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MyFrame1::m_buttonStabLetGoOnButtonClick ), NULL, this );
    m_radioBtnNoZoom->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( MyFrame1::m_radioBtnNoZoomOnRadioButton ), NULL, this );
    m_radioBtn2xZoom->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( MyFrame1::m_radioBtn2xZoomOnRadioButton ), NULL, this );
    radioBtn4xZoom->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( MyFrame1::radioBtn4xZoomOnRadioButton ), NULL, this );
    radioBtn8xZoom->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( MyFrame1::radioBtn8xZoomOnRadioButton ), NULL, this );
    m_sliderEzoomVerticalOffset->Connect( wxEVT_SCROLL_TOP, wxScrollEventHandler( MyFrame1::m_sliderEzoomVerticalOffsetOnScroll ), NULL, this );
    m_sliderEzoomVerticalOffset->Connect( wxEVT_SCROLL_BOTTOM, wxScrollEventHandler( MyFrame1::m_sliderEzoomVerticalOffsetOnScroll ), NULL, this );
    m_sliderEzoomVerticalOffset->Connect( wxEVT_SCROLL_LINEUP, wxScrollEventHandler( MyFrame1::m_sliderEzoomVerticalOffsetOnScroll ), NULL, this );
    m_sliderEzoomVerticalOffset->Connect( wxEVT_SCROLL_LINEDOWN, wxScrollEventHandler( MyFrame1::m_sliderEzoomVerticalOffsetOnScroll ), NULL, this );
    m_sliderEzoomVerticalOffset->Connect( wxEVT_SCROLL_PAGEUP, wxScrollEventHandler( MyFrame1::m_sliderEzoomVerticalOffsetOnScroll ), NULL, this );
    m_sliderEzoomVerticalOffset->Connect( wxEVT_SCROLL_PAGEDOWN, wxScrollEventHandler( MyFrame1::m_sliderEzoomVerticalOffsetOnScroll ), NULL, this );
    m_sliderEzoomVerticalOffset->Connect( wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler( MyFrame1::m_sliderEzoomVerticalOffsetOnScroll ), NULL, this );
    m_sliderEzoomVerticalOffset->Connect( wxEVT_SCROLL_THUMBRELEASE, wxScrollEventHandler( MyFrame1::m_sliderEzoomVerticalOffsetOnScroll ), NULL, this );
    m_sliderEzoomVerticalOffset->Connect( wxEVT_SCROLL_CHANGED, wxScrollEventHandler( MyFrame1::m_sliderEzoomVerticalOffsetOnScroll ), NULL, this );
    m_sliderEzoomHorisontalOffset->Connect( wxEVT_SCROLL_TOP, wxScrollEventHandler( MyFrame1::m_sliderEzoomHorisontalOffsetOnScroll ), NULL, this );
    m_sliderEzoomHorisontalOffset->Connect( wxEVT_SCROLL_BOTTOM, wxScrollEventHandler( MyFrame1::m_sliderEzoomHorisontalOffsetOnScroll ), NULL, this );
    m_sliderEzoomHorisontalOffset->Connect( wxEVT_SCROLL_LINEUP, wxScrollEventHandler( MyFrame1::m_sliderEzoomHorisontalOffsetOnScroll ), NULL, this );
    m_sliderEzoomHorisontalOffset->Connect( wxEVT_SCROLL_LINEDOWN, wxScrollEventHandler( MyFrame1::m_sliderEzoomHorisontalOffsetOnScroll ), NULL, this );
    m_sliderEzoomHorisontalOffset->Connect( wxEVT_SCROLL_PAGEUP, wxScrollEventHandler( MyFrame1::m_sliderEzoomHorisontalOffsetOnScroll ), NULL, this );
    m_sliderEzoomHorisontalOffset->Connect( wxEVT_SCROLL_PAGEDOWN, wxScrollEventHandler( MyFrame1::m_sliderEzoomHorisontalOffsetOnScroll ), NULL, this );
    m_sliderEzoomHorisontalOffset->Connect( wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler( MyFrame1::m_sliderEzoomHorisontalOffsetOnScroll ), NULL, this );
    m_sliderEzoomHorisontalOffset->Connect( wxEVT_SCROLL_THUMBRELEASE, wxScrollEventHandler( MyFrame1::m_sliderEzoomHorisontalOffsetOnScroll ), NULL, this );
    m_sliderEzoomHorisontalOffset->Connect( wxEVT_SCROLL_CHANGED, wxScrollEventHandler( MyFrame1::m_sliderEzoomHorisontalOffsetOnScroll ), NULL, this );
}

MyFrame1::~MyFrame1()
{
	/* -------------- Generated code (wxFormBuilder) ----------------------------------------------------------------*/
    // Disconnect Events
    m_buttonRaw->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MyFrame1::m_buttonRawOnButtonClick ), NULL, this );
    m_checkBoxRaw->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( MyFrame1::m_checkBox10OnCheckBox ), NULL, this );
    m_buttonGrayScale->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MyFrame1::m_buttonGrayScaleOnButtonClick ), NULL, this );
    m_checkBoxGrayScale->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( MyFrame1::m_checkBoxGrayScaleOnCheckBox ), NULL, this );
    m_buttonNonU->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MyFrame1::m_buttonNonUOnButtonClick ), NULL, this );
    m_checkBoxNonUniformity->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( MyFrame1::m_checkBoxNonUniformityOnCheckBox ), NULL, this );
    m_buttonFrameAverager->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MyFrame1::m_buttonFrameAveragerOnButtonClick ), NULL, this );
    m_checkBoxFrameAverager->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( MyFrame1::m_checkBoxFrameAveragerOnCheckBox ), NULL, this );
    m_buttonNuc->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MyFrame1::m_buttonNucOnButtonClick ), NULL, this );
    m_checkBoxNuc->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( MyFrame1::m_checkBoxNucOnCheckBox ), NULL, this );
    m_buttonTFilter->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MyFrame1::m_buttonTFilterOnButtonClick ), NULL, this );
    m_checkBoxTFilter->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( MyFrame1::m_checkBoxTFilterOnCheckBox ), NULL, this );
    m_buttonSFilter->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MyFrame1::m_buttonSFilterOnButtonClick ), NULL, this );
    m_checkBoxSFilter->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( MyFrame1::m_checkBoxSFilterOnCheckBox ), NULL, this );
    m_buttonEdgeEnhance->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MyFrame1::m_buttonEdgeEnhanceOnButtonClick ), NULL, this );
    m_checkBoxEdgeEnhance->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( MyFrame1::m_checkBoxEdgeEnhanceOnCheckBox ), NULL, this );
    m_buttonStab->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MyFrame1::m_buttonStabOnButtonClick ), NULL, this );
    m_checkBoxAgc->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( MyFrame1::m_checkBoxAgcOnCheckBox ), NULL, this );
    m_buttonEzoom->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MyFrame1::m_buttonEzoomOnButtonClick ), NULL, this );
    m_checkBoxEzoom->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( MyFrame1::m_checkBoxEzoomOnCheckBox ), NULL, this );
    m_buttonStretch->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MyFrame1::m_buttonStretchOnButtonClick ), NULL, this );
    m_checkBoxStretch->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( MyFrame1::m_checkBoxStretchOnCheckBox ), NULL, this );
    m_buttonColorize->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MyFrame1::m_buttonColorizeOnButtonClick ), NULL, this );
    m_checkBoxColorize->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( MyFrame1::m_checkBoxColorizeOnCheckBox ), NULL, this );
    m_sliderFrameAveragerThreshold->Disconnect( wxEVT_SCROLL_TOP, wxScrollEventHandler( MyFrame1::m_sliderFrameAveragerThresholdOnScroll ), NULL, this );
    m_sliderFrameAveragerThreshold->Disconnect( wxEVT_SCROLL_BOTTOM, wxScrollEventHandler( MyFrame1::m_sliderFrameAveragerThresholdOnScroll ), NULL, this );
    m_sliderFrameAveragerThreshold->Disconnect( wxEVT_SCROLL_LINEUP, wxScrollEventHandler( MyFrame1::m_sliderFrameAveragerThresholdOnScroll ), NULL, this );
    m_sliderFrameAveragerThreshold->Disconnect( wxEVT_SCROLL_LINEDOWN, wxScrollEventHandler( MyFrame1::m_sliderFrameAveragerThresholdOnScroll ), NULL, this );
    m_sliderFrameAveragerThreshold->Disconnect( wxEVT_SCROLL_PAGEUP, wxScrollEventHandler( MyFrame1::m_sliderFrameAveragerThresholdOnScroll ), NULL, this );
    m_sliderFrameAveragerThreshold->Disconnect( wxEVT_SCROLL_PAGEDOWN, wxScrollEventHandler( MyFrame1::m_sliderFrameAveragerThresholdOnScroll ), NULL, this );
    m_sliderFrameAveragerThreshold->Disconnect( wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler( MyFrame1::m_sliderFrameAveragerThresholdOnScroll ), NULL, this );
    m_sliderFrameAveragerThreshold->Disconnect( wxEVT_SCROLL_THUMBRELEASE, wxScrollEventHandler( MyFrame1::m_sliderFrameAveragerThresholdOnScroll ), NULL, this );
    m_sliderFrameAveragerThreshold->Disconnect( wxEVT_SCROLL_CHANGED, wxScrollEventHandler( MyFrame1::m_sliderFrameAveragerThresholdOnScroll ), NULL, this );
    m_buttonSample->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MyFrame1::m_buttonSampleOnButtonClick ), NULL, this );
    m_buttonGaussian->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MyFrame1::m_buttonGaussianOnButtonClick ), NULL, this );
    m_buttonSharpen->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MyFrame1::m_buttonSharpenOnButtonClick ), NULL, this );
    m_buttonUnsharpMask->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MyFrame1::m_buttonUnsharpMaskOnButtonClick ), NULL, this );
    m_buttonStabLock->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MyFrame1::m_buttonStabLockOnButtonClick ), NULL, this );
    m_buttonStabLetGo->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MyFrame1::m_buttonStabLetGoOnButtonClick ), NULL, this );
    m_radioBtnNoZoom->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( MyFrame1::m_radioBtnNoZoomOnRadioButton ), NULL, this );
    m_radioBtn2xZoom->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( MyFrame1::m_radioBtn2xZoomOnRadioButton ), NULL, this );
    radioBtn4xZoom->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( MyFrame1::radioBtn4xZoomOnRadioButton ), NULL, this );
    radioBtn8xZoom->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( MyFrame1::radioBtn8xZoomOnRadioButton ), NULL, this );
    m_sliderEzoomVerticalOffset->Disconnect( wxEVT_SCROLL_TOP, wxScrollEventHandler( MyFrame1::m_sliderEzoomVerticalOffsetOnScroll ), NULL, this );
    m_sliderEzoomVerticalOffset->Disconnect( wxEVT_SCROLL_BOTTOM, wxScrollEventHandler( MyFrame1::m_sliderEzoomVerticalOffsetOnScroll ), NULL, this );
    m_sliderEzoomVerticalOffset->Disconnect( wxEVT_SCROLL_LINEUP, wxScrollEventHandler( MyFrame1::m_sliderEzoomVerticalOffsetOnScroll ), NULL, this );
    m_sliderEzoomVerticalOffset->Disconnect( wxEVT_SCROLL_LINEDOWN, wxScrollEventHandler( MyFrame1::m_sliderEzoomVerticalOffsetOnScroll ), NULL, this );
    m_sliderEzoomVerticalOffset->Disconnect( wxEVT_SCROLL_PAGEUP, wxScrollEventHandler( MyFrame1::m_sliderEzoomVerticalOffsetOnScroll ), NULL, this );
    m_sliderEzoomVerticalOffset->Disconnect( wxEVT_SCROLL_PAGEDOWN, wxScrollEventHandler( MyFrame1::m_sliderEzoomVerticalOffsetOnScroll ), NULL, this );
    m_sliderEzoomVerticalOffset->Disconnect( wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler( MyFrame1::m_sliderEzoomVerticalOffsetOnScroll ), NULL, this );
    m_sliderEzoomVerticalOffset->Disconnect( wxEVT_SCROLL_THUMBRELEASE, wxScrollEventHandler( MyFrame1::m_sliderEzoomVerticalOffsetOnScroll ), NULL, this );
    m_sliderEzoomVerticalOffset->Disconnect( wxEVT_SCROLL_CHANGED, wxScrollEventHandler( MyFrame1::m_sliderEzoomVerticalOffsetOnScroll ), NULL, this );
    m_sliderEzoomHorisontalOffset->Disconnect( wxEVT_SCROLL_TOP, wxScrollEventHandler( MyFrame1::m_sliderEzoomHorisontalOffsetOnScroll ), NULL, this );
    m_sliderEzoomHorisontalOffset->Disconnect( wxEVT_SCROLL_BOTTOM, wxScrollEventHandler( MyFrame1::m_sliderEzoomHorisontalOffsetOnScroll ), NULL, this );
    m_sliderEzoomHorisontalOffset->Disconnect( wxEVT_SCROLL_LINEUP, wxScrollEventHandler( MyFrame1::m_sliderEzoomHorisontalOffsetOnScroll ), NULL, this );
    m_sliderEzoomHorisontalOffset->Disconnect( wxEVT_SCROLL_LINEDOWN, wxScrollEventHandler( MyFrame1::m_sliderEzoomHorisontalOffsetOnScroll ), NULL, this );
    m_sliderEzoomHorisontalOffset->Disconnect( wxEVT_SCROLL_PAGEUP, wxScrollEventHandler( MyFrame1::m_sliderEzoomHorisontalOffsetOnScroll ), NULL, this );
    m_sliderEzoomHorisontalOffset->Disconnect( wxEVT_SCROLL_PAGEDOWN, wxScrollEventHandler( MyFrame1::m_sliderEzoomHorisontalOffsetOnScroll ), NULL, this );
    m_sliderEzoomHorisontalOffset->Disconnect( wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler( MyFrame1::m_sliderEzoomHorisontalOffsetOnScroll ), NULL, this );
    m_sliderEzoomHorisontalOffset->Disconnect( wxEVT_SCROLL_THUMBRELEASE, wxScrollEventHandler( MyFrame1::m_sliderEzoomHorisontalOffsetOnScroll ), NULL, this );
    m_sliderEzoomHorisontalOffset->Disconnect( wxEVT_SCROLL_CHANGED, wxScrollEventHandler( MyFrame1::m_sliderEzoomHorisontalOffsetOnScroll ), NULL, this );
    /* -------------- Generated code (wxFormBuilder) ----------------------------------------------------------------*/
}

// event handlers
void MyFrame1::OnQueueTimer(wxTimerEvent& event)
{
    FromTiDspThread tiDspMsg;
    if(!(queues->fromTiDspToGui.empty()))
    {
        queues->fromTiDspToGui.pop(tiDspMsg);
        m_staticTextPipeline->SetLabel(wxString::Format(wxT("%i %s"), tiDspMsg.info.pipeLineFrameRate, " Hz"));
    }

    FromTiCameraThread tiCameraMsg;
    if (!(queues->fromTiCameraToGui.empty()))
    {
        queues->fromTiCameraToGui.pop(tiCameraMsg);
        m_staticTextFramerate->SetLabel(wxString::Format(wxT("%i %s"), tiCameraMsg.info.frameRate, " Hz"));
        m_staticTextHorisontalPixels->SetLabel(wxString::Format(wxT("%i"), tiCameraMsg.info.horisontalPixels));
        m_staticTextVerticalPixels->SetLabel(wxString::Format(wxT("%i"), tiCameraMsg.info.verticalPixels));
        m_staticTextColourSpace->SetLabel(wxString::Format(wxT("%i : %i"), tiCameraMsg.info.colourSpace, tiCameraMsg.info.bitDepth));
    }
    boost::this_thread::yield();
}

void MyFrame1::OnQuit(wxCommandEvent& WXUNUSED(event))
{
    // true is to force the frame to close
    exit(0);
}

void MyFrame1::OnAbout(wxCommandEvent& WXUNUSED(event))
{
    wxMessageBox(wxString::Format
                 (
                    "Welcome to %s!\n"
                    "\n"
                    "This is the minimal wxWidgets sample\n"
                    "running under %s.",
                    wxVERSION_STRING,
                    wxGetOsDescription()
                 ),
                 "About wxWidgets minimal sample",
                 wxOK | wxICON_INFORMATION,
                 this);
}

void MyFrame1::m_buttonRawOnButtonClick( wxCommandEvent& event )
{
    tiDspParams.outputSelect = OutputSelect::Raw;
    queues->fromGuiToTiDsp.push(ToTiDspThread{
            .reason = ToTiDspReason::OutputSelectChange,
            .params = tiDspParams
    });
}

void MyFrame1::m_buttonGrayScaleOnButtonClick( wxCommandEvent& event )
{
    tiDspParams.outputSelect = OutputSelect::GrayScale;
    queues->fromGuiToTiDsp.push(ToTiDspThread{
            .reason = ToTiDspReason::OutputSelectChange,
            .params = tiDspParams
    });
}

void MyFrame1::m_checkBoxGrayScaleOnCheckBox( wxCommandEvent& event )
{

}

void MyFrame1::m_buttonNonUOnButtonClick( wxCommandEvent& event )
{
    tiDspParams.outputSelect = OutputSelect::NonUniformity;
    queues->fromGuiToTiDsp.push(ToTiDspThread{
            .reason = ToTiDspReason::OutputSelectChange,
            .params = tiDspParams
    });
}

void MyFrame1::m_checkBoxNonUniformityOnCheckBox( wxCommandEvent& event )
{

}

void MyFrame1::m_buttonFrameAveragerOnButtonClick( wxCommandEvent& event )
{
    tiDspParams.outputSelect = OutputSelect::FrameAverage;
    queues->fromGuiToTiDsp.push(ToTiDspThread{
            .reason = ToTiDspReason::OutputSelectChange,
            .params = tiDspParams
    });
}

void MyFrame1::m_checkBoxFrameAveragerOnCheckBox( wxCommandEvent& event )
{
    if (event.IsChecked())
    {
        tiDspParams.frameAverageOn = true;
    }
    else
    {
        tiDspParams.frameAverageOn = false;
    }
    queues->fromGuiToTiDsp.push(ToTiDspThread{
            .reason = ToTiDspReason::PipelineStageActiveChange,
            .params = tiDspParams
    });
}

void MyFrame1::m_buttonNucOnButtonClick( wxCommandEvent& event )
{
    tiDspParams.outputSelect = OutputSelect::Nuc;
    queues->fromGuiToTiDsp.push(ToTiDspThread{
            .reason = ToTiDspReason::OutputSelectChange,
            .params = tiDspParams
    });
}

void MyFrame1::m_checkBoxNucOnCheckBox( wxCommandEvent& event )
{
    if (event.IsChecked())
    {
        tiDspParams.nucOn = true;
    }
    else
    {
        tiDspParams.nucOn = false;
    }
    queues->fromGuiToTiDsp.push(ToTiDspThread{
            .reason = ToTiDspReason::NucChange,
            .params = tiDspParams
    });
}

void MyFrame1::m_buttonTFilterOnButtonClick( wxCommandEvent& event )
{
    tiDspParams.outputSelect = OutputSelect::TemporalFilter;
    queues->fromGuiToTiDsp.push(ToTiDspThread{
            .reason = ToTiDspReason::OutputSelectChange,
            .params = tiDspParams
    });
}

void MyFrame1::m_checkBoxTFilterOnCheckBox( wxCommandEvent& event )
{
    if (event.IsChecked())
    {
        tiDspParams.temporalFilterOn = true;
    }
    else
    {
        tiDspParams.temporalFilterOn = false;
    }
    queues->fromGuiToTiDsp.push(ToTiDspThread{
            .reason = ToTiDspReason::PipelineStageActiveChange,
            .params = tiDspParams
    });
}

void MyFrame1::m_buttonSFilterOnButtonClick( wxCommandEvent& event )
{
    tiDspParams.outputSelect = OutputSelect::SpatialFilter;
    queues->fromGuiToTiDsp.push(ToTiDspThread{
            .reason = ToTiDspReason::OutputSelectChange,
            .params = tiDspParams
    });
}

void MyFrame1::m_checkBoxSFilterOnCheckBox( wxCommandEvent& event )
{
    if (event.IsChecked())
    {
        tiDspParams.spatialFilterOn = true;
    }
    else
    {
        tiDspParams.spatialFilterOn = false;
    }
    queues->fromGuiToTiDsp.push(ToTiDspThread{
            .reason = ToTiDspReason::PipelineStageActiveChange,
            .params = tiDspParams
    });
}

void MyFrame1::m_buttonEdgeEnhanceOnButtonClick( wxCommandEvent& event )
{
    tiDspParams.outputSelect = OutputSelect::EdgeEnhance;
    queues->fromGuiToTiDsp.push(ToTiDspThread{
            .reason = ToTiDspReason::OutputSelectChange,
            .params = tiDspParams
    });
}

void MyFrame1::m_checkBoxEdgeEnhanceOnCheckBox( wxCommandEvent& event )
{
	static EdgeEnhanceType previousType = EdgeEnhanceType::Gaussian;

	if (event.IsChecked())
	{
        tiDspParams.edgeEnhanceOn = true;
	}
	else
	{
		tiDspParams.edgeEnhanceOn = false;
	}
    queues->fromGuiToTiDsp.push(ToTiDspThread{
            .reason = ToTiDspReason::PipelineStageActiveChange,
            .params = tiDspParams
    });
}

void MyFrame1::m_buttonStabOnButtonClick( wxCommandEvent& event )
{
    tiDspParams.outputSelect = OutputSelect::Stab;
    queues->fromGuiToTiDsp.push(ToTiDspThread{
            .reason = ToTiDspReason::OutputSelectChange,
            .params = tiDspParams
    });
}

void MyFrame1::m_buttonStabLockOnButtonClick(wxCommandEvent &event)
{
    tiDspParams.stabLockOn = true;
    queues->fromGuiToTiDsp.push(ToTiDspThread{
            .reason = ToTiDspReason::StabLock,
            .params = tiDspParams
    });
}

void MyFrame1::m_buttonStabLetGoOnButtonClick(wxCommandEvent &event)
{
    tiDspParams.stabLockOn = false;
    queues->fromGuiToTiDsp.push(ToTiDspThread{
            .reason = ToTiDspReason::StabLock,
            .params = tiDspParams
    });
}

void MyFrame1::m_checkBoxAgcOnCheckBox( wxCommandEvent& event )
{

}

void MyFrame1::m_buttonEzoomOnButtonClick( wxCommandEvent& event )
{
    tiDspParams.outputSelect = OutputSelect::Ezoom;
    queues->fromGuiToTiDsp.push(ToTiDspThread{
            .reason = ToTiDspReason::OutputSelectChange,
            .params = tiDspParams
    });
}

void MyFrame1::m_checkBoxEzoomOnCheckBox( wxCommandEvent& event )
{
    if (event.IsChecked())
    {
        tiDspParams.eZoomOn = true;
    }
    else
    {
        tiDspParams.eZoomOn = false;
    }
    queues->fromGuiToTiDsp.push(ToTiDspThread{
            .reason = ToTiDspReason::PipelineStageActiveChange,
            .params = tiDspParams
    });
}

void MyFrame1::m_buttonStretchOnButtonClick( wxCommandEvent& event )
{
    tiDspParams.outputSelect = OutputSelect::HistogramStretch;
    queues->fromGuiToTiDsp.push(ToTiDspThread{
            .reason = ToTiDspReason::OutputSelectChange,
            .params = tiDspParams
    });
}

void MyFrame1::m_checkBoxStretchOnCheckBox( wxCommandEvent& event )
{
    if (event.IsChecked())
    {
        tiDspParams.histogramStretchOn = true;
    }
    else
    {
        tiDspParams.histogramStretchOn = false;
    }
    queues->fromGuiToTiDsp.push(ToTiDspThread{
            .reason = ToTiDspReason::PipelineStageActiveChange,
            .params = tiDspParams
    });
}

void MyFrame1::m_buttonColorizeOnButtonClick( wxCommandEvent& event )
{
    tiDspParams.outputSelect = OutputSelect::Colorize;
    queues->fromGuiToTiDsp.push(ToTiDspThread{
            .reason = ToTiDspReason::OutputSelectChange,
            .params = tiDspParams
    });
}

void MyFrame1::m_checkBoxColorizeOnCheckBox( wxCommandEvent& event )
{

}

void MyFrame1::m_sliderFrameAveragerThresholdOnScroll( wxScrollEvent& event )
{
    tiDspParams.frameAveragerThreshold = event.GetPosition();
    queues->fromGuiToTiDsp.push(ToTiDspThread{
            .reason = ToTiDspReason::FrameAveragerChange,
            .params = tiDspParams
    });
}

void MyFrame1::m_buttonGaussianOnButtonClick(wxCommandEvent& event)
{
    tiDspParams.edgeEnhanceType = EdgeEnhanceType::Gaussian;
    m_panelGaussian->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
    m_panelSharpen->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BACKGROUND ) );
    m_panelUnsharpMask->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BACKGROUND ) );
    queues->fromGuiToTiDsp.push(ToTiDspThread{
            .reason = ToTiDspReason::EdgeEnhanceChange,
            .params = tiDspParams
    });
}

void MyFrame1::m_buttonSharpenOnButtonClick(wxCommandEvent& event)
{
    tiDspParams.edgeEnhanceType = EdgeEnhanceType::Sharpen;
    m_panelGaussian->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BACKGROUND ) );
    m_panelSharpen->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
    m_panelUnsharpMask->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BACKGROUND ) );
    queues->fromGuiToTiDsp.push(ToTiDspThread{
            .reason = ToTiDspReason::EdgeEnhanceChange,
            .params = tiDspParams
    });
}

void MyFrame1::m_buttonUnsharpMaskOnButtonClick(wxCommandEvent& event)
{
    tiDspParams.edgeEnhanceType = EdgeEnhanceType::Unsharp_mask;
    m_panelGaussian->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BACKGROUND ) );
    m_panelSharpen->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BACKGROUND ) );
    m_panelUnsharpMask->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
    queues->fromGuiToTiDsp.push(ToTiDspThread{
            .reason = ToTiDspReason::EdgeEnhanceChange,
            .params = tiDspParams
    });
}

void MyFrame1::m_radioBtnNoZoomOnRadioButton( wxCommandEvent& event )
{
    tiDspParams.ezoom = Ezoom::NoZoom;
    queues->fromGuiToTiDsp.push(ToTiDspThread{
            .reason = ToTiDspReason::EzoomChange,
            .params = tiDspParams
    });
}

void MyFrame1::m_radioBtn2xZoomOnRadioButton( wxCommandEvent& event )
{
    tiDspParams.ezoom = Ezoom::x2;
    queues->fromGuiToTiDsp.push(ToTiDspThread{
            .reason = ToTiDspReason::EzoomChange,
            .params = tiDspParams
    });
}

void MyFrame1::radioBtn4xZoomOnRadioButton( wxCommandEvent& event )
{
    tiDspParams.ezoom = Ezoom::x4;
    queues->fromGuiToTiDsp.push(ToTiDspThread{
            .reason = ToTiDspReason::EzoomChange,
            .params = tiDspParams
    });
}

void MyFrame1::radioBtn8xZoomOnRadioButton( wxCommandEvent& event )
{
    tiDspParams.ezoom = Ezoom::x8;
    queues->fromGuiToTiDsp.push(ToTiDspThread{
            .reason = ToTiDspReason::EzoomChange,
            .params = tiDspParams
    });
}

void MyFrame1::m_sliderEzoomVerticalOffsetOnScroll( wxScrollEvent& event )
{
    tiDspParams.verticalOffset = event.GetPosition();
    queues->fromGuiToTiDsp.push(ToTiDspThread{
            .reason = ToTiDspReason::EzoomChange,
            .params = tiDspParams
    });
}

void MyFrame1::m_sliderEzoomHorisontalOffsetOnScroll( wxScrollEvent& event )
{
    tiDspParams.horisontalOffset = event.GetPosition();
    queues->fromGuiToTiDsp.push(ToTiDspThread{
            .reason = ToTiDspReason::EzoomChange,
            .params = tiDspParams
    });
}

void MyFrame1::m_buttonSampleOnButtonClick(wxCommandEvent &event)
{
    queues->fromGuiToTiDsp.push(ToTiDspThread{
            .reason = ToTiDspReason::NucSample,
            .params = tiDspParams
    });
}

void MyFrame1::m_checkBox10OnCheckBox(wxCommandEvent &event) {

}

max_stars_repo_name: kabousvlieg/NUC-with-image-stab

max_issues_repo_name: kabousvlieg/NUC-with-image-stab

max_forks_repo_name: kabousvlieg/NUC-with-image-stab


text:
//==================================================================================================
/*!

  Copyright 2015 NumScale SAS

  Distributed under the Boost Software License, Version 1.0.
  (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
*/
//==================================================================================================
#include <boost/simd/constant/constant.hpp>
#include <simd_test.hpp>

STF_CASE_TPL( "Check constant behavior for signed integral values", STF_SIGNED_INTEGRAL_TYPES)
{
  using boost::simd::Constant;
  STF_EXPR_IS( (Constant<T,42>()  ) , T      );
  STF_EQUAL  ( (Constant<T,42>()  ) , T(42)  );

  STF_EXPR_IS( (Constant<T,-69>()  ) , T      );
  STF_EQUAL  ( (Constant<T,-69>()  ) , T(-69) );

  STF_EXPR_IS( (Constant<T,~0>()  ) , T      );
  STF_EQUAL  ( (Constant<T,~0>()  ) , T(~0) );
}

STF_CASE_TPL( "Check constant behavior for unsigned integral values", STF_UNSIGNED_INTEGRAL_TYPES)
{
  using boost::simd::Constant;

  STF_EXPR_IS( (Constant<T,42>()  ) , T      );
  STF_EQUAL  ( (Constant<T,42>()  ) , T(42)  );

  STF_EXPR_IS( (Constant<T,T(~0)>()  ) , T      );
  STF_EQUAL  ( (Constant<T,T(~0)>()  ) , T(~0) );
}

STF_CASE( "Check constant behavior for double values")
{
  using boost::simd::Constant;

  STF_EXPR_IS   ( (Constant<double,0x402ABD70A3D70A3DULL>()   ) , double  );
  STF_IEEE_EQUAL( (Constant<double,0x402ABD70A3D70A3DULL>()   ) , 13.37   );
  STF_IEEE_EQUAL( (Constant<double,13817391734754107382ULL>() ) , -0.13466110473359521604 );
}

STF_CASE( "Check constant behavior for single values")
{
  using boost::simd::Constant;

  STF_EXPR_IS   ( (Constant<float,0x4155EB85UL>() ) , float   );
  STF_IEEE_EQUAL( (Constant<float,0x4155EB85UL>() ) , 13.37f  );
}

ext: cpp


text:
//
// Created by Erik Kvam Måland on 02/06/2021.
//

#include <boost/test/unit_test.hpp>

#include "models/models.h"

#include "tag_hierarchy/tag_hierarchy.h"
#include "tag_hierarchy/unittests/fixture.h"

// Used for verifying that the values of field for severity level of nodes
// is propagated to through the hierarchy as expected.
void verify_correct_node_severity_level(int parent_severity_level,
                                        const std::string& parent_id,
                                        const std::vector<NodeType>& command) {
    // We verify the severity level by obtaining the severity levels of all children,
    // and checking that the severity level of the parent is the maximum of these.

    // Make a query containing the parent ID, and insert the command.
    auto children_query = std::vector<NodeType>(
            {{
                     {std::string("parentId"), parent_id}
             }}
    );

    children_query[0].insert(command[0].begin(), command[0].end());

    auto children_query_response = TagHierarchy::Handle(children_query);

    // Did the query return any child nodes?
    if (children_query_response.empty()) {
        // No, then we return. This is the stop condition of the recursion.
        return;
    }

    int expected_parent_severity_level = -1;
    for (auto const& node: children_query_response) {
        int child_severity_level = -1;
        if (node.count("severity") > 0) {
            child_severity_level = boost::get<int>(node.find("severity")->second);
        }
        expected_parent_severity_level = std::max(expected_parent_severity_level, child_severity_level);

        // Verify the same for all the children.
        std::string node_id = boost::get<std::string>(node.find("id")->second);
        verify_correct_node_severity_level(
                child_severity_level,
                node_id,
                command
        );
    }

    BOOST_TEST(expected_parent_severity_level == parent_severity_level);
}

void verify_correct_severity_level_with_filter(const std::vector<NodeType>& filter) {

    // Update the tag hierarchy with nodes that have severity level set.
    auto updateQuery = std::vector<NodeType>(
            {
                    {{std::string("command"), std::string("update")},
                    },
                    {
                        {std::string("name"),std::string("Level1-2->Level2-3->Level3-1->L4Model-1-input0-element-1")},
                        {std::string("description"),std::string("Description")},
                        {std::string("id"),std::string("37eb955a-5866-4757-b5b1-497497c74325")},
                        {std::string("parent_id"),std::string("a725ab7c-c4c3-47e4-81af-526bf50b8e05")},
                        {std::string("levelno"), 4 },
                        {std::string("is_modelelement"), true },
                        {std::string("elementtype"),std::string("Database")},
                        {std::string("type"),std::string("modelElement")},
                        {std::string("isrunningtag"), false },
                        {std::string("kpigroup"),std::string("Temporib")},
                        {std::string("kpigroup_id"),std::string("f9479292-b852-401f-9e34-33cc2a7decb6")},
                        {std::string("issuppressed"), false },
                        {std::string("severity"), 1 }
                    },
                    {
                        {std::string("name"),std::string("Level1-2->Level2-3->Level3-2->L4Model-1-input1-element-1")},
                        {std::string("description"),std::string("Description")},
                        {std::string("id"),std::string("51f71096-62b5-4e08-a250-d7214feef245")},
                        {std::string("parent_id"),std::string("4a265338-a12b-4736-97ad-88e4cc3308ed")},
                        {std::string("levelno"), 4 },
                        {std::string("is_modelelement"), true },
                        {std::string("elementtype"),std::string("Database")},
                        {std::string("type"),std::string("modelElement")},
                        {std::string("isrunningtag"), false },
                        {std::string("kpigroup"),std::string("Temporib")},
                        {std::string("kpigroup_id"),std::string("f9479292-b852-401f-9e34-33cc2a7decb6")},
                        {std::string("issuppressed"), true },
                        {std::string("severity"), 2 }
                    },
                    {
                        {std::string("name"),std::string("Level1-2->Level2-3->Level3-3->L4Model-1-output0-element-1")},
                        {std::string("description"),std::string("Description")},
                        {std::string("id"),std::string("8639784c-7bd3-488f-9a17-5c6f0dbaec32")},
                        {std::string("parent_id"),std::string("1ee52fee-07bc-4bdb-88ac-711708c2f5fc")},
                        {std::string("levelno"), 4 },
                        {std::string("is_modelelement"), true },
                        {std::string("elementtype"),std::string("Calculated")},
                        {std::string("type"),std::string("modelElement")},
                        {std::string("isrunningtag"), false },
                        {std::string("kpigroup"),std::string("Temporib")},
                        {std::string("kpigroup_id"),std::string("f9479292-b852-401f-9e34-33cc2a7decb6")},
                        {std::string("issuppressed"), true },
                        {std::string("severity"), 3 }
                    },
            }
    );

    TagHierarchy::Handle(updateQuery);

    // Construct the query for the top nodes.
    auto query = std::vector<NodeType>(
            {{
                     {std::string("command"), std::string("nodes")},
                     {std::string("parentId"), pybind11::none()}
             }}
    );
    for (const auto& filter_entry : filter) {
        query[0].insert(filter_entry.begin(), filter_entry.end());
    }

    auto response = TagHierarchy::Handle(query);

    // Construct the command to pass on when querying for child nodes.
    auto child_nodes_command = std::vector<NodeType>(
            {{
                     {std::string("command"), std::string("nodes")}
             }}
    );

    // Insert filter into the command.
    for (const auto& filter_entry : filter) {
        child_nodes_command[0].insert(filter_entry.begin(), filter_entry.end());
    }

    for (const auto& props : response) {
        std::string node_id = boost::get<std::string>(props.find("id")->second);
        int severity_level = -1;
        if (props.count("severity") > 0) {
            severity_level = boost::get<int>(props.find("severity")->second);
        }
        verify_correct_node_severity_level(
                severity_level,
                node_id,
                child_nodes_command
        );
    }
}

BOOST_FIXTURE_TEST_SUITE( FieldSeverityTest, Fixture );

    // Tests that the field for severity is propagated from
    // model element nodes all the way up to the root node.
    BOOST_AUTO_TEST_CASE( test_severity_propagation )
    {
        verify_correct_severity_level_with_filter(std::vector<NodeType>());
    }

    // Tests that the field for severity is propagated from model element nodes
    // all the way up to the root node, when the query contains a model owner filter.
    BOOST_AUTO_TEST_CASE( test_severity_propagation_with_model_owner_filter )
    {
        verify_correct_severity_level_with_filter(std::vector<NodeType>(
                {{
                    {
                        std::string("modelownerfilter"), std::vector<std::string>{"3627b2f8-050b-43ec-8d3f-cadfb652880b"}
                    }
                }}
                ));
    }

    // Tests that the field for severity is propagated from model element nodes
    // all the way up to the root node, when the query contains a model class filter.
    BOOST_AUTO_TEST_CASE( test_severity_propagation_with_model_class_filter )
    {
        verify_correct_severity_level_with_filter(std::vector<NodeType>({{
                    {
                    std::string("modelclassfilter"), std::vector<std::string>{"56ce0ce9-596e-43d2-8e6c-4ece3e81b20a"}
                    }
            }}
            ));
    }

BOOST_AUTO_TEST_SUITE_END()

max_stars_repo_name: equinor/ioc-hierarchy-service

max_issues_repo_name: equinor/ioc-hierarchy-service

max_forks_repo_name: equinor/ioc-hierarchy-service


text:
// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
// de Barcelona (UAB).
//
// This work is licensed under the terms of the MIT license.
// For a copy, see <https://opensource.org/licenses/MIT>.

#include <boost/python.hpp>

#include "Actor.cpp"
#include "Blueprint.cpp"
#include "Client.cpp"
#include "Control.cpp"
#include "Exception.cpp"
#include "Transform.cpp"
#include "World.cpp"

BOOST_PYTHON_MODULE(libcarla) {
  using namespace boost::python;
  PyEval_InitThreads();
  scope().attr("__path__") = "libcarla";
  export_transform();
  export_control();
  export_blueprint();
  export_actor();
  export_world();
  export_client();
  export_exception();
}

max_stars_repo_name: edufford/carla

max_issues_repo_name: edufford/carla

max_forks_repo_name: edufford/carla


text:
/**
 * \file dcs/math/policies/policy.hpp
 *
 * \brief Mathematical policy.
 *
 * \author Marco Guazzone (marco.guazzone@gmail.com)
 *
 * <hr/>
 *
 * Copyright 2009 Marco Guazzone (marco.guazzone@gmail.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef DCS_MATH_POLICIES_POLICY_HPP
#define DCS_MATH_POLICIES_POLICY_HPP

#include <boost/math/policies/policy.hpp>

namespace dcs { namespace math { namespace policies {

using ::boost::math::policies::policy;

}}} // Namespace dcs::math::policies

#endif // DCS_MATH_POLICIES_POLICY_HPP

ext: hpp

max_stars_repo_name: sguazt/dcsxx-commons

max_issues_repo_name: sguazt/dcsxx-commons

max_forks_repo_name: sguazt/dcsxx-commons


text:
#ifndef HMM_H
#define HMM_H

#include <armadillo>
#include <HSMM.hpp>

namespace hsmm {

    class HMM : public HSMM {
        public:
            HMM(std::shared_ptr<AbstractEmission> emission,
                    arma::mat transition, arma::vec pi);
    };

};

#endif

max_stars_repo_name: DiegoAE/BOSD

max_issues_repo_name: DiegoAE/BOSD

max_forks_repo_name: DiegoAE/BOSD


text:
// __BEGIN_LICENSE__
//  Copyright (c) 2009-2013, United States Government as represented by the
//  Administrator of the National Aeronautics and Space Administration. All
//  rights reserved.
//
//  The NGT platform is licensed under the Apache License, Version 2.0 (the
//  "License"); you may not use this file except in compliance with the
//  License. You may obtain a copy of the License at
//  http://www.apache.org/licenses/LICENSE-2.0
//
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS,
//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//  See the License for the specific language governing permissions and
//  limitations under the License.
// __END_LICENSE__

/// \file dem_geoid.cc
///

#include <vw/FileIO.h>
#include <vw/Image.h>
#include <vw/Cartography.h>
#include <vw/Math.h>
#include <asp/Core/Macros.h>
#include <asp/Core/Common.h>

#include <boost/filesystem.hpp>
namespace po = boost::program_options;
namespace fs = boost::filesystem;

using std::endl;
using std::string;
using namespace vw;
using namespace vw::cartography;

template <class ImageT>
class DemGeoidView : public ImageViewBase<DemGeoidView<ImageT> >
{
  ImageT m_img;
  GeoReference const& m_georef;
  ImageViewRef<PixelMask<double> > const& m_geoid;
  GeoReference const& m_geoid_georef;
  bool m_reverse_adjustment;
  double m_correction;
  double m_nodata_val;

public:

  typedef double pixel_type;
  typedef double result_type;
  typedef ProceduralPixelAccessor<DemGeoidView> pixel_accessor;

  DemGeoidView(ImageT const& img, GeoReference const& georef,
               ImageViewRef<PixelMask<double> > const& geoid,
               GeoReference const& geoid_georef, bool reverse_adjustment, double correction, double nodata_val):
    m_img(img), m_georef(georef),
    m_geoid(geoid), m_geoid_georef(geoid_georef),
    m_reverse_adjustment(reverse_adjustment),
    m_correction(correction),
    m_nodata_val(nodata_val){}

  inline int32 cols() const { return m_img.cols(); }
  inline int32 rows() const { return m_img.rows(); }
  inline int32 planes() const { return 1; }

  inline pixel_accessor origin() const { return pixel_accessor(*this); }

  inline result_type operator()( size_t col, size_t row, size_t p=0 ) const {

    if ( m_img(col, row, p) == m_nodata_val ) return m_nodata_val;

    Vector2 lonlat = m_georef.pixel_to_lonlat(Vector2(col, row));

    // For testing (see the link to the reference web form belows).
    //lonlat[0] = -121;   lonlat[1] = 37;   // mainland US
    //lonlat[0] = -152;   lonlat[1] = 66;   // Alaska
    //lonlat[0] = -155.5; lonlat[1] = 19.5; // Hawaii

    // Need to carefully wrap lonlat to the [0, 360) x [-90, 90) box.
    // Note that lon = 25, lat = 91 is the same as lon = 180 + 25, lat = 89
    // as we go through the North pole and show up on the other side.
    while ( std::abs(lonlat[1]) > 90.0 ){
      if ( lonlat[1] > 90.0 ){
        lonlat[1] = 180.0 - lonlat[1];
        lonlat[0] += 180.0;
      }
      if ( lonlat[1] < -90.0 ){
        lonlat[1] = -180.0 - lonlat[1];
        lonlat[0] += 180.0;
      }
    }
    while( lonlat[0] <   0.0  ) lonlat[0] += 360.0;
    while( lonlat[0] >= 360.0 ) lonlat[0] -= 360.0;

    result_type       geoid_height           = 0.0;
    Vector2           pix                    = m_geoid_georef.lonlat_to_pixel(lonlat);
    PixelMask<double> interp_val             = m_geoid(pix[0], pix[1]);
    if (!is_valid(interp_val)) return m_nodata_val;
    geoid_height                             = interp_val.child() + m_correction;
    result_type       height_above_ellipsoid = m_img(col, row, p);
    double            direction              = m_reverse_adjustment?-1:1;
    // See the note in the main program about the formula below
    result_type height_above_geoid           = height_above_ellipsoid - direction*geoid_height;

    return height_above_geoid;
  }

  /// \cond INTERNAL
  typedef DemGeoidView<typename ImageT::prerasterize_type> prerasterize_type;
  inline prerasterize_type prerasterize( BBox2i const& bbox ) const {
    return prerasterize_type( m_img.prerasterize(bbox), m_georef,
                              m_geoid, m_geoid_georef, m_reverse_adjustment, m_correction, m_nodata_val );
  }
  template <class DestT> inline void rasterize( DestT const& dest, BBox2i const& bbox ) const {
    vw::rasterize( prerasterize(bbox), dest, bbox );
  }
  /// \endcond
};

template <class ImageT>
DemGeoidView<ImageT>
dem_geoid( ImageViewBase<ImageT> const& img, GeoReference const& georef,
           ImageViewRef<PixelMask<double> > const& geoid,
           GeoReference const& geoid_georef, bool reverse_adjustment, double correction, double nodata_val) {
  return DemGeoidView<ImageT>( img.impl(), georef, geoid, geoid_georef,
                               reverse_adjustment, correction, nodata_val );
}

struct Options : asp::BaseOptions {
  string dem_name, out_prefix;
  double nodata_value;
  bool use_double;
  bool reverse_adjustment;
};

std::string get_geoid_full_path(std::string geoid_file){

  // We try two ways of finding the path to the geoid file.

  // 1. Using the compile flag, from the GEOID_PATH macro.
#define STR_EXPAND(tok) #tok
#define STR_QUOTE(tok) STR_EXPAND(tok)
  std::string full_path = std::string(STR_QUOTE(GEOID_PATH)) + "/" + geoid_file;
  if (fs::exists(full_path)) return full_path;

  // 2. Using the ASP_DATA path.
  char * asp_data = getenv("ASP_DATA");
  if (asp_data == NULL){
    vw_throw( ArgumentErr() << "The environmental variable ASP_DATA was not set. "
              << "It should point to the 'share' directory of your ASP distribution.\n" );
  }

  // Must keep this version synchronized with Packages.py!
  full_path = std::string(asp_data) + "/geoids-1.1/" + geoid_file;
  if (!fs::exists(full_path)){
    vw_throw( ArgumentErr() << "Could not find geoid: " << full_path << ".\n"
              << "The value of environmental variable ASP_DATA is '" << asp_data << "'.\n");
  }

  return full_path;
}

void handle_arguments( int argc, char *argv[], Options& opt ){

  po::options_description general_options("");
  general_options.add_options()
    ("nodata_value", po::value(&opt.nodata_value)->default_value(-32768),
     "The value of no-data pixels, unless specified in the DEM.")
    ("output-prefix,o", po::value(&opt.out_prefix), "Specify the output prefix.")
    ("double", po::bool_switch(&opt.use_double)->default_value(false)->implicit_value(true),
     "Output using double precision (64 bit) instead of float (32 bit).")
    ("reverse-adjustment",
     po::bool_switch(&opt.reverse_adjustment)->default_value(false)->implicit_value(true),
     "Go from DEM relative to the geoid to DEM relative to the ellipsoid.");

  general_options.add( asp::BaseOptionsDescription(opt) );

  po::options_description positional("");
  positional.add_options()
    ("dem", po::value(&opt.dem_name), "Explicitly specify the DEM.");

  po::positional_options_description positional_desc;
  positional_desc.add("dem", 1);

  std::string usage("[options] <dem>");
  po::variables_map vm =
    asp::check_command_line( argc, argv, opt, general_options, general_options,
                             positional, positional_desc, usage );

  if ( opt.dem_name.empty() )
    vw_throw( ArgumentErr() << "Requires <dem> in order to proceed.\n\n"
              << usage << general_options );

  if ( opt.out_prefix.empty() )
    opt.out_prefix = fs::path(opt.dem_name).stem().string();

  // Create the output directory
  asp::create_out_dir(opt.out_prefix);

  // Turn on logging to file
  asp::log_to_file(argc, argv, "", opt.out_prefix);

}

// Given a DEM, with each height value relative to the datum
// ellipsoid, convert the heights to be relative to the geoid.

// From: http://earth-info.nga.mil/GandG/wgs84/gravitymod/egm96/intpthel.html
// Geoid heights can be used to convert between orthometric
// heights (approximately mean sea level) and ellipsoid heights
// according to the formula:
// h   =   H   +   N
// where,
// h = WGS 84 Ellipsoid height
// H = Orthometric height
// N = EGM96 Geoid height
// Therefore: H = h - N.

// We support three geoids: EGM96, NAVD88 (Earth) and MOLA MEGDR (Mars).
// Online tools for verification:
// EGM96:  http://earth-info.nga.mil/GandG/wgs84/gravitymod/egm96/intpt.html
// NAVD88: http://www.ngs.noaa.gov/cgi-bin/GEOID_STUFF/geoid09_prompt1.prl

// MOLA MEGDR: http://geo.pds.nasa.gov/missions/mgs/megdr.html

// Examples: At lat = 37 and lon = -121 (Basalt Hills, CA), we have
// EGM96  geoid height = -32.69 m
// NAVD88 geoid height = -32.931 m
// At lat = 66 and lon = -152 (Alaska):
// EGM96 geoid height  = 9.51 m
// NAVD88 geoid height = 8.255 m
// At lat = 19.5 and lon = -155.5 (Hawaii)
// NAVD88 geoid height: 27.353
// EGM96 geoid height:  26.58

int main( int argc, char *argv[] ) {

  Options opt;
  try {
    handle_arguments( argc, argv, opt );

    bool reverse_adjustment = opt.reverse_adjustment;

    // Read the DEM to adjust
    DiskImageResourceGDAL dem_rsrc(opt.dem_name);
    double dem_nodata_val = opt.nodata_value;
    if ( dem_rsrc.has_nodata_read() ) {
      dem_nodata_val = dem_rsrc.nodata_read();
      vw_out() << "\tFound input nodata value for " << opt.dem_name << ": "
               << dem_nodata_val << endl;
    }
    DiskImageView<double> dem_img(dem_rsrc);
    GeoReference dem_georef;
    bool has_georef = read_georeference(dem_georef, dem_rsrc);
    if (!has_georef)
      vw_throw( ArgumentErr() << "Missing georeference for DEM: " << opt.dem_name << "\n" );

    // Find out the datum from the DEM. If we fail, we do an educated guess.
    std::string datum_name = dem_georef.datum().name();
    std::string lname = boost::to_lower_copy(datum_name);
    std::string geoid_file;
    if ( lname == "wgs_1984" || lname == "wgs 1984" || lname == "wgs1984" ||
         lname == "wgs84" || lname == "world geodetic system 1984" ){
      geoid_file = "egm96-5.tif";
    }else if (lname == "north_american_datum_1983"){
      geoid_file = "navd88.tif";
    }else if (lname == "d_mars"){
      geoid_file = "mola_areoid.tif";
    }else if ( std::abs( dem_georef.datum().semi_major_axis() - 6378137.0 ) < 500.0){
      // Guess Earth
      vw_out(WarningMessage) << "Unknown datum: " << datum_name << ". Guessing: WGS_1984.\n";
      geoid_file = "egm96-5.tif";
    }else if ( std::abs( dem_georef.datum().semi_major_axis() - 3396190.0) < 500.0){
      // Guess Mars
      vw_out(WarningMessage) << "Unknown datum: " << datum_name << ". Guessing: D_MARS.\n";
      geoid_file = "mola_areoid.tif";
    }else{
      vw_throw( ArgumentErr() << "Cannot apply geoid adjustment to DEM relative to datum: "
                << datum_name << "\n");
    }
    geoid_file = get_geoid_full_path(geoid_file);
    vw_out() << "Adjusting the DEM using the geoid: " << geoid_file << endl;

    // Read the geoid containing the adjustments. Read it in memory
    // entirely to dramatically speed up the computations.
    double geoid_nodata_val = std::numeric_limits<float>::quiet_NaN();
    DiskImageResourceGDAL geoid_rsrc(geoid_file);
    if ( geoid_rsrc.has_nodata_read() ) {
      geoid_nodata_val = geoid_rsrc.nodata_read();
    }
    ImageView<float> geoid_img = DiskImageView<float>(geoid_rsrc);
    GeoReference geoid_georef;
    read_georeference(geoid_georef, geoid_rsrc);

    // Need to apply an extra correction if the datum radius of the geoid is different
    // than the datum radius of the DEM to correct. We do this only if the datum is
    // a sphere, such on mars, as otherwise a uniform correction won't work.
    double major_correction
      = geoid_georef.datum().semi_major_axis() - dem_georef.datum().semi_major_axis();
    double minor_correction
      = geoid_georef.datum().semi_minor_axis() - dem_georef.datum().semi_minor_axis();
    if (major_correction != 0){
      if (std::abs(1.0 - minor_correction/major_correction) > 1.0e-5){
        vw_throw( ArgumentErr() << "The input DEM and geoid datums are incompatible. "
                  << "Cannot apply geoid adjustment.\n" );
      }
      vw_out(WarningMessage) << "Will compensate for the fact that the input DEM and geoid datums "
                             << "axis lengths differ.\n";
    }

    ImageViewRef<PixelMask<double> > geoid
      = interpolate(create_mask( pixel_cast<double>(geoid_img), geoid_nodata_val ),
                    BicubicInterpolation(), ZeroEdgeExtension());

    ImageViewRef<double> adj_dem = dem_geoid(dem_img, dem_georef, geoid, geoid_georef,
                                             reverse_adjustment, major_correction, dem_nodata_val);

    std::string adj_dem_file = opt.out_prefix + "-adj.tif";
    vw_out() << "Writing adjusted DEM: " << adj_dem_file << std::endl;

    if ( opt.use_double ) {
      // Output as double
      boost::scoped_ptr<DiskImageResourceGDAL> rsrc( asp::build_gdal_rsrc(adj_dem_file,
                                                                          adj_dem, opt ) );
      rsrc->set_nodata_write( dem_nodata_val );
      write_georeference( *rsrc, dem_georef );
      block_write_image( *rsrc, adj_dem,
                         TerminalProgressCallback("asp", "\t--> Applying DEM adjustment: ") );
    }else{
      // Output as float
      ImageViewRef<float> adj_dem_float = channel_cast<float>( adj_dem );
      boost::scoped_ptr<DiskImageResourceGDAL> rsrc( asp::build_gdal_rsrc(adj_dem_file,
                                                                          adj_dem_float, opt ) );
      rsrc->set_nodata_write( dem_nodata_val );
      write_georeference( *rsrc, dem_georef );
      block_write_image( *rsrc, adj_dem_float,
                         TerminalProgressCallback("asp", "\t--> Applying DEM adjustment: ") );
    }

  } ASP_STANDARD_CATCHES;

  return 0;
}

ext: cc


text:
#include <typeinfo>
#include <boost/type_traits/is_same.hpp>
#include <stan/model/indexing/rvalue_return.hpp>
#include <gtest/gtest.h>

using stan::model::cons_index_list;
using stan::model::index_max;
using stan::model::index_min;
using stan::model::index_min_max;
using stan::model::index_multi;
using stan::model::index_omni;
using stan::model::index_uni;
using stan::model::nil_index_list;
using stan::model::rvalue_return;

typedef std::vector<double> doubles;
typedef std::vector<doubles> doubless;

typedef Eigen::MatrixXd mat;
typedef std::vector<mat> mats;
typedef std::vector<mats> matss;

typedef Eigen::VectorXd vec;
typedef std::vector<vec> vecs;
typedef std::vector<vecs> vecss;

typedef Eigen::RowVectorXd rowvec;
typedef std::vector<rowvec> rowvecs;
typedef std::vector<rowvecs> rowvecss;

typedef cons_index_list<index_uni, nil_index_list> uni;
typedef cons_index_list<index_multi, nil_index_list> multi;

typedef cons_index_list<index_uni, uni> uni_uni;
typedef cons_index_list<index_uni, multi> uni_multi;
typedef cons_index_list<index_multi, uni> multi_uni;
typedef cons_index_list<index_multi, multi> multi_multi;

typedef cons_index_list<index_uni, uni_uni> uni_uni_uni;
typedef cons_index_list<index_uni, uni_multi> uni_uni_multi;
typedef cons_index_list<index_uni, multi_uni> uni_multi_uni;
typedef cons_index_list<index_uni, multi_multi> uni_multi_multi;
typedef cons_index_list<index_multi, uni_uni> multi_uni_uni;
typedef cons_index_list<index_multi, uni_multi> multi_uni_multi;
typedef cons_index_list<index_multi, multi_uni> multi_multi_uni;
typedef cons_index_list<index_multi, multi_multi> multi_multi_multi;

template <typename T, typename C, typename I>
void expect_same() {
  EXPECT_TRUE((boost::is_same<T, typename rvalue_return<C, I>::type>::value))
      << "type(T)=" << typeid(T).name() << std::endl
      << "type(C)=" << typeid(C).name() << std::endl
      << "type(I)=" << typeid(I).name() << std::endl
      << "rvalue_return=" << typeid(typename rvalue_return<C, I>::type).name()
      << std::endl
      << std::endl;
}

// EXHAUSTIVE TESTS OF ALL INDEXING UP TO 2nd ORDER

TEST(modelIndexing, rvalueReturnNil) {
  expect_same<double, double, nil_index_list>();
  expect_same<doubles, doubles, nil_index_list>();
  expect_same<doubless, doubless, nil_index_list>();
  expect_same<mat, mat, nil_index_list>();
  expect_same<mats, mats, nil_index_list>();
  expect_same<matss, matss, nil_index_list>();
  expect_same<vec, vec, nil_index_list>();
  expect_same<vecs, vecs, nil_index_list>();
  expect_same<vecss, vecss, nil_index_list>();
  expect_same<rowvec, rowvec, nil_index_list>();
  expect_same<rowvecs, rowvecs, nil_index_list>();
  expect_same<rowvecss, rowvecss, nil_index_list>();
}

TEST(modelIndex, rvalueReturnUni) {
  expect_same<double, doubles, uni>();
  expect_same<doubles, doubless, uni>();
  expect_same<double, vec, uni>();
  expect_same<vec, vecs, uni>();
  expect_same<vecs, vecss, uni>();
  expect_same<double, rowvec, uni>();
  expect_same<rowvec, rowvecs, uni>();
  expect_same<rowvecs, rowvecss, uni>();
  expect_same<rowvec, mat, uni>();
  expect_same<mat, mats, uni>();
  expect_same<mats, matss, uni>();
}

TEST(modelIndex, rvalueReturnMulti) {
  expect_same<doubles, doubles, multi>();
  expect_same<doubless, doubless, multi>();
  expect_same<mats, mats, multi>();
  expect_same<matss, matss, multi>();
  expect_same<vecs, vecs, multi>();
  expect_same<vecss, vecss, multi>();
  expect_same<rowvecs, rowvecs, multi>();
  expect_same<rowvecss, rowvecss, multi>();
}

TEST(modelIndex, rvalueReturnUniUni) {
  expect_same<double, doubless, uni_uni>();
  expect_same<double, vecs, uni_uni>();
  expect_same<vec, vecss, uni_uni>();
  expect_same<double, rowvecs, uni_uni>();
  expect_same<rowvec, rowvecss, uni_uni>();
  expect_same<double, mat, uni_uni>();
  expect_same<rowvec, mats, uni_uni>();
  expect_same<mat, matss, uni_uni>();
}

TEST(modelIndex, rvalueReturnUniMulti) {
  expect_same<doubles, doubless, uni_multi>();
  expect_same<vec, vecs, uni_multi>();
  expect_same<vecs, vecss, uni_multi>();
  expect_same<rowvec, rowvecs, uni_multi>();
  expect_same<rowvecs, rowvecss, uni_multi>();
  expect_same<rowvec, mat, uni_multi>();
  expect_same<mat, mats, uni_multi>();
  expect_same<mats, matss, uni_multi>();
}

TEST(modelIndex, rvalueReturnMultiUni) {
  expect_same<doubles, doubless, multi_uni>();
  expect_same<doubles, vecs, multi_uni>();
  expect_same<vecs, vecss, multi_uni>();
  expect_same<doubles, rowvecs, multi_uni>();
  expect_same<rowvecs, rowvecss, multi_uni>();
  expect_same<vec, mat, multi_uni>();
  expect_same<rowvecs, mats, multi_uni>();
  expect_same<mats, matss, multi_uni>();
}

TEST(modelIndex, rvalueReturnMultiMulti) {
  expect_same<doubless, doubless, multi_multi>();
  expect_same<vecs, vecs, multi_multi>();
  expect_same<vecss, vecss, multi_multi>();
  expect_same<rowvecs, rowvecs, multi_multi>();
  expect_same<rowvecss, rowvecss, multi_multi>();
  expect_same<mat, mat, multi_multi>();
  expect_same<mats, mats, multi_multi>();
  expect_same<matss, matss, multi_multi>();
}

max_stars_repo_name: ludkinm/stan

max_issues_repo_name: ludkinm/stan

max_forks_repo_name: ludkinm/stan


text:
/*
 * IpcMessageTest.cpp - boost unit test cases for IpcMessage class
 *
 *  Created on: Jan 27, 2015
 *      Author: Tim Nicholls, STFC Application Engineering Group
 */

#include <boost/test/unit_test.hpp>

#include <time.h>
#include <exception>

#include "IpcMessage.h"
#include "gettime.h"

BOOST_AUTO_TEST_SUITE(IpcMessageUnitTest);

BOOST_AUTO_TEST_CASE( ValidIpcMessageFromString )
{
  // Instantiate a valid message from a JSON string
  OdinData::IpcMessage validMsgFromString("{\"msg_type\":\"cmd\", "
                                              "\"msg_val\":\"status\", "
                                              "\"timestamp\" : \"2015-01-27T15:26:01.123456\", "
                                              "\"params\" : {"
                                              "    \"paramInt\" : 1234, "
                                              "    \"paramStr\" : \"testParam\", "
                                              "    \"paramDouble\" : 3.1415 "
                                              "  } "
                                              "}");

  // Check the message is indeed valid
  BOOST_CHECK_EQUAL(validMsgFromString.is_valid(), true);

  // Check that all attributes are as expected
  BOOST_CHECK_EQUAL(validMsgFromString.get_msg_type(), OdinData::IpcMessage::MsgTypeCmd);
  BOOST_CHECK_EQUAL(validMsgFromString.get_msg_val(), OdinData::IpcMessage::MsgValCmdStatus);
  BOOST_CHECK_EQUAL(validMsgFromString.get_msg_timestamp(), "2015-01-27T15:26:01.123456");
  struct tm timestamp_tm = validMsgFromString.get_msg_datetime();
  BOOST_CHECK_EQUAL(asctime(&timestamp_tm), "Tue Jan 27 15:26:01 2015\n");

  // Check that all parameters are as expected
  BOOST_CHECK_EQUAL(validMsgFromString.get_param<int>("paramInt"), 1234);
  BOOST_CHECK_EQUAL(validMsgFromString.get_param<std::string>("paramStr"), "testParam");
  BOOST_CHECK_EQUAL(validMsgFromString.get_param<double>("paramDouble"), 3.1415);

  // Check valid message throws exception on missing parameter
  BOOST_CHECK_THROW(validMsgFromString.get_param<int>("missingParam"), OdinData::IpcMessageException);

  // Check valid message can fall back to default value if parameter missing
  int defaultParamValue = 90210;
  BOOST_CHECK_EQUAL(validMsgFromString.get_param<int>("missingParam", defaultParamValue), defaultParamValue);

}

BOOST_AUTO_TEST_CASE( EmptyIpcMessage )
{
  // Instantiate an empty message, which will be invalid by default since no attributes have been set
  OdinData::IpcMessage emptyMsg;

  // Check the message isn't valid
  BOOST_CHECK_EQUAL(emptyMsg.is_valid(), false);
}

BOOST_AUTO_TEST_CASE( CreateValidIpcMessageFromEmpty)
{
  // Instantiate an empty message, which will be invalid by default since no attributes have been set
  OdinData::IpcMessage theMsg;

  // Empty message isn't valid
  BOOST_CHECK_EQUAL(theMsg.is_valid(), false);

  // Set message type and value
  OdinData::IpcMessage::MsgType msg_type = OdinData::IpcMessage::MsgTypeCmd;
  theMsg.set_msg_type(msg_type);
  OdinData::IpcMessage::MsgVal msg_val = OdinData::IpcMessage::MsgValCmdReset;
  theMsg.set_msg_val(msg_val);

  // Check the message is now valid
  BOOST_CHECK_EQUAL(theMsg.is_valid(), true);

}

BOOST_AUTO_TEST_CASE( CreateAndModifyParametersInEmptyIpcMessage )
{
  // Create an emprty message
  OdinData::IpcMessage emptyMsg;

  // Define and set some parameters
  int paramIntVal = 1234;
  int paramIntVal2 = 90210;
  int paramIntVal3 = 4567;
  std::string paramStringVal("paramString");

  emptyMsg.set_param("paramInt", paramIntVal);
  emptyMsg.set_param("paramInt2", paramIntVal2);
  emptyMsg.set_param("paramInt3", paramIntVal3);
  emptyMsg.set_param("paramStr", paramStringVal);

  // Read them back and check they have correct values
  BOOST_CHECK_EQUAL(emptyMsg.get_param<int>("paramInt"), paramIntVal);
  BOOST_CHECK_EQUAL(emptyMsg.get_param<int>("paramInt2"), paramIntVal2);
  BOOST_CHECK_EQUAL(emptyMsg.get_param<int>("paramInt3"), paramIntVal3);
  BOOST_CHECK_EQUAL(emptyMsg.get_param<std::string>("paramStr"), paramStringVal);

  // Modify several parameters and check they are still correct
  paramIntVal2 = 228724;
  emptyMsg.set_param("paramInt2", paramIntVal2);
  std::string paramStringValNew("another string");
  emptyMsg.set_param("paramStr", paramStringValNew);

  BOOST_CHECK_EQUAL(emptyMsg.get_param<int>("paramInt2"), paramIntVal2);
  BOOST_CHECK_EQUAL(emptyMsg.get_param<std::string>("paramStr"), paramStringValNew);

}

BOOST_AUTO_TEST_CASE( UpdateParametersInExistingIpcMessage )
{
  OdinData::IpcMessage msg1;

  // Define and set some parameters
  int paramIntVal = 1234;
  int paramIntVal2 = 90210;
  int paramIntVal3 = 4567;
  std::string paramStringVal("paramString");

  msg1.set_param("paramInt", paramIntVal);
  msg1.set_param("paramInt2", paramIntVal2);
  msg1.set_param("paramInt3", paramIntVal3);
  msg1.set_param("paramStr", paramStringVal);

  // Read them back and check they have correct values
  BOOST_CHECK_EQUAL(msg1.get_param<int>("paramInt"), paramIntVal);
  BOOST_CHECK_EQUAL(msg1.get_param<int>("paramInt2"), paramIntVal2);
  BOOST_CHECK_EQUAL(msg1.get_param<int>("paramInt3"), paramIntVal3);
  BOOST_CHECK_EQUAL(msg1.get_param<std::string>("paramStr"), paramStringVal);

  OdinData::IpcMessage msg2;

  // Create a different message and update the first with it
  int newParamIntVal2 = 90310;
  int paramIntVal4 = 42;
  std::string newParamStringVal("newParamStr");
  std::string paramStringVal2("paramStr2");

  msg2.set_param("paramInt2", newParamIntVal2);
  msg2.set_param("paramInt4", paramIntVal4);
  msg2.set_param("paramStr", newParamStringVal);
  msg2.set_param("paramStr2", paramStringVal2);

  msg1.update(msg2);

  // Check that values are overwritten / added / still there
  BOOST_CHECK_EQUAL(msg1.get_param<int>("paramInt"), paramIntVal);
  BOOST_CHECK_EQUAL(msg1.get_param<int>("paramInt2"), newParamIntVal2);
  BOOST_CHECK_EQUAL(msg1.get_param<int>("paramInt3"), paramIntVal3);
  BOOST_CHECK_EQUAL(msg1.get_param<int>("paramInt4"), paramIntVal4);
  BOOST_CHECK_EQUAL(msg1.get_param<std::string>("paramStr"), newParamStringVal);
  BOOST_CHECK_EQUAL(msg1.get_param<std::string>("paramStr2"), paramStringVal2);

}

BOOST_AUTO_TEST_CASE( RoundTripFromEmptyIpcMessage )
{

  // Create an empty message
  OdinData::IpcMessage theMsg;

  // Set message type and value
  OdinData::IpcMessage::MsgType msg_type = OdinData::IpcMessage::MsgTypeCmd;
  theMsg.set_msg_type(msg_type);
  OdinData::IpcMessage::MsgVal msg_val = OdinData::IpcMessage::MsgValCmdReset;
  theMsg.set_msg_val(msg_val);

  // Define and set some parameters
  int paramIntVal = 1234;
  int paramIntVal2 = 90210;
  int paramIntVal3 = 4567;
  std::string paramStringVal("paramString");

  theMsg.set_param("paramInt", paramIntVal);
  theMsg.set_param("paramInt2", paramIntVal2);
  theMsg.set_param("paramInt3", paramIntVal3);
  theMsg.set_param("paramStr", paramStringVal);

  // Retrieve the encoded version
  const char* theMsgEncoded = theMsg.encode();

  // Create another message from the encoded version
  OdinData::IpcMessage msgFromEncoded(theMsgEncoded);

  // Validate the contents of all attributes and parameters of the new message
  BOOST_CHECK_EQUAL(msgFromEncoded.get_msg_type(), msg_type);
  BOOST_CHECK_EQUAL(msgFromEncoded.get_msg_val(), msg_val);
  BOOST_CHECK_EQUAL(msgFromEncoded.get_msg_timestamp(), theMsg.get_msg_timestamp());
  BOOST_CHECK_EQUAL(msgFromEncoded.get_param<int>("paramInt"), paramIntVal);
  BOOST_CHECK_EQUAL(msgFromEncoded.get_param<int>("paramInt2"), paramIntVal2);
  BOOST_CHECK_EQUAL(msgFromEncoded.get_param<int>("paramInt3"), paramIntVal3);
  BOOST_CHECK_EQUAL(msgFromEncoded.get_param<std::string>("paramStr"), paramStringVal);

}

BOOST_AUTO_TEST_CASE( RoundTripFromEmptyIpcMessageComparison )
{

  // Create an empty message
  OdinData::IpcMessage theMsg;

  // Set message type and value
  OdinData::IpcMessage::MsgType msg_type = OdinData::IpcMessage::MsgTypeCmd;
  theMsg.set_msg_type(msg_type);
  OdinData::IpcMessage::MsgVal msg_val = OdinData::IpcMessage::MsgValCmdReset;
  theMsg.set_msg_val(msg_val);

  // Define and set some parameters
  int paramIntVal = 1234;
  int paramIntVal2 = 90210;
  int paramIntVal3 = 4567;
  std::string paramStringVal("paramString");

  theMsg.set_param("paramInt", paramIntVal);
  theMsg.set_param("paramInt2", paramIntVal2);
  theMsg.set_param("paramInt3", paramIntVal3);
  theMsg.set_param("paramStr", paramStringVal);

  // Retrieve the encoded version
  const char* theMsgEncoded = theMsg.encode();

  // Create another message from the encoded version
  OdinData::IpcMessage msgFromEncoded(theMsgEncoded);

  // Test that the relational (in)equality operators work correctly for the IpcMessage class
  BOOST_CHECK_EQUAL((msgFromEncoded == theMsg), true);
  BOOST_CHECK_EQUAL((msgFromEncoded != theMsg), false);

}

BOOST_AUTO_TEST_CASE( InvalidIpcMessageFromString )
{
  // Instantiate an invalid message from an illegal JSON string - should throw an IpcMessageException
  BOOST_CHECK_THROW(OdinData::IpcMessage invalidMsgFromString("{\"wibble\" : \"wobble\" \"shouldnt be here\"}"), OdinData::IpcMessageException);
}

BOOST_AUTO_TEST_CASE( IllegalTypeIpcMessageFromString )
{
  // Instantiate a  message from a JSON string with valid syntax but an illegal type. Turning off strict validation will prevent an exception
  // at this point but render the message invalid
  OdinData::IpcMessage illegalTypeMsgFromString("{\"msg_type\":\"wrong\", \"msg_val\":\"status\", \"timestamp\" : \"2015-01-27T15:26:01.123456\" }", false);

  // Check that the message isn't valid
  BOOST_CHECK_EQUAL(illegalTypeMsgFromString.is_valid(), false);
}

BOOST_AUTO_TEST_CASE( IllegalValueIpcMessageFromString )
{
  // Instantiate a  message from a JSON string with valid syntax but an illegal value. Turning off strict validation will prevent an exception
  // at this point but render the message invalid
  OdinData::IpcMessage illegalValueMsgFromString("{\"msg_type\":\"cmd\", \"msg_val\":\"wrong\", \"timestamp\" : \"2015-01-27T15:26:01.123456\" }", false);

  // Check that the message isn't valid
  BOOST_CHECK_EQUAL(illegalValueMsgFromString.is_valid(), false);
}

BOOST_AUTO_TEST_CASE( IllegalTimestampIpcMessageFromString )
{
  // Instantiate a  message from a JSON string with valid syntax but an illegal timestamp. Turning off strict validation will prevent an exception
  // at this point but render the message invalid
  OdinData::IpcMessage illegalTimestampMsgFromString("{\"msg_type\":\"cmd\", \"msg_val\":\"status\", \"timestamp\" : \"1 Jan 1970 00:00:00\" }", false);

  // Check that the message isn't valid
  BOOST_CHECK_EQUAL(illegalTimestampMsgFromString.is_valid(), false);
}

BOOST_AUTO_TEST_CASE( IllegalTypeIpcMessageFromStringStrictValidation )
{
  // Instantiate a  message from a JSON string with valid syntax but an illegal type - with strict validation on, should throw an IpcMessageException
  BOOST_CHECK_THROW(
      OdinData::IpcMessage illegalTypeMsgFromString("{\"msg_type\":\"wrong\", \"msg_val\":\"status\", \"timestamp\" : \"2015-01-27T15:26:01.123456\" }", true),
      OdinData::IpcMessageException);
}

BOOST_AUTO_TEST_CASE( IllegalValueIpcMessageFromStringStrictValidation )
{
  // Instantiate a  message from a JSON string with valid syntax but an illegal value - with strict validation on, should throw an IpcMessageException
  BOOST_CHECK_THROW(
      OdinData::IpcMessage illegalValueMsgFromString("{\"msg_type\":\"cmd\", \"msg_val\":\"wrong\", \"timestamp\" : \"2015-01-27T15:26:01.123456\" }", true),
      OdinData::IpcMessageException);
}

BOOST_AUTO_TEST_CASE( IllegalTimestampIpcMessageFromStringStrictValidation )
{
  // Instantiate a  message from a JSON string with valid syntax but an illegal timestamp - with strict validation on, should throw an IpcMessageException
  BOOST_CHECK_THROW(
      OdinData::IpcMessage illegalTimestampMsgFromString("{\"msg_type\":\"cmd\", \"msg_val\":\"status\", \"timestamp\" : \"1 Jan 1970 00:00:00\" }", true),
      OdinData::IpcMessageException);
}

BOOST_AUTO_TEST_CASE( MissingParamsIpcMessageFromStringStrictValidation )
{
  // Instantiate a valid message from a JSON string
  BOOST_CHECK_THROW(
      OdinData::IpcMessage missingParamsMsgFromString("{\"msg_type\":\"cmd\", \"msg_val\":\"status\", \"timestamp\" : \"2015-01-27T15:26:01.123456\" }", true),
      OdinData::IpcMessageException);
}

// Calculate the difference, in seconds, between two timespecs
#define NANOSECONDS_PER_SECOND 1000000000
double timeDiff(struct timespec* start, struct timespec* end)
{

  double startNs = ((double)start->tv_sec * NANOSECONDS_PER_SECOND) + start->tv_nsec;
  double endNs   = ((double)  end->tv_sec * NANOSECONDS_PER_SECOND) +   end->tv_nsec;

  return (endNs - startNs) / NANOSECONDS_PER_SECOND;
}

BOOST_AUTO_TEST_CASE( TestIpcMessageCreationSpeed )
{
  int numLoops = 10000;
  struct timespec start, end;
  double deltaT, rate;

  gettime(&start);

  BOOST_CHECK_NO_THROW(
      for (int i = 0; i < numLoops; i++)
      {
        OdinData::IpcMessage simpleMessage(OdinData::IpcMessage::MsgTypeCmd, OdinData::IpcMessage::MsgValCmdStatus);
        simpleMessage.set_param<int>("loopParam", i);
        const char *encodedMsg = simpleMessage.encode();
      }
  );

  gettime(&end);
  deltaT = timeDiff(&start, &end);
  rate = (double)numLoops / deltaT;
  BOOST_TEST_MESSAGE("Created and encoded " << numLoops << " IPC messages in " << timeDiff(&start, &end) << " secs, rate " << rate << " Hz" );

  gettime(&start);

  BOOST_CHECK_NO_THROW(
      for (int i = 0 ; i < numLoops; i++)
      {
        OdinData::IpcMessage validMsgFromString("{\"msg_type\":\"cmd\", "
                                                    "\"msg_val\":\"status\", "
                                                    "\"timestamp\" : \"2015-01-27T15:26:01.123456\", "
                                                    "\"params\" : {"
                                                    "    \"paramInt\" : 1234, "
                                                    "    \"paramStr\" : \"testParam\", "
                                                    "    \"paramDouble\" : 3.1415 "
                                                    "  } "
                                                    "}");
        validMsgFromString.set_param<int>("loopParam", i);
      }
  );

  gettime(&end);
  deltaT = timeDiff(&start, &end);
  rate = (double)numLoops / deltaT;
  BOOST_TEST_MESSAGE("Created and parsed " << numLoops << " IPC messages from string in " << timeDiff(&start, &end) << " secs, rate " << rate << " Hz");

}

BOOST_AUTO_TEST_SUITE_END();

max_stars_repo_name: stfc-aeg/odin-data

max_issues_repo_name: stfc-aeg/odin-data

max_forks_repo_name: dls-controls/odin-data