Загрузка данных


#pragma once
#include "ivideoprocessor.h"
#include <QApplication>
#include <QLabel>
#include <QPainter>
#include <QPixmap>
#include <QThread>

class VideoLabelWidget : public IVideoProcessor, public QLabel
{
  public:
    VideoLabelWidget(QWidget *parent = nullptr)
        : QLabel(parent)
        , IVideoProcessor()
    {
        setAlignment(Qt::AlignCenter);
        setMinimumSize(125, 100);    // Set minimum size of the label
    }
    QThread *rendererThread() override;
    void fillWithColor(QColor color) override;
    void setPixmap(const QPixmap &pm) { QLabel::setPixmap(pm); }

  public slots:
    void updatePixmap(const QPixmap &pxMap, FrameId frameId) override;

  private:
    QImage mScaledImage;
    QColor mDefaultBackground;
    void processRequestedImageIfNeeded(FrameId frameId, const QPixmap &px);
    void hideEvent(QHideEvent *event) override;
};
#pragma once

#include <QDebug>
#include <QLabel>
#include <QPainter>
#include <QPushButton>
#include <QSettings>
#include <QSlider>
#include <QStackedLayout>
#include <QVBoxLayout>
#include <QWidget>

#include "../gunnerdata.h"
#include "alertwidget.h"
#include "axessettingswidget.h"
#include "bottommenu.h"
#include "button.h"
#include "commandmanager.h"
#include "common_gui/inputclickonframecontroller.h"
#include "compass.h"
#include "crosshairs.h"
#include "framesizegroup.h"
#include "helpwidget.h"
#include "lib_qt_common/userinfo.h"
#include "libs/wgt_common/src/camerawidget.h"
#include "maskedwidget.h"
#include "neuralnetworkwidget.h"
#include "pavdisplay.h"
#include "recordindicator.h"
#include "scalablewidget.h"
#include "setupmenuwidget.h"
#include "slider.h"
#include "trackerwidget.h"
#include "uiconst.h"
#include "uitools.h"
#include "visualconstraint.h"
#include "widgetplank.h"
#include "windowmanager.h"
#include <scalablelayout.h>

namespace gunner
{

class MarksWidget;

/*!
 * \brief Виджет на котором отображается видео и куча мелких виджетов поверх видео.
 */
class CentralWidget : public CameraWidget
{
    Q_OBJECT
    static constexpr double widthToHeightRatio =
        ProjectUiConst::DefaultResolutionHeight / static_cast<double>(ProjectUiConst::DefaultResolutionWidth);
    static constexpr QSize promptWidgetSize = {82, 32};
    static constexpr int offsetBetweenPromptWidgets = 30;

  public:
    explicit CentralWidget(std::shared_ptr<GunnerData> gunnerData, QWidget *videoWt, CommandManager *commandManager,
                           QWidget *parent = nullptr);
    ~CentralWidget();

    void setNoPanelView(bool enabled);
    void setSetupMenuVisibility(bool enabled);
    RecordIndicator *recIndicator = nullptr;
    Compass *compass = nullptr;
    MarksWidget *marksWidget = nullptr;
    VisualConstraint *gunConstraintView = nullptr;
    VisualConstraint *sightConstraintView = nullptr;
    VisualConstraint *gunConstraintCombat = nullptr;
    Slider *sightAngleSlider = nullptr;
    Slider *gunAngleSlider = nullptr;
    AxesSettingsWidget *axesSettingsWgt = nullptr;
    AlertWidget *alertWidget = nullptr;
    BottomWidget *const bottomWidget = nullptr;
    Button *noPanelViewButton = nullptr;
    TrackerWidget *tracker = nullptr;
    Crosshairs *crosshairs = nullptr;
    WindowManager *windowManager = nullptr;
    // надписи
    ScalableSizedColorWidgetWithText *prompt = nullptr;
    ScalableSizedWidgetSvg *const moveLockPrompt = nullptr;
    ScalableSizedWidgetSvg *const safetyPrompt = nullptr;
    ScalableSizedWidgetSvg *const continuousRangefinderPrompt = nullptr;
    ScalableSizedColorWidgetWithText *cameraChannelWidget = nullptr;
    ScalableSizedColorWidgetWithText *hFovWidget = nullptr;
    ScalableSizedColorWidgetWithText *vFovWidget = nullptr;
    ScalableSizedColorWidgetWithText *oppWidget = nullptr;
    ScalableSizedColorWidgetWithText *opsWidget = nullptr;
    ScalableSizedColorWidgetWithText *currentTimeWidget = nullptr;

    NeuralNetworkWidget *neuralNetworkWgt = nullptr;

