<commit_before>// For conditions of distribution and use, see copyright notice in license.txt

#include "StableHeaders.h"
#include "CameraControl.h"
#include "EventManager.h"
#include <QKeyEvent>
#include <QApplication>
#include <QInputContext>
#include <QGraphicsView>
#include "InputContext.h"
#include "ObjectCameraController.h"
#include "UiServiceInterface.h"
#include "Frame.h"

namespace RexLogic
{
    RotationWidget::RotationWidget(QWidget *parent) :
        QWidget(parent)
    {
        setupUi(this);
    }

    MovementWidget::MovementWidget(QWidget *parent) : 
        QWidget(parent)
    {
        setupUi(this);

        // Init styles for actions
        QString style_start = "QPushButton{border-image:url(./data/ui/images/cameracontrol/";
        QString style_end = ");}";
        release_style_= styleSheet();

        using namespace InputEvents;
        event_to_image_[MOVE_FORWARD_PRESSED] = style_start + "arrow_up_green1.png" + style_end;
        event_to_image_[MOVE_BACK_PRESSED] = style_start + "arrow_down_green1.png" + style_end;
        event_to_image_[MOVE_LEFT_PRESSED] = style_start + "arrow_left_green1.png" + style_end;
        event_to_image_[MOVE_RIGHT_PRESSED] = style_start + "arrow_right_green1.png" + style_end;
    }

    ZoomWidget::ZoomWidget(QWidget *parent) : 
        QWidget(parent)
    {
        setupUi(this);

        connect(zoomIN_button, SIGNAL(clicked()), this, SIGNAL(ZoomIn()));
        connect(zoomOUT_button, SIGNAL(clicked()), this, SIGNAL(ZoomOut()));
    }

    CameraControl::CameraControl(RexLogicModule *rex_logic, QWidget *parent) :
        rex_logic_(rex_logic),
        framework_(rex_logic->GetFramework()),
        QWidget(parent),
        widget_state_(None),
        camera_up_pressed_(false),
        camera_down_pressed_(false),
        camera_left_pressed_(false),
        camera_right_pressed_(false),
        zoom_in_pressed_(false),
        zoom_out_pressed_(false)
    {
        setupUi(this);
        using namespace InputEvents;

        rotation_widget = new RotationWidget(this);
        horizontalLayout_9->addWidget(rotation_widget);
        rotation_widget->hide();
        
        movement_widget = new MovementWidget(this);
        horizontalLayout_8->addWidget(movement_widget);
        movement_widget->hide();

        zoom_widget = new ZoomWidget(this);
        horizontalLayout_10->addWidget(zoom_widget);
        zoom_widget->hide();

        connect(cameraTRIPOD_button, SIGNAL(toggled(bool)), this, SLOT(CameraTripod(bool)));
        connect(cameraFREE_button, SIGNAL(toggled(bool)), this, SLOT(CameraFree(bool)));
        connect(cameraFOCUS_button, SIGNAL(toggled(bool)), this, SLOT(CameraFocus(bool)));
        connect(cameraAVATAR_button, SIGNAL(toggled(bool)), this, SLOT(CameraAvatar(bool)));

        connect(movement_widget->moveFORWARD_button, SIGNAL(pressed()), this, SLOT(MoveForwardPressed()));
        connect(movement_widget->moveFORWARD_button, SIGNAL(released()), this, SLOT(MoveForwardReleased()));
        connect(movement_widget->moveBACKWARD_button, SIGNAL(pressed()), this, SLOT(MoveBackwardPressed()));
        connect(movement_widget->moveBACKWARD_button, SIGNAL(released()), this, SLOT(MoveBackwardReleased()));
        connect(movement_widget->moveRIGHT_button, SIGNAL(pressed()), this, SLOT(MoveRightPressed()));
        connect(movement_widget->moveRIGHT_button, SIGNAL(released()), this, SLOT(MoveRightReleased()));
        connect(movement_widget->moveLEFT_button, SIGNAL(pressed()), this, SLOT(MoveLeftPressed()));
        connect(movement_widget->moveLEFT_button, SIGNAL(released()), this, SLOT(MoveLeftReleased()));

        connect(rotation_widget->cameraUP_button, SIGNAL(pressed()), this, SLOT(CameraUpPressed()));
        connect(rotation_widget->cameraUP_button, SIGNAL(released()), this, SLOT(CameraUpReleased()));
        connect(rotation_widget->cameraDOWN_button, SIGNAL(pressed()), this, SLOT(CameraDownPressed()));
        connect(rotation_widget->cameraDOWN_button, SIGNAL(released()), this, SLOT(CameraDownReleased()));
        connect(rotation_widget->cameraRIGHT_button, SIGNAL(pressed()), this, SLOT(CameraRightPressed()));
        connect(rotation_widget->cameraRIGHT_button, SIGNAL(released()), this, SLOT(CameraRightReleased()));
        connect(rotation_widget->cameraLEFT_button, SIGNAL(pressed()), this, SLOT(CameraLeftPressed()));
        connect(rotation_widget->cameraLEFT_button, SIGNAL(released()), this, SLOT(CameraLeftReleased()));

        connect(zoom_widget->zoomIN_button, SIGNAL(pressed()), this, SLOT(ZoomInPressed()));
        connect(zoom_widget->zoomIN_button, SIGNAL(released()), this, SLOT(ZoomInReleased()));
        connect(zoom_widget->zoomOUT_button, SIGNAL(pressed()), this, SLOT(ZoomOutPressed()));
        connect(zoom_widget->zoomOUT_button, SIGNAL(released()), this, SLOT(ZoomOutReleased()));

        connect(framework_->GetFrame(), SIGNAL(Updated(float)), this, SLOT(Update(float)));

        UiServiceInterface *ui_service = framework_->GetService<UiServiceInterface>();
        if (ui_service)
		{
			proxy_widget_ = ui_service->AddWidgetToScene(this);
            proxy_widget_->setMaximumHeight(800);
            proxy_widget_->setMaximumWidth(600);
			ui_service->AddWidgetToMenu(this, tr("Camera Controls"), "", "./data/ui/images/menus/edbutton_WRLDTOOLS_icon.png");
		}
        connect(proxy_widget_, SIGNAL(Visible(bool)), this, SLOT(Visible(bool)));
	}

