Skip to content

Commit 37f44d8

Browse files
authored
Merge pull request #28 from Ludwigstrasse/Development_Hananiah
【AL-75】MDI Function
2 parents 1ad6c0a + b3c9003 commit 37f44d8

10 files changed

Lines changed: 560 additions & 146 deletions

File tree

Alice

Submodule Alice updated from 6e7d058 to ae46623

Designer/UI/SolidDesignerCommand/CMakeLists.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ else()
1818

1919
endif()
2020

21+
find_package(Qt5 COMPONENTS Core Gui Widgets Network Quick Qml REQUIRED)
2122

2223
# 然后再找 Python3
2324
find_package(Python3 REQUIRED COMPONENTS Interpreter)
@@ -58,7 +59,7 @@ include_directories(${PROJECT_SOURCE_DIR}/Alice/Interaction/Interface/AliceCoreA
5859
include_directories(${PROJECT_SOURCE_DIR}/Alice/Data/Interface/AliceModelInterface/Public)
5960

6061
include_directories(${PROJECT_SOURCE_DIR}/Alice/UI/QFrameWork/AliceUiFrameWork/Public)
61-
62+
include_directories(${PROJECT_SOURCE_DIR}/Designer/UI/SolidDesignerUI/Public)
6263

6364
#-----------------------------------------------------------------------------
6465
# 定义项目构建中间文件的生成目录
@@ -165,6 +166,12 @@ set_target_properties(SolidDesignerCommandsId PROPERTIES FOLDER "Designer/UI")
165166
# 链接第三方的库 链接的动作需要放到add_library之后
166167
#-----------------------------------------------------------------------------
167168
target_link_libraries(SolidDesignerCommand PRIVATE
169+
Qt5::Core
170+
Qt5::Gui
171+
Qt5::Widgets
172+
Qt5::Network
173+
Qt5::Quick
174+
Qt5::Qml
168175
AliceFoundation
169176
AliceBasicTool
170177
AliceCoreApplicationInterface
@@ -173,6 +180,7 @@ target_link_libraries(SolidDesignerCommand PRIVATE
173180
AliceModelInterface
174181
AliceUiFrameWork
175182
AlicePluginSystem
183+
SolidDesignerUI
176184
)
177185

178186

Designer/UI/SolidDesignerCommand/GeneralCommands/SolidFileNewCommand.cpp

Lines changed: 65 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,29 @@
77
#include "AliceCoreAppUtil.h"
88
#include "AliceISession.h"
99
#include "AliceDiagnosticMacro.h"
10+
#include "AliceIUiApplicationFactory.h"
11+
#include "AliceIUiApplication.h"
12+
#include "SolidNewFileDialog.h"
13+
#include <QMainWindow>
14+
#include "AliceIWorkBenchManager.h"
1015

1116
using namespace alice;
1217
using namespace sdr;
1318

19+
namespace
20+
{
21+
static IMainWindow* GetMainWindow()
22+
{
23+
IUiApplicationFactory* pAppFactory = IUiApplicationFactory::Get();
24+
if (!pAppFactory)
25+
return nullptr;
26+
IUiApplication* pApp = pAppFactory->GetUiApplication();
27+
if (!pApp)
28+
return nullptr;
29+
// AliceIUiApplication returns const IMainWindow*, but we need non-const methods.
30+
return const_cast<IMainWindow*>(pApp->GetMainWindow());
31+
}
32+
}
1433
SolidFileNewCommand::~SolidFileNewCommand()
1534
{
1635

@@ -24,38 +43,73 @@ SolidFileNewCommand::SolidFileNewCommand() noexcept
2443

2544
std::string SolidFileNewCommand::DisabledReason() const
2645
{
46+
if (CoreAppUtil::GetCurrentSession() == nullptr)
47+
return "Session is not available.";
48+
49+
ISession* session = CoreAppUtil::GetCurrentSession();
50+
if (session && session->GetDocumentManager() == nullptr)
51+
return "Document manager is not available.";
52+
53+
if (GetMainWindow() == nullptr)
54+
return "Main window is not available.";
2755
return std::string();
2856
}
2957

3058
bool SolidFileNewCommand::IsEnabled() const
3159
{
32-
return true;
60+
return IsSupported();
3361
}
3462

3563
bool SolidFileNewCommand::IsVisible() const
3664
{
37-
return true;
65+
return IsSupported();
3866
}
3967

4068
bool SolidFileNewCommand::IsSupported() const
4169
{
42-
return true;
70+
ISession* session = CoreAppUtil::GetCurrentSession();
71+
if (!session)
72+
return false;
73+
74+
IDocumentManager* docMgr = session->GetDocumentManagerFw();
75+
if (!docMgr)
76+
return false;
77+
78+
IMainWindow* pMainWindow = GetMainWindow();
79+
if (!pMainWindow)
80+
return false;
81+
82+
return true;
4383
}
4484

4585
std::unique_ptr<alice::IOperation> SolidFileNewCommand::Execute(const alice::CommandParameter& param)
4686
{
4787
ISession* pSession = CoreAppUtil::GetCurrentSession();
4888
DIAG_RETURN_NULL_IF_FALSE(pSession, "pSession is null", "hananiah", "2025.12.25");
4989

50-
// 此处弹出creo 风格的新建对话框,选择文档类型,填写文档名称,Common Name
51-
std::wstring strFileName;
90+
IMainWindow* pMainWindow = GetMainWindow();
91+
DIAG_RETURN_NULL_IF_FALSE(pMainWindow, "pMainWindow is null", "hananiah", "2026.01.16");
92+
QMainWindow* pParent = pMainWindow->AsQMainWindow();
5293

94+
SolidNewFileDialog::NewFileRequest oRequest;
95+
if (!SolidNewFileDialog::GetNewFileRequest(pParent, oRequest))
96+
return nullptr;
5397

54-
IDocument* pDoc = pSession->CreateDocument(strFileName);
55-
DIAG_RETURN_NULL_IF_FALSE(pDoc, "pDoc is null", "hananiah", "2025.12.25");
98+
IDocument* pDoc = pSession->CreateDocument(oRequest.kind, oRequest.name.toStdWString());
99+
DIAG_RETURN_NULL_IF_FALSE(pDoc, "Failed to create a new document", "hananiah", "2025.12.25");
56100

57-
// 新建文档之后,Alice平台层中如何切换WorkBench
58-
// 不同的文档对应不同的workbench
101+
// Workbench switching: pick by document kind (ResolveWorkbenchByDocument).
102+
if (IWorkBenchManager* pWbMgr = pMainWindow->GetWorkbenchManager())
103+
{
104+
std::string wbId = pWbMgr->ResolveWorkbenchByDocument(pDoc);
105+
if (!wbId.empty())
106+
pWbMgr->ActivateWorkBench(wbId, pDoc);
107+
else
108+
pWbMgr->ActiveStartupWorkbench(pDoc);
109+
}
59110

60-
return nullptr;
61-
}
111+
// TODO: each document opens exactly one default 3D view.
112+
// MdiViewManagerQt::OpenPrimaryView replaces the pane content, so this call is idempotent.
113+
pMainWindow->OpenView("view.model3d", pDoc, oRequest.name.toStdWString());
114+
return nullptr;
115+
}

Designer/UI/SolidDesignerUI/CMakeLists.txt

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,18 @@ find_package(Qt5 COMPONENTS Core Gui Widgets Network Quick Qml REQUIRED)
1515

1616
message("${PROJECT_SOURCE_DIR}")
1717

18-
19-
FILE(GLOB SOURCE_FILES "${PROJECT_SOURCE_DIR}/Designer/UI/SolidDesignerUI/*.cpp")
20-
FILE(GLOB HEADER_FILES "${PROJECT_SOURCE_DIR}/Designer/UI/SolidDesignerUI/*.h")
21-
22-
2318
set(RESOURCES ${PROJECT_SOURCE_DIR}/Designer/UI/SolidDesignerUI/StyleTemplate.qrc)
2419
source_group("resources" FILES ${RESOURCES})
2520

21+
set(ABS_SDU "${PROJECT_SOURCE_DIR}/Designer/UI/SolidDesignerUI")
22+
23+
file(GLOB SDU_FILES
24+
"${ABS_SDU}/*.cpp" "${ABS_SDU}/*.h"
25+
"${ABS_SDU}/Public/*.h"
26+
"${ABS_SDU}/GeneralDialogs/*.h" "${ABS_SDU}/GeneralDialogs/*.cpp"
27+
)
28+
29+
source_group(TREE "${ABS_SDU}" FILES ${SDU_FILES})
2630

2731
#-----------------------------------------------------------------------------
2832
# 库文件链接路径(ALICE_LIB_DIR 在上级定义了)
@@ -31,7 +35,7 @@ link_directories(${ALICE_LIB_DIR})
3135

3236
#=============================================================================
3337
#指定工程为动态库程序
34-
add_library(SolidDesignerUI SHARED ${SOURCE_FILES} ${HEADER_FILES})
38+
add_library(SolidDesignerUI SHARED ${SDU_FILES})
3539
#设定工程的过滤器
3640
set_target_properties(SolidDesignerUI PROPERTIES FOLDER "Designer/UI")
3741
#=============================================================================
@@ -51,6 +55,8 @@ target_include_directories(SolidDesignerUI
5155
${CMAKE_CURRENT_SOURCE_DIR}
5256
${CMAKE_CURRENT_SOURCE_DIR}/Public
5357
${PROJECT_SOURCE_DIR}/Alice/Core/Foundation/AliceBasicTool/Public
58+
${PROJECT_SOURCE_DIR}/Alice/UI/QFrameWork/AliceUiBasicTools/Public
59+
${PROJECT_SOURCE_DIR}/Alice/Data/Interface/AliceModelInterface/Public
5460
)
5561

5662
#-----------------------------------------------------------------------------
@@ -115,7 +121,15 @@ endif()
115121
# @1、链接的动作需要放到add_library之后
116122
#-----------------------------------------------------------------------------
117123
target_link_libraries(SolidDesignerUI PRIVATE
124+
Qt5::Core
125+
Qt5::Gui
126+
Qt5::Widgets
127+
Qt5::Network
128+
Qt5::Quick
129+
Qt5::Qml
118130
AliceBasicTool
131+
AliceUiBasicTools
132+
AliceModelInterface
119133
)
120134

121135

0 commit comments

Comments
 (0)