modify mainfram and remove chart plotmenu
This commit is contained in:
parent
c840f4ff3f
commit
a6d8351546
@ -22,7 +22,6 @@
|
||||
#include "chartPlot/FitCurveDialog.h"
|
||||
#include "chartPlot/SurfaceDialog.h"
|
||||
|
||||
#include "ui/Menu/ChartPlotMenu.h" // lz 20140914
|
||||
#include "common/SpdLogger.h"
|
||||
|
||||
#include "ui/Menu/SimuRunMenu.h"
|
||||
|
||||
@ -85,9 +85,22 @@ void MainWindow::InitUI() {
|
||||
//addDockWidget(pSettingUI->GetArea("PropertyBrowser"), attribte);
|
||||
propertyBrowser_ = new PropertyBrowser(0);
|
||||
propertyBrowser_->AttachDock(attribte);
|
||||
// Ensure property panel has a reasonable minimum width; no maximum limit
|
||||
attribte->setMinimumWidth(240);
|
||||
mapDockWidget_.insert("PropertyBrowser", attribte);
|
||||
addDockWidget(Qt::RightDockWidgetArea, attribte);
|
||||
|
||||
// Set an initial width for the property dock (no max constraint),
|
||||
// this serves as default when there is no saved layout yet.
|
||||
{
|
||||
const int totalWidth = qMax(800, this->width());
|
||||
const int initialPropWidth = qBound(240, totalWidth / 4, 480); // ~25% of window, within [240, 480]
|
||||
QList<QDockWidget*> docksProp;
|
||||
QList<int> sizesProp;
|
||||
docksProp << attribte; sizesProp << initialPropWidth;
|
||||
resizeDocks(docksProp, sizesProp, Qt::Horizontal);
|
||||
}
|
||||
|
||||
connect(modelBrowser_, &ModelBrowser::WorkSpaceChange, propertyBrowser_, &PropertyBrowser::OnWorkSpaceChange);
|
||||
connect(modelBrowser_, &ModelBrowser::EntityChange, propertyBrowser_, &PropertyBrowser::OnEntityChange);
|
||||
|
||||
@ -98,6 +111,10 @@ void MainWindow::InitUI() {
|
||||
viewDock->SetDockWidgetTitleBar(new DockTitleBar(viewDock));
|
||||
viewDock->setObjectName("Dock.MainView");
|
||||
viewDock->setWidget(qtOsgViewWidget_);
|
||||
// Ensure main view has a reasonable minimum size to avoid being squeezed
|
||||
// Use smaller minimum size to support smaller displays
|
||||
qtOsgViewWidget_->setMinimumSize(640, 480);
|
||||
viewDock->setMinimumSize(640, 480);
|
||||
addDockWidget(Qt::LeftDockWidgetArea, viewDock);
|
||||
mapDockWidget_.insert("MainView", viewDock);
|
||||
|
||||
@ -116,6 +133,51 @@ void MainWindow::InitUI() {
|
||||
UiLayoutManager::Restore(this, 1);
|
||||
LOG_INFO("MainWindow::InitUI - UiLayoutManager::Restore completed");
|
||||
|
||||
// After restore, if the main view is too small, expand it
|
||||
{
|
||||
QDockWidget* mainViewDock = mapDockWidget_.value("MainView", nullptr);
|
||||
QDockWidget* modelDock = mapDockWidget_.value("ModelBrowser", nullptr);
|
||||
QDockWidget* propertyDock = mapDockWidget_.value("PropertyBrowser", nullptr);
|
||||
if (mainViewDock) {
|
||||
// Use percentage-based allocation instead of fixed pixel values
|
||||
const int totalWidth = this->width();
|
||||
const int modelBrowserWidth = qMin(280, totalWidth / 6); // ~15% or max 280px
|
||||
const int propertyBrowserWidth = qMin(320, totalWidth / 4); // ~25% or max 320px
|
||||
const int mainViewMinWidth = totalWidth - modelBrowserWidth - propertyBrowserWidth - 50; // Reserve some margin
|
||||
|
||||
// Only resize if main view is too small (less than 50% of available space)
|
||||
if (mainViewDock->width() < mainViewMinWidth * 0.5) {
|
||||
QList<QDockWidget*> docks;
|
||||
QList<int> sizes;
|
||||
if (modelDock) { docks << modelDock; sizes << modelBrowserWidth; }
|
||||
docks << mainViewDock; sizes << mainViewMinWidth;
|
||||
resizeDocks(docks, sizes, Qt::Horizontal);
|
||||
}
|
||||
}
|
||||
|
||||
// Defer setting an initial width for the property dock once, without constraining max width
|
||||
if (propertyDock) {
|
||||
QDockWidget* capturedDock = propertyDock;
|
||||
QMetaObject::invokeMethod(this, [this, capturedDock]() {
|
||||
QDockWidget* pd = capturedDock;
|
||||
if (!pd) return;
|
||||
const int totalW = this->width();
|
||||
const int desired = qBound(240, totalW / 4, 480); // ~25% of window
|
||||
LOG_INFO("PropertyDock pre-adjust width=%d, desired=%d, windowW=%d", pd->width(), desired, totalW);
|
||||
const int oldMin = pd->minimumWidth();
|
||||
const int oldMax = pd->maximumWidth();
|
||||
pd->setMinimumWidth(desired);
|
||||
pd->setMaximumWidth(desired);
|
||||
QList<QDockWidget*> docksProp; QList<int> sizesProp;
|
||||
docksProp << pd; sizesProp << desired;
|
||||
resizeDocks(docksProp, sizesProp, Qt::Horizontal);
|
||||
pd->setMinimumWidth(oldMin > 0 ? oldMin : 240);
|
||||
pd->setMaximumWidth(QWIDGETSIZE_MAX);
|
||||
LOG_INFO("PropertyDock post-adjust width=%d (min=%d,max=%d)", pd->width(), pd->minimumWidth(), pd->maximumWidth());
|
||||
}, Qt::QueuedConnection);
|
||||
}
|
||||
}
|
||||
|
||||
//ui->viewWidget->layout()->addWidget(qtOsgViewWidget_);
|
||||
qtOsgViewWidget_->LoadDefaultScene();
|
||||
|
||||
|
||||
@ -1,60 +0,0 @@
|
||||
#include "ChartPlotMenu.h"
|
||||
|
||||
#include "../Matlab/MatlabObject.h"
|
||||
#include "../../common/RecourceHelper.h"
|
||||
#include "workspace/WorkSpace.h"
|
||||
#include "workspace/WorkSpaceManager.h"
|
||||
#include "workspace/LampStatus.h"
|
||||
#include "utils/FileUtils.h"
|
||||
#include <qmessagebox.h>
|
||||
|
||||
#include <qfiledialog.h>
|
||||
#include <QDir>
|
||||
|
||||
ChartPlotMenu::ChartPlotMenu(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
|
||||
InitMenu();
|
||||
}
|
||||
|
||||
ChartPlotMenu::~ChartPlotMenu()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ChartPlotMenu::InitMenu()
|
||||
{
|
||||
// Deprecated: SimMatlab run action removed
|
||||
|
||||
// Deprecated: SimMatlab selection removed
|
||||
|
||||
// Deprecated: Wave file selection removed
|
||||
|
||||
// Deprecated: RD file selection removed
|
||||
|
||||
// Deprecated: Report file selection removed
|
||||
|
||||
// Restore Lamp file selection with safe encoding
|
||||
connect(ui.toolButton_6, &QToolButton::clicked, this, [this]() {
|
||||
auto* ws = WorkSpaceManager::Get().GetCurrent();
|
||||
const QString defaultDir = ws ? ws->GetDir() : QDir::currentPath();
|
||||
const QString title = QString::fromLocal8Bit("选择Lamp文件");
|
||||
const QString filters = QString::fromLocal8Bit("文本文件 (*.txt);;所有文件 (*.*)");
|
||||
const QString file = QFileDialog::getOpenFileName(this, title, defaultDir, filters);
|
||||
if (file.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (!ws) {
|
||||
QMessageBox::warning(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("当前无工作区"));
|
||||
return;
|
||||
}
|
||||
const bool ok = ws->SetLampPath(file);
|
||||
if (ok) {
|
||||
QMessageBox::information(this, QString::fromLocal8Bit("Lamp"), QString::fromLocal8Bit("已加载 Lamp 文件"));
|
||||
} else {
|
||||
QMessageBox::warning(this, QString::fromLocal8Bit("Lamp"), QString::fromLocal8Bit("加载 Lamp 文件失败"));
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -1,25 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include "ui_ChartPlotMenu.h"
|
||||
|
||||
class DYTChart;
|
||||
class ChartPlotMenu : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ChartPlotMenu(QWidget *parent = nullptr);
|
||||
~ChartPlotMenu();
|
||||
|
||||
protected:
|
||||
void InitMenu();
|
||||
bool IsRuning();
|
||||
|
||||
signals:
|
||||
|
||||
|
||||
private:
|
||||
Ui::ChartPlotMenuClass ui;
|
||||
};
|
||||
Loading…
Reference in New Issue
Block a user