    void CameraControl::CameraTripod(bool checked)
    {
        if (checked)
        {
            movement_widget->show();
            rotation_widget->hide();<commit_msg>Fixed UDB in CameraControl.<commit_after>// For conditions of distribution and use, see copyright notice in license.txt

#include "StableHeaders.h"
#include "CameraControl.h"
#include "EventManager.h"
#include <QKeyEvent>
#include <QApplication>
#include <QInputContext>
#include <QGraphicsView>
#include "InputContext.h"
#include "ObjectCameraController.h"
#include "UiServiceInterface.h"
#include "Frame.h"

namespace RexLogic
{
    RotationWidget::RotationWidget(QWidget *parent) :
        QWidget(parent)
    {
        setupUi(this);
    }

    MovementWidget::MovementWidget(QWidget *parent) : 
        QWidget(parent)
    {
        setupUi(this);

        // Init styles for actions
        QString style_start = "QPushButton{border-image:url(./data/ui/images/cameracontrol/";
        QString style_end = ");}";
        release_style_= styleSheet();

        using namespace InputEvents;
        event_to_image_[MOVE_FORWARD_PRESSED] = style_start + "arrow_up_green1.png" + style_end;
        event_to_image_[MOVE_BACK_PRESSED] = style_start + "arrow_down_green1.png" + style_end;
        event_to_image_[MOVE_LEFT_PRESSED] = style_start + "arrow_left_green1.png" + style_end;
        event_to_image_[MOVE_RIGHT_PRESSED] = style_start + "arrow_right_green1.png" + style_end;
    }

    ZoomWidget::ZoomWidget(QWidget *parent) : 
        QWidget(parent)
    {
        setupUi(this);

        connect(zoomIN_button, SIGNAL(clicked()), this, SIGNAL(ZoomIn()));
        connect(zoomOUT_button, SIGNAL(clicked()), this, SIGNAL(ZoomOut()));
    }

    CameraControl::CameraControl(RexLogicModule *rex_logic, QWidget *parent) :
        rex_logic_(rex_logic),
        framework_(rex_logic->GetFramework()),
        QWidget(parent),
        widget_state_(None),
        camera_up_pressed_(false),
        camera_down_pressed_(false),
        camera_left_pressed_(false),
        camera_right_pressed_(false),
        zoom_in_pressed_(false),
        zoom_out_pressed_(false),
        proxy_widget_(0)
    {
        setupUi(this);
        using namespace InputEvents;

        rotation_widget = new RotationWidget(this);
        horizontalLayout_9->addWidget(rotation_widget);
        rotation_widget->hide();
        
        movement_widget = new MovementWidget(this);
        horizontalLayout_8->addWidget(movement_widget);
        movement_widget->hide();

        zoom_widget = new ZoomWidget(this);
        horizontalLayout_10->addWidget(zoom_widget);
        zoom_widget->hide();

        connect(cameraTRIPOD_button, SIGNAL(toggled(bool)), this, SLOT(CameraTripod(bool)));
        connect(cameraFREE_button, SIGNAL(toggled(bool)), this, SLOT(CameraFree(bool)));
        connect(cameraFOCUS_button, SIGNAL(toggled(bool)), this, SLOT(CameraFocus(bool)));
        connect(cameraAVATAR_button, SIGNAL(toggled(bool)), this, SLOT(CameraAvatar(bool)));

        connect(movement_widget->moveFORWARD_button, SIGNAL(pressed()), this, SLOT(MoveForwardPressed()));
        connect(movement_widget->moveFORWARD_button, SIGNAL(released()), this, SLOT(MoveForwardReleased()));
        connect(movement_widget->moveBACKWARD_button, SIGNAL(pressed()), this, SLOT(MoveBackwardPressed()));
        connect(movement_widget->moveBACKWARD_button, SIGNAL(released()), this, SLOT(MoveBackwardReleased()));
        connect(movement_widget->moveRIGHT_button, SIGNAL(pressed()), this, SLOT(MoveRightPressed()));
        connect(movement_widget->moveRIGHT_button, SIGNAL(released()), this, SLOT(MoveRightReleased()));
        connect(movement_widget->moveLEFT_button, SIGNAL(pressed()), this, SLOT(MoveLeftPressed()));
        connect(movement_widget->moveLEFT_button, SIGNAL(released()), this, SLOT(MoveLeftReleased()));

        connect(rotation_widget->cameraUP_button, SIGNAL(pressed()), this, SLOT(CameraUpPressed()));
        connect(rotation_widget->cameraUP_button, SIGNAL(released()), this, SLOT(CameraUpReleased()));
        connect(rotation_widget->cameraDOWN_button, SIGNAL(pressed()), this, SLOT(CameraDownPressed()));
        connect(rotation_widget->cameraDOWN_button, SIGNAL(released()), this, SLOT(CameraDownReleased()));
        connect(rotation_widget->cameraRIGHT_button, SIGNAL(pressed()), this, SLOT(CameraRightPressed()));
        connect(rotation_widget->cameraRIGHT_button, SIGNAL(released()), this, SLOT(CameraRightReleased()));
        connect(rotation_widget->cameraLEFT_button, SIGNAL(pressed()), this, SLOT(CameraLeftPressed()));
        connect(rotation_widget->cameraLEFT_button, SIGNAL(released()), this, SLOT(CameraLeftReleased()));

        connect(zoom_widget->zoomIN_button, SIGNAL(pressed()), this, SLOT(ZoomInPressed()));
        connect(zoom_widget->zoomIN_button, SIGNAL(released()), this, SLOT(ZoomInReleased()));
        connect(zoom_widget->zoomOUT_button, SIGNAL(pressed()), this, SLOT(ZoomOutPressed()));
        connect(zoom_widget->zoomOUT_button, SIGNAL(released()), this, SLOT(ZoomOutReleased()));

        connect(framework_->GetFrame(), SIGNAL(Updated(float)), this, SLOT(Update(float)));

        UiServiceInterface *ui_service = framework_->GetService<UiServiceInterface>();
        if (ui_service)
		{
			proxy_widget_ = ui_service->AddWidgetToScene(this);
			if (proxy_widget_)
			{
                proxy_widget_->setMaximumHeight(800);
                proxy_widget_->setMaximumWidth(600);
			    ui_service->AddWidgetToMenu(this, tr("Camera Controls"), "", "./data/ui/images/menus/edbutton_WRLDTOOLS_icon.png");
                connect(proxy_widget_, SIGNAL(Visible(bool)), this, SLOT(Visible(bool)));
            }
		}
	}

    void CameraControl::CameraTripod(bool checked)
    {
        if (checked)
        {
            movement_widget->show();
            rotation_widget->hide();
{'fraction_non_alphanumeric': 0.13231013495633764, 'fraction_numerical': 0.0025579959424891947, 'mean_word_length': 4.363292336802271, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 83, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5700631', 'n_tokens_mistral': 3488, 'n_tokens_neox': 3313, 'n_words': 491}