    SetupMenuWidget *setupMenuWgt = nullptr;
    PAVDisplay *pavDisplay = nullptr;
    arm::InputClickOnFrameController *inputClick = nullptr;
#ifdef DEBUG_MODE
    ScalableSizedColorWidgetWithText *debugFrameData = nullptr;
    ScalableSizedColorWidgetWithText *debugJoystickBtns = nullptr;
    ScalableSizedColorWidgetWithText *debugJoystickAxes = nullptr;
#endif
    ScalableSizedColorWidgetWithText *speedLbl = nullptr;
    ScalableSizedColorWidgetWithText *rollLbl = nullptr;
    ScalableSizedColorWidgetWithText *adjustLbl = nullptr;
    ScalableSizedWidget *spacerForLbl = nullptr;
    virtual int heightForWidth(int width) const override { return std::ceil(widthToHeightRatio * width); }
    virtual bool hasHeightForWidth() const override { return true; }

  protected:
    virtual void paintEvent(QPaintEvent *event) override;

private slots:
  void onCurrentTimeTimerTimeout();

private:
  // Нижнее меню в "безпанельном" режиме
  ScalableLayoutOwner *bottomWgtOwner = nullptr;
  // виджет-подсказка
  ScalableLayoutOwner *promptOwnerWgt = nullptr;
  ScalableLayoutOwner *topPromptOwnerWgt = nullptr;
#ifdef DEBUG_MODE
    // debug - подсказка
    ScalableLayoutOwner *debugPromptOwnerWgt = nullptr;
#endif
    // пав
    ScalableLayoutOwner *pavOwner = nullptr;
    // индикатор записи видео
    ScalableLayoutOwner *recIndicatorOwnerWgt = nullptr;
    // компас
    ScalableLayoutOwner *compassOwnerWgt = nullptr;
    // уровень наклона
    ScalableLayoutOwner *titlOwnerWgt = nullptr;
    // Левые слайдеры - углы камеры и лафета
    ScalableLayoutOwner *leftSlidersWgt = nullptr;
    // Правые верхние слайдеры - зум, фокус, яркость и виджет смены видеоканала
    ScalableLayoutOwner *topRightSlidersWgt = nullptr;
    // ScalableLayoutOwner *fovOwnerWgt = nullptr;
    ScalableSizedWidget *plug = nullptr;
    QWidget *detectRect = nullptr;
    ScalableLayoutOwner *noPanelViewButtonOwnerWgt = nullptr;
    // виджет настройки осей и менеджер окон
    WidgetPlank *const widgetPlank;
    // время
    ScalableLayoutOwner *currentTimeOwnerWgt = nullptr;

    bool fullscreenEnabled = false;
    bool directiveActive = false;
    std::shared_ptr<GunnerData> mGunnerData;
    // обновление порядка слоев виджетов
    void updateStackOrder();
    QTimer *mCurentTimeTimer;
};

}    // namespace gunner
#pragma once

#include "../src/renderers/framerendererfactory.h"
#include "easyapi/ieasyframe.h"
#include "easygl/fpsdetector.h"
#include "lib_qt_common/qlogtools.h"
#include "renderers/iframerenderer.h"
#include <QColor>
#include <QMutex>
#include <QOpenGLBuffer>
#include <QOpenGLFramebufferObject>
#include <QOpenGLFunctions>
#include <QOpenGLShaderProgram>
#include <QOpenGLVertexArrayObject>
#include <QOpenGLWidget>
#include <atomic>
#include <memory>

namespace EasyGL
{

class VideoGlWidget : public QOpenGLWidget, protected QOpenGLFunctions
{
    Q_OBJECT
  public:
    explicit VideoGlWidget(QWidget *parent = nullptr);
    ~VideoGlWidget();

    void submitFrame(const std::shared_ptr<const EasyApi::IEasyFrame> &frame);
    void fillWithColor(QColor color);

  protected:
    void initializeGL() override;
    void paintGL() override;
    void resizeGL(int w, int h) override;

  private slots:
    void onFrameSubmitted();

  private:
    std::shared_ptr<IFrameRenderer> mFrameRenderer;
    EasyApi::PixelFormat::Type mCurrentFormat = EasyApi::PixelFormat::unknown;
    int mCurrentWidth = 0;
    int mCurrentHeight = 0;
    QSize mTextureSize;

    std::shared_ptr<const EasyApi::IEasyFrame> mLastFrame;
    QColor mBackgroundColor = Qt::black;
    std::atomic_bool mShuttingDown{false};

    // Для рендеринга в FBO и вывода на экран
    std::unique_ptr<QOpenGLFramebufferObject> mFbo;
    QOpenGLShaderProgram *mDisplayProgram = nullptr;
    QOpenGLVertexArrayObject *mDisplayVao = nullptr;
    QOpenGLBuffer *mDisplayVbo = nullptr;
    QMetaObject::Connection mContextCleanUpConnect;
    bool mCleanedUp = true;

    void setupViewport();
    bool prepareRenderer(const std::shared_ptr<const EasyApi::IEasyFrame> &frame);
    bool createRenderer(const std::shared_ptr<const EasyApi::IEasyFrame> &frame);
    void renderFboTexture(GLuint textureId);
    void cleanUp();
};

}    // namespace EasyGL
mCentralWidget(new CentralWidget(mGunnerData, new VideoLabelWidget(this), commandManager)) вот тут если я меняю на mCentralWidget(new CentralWidget(mGunnerData, new EasyGL::VideoGlWidget(this), commandManager)) у меня сразу крашится приложение