Merge branch 'new_osg' of http://brigecode.icu:16623/PM/DYTSrouce into new_osg
This commit is contained in:
commit
7d336212ea
@ -573,22 +573,22 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>AddParamSetting</name>
|
<name>AddParamSetting</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/Layout/AddParamSetting.cpp" line="67"/>
|
<location filename="../ui/Layout/AddParamSetting.cpp" line="69"/>
|
||||||
<source>ParamSetting</source>
|
<source>ParamSetting</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/Layout/AddParamSetting.cpp" line="110"/>
|
<location filename="../ui/Layout/AddParamSetting.cpp" line="112"/>
|
||||||
<source>param</source>
|
<source>param</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/Layout/AddParamSetting.cpp" line="117"/>
|
<location filename="../ui/Layout/AddParamSetting.cpp" line="119"/>
|
||||||
<source>input param descript</source>
|
<source>input param descript</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/Layout/AddParamSetting.cpp" line="170"/>
|
<location filename="../ui/Layout/AddParamSetting.cpp" line="172"/>
|
||||||
<source>input value</source>
|
<source>input value</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
@ -641,17 +641,17 @@
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/Layout/AddParamSetting.ui" line="78"/>
|
<location filename="../ui/Layout/AddParamSetting.ui" line="91"/>
|
||||||
<source>添加</source>
|
<source>添加</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/Layout/AddParamSetting.ui" line="91"/>
|
<location filename="../ui/Layout/AddParamSetting.ui" line="104"/>
|
||||||
<source>删除</source>
|
<source>删除</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/Layout/AddParamSetting.ui" line="104"/>
|
<location filename="../ui/Layout/AddParamSetting.ui" line="117"/>
|
||||||
<source>应用</source>
|
<source>应用</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
@ -1589,135 +1589,25 @@
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="60"/>
|
<location filename="../ui/MainWindow.cpp" line="61"/>
|
||||||
<source>model elements</source>
|
<source>model elements</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="68"/>
|
<location filename="../ui/MainWindow.cpp" line="70"/>
|
||||||
|
<source>preset models</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../ui/MainWindow.cpp" line="77"/>
|
||||||
<source>attribte</source>
|
<source>attribte</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="83"/>
|
<location filename="../ui/MainWindow.cpp" line="92"/>
|
||||||
<source>Main View</source>
|
<source>Main View</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
|
||||||
<location filename="../ui/MainWindow.cpp" line="117"/>
|
|
||||||
<source>Wave Curve</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../ui/MainWindow.cpp" line="126"/>
|
|
||||||
<source>Speed Curve</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../ui/MainWindow.cpp" line="139"/>
|
|
||||||
<source>3D Curve</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../ui/MainWindow.cpp" line="155"/>
|
|
||||||
<source>Target number</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../ui/MainWindow.cpp" line="155"/>
|
|
||||||
<source>Signal-to-noise ratio</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../ui/MainWindow.cpp" line="156"/>
|
|
||||||
<source>Azimuth line of sight</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../ui/MainWindow.cpp" line="156"/>
|
|
||||||
<source>Pitch gaze angle</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../ui/MainWindow.cpp" line="157"/>
|
|
||||||
<source>azimuth</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../ui/MainWindow.cpp" line="157"/>
|
|
||||||
<source>Pitch angle</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../ui/MainWindow.cpp" line="158"/>
|
|
||||||
<source>attribute</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../ui/MainWindow.cpp" line="158"/>
|
|
||||||
<source>Doppler</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../ui/MainWindow.cpp" line="159"/>
|
|
||||||
<source>course</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../ui/MainWindow.cpp" line="159"/>
|
|
||||||
<source>Speed</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../ui/MainWindow.cpp" line="160"/>
|
|
||||||
<source>longitude</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../ui/MainWindow.cpp" line="160"/>
|
|
||||||
<source>latitude</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../ui/MainWindow.cpp" line="161"/>
|
|
||||||
<source>distance</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../ui/MainWindow.cpp" line="161"/>
|
|
||||||
<source>velocity</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../ui/MainWindow.cpp" line="162"/>
|
|
||||||
<source>Radial dimensions</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../ui/MainWindow.cpp" line="162"/>
|
|
||||||
<source>Target RCS</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../ui/MainWindow.cpp" line="168"/>
|
|
||||||
<source>Report Table</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../ui/MainWindow.cpp" line="181"/>
|
|
||||||
<source>Signal Indicator Lamp</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../ui/MainWindow.cpp" line="192"/>
|
|
||||||
<source>ParamSetting</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../ui/MainWindow.cpp" line="201"/>
|
|
||||||
<source>bat File</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>ModelTreeWidget</name>
|
<name>ModelTreeWidget</name>
|
||||||
@ -1785,12 +1675,12 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>OsgWidget</name>
|
<name>OsgWidget</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../viewer/OsgWidget.cpp" line="115"/>
|
<location filename="../viewer/OsgWidget.cpp" line="122"/>
|
||||||
<source>warning</source>
|
<source>warning</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../viewer/OsgWidget.cpp" line="116"/>
|
<location filename="../viewer/OsgWidget.cpp" line="123"/>
|
||||||
<source>open dyt file failed</source>
|
<source>open dyt file failed</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
@ -1884,6 +1774,29 @@
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>PresetModelPanel</name>
|
||||||
|
<message>
|
||||||
|
<location filename="../ui/PresetModelPanel.cpp" line="57"/>
|
||||||
|
<source>Ships</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../ui/PresetModelPanel.cpp" line="58"/>
|
||||||
|
<source>Satellites</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../ui/PresetModelPanel.cpp" line="59"/>
|
||||||
|
<source>Missiles</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../ui/PresetModelPanel.cpp" line="60"/>
|
||||||
|
<source>Jammers</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>PropertyBrowser</name>
|
<name>PropertyBrowser</name>
|
||||||
<message>
|
<message>
|
||||||
@ -2850,25 +2763,32 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>SimuRunMenu</name>
|
<name>SimuRunMenu</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/Menu/SimuRunMenu.cpp" line="55"/>
|
<location filename="../ui/Menu/SimuRunMenu.cpp" line="50"/>
|
||||||
<source>no workspace</source>
|
<source>no workspace</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/Menu/SimuRunMenu.cpp" line="65"/>
|
<location filename="../ui/Menu/SimuRunMenu.cpp" line="64"/>
|
||||||
<source>no commands</source>
|
<source>no commands</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/Menu/SimuRunMenu.cpp" line="72"/>
|
<location filename="../ui/Menu/SimuRunMenu.cpp" line="74"/>
|
||||||
<source>Commands</source>
|
<source>Commands</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/Menu/SimuRunMenu.cpp" line="87"/>
|
<location filename="../ui/Menu/SimuRunMenu.cpp" line="93"/>
|
||||||
<source>unnamed</source>
|
<source>unnamed</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../ui/Menu/SimuRunMenu.cpp" line="125"/>
|
||||||
|
<location filename="../ui/Menu/SimuRunMenu.cpp" line="127"/>
|
||||||
|
<location filename="../ui/Menu/SimuRunMenu.cpp" line="187"/>
|
||||||
|
<source>MatlabParam</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>SimuRunMenuClass</name>
|
<name>SimuRunMenuClass</name>
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include "PropertyBrowser.h"
|
#include "PropertyBrowser.h"
|
||||||
#include "ModelBrowser.h"
|
#include "ModelBrowser.h"
|
||||||
|
#include "PresetModelPanel.h"
|
||||||
#include "DockWidget.h"
|
#include "DockWidget.h"
|
||||||
|
|
||||||
#include "viewer/QtOsgViewWidget.h"
|
#include "viewer/QtOsgViewWidget.h"
|
||||||
@ -65,6 +66,14 @@ void MainWindow::InitUI() {
|
|||||||
modelBrowser_->AttachDock(model);
|
modelBrowser_->AttachDock(model);
|
||||||
m_mapDockWidget.insert("ModelBrowser", model);
|
m_mapDockWidget.insert("ModelBrowser", model);
|
||||||
|
|
||||||
|
// 创建预制模型面板
|
||||||
|
DockWidget* presetModel = new DockWidget(tr("preset models"), 0);
|
||||||
|
presetModel->SetDockWidgetTitleBar(new DockTitleBar(presetModel));
|
||||||
|
presetModel->setObjectName("Dock.PresetModelPanel");
|
||||||
|
presetModelPanel_ = new PresetModelPanel(0);
|
||||||
|
presetModelPanel_->AttachDock(presetModel);
|
||||||
|
m_mapDockWidget.insert("PresetModelPanel", presetModel);
|
||||||
|
|
||||||
DockWidget* attribte = new DockWidget(tr("attribte"), 0);
|
DockWidget* attribte = new DockWidget(tr("attribte"), 0);
|
||||||
attribte->SetDockWidgetTitleBar(new DockTitleBar(attribte));
|
attribte->SetDockWidgetTitleBar(new DockTitleBar(attribte));
|
||||||
attribte->setObjectName("Dock.PropertyBrowser");
|
attribte->setObjectName("Dock.PropertyBrowser");
|
||||||
@ -88,8 +97,12 @@ void MainWindow::InitUI() {
|
|||||||
m_mapDockWidget.insert("MainView", viewDock);
|
m_mapDockWidget.insert("MainView", viewDock);
|
||||||
|
|
||||||
addDockWidget(Qt::LeftDockWidgetArea, model);
|
addDockWidget(Qt::LeftDockWidgetArea, model);
|
||||||
|
addDockWidget(Qt::LeftDockWidgetArea, presetModel);
|
||||||
splitDockWidget(model, viewDock, Qt::Horizontal);
|
splitDockWidget(model, viewDock, Qt::Horizontal);
|
||||||
|
|
||||||
|
// 将预制模型面板与模型浏览器标签化
|
||||||
|
tabifyDockWidget(model, presetModel);
|
||||||
|
|
||||||
QString wavePath ="", speedPath = "", rdPath = "", matlabParam="";
|
QString wavePath ="", speedPath = "", rdPath = "", matlabParam="";
|
||||||
if (WorkSpaceManager::Get().GetCurrent())
|
if (WorkSpaceManager::Get().GetCurrent())
|
||||||
{
|
{
|
||||||
|
|||||||
@ -25,6 +25,9 @@ public:
|
|||||||
class ModelBrowser* GetModelBrowser() const {
|
class ModelBrowser* GetModelBrowser() const {
|
||||||
return modelBrowser_;
|
return modelBrowser_;
|
||||||
}
|
}
|
||||||
|
class PresetModelPanel* GetPresetModelPanel() const {
|
||||||
|
return presetModelPanel_;
|
||||||
|
}
|
||||||
class OsgWidget* GetViewWidget() const {
|
class OsgWidget* GetViewWidget() const {
|
||||||
return qtOsgViewWidget_;
|
return qtOsgViewWidget_;
|
||||||
}
|
}
|
||||||
@ -58,6 +61,7 @@ private:
|
|||||||
Ui::MainWindow* ui;
|
Ui::MainWindow* ui;
|
||||||
|
|
||||||
class ModelBrowser* modelBrowser_{ nullptr };
|
class ModelBrowser* modelBrowser_{ nullptr };
|
||||||
|
class PresetModelPanel* presetModelPanel_{ nullptr };
|
||||||
class PropertyBrowser* propertyBrowser_{ nullptr };
|
class PropertyBrowser* propertyBrowser_{ nullptr };
|
||||||
class QWebEngineView* webEngineView_{ nullptr };
|
class QWebEngineView* webEngineView_{ nullptr };
|
||||||
class OsgWidget* qtOsgViewWidget_{ nullptr };
|
class OsgWidget* qtOsgViewWidget_{ nullptr };
|
||||||
|
|||||||
238
src/ui/PresetModelPanel.cpp
Normal file
238
src/ui/PresetModelPanel.cpp
Normal file
@ -0,0 +1,238 @@
|
|||||||
|
#include "PresetModelPanel.h"
|
||||||
|
#include "DockTitleBar.h"
|
||||||
|
#include "DockWidget.h"
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QListWidgetItem>
|
||||||
|
#include <QMimeData>
|
||||||
|
#include <QDrag>
|
||||||
|
#include <QPixmap>
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QIcon>
|
||||||
|
#include <QMouseEvent>
|
||||||
|
|
||||||
|
PresetModelPanel::PresetModelPanel(QWidget *parent)
|
||||||
|
: QWidget(parent)
|
||||||
|
, toolBox_(nullptr)
|
||||||
|
, mainLayout_(nullptr)
|
||||||
|
, shipList_(nullptr)
|
||||||
|
, satelliteList_(nullptr)
|
||||||
|
, missileList_(nullptr)
|
||||||
|
, jammerList_(nullptr)
|
||||||
|
{
|
||||||
|
InitUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
PresetModelPanel::~PresetModelPanel()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void PresetModelPanel::AttachDock(DockWidget* dockWidget)
|
||||||
|
{
|
||||||
|
if (nullptr == dockWidget) {
|
||||||
|
qDebug() << __FUNCTION__ << "dockwidget is nullptr";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dockWidget->SetDockWidgetTitleBar(nullptr);
|
||||||
|
dockWidget->setWidget(this);
|
||||||
|
|
||||||
|
DockTitleBar* dockTitleBar = new DockTitleBar;
|
||||||
|
dockWidget->SetDockWidgetTitleBar(dockTitleBar);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PresetModelPanel::InitUI()
|
||||||
|
{
|
||||||
|
mainLayout_ = new QVBoxLayout(this);
|
||||||
|
mainLayout_->setContentsMargins(5, 5, 5, 5);
|
||||||
|
mainLayout_->setSpacing(5);
|
||||||
|
|
||||||
|
toolBox_ = new QToolBox(this);
|
||||||
|
toolBox_->setObjectName("PresetModelToolBox");
|
||||||
|
|
||||||
|
toolBox_->addItem(CreateShipPage(), QIcon(), tr("Ships"));
|
||||||
|
toolBox_->addItem(CreateSatellitePage(), QIcon(), tr("Satellites"));
|
||||||
|
toolBox_->addItem(CreateMissilePage(), QIcon(), tr("Missiles"));
|
||||||
|
toolBox_->addItem(CreateJammerPage(), QIcon(), tr("Jammers"));
|
||||||
|
|
||||||
|
mainLayout_->addWidget(toolBox_);
|
||||||
|
|
||||||
|
setLayout(mainLayout_);
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget* PresetModelPanel::CreateShipPage()
|
||||||
|
{
|
||||||
|
QWidget* page = new QWidget;
|
||||||
|
QVBoxLayout* layout = new QVBoxLayout(page);
|
||||||
|
|
||||||
|
QStringList shipModels = {
|
||||||
|
"Destroyer",
|
||||||
|
"Aircraft Carrier",
|
||||||
|
"Frigate",
|
||||||
|
"Submarine"
|
||||||
|
};
|
||||||
|
|
||||||
|
shipList_ = CreateModelList(page, "Ship", shipModels);
|
||||||
|
layout->addWidget(shipList_);
|
||||||
|
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget* PresetModelPanel::CreateSatellitePage()
|
||||||
|
{
|
||||||
|
QWidget* page = new QWidget;
|
||||||
|
QVBoxLayout* layout = new QVBoxLayout(page);
|
||||||
|
|
||||||
|
QStringList satelliteModels = {
|
||||||
|
"Geostationary Satellite",
|
||||||
|
"Communication Satellite",
|
||||||
|
"Weather Satellite",
|
||||||
|
"Navigation Satellite"
|
||||||
|
};
|
||||||
|
|
||||||
|
satelliteList_ = CreateModelList(page, "Satellite", satelliteModels);
|
||||||
|
layout->addWidget(satelliteList_);
|
||||||
|
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget* PresetModelPanel::CreateMissilePage()
|
||||||
|
{
|
||||||
|
QWidget* page = new QWidget;
|
||||||
|
QVBoxLayout* layout = new QVBoxLayout(page);
|
||||||
|
|
||||||
|
QStringList missileModels = {
|
||||||
|
"Hypersonic Missile",
|
||||||
|
"Cruise Missile",
|
||||||
|
"Ballistic Missile",
|
||||||
|
"Anti-Ship Missile"
|
||||||
|
};
|
||||||
|
|
||||||
|
missileList_ = CreateModelList(page, "Missile", missileModels);
|
||||||
|
layout->addWidget(missileList_);
|
||||||
|
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget* PresetModelPanel::CreateJammerPage()
|
||||||
|
{
|
||||||
|
QWidget* page = new QWidget;
|
||||||
|
QVBoxLayout* layout = new QVBoxLayout(page);
|
||||||
|
|
||||||
|
QStringList jammerModels = {
|
||||||
|
"Passive Jammer",
|
||||||
|
"Active Jammer",
|
||||||
|
"Electronic Warfare Pod",
|
||||||
|
"Decoy System"
|
||||||
|
};
|
||||||
|
|
||||||
|
jammerList_ = CreateModelList(page, "Jammer", jammerModels);
|
||||||
|
layout->addWidget(jammerList_);
|
||||||
|
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
|
||||||
|
QListWidget* PresetModelPanel::CreateModelList(QWidget* parent, const QString& modelType, const QStringList& models)
|
||||||
|
{
|
||||||
|
DraggableListWidget* listWidget = new DraggableListWidget(modelType, parent);
|
||||||
|
|
||||||
|
listWidget->setDragDropMode(QAbstractItemView::DragOnly);
|
||||||
|
listWidget->setDefaultDropAction(Qt::CopyAction);
|
||||||
|
|
||||||
|
for (const QString& model : models) {
|
||||||
|
QListWidgetItem* item = new QListWidgetItem(model);
|
||||||
|
item->setFlags(item->flags() | Qt::ItemIsDragEnabled);
|
||||||
|
|
||||||
|
if (modelType == "Ship") {
|
||||||
|
item->setIcon(QIcon(":/icons/ship.png"));
|
||||||
|
} else if (modelType == "Satellite") {
|
||||||
|
item->setIcon(QIcon(":/icons/satellite.png"));
|
||||||
|
} else if (modelType == "Missile") {
|
||||||
|
item->setIcon(QIcon(":/icons/missile.png"));
|
||||||
|
} else if (modelType == "Jammer") {
|
||||||
|
item->setIcon(QIcon(":/icons/jammer.png"));
|
||||||
|
}
|
||||||
|
|
||||||
|
listWidget->addItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
connect(listWidget, &QListWidget::itemDoubleClicked, this, &PresetModelPanel::OnModelItemDoubleClicked);
|
||||||
|
|
||||||
|
return listWidget;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PresetModelPanel::SetupDragAndDrop(QListWidget* listWidget)
|
||||||
|
{
|
||||||
|
listWidget->setDragDropMode(QAbstractItemView::DragOnly);
|
||||||
|
listWidget->setDefaultDropAction(Qt::CopyAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PresetModelPanel::OnModelItemDoubleClicked(QListWidgetItem* item)
|
||||||
|
{
|
||||||
|
if (!item) return;
|
||||||
|
|
||||||
|
QListWidget* listWidget = item->listWidget();
|
||||||
|
if (!listWidget) return;
|
||||||
|
|
||||||
|
QString modelType = listWidget->property("modelType").toString();
|
||||||
|
QString modelName = item->text();
|
||||||
|
|
||||||
|
emit ModelDropped(modelType, modelName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// DraggableListWidget implementation
|
||||||
|
DraggableListWidget::DraggableListWidget(const QString& modelType, QWidget* parent)
|
||||||
|
: QListWidget(parent), modelType_(modelType)
|
||||||
|
{
|
||||||
|
setProperty("modelType", modelType);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DraggableListWidget::mousePressEvent(QMouseEvent* event)
|
||||||
|
{
|
||||||
|
if (event->button() == Qt::LeftButton) {
|
||||||
|
dragStartPosition_ = event->pos();
|
||||||
|
}
|
||||||
|
QListWidget::mousePressEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DraggableListWidget::mouseMoveEvent(QMouseEvent* event) {
|
||||||
|
if (!(event->buttons() & Qt::LeftButton)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((event->pos() - dragStartPosition_).manhattanLength() < QApplication::startDragDistance()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QListWidgetItem* item = itemAt(dragStartPosition_);
|
||||||
|
if (!item) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDrag* drag = new QDrag(this);
|
||||||
|
QMimeData* mimeData = new QMimeData;
|
||||||
|
|
||||||
|
QString modelType = this->property("modelType").toString();
|
||||||
|
QString modelName = item->text();
|
||||||
|
QString dragData = QString("%1|%2").arg(modelType, modelName);
|
||||||
|
|
||||||
|
mimeData->setData("application/x-preset-model", dragData.toUtf8());
|
||||||
|
drag->setMimeData(mimeData);
|
||||||
|
|
||||||
|
QPixmap pixmap(item->icon().pixmap(32, 32));
|
||||||
|
if (pixmap.isNull()) {
|
||||||
|
pixmap = QPixmap(100, 30);
|
||||||
|
pixmap.fill(Qt::transparent);
|
||||||
|
QPainter painter(&pixmap);
|
||||||
|
painter.setPen(Qt::black);
|
||||||
|
painter.drawText(pixmap.rect(), Qt::AlignCenter, modelName);
|
||||||
|
}
|
||||||
|
drag->setPixmap(pixmap);
|
||||||
|
|
||||||
|
Qt::DropAction dropAction = drag->exec(Qt::CopyAction);
|
||||||
|
Q_UNUSED(dropAction);
|
||||||
|
}
|
||||||
128
src/ui/PresetModelPanel.h
Normal file
128
src/ui/PresetModelPanel.h
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QToolBox>
|
||||||
|
#include <QListWidget>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QMimeData>
|
||||||
|
#include <QDrag>
|
||||||
|
#include <QMouseEvent>
|
||||||
|
|
||||||
|
class DockWidget;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Preset model panel class
|
||||||
|
*
|
||||||
|
* Provides preset 3D models for users to drag into the 3D scene, including:
|
||||||
|
* - Ships: Destroyer, Aircraft Carrier
|
||||||
|
* - Satellites: Geostationary Satellites
|
||||||
|
* - Missiles: Hypersonic Missiles
|
||||||
|
* - Jammers: Passive Jammers, Active Jammers
|
||||||
|
*/
|
||||||
|
class PresetModelPanel : public QWidget {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit PresetModelPanel(QWidget *parent = nullptr);
|
||||||
|
~PresetModelPanel() override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Attach to dock widget
|
||||||
|
* @param dockWidget Dock widget pointer
|
||||||
|
*/
|
||||||
|
void AttachDock(DockWidget* dockWidget);
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
/**
|
||||||
|
* @brief Signal emitted when model is dragged to scene
|
||||||
|
* @param modelType Model type
|
||||||
|
* @param modelName Model name
|
||||||
|
* @param position Scene position (optional)
|
||||||
|
*/
|
||||||
|
void ModelDropped(const QString& modelType, const QString& modelName, const QPointF& position = QPointF());
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
/**
|
||||||
|
* @brief Handle model item double click event
|
||||||
|
* @param item Clicked item
|
||||||
|
*/
|
||||||
|
void OnModelItemDoubleClicked(QListWidgetItem* item);
|
||||||
|
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* @brief Initialize user interface
|
||||||
|
*/
|
||||||
|
void InitUI();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Create ship category page
|
||||||
|
* @return Ship page widget
|
||||||
|
*/
|
||||||
|
QWidget* CreateShipPage();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Create satellite category page
|
||||||
|
* @return Satellite page widget
|
||||||
|
*/
|
||||||
|
QWidget* CreateSatellitePage();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Create missile category page
|
||||||
|
* @return Missile page widget
|
||||||
|
*/
|
||||||
|
QWidget* CreateMissilePage();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Create jammer category page
|
||||||
|
* @return Jammer page widget
|
||||||
|
*/
|
||||||
|
QWidget* CreateJammerPage();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Create model list items
|
||||||
|
* @param parent Parent widget
|
||||||
|
* @param modelType Model type
|
||||||
|
* @param models Model name list
|
||||||
|
* @return Configured QListWidget
|
||||||
|
*/
|
||||||
|
QListWidget* CreateModelList(QWidget* parent, const QString& modelType, const QStringList& models);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Setup drag and drop functionality
|
||||||
|
* @param listWidget List widget to setup drag and drop
|
||||||
|
*/
|
||||||
|
void SetupDragAndDrop(QListWidget* listWidget);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QToolBox* toolBox_;
|
||||||
|
QVBoxLayout* mainLayout_;
|
||||||
|
|
||||||
|
QListWidget* shipList_;
|
||||||
|
QListWidget* satelliteList_;
|
||||||
|
QListWidget* missileList_;
|
||||||
|
QListWidget* jammerList_;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Custom list widget with drag and drop support
|
||||||
|
*/
|
||||||
|
class DraggableListWidget : public QListWidget {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit DraggableListWidget(const QString& modelType, QWidget* parent = nullptr);
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void ItemDragged(const QString& modelType, const QString& modelName);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void mousePressEvent(QMouseEvent* event) override;
|
||||||
|
void mouseMoveEvent(QMouseEvent* event) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString modelType_;
|
||||||
|
QPoint dragStartPosition_;
|
||||||
|
};
|
||||||
@ -5,6 +5,10 @@
|
|||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
|
#include <QDragEnterEvent>
|
||||||
|
#include <QDropEvent>
|
||||||
|
#include <QMimeData>
|
||||||
|
#include <QDebug>
|
||||||
#include <osgDB/ReadFile>
|
#include <osgDB/ReadFile>
|
||||||
#include <osgEarthUtil/EarthManipulator>
|
#include <osgEarthUtil/EarthManipulator>
|
||||||
|
|
||||||
@ -44,6 +48,9 @@ OsgWidget::OsgWidget(QWidget* parent, Qt::WindowFlags f)
|
|||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
setKeyEventSetsDone(0);
|
setKeyEventSetsDone(0);
|
||||||
|
|
||||||
|
// 启用拖拽接收
|
||||||
|
setAcceptDrops(true);
|
||||||
|
|
||||||
connect( &timer_, SIGNAL(timeout()), this, SLOT(update()) );
|
connect( &timer_, SIGNAL(timeout()), this, SLOT(update()) );
|
||||||
timer_.start( 10 );
|
timer_.start( 10 );
|
||||||
|
|
||||||
@ -183,3 +190,59 @@ void OsgWidget::paintEvent(QPaintEvent*) {
|
|||||||
frame();
|
frame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OsgWidget::dragEnterEvent(QDragEnterEvent* event) {
|
||||||
|
// 检查是否是预制模型拖拽
|
||||||
|
if (event->mimeData()->hasFormat("application/x-preset-model")) {
|
||||||
|
event->acceptProposedAction();
|
||||||
|
} else {
|
||||||
|
event->ignore();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OsgWidget::dragMoveEvent(QDragMoveEvent* event) {
|
||||||
|
// 检查是否是预制模型拖拽
|
||||||
|
if (event->mimeData()->hasFormat("application/x-preset-model")) {
|
||||||
|
event->acceptProposedAction();
|
||||||
|
} else {
|
||||||
|
event->ignore();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OsgWidget::dropEvent(QDropEvent* event) {
|
||||||
|
// 检查是否是预制模型拖拽
|
||||||
|
if (event->mimeData()->hasFormat("application/x-preset-model")) {
|
||||||
|
QByteArray data = event->mimeData()->data("application/x-preset-model");
|
||||||
|
QString modelInfo = QString::fromUtf8(data);
|
||||||
|
|
||||||
|
// 解析模型信息 (格式: "modelType|modelName")
|
||||||
|
QStringList parts = modelInfo.split("|");
|
||||||
|
if (parts.size() == 2) {
|
||||||
|
QString modelType = parts[0];
|
||||||
|
QString modelName = parts[1];
|
||||||
|
|
||||||
|
// 获取拖拽位置
|
||||||
|
QPointF position = event->posF();
|
||||||
|
|
||||||
|
// 处理预制模型拖拽
|
||||||
|
OnPresetModelDropped(modelType, modelName, position);
|
||||||
|
|
||||||
|
event->acceptProposedAction();
|
||||||
|
} else {
|
||||||
|
event->ignore();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
event->ignore();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OsgWidget::OnPresetModelDropped(const QString& modelType, const QString& modelName, const QPointF& position) {
|
||||||
|
// TODO: 实现预制模型拖拽处理逻辑
|
||||||
|
// 1. 将屏幕坐标转换为世界坐标
|
||||||
|
// 2. 创建对应的Entity和MeshComponent
|
||||||
|
// 3. 添加到场景中
|
||||||
|
|
||||||
|
qDebug() << "预制模型拖拽:" << modelType << modelName << "位置:" << position;
|
||||||
|
|
||||||
|
// 这里暂时只是输出调试信息,后续需要集成实体系统
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@ -29,6 +29,20 @@ protected:
|
|||||||
void resizeEvent(QResizeEvent* event) override;
|
void resizeEvent(QResizeEvent* event) override;
|
||||||
void paintEvent( QPaintEvent* /*event*/ ) override;
|
void paintEvent( QPaintEvent* /*event*/ ) override;
|
||||||
|
|
||||||
|
// 拖拽事件处理
|
||||||
|
void dragEnterEvent(QDragEnterEvent* event) override;
|
||||||
|
void dragMoveEvent(QDragMoveEvent* event) override;
|
||||||
|
void dropEvent(QDropEvent* event) override;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
/**
|
||||||
|
* @brief 处理预制模型拖拽
|
||||||
|
* @param modelType 模型类型
|
||||||
|
* @param modelName 模型名称
|
||||||
|
* @param position 屏幕位置(可选)
|
||||||
|
*/
|
||||||
|
void OnPresetModelDropped(const QString& modelType, const QString& modelName, const QPointF& position = QPointF());
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QTimer timer_;
|
QTimer timer_;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user