Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Alice
Submodule Alice updated from 6e7d05 to ae4662
10 changes: 9 additions & 1 deletion Designer/UI/SolidDesignerCommand/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ else()

endif()

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

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

include_directories(${PROJECT_SOURCE_DIR}/Alice/UI/QFrameWork/AliceUiFrameWork/Public)

include_directories(${PROJECT_SOURCE_DIR}/Designer/UI/SolidDesignerUI/Public)

#-----------------------------------------------------------------------------
# 定义项目构建中间文件的生成目录
Expand Down Expand Up @@ -165,6 +166,12 @@ set_target_properties(SolidDesignerCommandsId PROPERTIES FOLDER "Designer/UI")
# 链接第三方的库 链接的动作需要放到add_library之后
#-----------------------------------------------------------------------------
target_link_libraries(SolidDesignerCommand PRIVATE
Qt5::Core
Qt5::Gui
Qt5::Widgets
Qt5::Network
Qt5::Quick
Qt5::Qml
AliceFoundation
AliceBasicTool
AliceCoreApplicationInterface
Expand All @@ -173,6 +180,7 @@ target_link_libraries(SolidDesignerCommand PRIVATE
AliceModelInterface
AliceUiFrameWork
AlicePluginSystem
SolidDesignerUI
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,29 @@
#include "AliceCoreAppUtil.h"
#include "AliceISession.h"
#include "AliceDiagnosticMacro.h"
#include "AliceIUiApplicationFactory.h"
#include "AliceIUiApplication.h"
#include "SolidNewFileDialog.h"
#include <QMainWindow>
#include "AliceIWorkBenchManager.h"

using namespace alice;
using namespace sdr;

namespace
{
static IMainWindow* GetMainWindow()
{
IUiApplicationFactory* pAppFactory = IUiApplicationFactory::Get();
if (!pAppFactory)
return nullptr;
IUiApplication* pApp = pAppFactory->GetUiApplication();
if (!pApp)
return nullptr;
// AliceIUiApplication returns const IMainWindow*, but we need non-const methods.
return const_cast<IMainWindow*>(pApp->GetMainWindow());
}
}
SolidFileNewCommand::~SolidFileNewCommand()
{

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

std::string SolidFileNewCommand::DisabledReason() const
{
if (CoreAppUtil::GetCurrentSession() == nullptr)
return "Session is not available.";

ISession* session = CoreAppUtil::GetCurrentSession();
if (session && session->GetDocumentManager() == nullptr)
return "Document manager is not available.";

if (GetMainWindow() == nullptr)
return "Main window is not available.";
return std::string();
}

bool SolidFileNewCommand::IsEnabled() const
{
return true;
return IsSupported();
}

bool SolidFileNewCommand::IsVisible() const
{
return true;
return IsSupported();
}

bool SolidFileNewCommand::IsSupported() const
{
return true;
ISession* session = CoreAppUtil::GetCurrentSession();
if (!session)
return false;

IDocumentManager* docMgr = session->GetDocumentManagerFw();
if (!docMgr)
return false;

IMainWindow* pMainWindow = GetMainWindow();
if (!pMainWindow)
return false;

return true;
}

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

// �˴�����creo �����½��Ի���ѡ���ĵ����ͣ���д�ĵ�����,Common Name
std::wstring strFileName;
IMainWindow* pMainWindow = GetMainWindow();
DIAG_RETURN_NULL_IF_FALSE(pMainWindow, "pMainWindow is null", "hananiah", "2026.01.16");
QMainWindow* pParent = pMainWindow->AsQMainWindow();

SolidNewFileDialog::NewFileRequest oRequest;
if (!SolidNewFileDialog::GetNewFileRequest(pParent, oRequest))
return nullptr;

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

// �½��ĵ�֮��Aliceƽ̨��������л�WorkBench
// ��ͬ���ĵ���Ӧ��ͬ��workbench
// Workbench switching: pick by document kind (ResolveWorkbenchByDocument).
if (IWorkBenchManager* pWbMgr = pMainWindow->GetWorkbenchManager())
{
std::string wbId = pWbMgr->ResolveWorkbenchByDocument(pDoc);
if (!wbId.empty())
pWbMgr->ActivateWorkBench(wbId, pDoc);
else
pWbMgr->ActiveStartupWorkbench(pDoc);
}

return nullptr;
}
// TODO: each document opens exactly one default 3D view.
// MdiViewManagerQt::OpenPrimaryView replaces the pane content, so this call is idempotent.
pMainWindow->OpenView("view.model3d", pDoc, oRequest.name.toStdWString());
return nullptr;
}
26 changes: 20 additions & 6 deletions Designer/UI/SolidDesignerUI/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@ find_package(Qt5 COMPONENTS Core Gui Widgets Network Quick Qml REQUIRED)

message("${PROJECT_SOURCE_DIR}")


FILE(GLOB SOURCE_FILES "${PROJECT_SOURCE_DIR}/Designer/UI/SolidDesignerUI/*.cpp")
FILE(GLOB HEADER_FILES "${PROJECT_SOURCE_DIR}/Designer/UI/SolidDesignerUI/*.h")


set(RESOURCES ${PROJECT_SOURCE_DIR}/Designer/UI/SolidDesignerUI/StyleTemplate.qrc)
source_group("resources" FILES ${RESOURCES})

set(ABS_SDU "${PROJECT_SOURCE_DIR}/Designer/UI/SolidDesignerUI")

file(GLOB SDU_FILES
"${ABS_SDU}/*.cpp" "${ABS_SDU}/*.h"
"${ABS_SDU}/Public/*.h"
"${ABS_SDU}/GeneralDialogs/*.h" "${ABS_SDU}/GeneralDialogs/*.cpp"
)

source_group(TREE "${ABS_SDU}" FILES ${SDU_FILES})

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

#=============================================================================
#指定工程为动态库程序
add_library(SolidDesignerUI SHARED ${SOURCE_FILES} ${HEADER_FILES})
add_library(SolidDesignerUI SHARED ${SDU_FILES})
#设定工程的过滤器
set_target_properties(SolidDesignerUI PROPERTIES FOLDER "Designer/UI")
#=============================================================================
Expand All @@ -51,6 +55,8 @@ target_include_directories(SolidDesignerUI
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/Public
${PROJECT_SOURCE_DIR}/Alice/Core/Foundation/AliceBasicTool/Public
${PROJECT_SOURCE_DIR}/Alice/UI/QFrameWork/AliceUiBasicTools/Public
${PROJECT_SOURCE_DIR}/Alice/Data/Interface/AliceModelInterface/Public
)

#-----------------------------------------------------------------------------
Expand Down Expand Up @@ -115,7 +121,15 @@ endif()
# @1、链接的动作需要放到add_library之后
#-----------------------------------------------------------------------------
target_link_libraries(SolidDesignerUI PRIVATE
Qt5::Core
Qt5::Gui
Qt5::Widgets
Qt5::Network
Qt5::Quick
Qt5::Qml
AliceBasicTool
AliceUiBasicTools
AliceModelInterface
)


Expand Down
Loading