From: ski Date: Fri, 12 Aug 2016 15:38:48 +0000 (+0300) Subject: 0027350: Support for Universal Windows Platform X-Git-Tag: V7_1_0_beta~180 X-Git-Url: http://git.dev.opencascade.org/gitweb/?p=occt.git;a=commitdiff_plain;h=742cc8b01d3f45327a482cfba317e7cd08a86114 0027350: Support for Universal Windows Platform - Toolchain file to configure a Visual Studio generator for a Windows 10 Universal Application was added (CMake). - There is no support for environment variables in UWP. - SID is not supported (were excluded). - Windows registry is not supported (were excluded). - Mess with usage of Unicode/ANSI was corrected. - Added sample to check UWP functionality. - Excluded usage of methods with Unicode characters where it is possible. - Minor corrections to allow building OCAF (except TKVCAF) and DE (except VRML and XDE) - Building of unsupported modules for UWP platform is off by default . - Checking of DataExchange functionality was added to XAML (UWP) sample. - Added information about UWP to the documentation. - Update of results of merge with issue 27801 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index de625e74f2..356714015d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,7 +65,7 @@ if (DEFINED CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE) # single-configuration ge endif() # enable extended messages of many OCCT algorithms -if ((SINGLE_GENERATOR AND "${CMAKE_BUILD_TYPE}" STREQUAL "Debug") OR NOT SINGLE_GENERATOR) +if (((SINGLE_GENERATOR AND "${CMAKE_BUILD_TYPE}" STREQUAL "Debug") OR NOT SINGLE_GENERATOR) AND (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")) if (NOT BUILD_WITH_DEBUG) set (BUILD_WITH_DEBUG OFF CACHE BOOL "${BUILD_WITH_DEBUG_DESCR}") endif() @@ -309,6 +309,15 @@ if (MSVC) set (BUILD_MODULE_MfcSamples OFF CACHE BOOL "${BUILD_MODULE_MfcSamples_DESCR}") endif() +# uwp sample +if (MSVC) + if ("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore") + set (BUILD_MODULE_UwpSample OFF CACHE BOOL "${BUILD_MODULE_UwpSample_DESCR}") + else() + unset (BUILD_MODULE_UwpSample) + endif() +endif() + # whether use optional 3rdparty or not if (APPLE) set (USE_GLX OFF CACHE BOOL "${USE_GLX_DESCR}") @@ -647,6 +656,10 @@ if (INSTALL_SAMPLES) OCCT_INSTALL_FILE_OR_DIR ("samples/CSharp" "${INSTALL_DIR}/${INSTALL_DIR_SAMPLES}") OCCT_INSTALL_FILE_OR_DIR ("samples/mfc" "${INSTALL_DIR}/${INSTALL_DIR_SAMPLES}") + if ("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore") + OCCT_INSTALL_FILE_OR_DIR ("samples/xaml" "${INSTALL_DIR}/${INSTALL_DIR_SAMPLES}") + endif() + install (FILES "${CMAKE_BINARY_DIR}/env.samples.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR}/${INSTALL_DIR_SAMPLES}/CSharp" RENAME "env.${SCRIPT_EXT}") install (FILES "${CMAKE_BINARY_DIR}/env.samples.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR}/${INSTALL_DIR_SAMPLES}/mfc/standard" RENAME "env.${SCRIPT_EXT}") endif() @@ -795,6 +808,10 @@ if (BUILD_MODULE_MfcSamples) add_subdirectory(samples/mfc/standard/10_Convert) endif() +if (BUILD_MODULE_UwpSample) + add_subdirectory(samples/xaml) +endif() + # Prepare variables for configuration of OpenCASCADE cmake config file set (OCCT_MODULES_ENABLED) set (OCCT_LIBRARIES) diff --git a/adm/cmake/vardescr.cmake b/adm/cmake/vardescr.cmake index c406cd4b52..eb64e81a69 100644 --- a/adm/cmake/vardescr.cmake +++ b/adm/cmake/vardescr.cmake @@ -108,6 +108,9 @@ set (BUILD_MODULE_MfcSamples_DESCR These samples show some possibilities of using OCCT and they can be executed with script samples.bat from the installation directory (INSTALL_DIR)") +set (BUILD_MODULE_UwpSample_DESCR +"Indicates whether OCCT UWP sample should be built together with OCCT.") + set (BUILD_DOC_Overview_DESCR "Indicates whether OCCT overview documentation project (Markdown format) should be created together with OCCT. It is not built together with OCCT. Checking this options @@ -144,5 +147,11 @@ set (USE_GLX_DESCR "Indicates whether X11 OpenGl on OSX is used or not") set (USE_D3D_DESCR "Indicates whether optional Direct3D wrapper in OCCT visualization module should be build or not") macro (BUILD_MODULE MODULE_NAME) - set (BUILD_MODULE_${MODULE_NAME} ON CACHE BOOL "${BUILD_MODULE_${MODULE_NAME}_DESCR}") + set (ENABLE_MODULE TRUE) + set (OCCT_MODULES_FOR_UWP FoundationClasses ModelingAlgorithms ModelingData) + list (FIND OCCT_MODULES_FOR_UWP ${OCCT_MODULE} CAN_BE_USED_IN_UWP) + if ("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore" AND CAN_BE_USED_IN_UWP EQUAL -1) + set (ENABLE_MODULE FALSE) + endif() + set (BUILD_MODULE_${MODULE_NAME} ${ENABLE_MODULE} CACHE BOOL "${BUILD_MODULE_${MODULE_NAME}_DESCR}") endmacro() diff --git a/adm/templates/uwp.toolchain.config.cmake b/adm/templates/uwp.toolchain.config.cmake new file mode 100644 index 0000000000..4dbd2ae6a9 --- /dev/null +++ b/adm/templates/uwp.toolchain.config.cmake @@ -0,0 +1,5 @@ +# A toolchain file to configure a Visual Studio generator for a Windows 10 Universal Application (UWP) +# Specify the CMAKE_SYSTEM_VERSION variable to be 10.0 to build with the latest available Windows 10 SDK. + +set (CMAKE_SYSTEM_NAME WindowsStore) +set (CMAKE_SYSTEM_VERSION 10.0) diff --git a/dox/dev_guides/building/cmake/cmake.md b/dox/dev_guides/building/cmake/cmake.md index ab4314b13f..c0892737fa 100644 --- a/dox/dev_guides/building/cmake/cmake.md +++ b/dox/dev_guides/building/cmake/cmake.md @@ -60,6 +60,10 @@ Once the source and build directories are selected, "Configure" button should be @figure{/dev_guides/building/cmake/images/cmake_image002.png} +To build OCCT with using Universal Windows Platform (UWP) specify path to toolchain file for cross-compiling d:/occt/adm/templates/uwp.toolchain.config.cmake. + +**Note**: Universal Windows Platform (UWP) is supported only on "Visual Studio 14 2015". File d:/occt/samples/xaml/ReadMe.md desribes building procedure of XAML (UWP) sample. + Once "Finish" button is pressed, the first pass of the configuration process is executed. At the end of the process, CMake outputs the list of environment variables which have to be properly specified for successful configuration. @figure{/dev_guides/building/cmake/images/cmake_image003.png} diff --git a/dox/dev_guides/debug/debug.md b/dox/dev_guides/debug/debug.md index 963957c46c..d48434f09f 100644 --- a/dox/dev_guides/debug/debug.md +++ b/dox/dev_guides/debug/debug.md @@ -35,6 +35,8 @@ This feature can be activated by defining environment variable *CSF_DEBUG_BOP*, The diagnostic code checks validity of the input arguments and the result of each Boolean operation. When an invalid situation is detected, the report consisting of argument shapes and a DRAW script to reproduce the problematic operation is saved to the directory pointed by *CSF_DEBUG_BOP*. +Note that this feature does not applicable for UWP build. + @section occt_debug_call Functions for calling from debugger Modern interactive debuggers provide the possibility to execute application code at a program break point. This feature can be used to analyse the temporary objects available only in the context of the debugged code. OCCT provides several global functions that can be used in this way. diff --git a/samples/xaml/App.xaml b/samples/xaml/App.xaml new file mode 100644 index 0000000000..e922bc13c4 --- /dev/null +++ b/samples/xaml/App.xaml @@ -0,0 +1,7 @@ + + diff --git a/samples/xaml/App.xaml.cpp b/samples/xaml/App.xaml.cpp new file mode 100644 index 0000000000..a948197a29 --- /dev/null +++ b/samples/xaml/App.xaml.cpp @@ -0,0 +1,124 @@ +// +// App.xaml.cpp +// Implementation of the App class. +// + +#include "pch.h" +#include "MainPage.xaml.h" + +using namespace uwp; + +using namespace Platform; +using namespace Windows::ApplicationModel; +using namespace Windows::ApplicationModel::Activation; +using namespace Windows::Foundation; +using namespace Windows::Foundation::Collections; +using namespace Windows::UI::Xaml; +using namespace Windows::UI::Xaml::Controls; +using namespace Windows::UI::Xaml::Controls::Primitives; +using namespace Windows::UI::Xaml::Data; +using namespace Windows::UI::Xaml::Input; +using namespace Windows::UI::Xaml::Interop; +using namespace Windows::UI::Xaml::Media; +using namespace Windows::UI::Xaml::Navigation; + +/// +/// Initializes the singleton application object. This is the first line of authored code +/// executed, and as such is the logical equivalent of main() or WinMain(). +/// +App::App() +{ + InitializeComponent(); + Suspending += ref new SuspendingEventHandler(this, &App::OnSuspending); +} + +/// +/// Invoked when the application is launched normally by the end user. Other entry points +/// will be used such as when the application is launched to open a specific file. +/// +/// Details about the launch request and process. +void App::OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ theEvent) +{ +#if _DEBUG + // Show graphics profiling information while debugging. + if (IsDebuggerPresent()) + { + // Display the current frame rate counters + DebugSettings->EnableFrameRateCounter = true; + } +#endif + auto rootFrame = dynamic_cast(Window::Current->Content); + + // Do not repeat app initialization when the Window already has content, + // just ensure that the window is active + if (rootFrame == nullptr) + { + // Create a Frame to act as the navigation context and associate it with + // a SuspensionManager key + rootFrame = ref new Frame(); + + rootFrame->NavigationFailed += ref new Windows::UI::Xaml::Navigation::NavigationFailedEventHandler(this, &App::OnNavigationFailed); + + if (theEvent->PreviousExecutionState == ApplicationExecutionState::Terminated) + { + // TODO: Restore the saved session state only when appropriate, scheduling the + // final launch steps after the restore is complete + + } + + if (theEvent->PrelaunchActivated == false) + { + if (rootFrame->Content == nullptr) + { + // When the navigation stack isn't restored navigate to the first page, + // configuring the new page by passing required information as a navigation + // parameter + rootFrame->Navigate(TypeName(MainPage::typeid), theEvent->Arguments); + } + // Place the frame in the current Window + Window::Current->Content = rootFrame; + // Ensure the current window is active + Window::Current->Activate(); + } + } + else + { + if (theEvent->PrelaunchActivated == false) + { + if (rootFrame->Content == nullptr) + { + // When the navigation stack isn't restored navigate to the first page, + // configuring the new page by passing required information as a navigation + // parameter + rootFrame->Navigate(TypeName(MainPage::typeid), theEvent->Arguments); + } + // Ensure the current window is active + Window::Current->Activate(); + } + } +} + +/// +/// Invoked when application execution is being suspended. Application state is saved +/// without knowing whether the application will be terminated or resumed with the contents +/// of memory still intact. +/// +/// The source of the suspend request. +/// Details about the suspend request. +void App::OnSuspending(Object^ theSender, SuspendingEventArgs^ theEvent) +{ + (void)theSender; // Unused parameter + (void)theEvent; // Unused parameter + + //TODO: Save application state and stop any background activity +} + +/// +/// Invoked when Navigation to a certain page fails +/// +/// The Frame which failed navigation +/// Details about the navigation failure +void App::OnNavigationFailed(Platform::Object ^theSender, Windows::UI::Xaml::Navigation::NavigationFailedEventArgs ^theEvent) +{ + throw ref new FailureException("Failed to load Page " + theEvent->SourcePageType.Name); +} \ No newline at end of file diff --git a/samples/xaml/App.xaml.h b/samples/xaml/App.xaml.h new file mode 100644 index 0000000000..20cba08021 --- /dev/null +++ b/samples/xaml/App.xaml.h @@ -0,0 +1,27 @@ +// +// App.xaml.h +// Declaration of the App class. +// + +#pragma once + +#include "App.g.h" + +namespace uwp +{ + /// + /// Provides application-specific behavior to supplement the default Application class. + /// + ref class App sealed + { + protected: + virtual void OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ theEvent) override; + + internal: + App(); + + private: + void OnSuspending(Platform::Object^ theSender, Windows::ApplicationModel::SuspendingEventArgs^ theEvent); + void OnNavigationFailed(Platform::Object ^theSender, Windows::UI::Xaml::Navigation::NavigationFailedEventArgs ^theEvent); + }; +} diff --git a/samples/xaml/Assets/LockScreenLogo.scale-200.png b/samples/xaml/Assets/LockScreenLogo.scale-200.png new file mode 100644 index 0000000000..735f57adb5 Binary files /dev/null and b/samples/xaml/Assets/LockScreenLogo.scale-200.png differ diff --git a/samples/xaml/Assets/SplashScreen.scale-200.png b/samples/xaml/Assets/SplashScreen.scale-200.png new file mode 100644 index 0000000000..023e7f1fed Binary files /dev/null and b/samples/xaml/Assets/SplashScreen.scale-200.png differ diff --git a/samples/xaml/Assets/Square150x150Logo.scale-200.png b/samples/xaml/Assets/Square150x150Logo.scale-200.png new file mode 100644 index 0000000000..af49fec1a5 Binary files /dev/null and b/samples/xaml/Assets/Square150x150Logo.scale-200.png differ diff --git a/samples/xaml/Assets/Square44x44Logo.scale-200.png b/samples/xaml/Assets/Square44x44Logo.scale-200.png new file mode 100644 index 0000000000..ce342a2ec8 Binary files /dev/null and b/samples/xaml/Assets/Square44x44Logo.scale-200.png differ diff --git a/samples/xaml/Assets/Square44x44Logo.targetsize-24_altform-unplated.png b/samples/xaml/Assets/Square44x44Logo.targetsize-24_altform-unplated.png new file mode 100644 index 0000000000..f6c02ce97e Binary files /dev/null and b/samples/xaml/Assets/Square44x44Logo.targetsize-24_altform-unplated.png differ diff --git a/samples/xaml/Assets/StoreLogo.png b/samples/xaml/Assets/StoreLogo.png new file mode 100644 index 0000000000..7385b56c0e Binary files /dev/null and b/samples/xaml/Assets/StoreLogo.png differ diff --git a/samples/xaml/Assets/Wide310x150Logo.scale-200.png b/samples/xaml/Assets/Wide310x150Logo.scale-200.png new file mode 100644 index 0000000000..288995b397 Binary files /dev/null and b/samples/xaml/Assets/Wide310x150Logo.scale-200.png differ diff --git a/samples/xaml/CMakeLists.txt b/samples/xaml/CMakeLists.txt new file mode 100644 index 0000000000..26d988bd96 --- /dev/null +++ b/samples/xaml/CMakeLists.txt @@ -0,0 +1,99 @@ +cmake_minimum_required(VERSION 3.4.0) +project(uwp) + +set_property(GLOBAL PROPERTY USE_FOLDERS ON) + +set(SOURCE_FILES + App.xaml.cpp + MainPage.xaml.cpp + pch.cpp + ) + +set(HEADER_FILES + App.xaml.h + MainPage.xaml.h + pch.h + ) + +set(XAML_FILES + App.xaml + MainPage.xaml + ) + +set(ASSET_FILES + Assets/LockScreenLogo.scale-200.png + Assets/SplashScreen.scale-200.png + Assets/Square150x150Logo.scale-200.png + Assets/Square44x44Logo.scale-200.png + Assets/Square44x44Logo.targetsize-24_altform-unplated.png + Assets/StoreLogo.png + Assets/Wide310x150Logo.scale-200.png + ) + +set(CONTENT_FILES + Package.appxmanifest + ) + +set(RESOURCE_FILES + ${CONTENT_FILES} ${ASSET_FILES} + uwp_TemporaryKey.pfx) + +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) + +set_property(SOURCE ${CONTENT_FILES} PROPERTY VS_DEPLOYMENT_CONTENT 1) +set_property(SOURCE ${ASSET_FILES} PROPERTY VS_DEPLOYMENT_CONTENT 1) +set_property(SOURCE ${ASSET_FILES} PROPERTY VS_DEPLOYMENT_LOCATION "Assets") + +set_property(SOURCE "App.xaml" PROPERTY VS_XAML_TYPE "ApplicationDefinition") + +source_group("Source Files" FILES ${SOURCE_FILES}) +source_group("Header Files" FILES ${HEADER_FILES}) +source_group("Resource Files" FILES ${RESOURCE_FILES}) +source_group("Xaml Files" FILES ${XAML_FILES}) + +add_executable(uwp WIN32 ${SOURCE_FILES} ${HEADER_FILES} ${RESOURCE_FILES} ${XAML_FILES}) + +set_property(TARGET uwp PROPERTY VS_WINRT_COMPONENT TRUE) + +set_property (TARGET uwp PROPERTY FOLDER Samples) + +if (SINGLE_GENERATOR) + install (TARGETS uwp DESTINATION "${INSTALL_DIR}/${INSTALL_DIR_BIN}") +else() + install (TARGETS uwp + CONFIGURATIONS Release RelWithDebInfo + DESTINATION "${INSTALL_DIR}/${INSTALL_DIR_BIN}") + install (TARGETS uwp + CONFIGURATIONS Debug + DESTINATION "${INSTALL_DIR}/${INSTALL_DIR_BIN}d") +endif() + +#include_directories + +# OCCT libraries for using +set (uwp_USED_LIBS TKernel + TKMath + TKG2d + TKG3d + TKGeomBase + TKBRep + TKGeomAlgo + TKTopAlgo + TKPrim + TKShHealing + TKBO + TKBool + TKFillet + TKMesh + TKFeat + TKHLR + TKOffset + TKXMesh + TKIGES + TKSTEP + TKXSBase + TKSTL +# TKVRML + ) + +target_link_libraries (uwp ${uwp_USED_LIBS}) \ No newline at end of file diff --git a/samples/xaml/MainPage.xaml b/samples/xaml/MainPage.xaml new file mode 100644 index 0000000000..58ca32c34e --- /dev/null +++ b/samples/xaml/MainPage.xaml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + +