Extending CMake procedure by 'BUILD_MODULE_QtSamples' variable to switch on qt samples build.
Implementation required:
- union of occt_toolkit_tool.cmake and occt_toolkit.cmake files;
- correction of qt samples sources by adding path to Qt 'plugins' folder. It helps to avoid definition of additional variable (QT_QPA_PLATFORM_PLUGIN_PATH) when staring sample.bat for qt samples;
- executable processing is extended in cmake procedure by providing 'EXECUTABLE_PROJECT' variable. Now we need not specify custom processing for DRAWEXE in occt_toolkit.cmake
if (MSVC)
set (BUILD_MODULE_MfcSamples OFF CACHE BOOL "${BUILD_MODULE_MfcSamples_DESCR}")
endif()
+set (BUILD_MODULE_QtSamples OFF CACHE BOOL "${BUILD_MODULE_QtSamples_DESCR}")
set (BUILD_Inspector OFF CACHE BOOL "${BUILD_Inspector_DESCR}")
# include the patched or original list of modules
# list <MODULENAME>_TOOLKITS is created foreach module and contains its toolkits
# list <OCCT_MODULES> will contain all modules
-OCCT_MODULES_AND_TOOLKITS (OCCT_MODULES)
+OCCT_MODULES_AND_TOOLKITS (MODULES "TOOLKITS" OCCT_MODULES)
foreach (OCCT_MODULE ${OCCT_MODULES})
BUILD_MODULE (${OCCT_MODULE})
set (SCRIPT_EXT sh)
endif()
+if (BUILD_Inspector OR BUILD_MODULE_QtSamples)
+ # check qt 3rdparty path
+ add_definitions (-DHAVE_QT)
+ OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/qt")
+ message (STATUS "Info: Qt is used by OCCT")
+else()
+ OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_QT")
+ OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TQTMALLOC")
+ OCCT_CHECK_AND_UNSET ("INSTALL_QT")
+endif()
+
# OCCT tools
# include the patched or original list of tools
# list <TOOLNAME>_TOOLKITS is created foreach tool and contains its toolkits
# list <OCCT_TOOLS> will contain all tools
-if (NOT BUILD_Inspector)
- OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_QT")
- OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TQTMALLOC")
- OCCT_CHECK_AND_UNSET ("INSTALL_QT")
-else()
- OCCT_TOOLS_AND_TOOLKITS (OCCT_TOOLS)
+if (BUILD_Inspector)
+ OCCT_MODULES_AND_TOOLKITS (TOOLS "TOOL_TOOLKITS" OCCT_TOOLS)
foreach (OCCT_TOOL ${OCCT_TOOLS})
list (APPEND BUILD_TOOL_TOOLKITS ${${OCCT_TOOL}_TOOL_TOOLKITS})
endforeach()
- # collect all the headers to <binary dir>/inc folder
+ # collect all the headers to <binary dir>/inc/inspector folder
string(TIMESTAMP CURRENT_TIME "%H:%M:%S")
- message (STATUS "\nInfo: \(${CURRENT_TIME}\) Start collecting all OCCT tool header files into ${CMAKE_BINARY_DIR}/tools/inc ...")
+ message (STATUS "\nInfo: \(${CURRENT_TIME}\) Start collecting all OCCT tool header files into ${CMAKE_BINARY_DIR}/inc/inspector ...")
COLLECT_AND_INSTALL_OCCT_HEADER_FILES ("${CMAKE_BINARY_DIR}" "${BUILD_TOOL_TOOLKITS}" "${CMAKE_SOURCE_DIR}/tools" "${INSTALL_DIR_INCLUDE}/inspector")
-
-
- # check qt 3rdparty path
- add_definitions (-DHAVE_QT)
- OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/qt")
- message (STATUS "Info: Qt is used by OCCT")
endif()
# OCCT samples
# write current custom.bat/sh (for build directory)
OCCT_CONFIGURE ("adm/templates/custom.build.${SCRIPT_EXT}.in" "${SUB_CUSTOM_NAME}")
-if (BUILD_MODULE_MfcSamples)
+if (BUILD_MODULE_MfcSamples OR BUILD_MODULE_QtSamples)
OCCT_INSTALL_FILE_OR_DIR ("adm/templates/sample.bat" "${INSTALL_DIR_SCRIPT}")
OCCT_COPY_FILE_OR_DIR ("adm/templates/sample.bat" "${CMAKE_BINARY_DIR}")
endif()
endif()
endforeach()
+if (BUILD_MODULE_QtSamples)
+ FILE_TO_LIST ("adm/SAMPLES_RESOURCES" SAMPLES_RESOURCES)
+ foreach(RESOURCE ${SAMPLES_RESOURCES})
+ OCCT_INSTALL_FILE_OR_DIR ("samples/${RESOURCE}" "${INSTALL_DIR_RESOURCE}/samples")
+ #message("Copy Sample resources: samples/${RESOURCE} into ${INSTALL_DIR_RESOURCE}/samples")
+ endforeach()
+endif()
+
+
# patch installed DrawDefault file if BUILD_SHARED_LIBRARY_NAME_POSTFIX is changed
if (NOT "${BUILD_SHARED_LIBRARY_NAME_POSTFIX}" STREQUAL "")
OCCT_UPDATE_DRAW_DEFAULT_FILE()
message (STATUS "Info: \(${CURRENT_TIME}\) OCCT toolkits processed")
# samples do not support patch usage
-if (BUILD_MODULE_MfcSamples)
+if (BUILD_MODULE_MfcSamples OR BUILD_MODULE_QtSamples)
set (OCCT_ROOT ${CMAKE_SOURCE_DIR})
+endif()
+if (BUILD_MODULE_MfcSamples)
set (MFC_STANDARD_SAMPLES_DIR ${OCCT_ROOT}/samples/mfc/standard)
set (COMMON_WINMAIN_FILE ${MFC_STANDARD_SAMPLES_DIR}/Common/Winmain.cpp)
message (STATUS "Info: \(${CURRENT_TIME}\) MFC Sample projects added")
endif()
+OCCT_MODULES_AND_TOOLKITS (SAMPLES "SAMPLES_TOOLKITS" OCCT_SAMPLES)
+
+if (BUILD_MODULE_QtSamples)
+ if (NOT Qt5_FOUND OR NOT USE_GLES2)
+ list (REMOVE_ITEM qt_SAMPLES_TOOLKITS AndroidQt)
+ message (STATUS "Info: AndroidQt sample excluded due to Qt5 or GLES2 usage are disabled")
+ endif()
+
+ if (NOT BUILD_Inspector)
+ list (REMOVE_ITEM tools_SAMPLES_TOOLKITS TInspectorEXE)
+ message (STATUS "Info: TInspectorEXE sample excluded due to BUILD_Inspector is disabled")
+ endif()
+
+ foreach (OCCT_SAMPLE ${OCCT_SAMPLES})
+ list (APPEND BUILD_SAMPLE_TOOLKITS ${${OCCT_SAMPLE}_SAMPLES_TOOLKITS})
+
+ # collect all the headers to <binary dir>/inc/samples folder
+ string(TIMESTAMP CURRENT_TIME "%H:%M:%S")
+ message (STATUS "Info: \(${CURRENT_TIME}\) ${OCCT_SAMPLE} Sample projects added")
+
+ # include patched toolkit projects or original ones
+ foreach (BUILD_SAMPLE_TOOLKIT ${${OCCT_SAMPLE}_SAMPLES_TOOLKITS})
+ OCCT_ADD_SUBDIRECTORY ("samples/${OCCT_SAMPLE}/${BUILD_SAMPLE_TOOLKIT}")
+ endforeach()
+ endforeach()
+endif()
+
if (BUILD_MODULE_UwpSample)
add_subdirectory(samples/xaml)
endif()
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE)
endif()
- set (BUILD_SAMPLE_TOOLKITS TInspectorEXE)
- foreach (BUILD_SAMPLE_TOOL_TOOLKIT ${BUILD_SAMPLE_TOOLKITS})
- OCCT_ADD_SUBDIRECTORY ("samples/tools/${BUILD_SAMPLE_TOOL_TOOLKIT}")
- endforeach()
-
# patch TInspectorEXE
OCCT_CONFIGURE ("adm/templates/TInspectorEXE.vcxproj.user.in" "${CMAKE_BINARY_DIR}/samples/tools/TInspectorEXE/TInspectorEXE.vcxproj.user")
endif()
--- /dev/null
+qt AndroidQt FuncDemo IESample Tutorial
+tools TInspectorEXE
\ No newline at end of file
--- /dev/null
+qt/Common/res/
+qt/Tutorial/res/
\ No newline at end of file
set (${TOOLKIT_FULL_DEPS} ${LOCAL_TOOLKIT_FULL_DEPS} PARENT_SCOPE)
endfunction()
-# Function to get list of modules and toolkits from file adm/MODULES.
+# Function to get list of modules/toolkits/samples from file adm/${FILE_NAME}.
# Creates list <$MODULE_LIST> to store list of MODULES and
-# <NAME_OF_MODULE>_TOOLKITS foreach module to store its toolkits.
-function (OCCT_MODULES_AND_TOOLKITS MODULE_LIST)
- FILE_TO_LIST ("adm/MODULES" FILE_CONTENT)
+# <NAME_OF_MODULE>_TOOLKITS foreach module to store its toolkits, where "TOOLKITS" is defined by TOOLKITS_NAME_SUFFIX.
+function (OCCT_MODULES_AND_TOOLKITS FILE_NAME TOOLKITS_NAME_SUFFIX MODULE_LIST)
+ FILE_TO_LIST ("adm/${FILE_NAME}" FILE_CONTENT)
foreach (CONTENT_LINE ${FILE_CONTENT})
string (REPLACE " " ";" CONTENT_LINE ${CONTENT_LINE})
list (REMOVE_AT CONTENT_LINE 0)
list (APPEND ${MODULE_LIST} ${MODULE_NAME})
# (!) REMOVE THE LINE BELOW (implicit variables)
- set (${MODULE_NAME}_TOOLKITS ${CONTENT_LINE} PARENT_SCOPE)
+ set (${MODULE_NAME}_${TOOLKITS_NAME_SUFFIX} ${CONTENT_LINE} PARENT_SCOPE)
endforeach()
set (${MODULE_LIST} ${${MODULE_LIST}} PARENT_SCOPE)
endfunction()
-# Function to get list of tools and toolkits from file adm/TOOLS.
-# Creates list <$TOOL_LIST> to store list of TOOLS and
-# <NAME_OF_TOOL>_TOOLKITS foreach tool to store its toolkits.
-function (OCCT_TOOLS_AND_TOOLKITS TOOL_LIST)
- FILE_TO_LIST ("adm/TOOLS" FILE_CONTENT)
-
- foreach (CONTENT_LINE ${FILE_CONTENT})
- string (REPLACE " " ";" CONTENT_LINE ${CONTENT_LINE})
- list (GET CONTENT_LINE 0 TOOL_NAME)
- list (REMOVE_AT CONTENT_LINE 0)
- list (APPEND ${TOOL_LIST} ${TOOL_NAME})
- # (!) REMOVE THE LINE BELOW (implicit variables)
- set (${TOOL_NAME}_TOOL_TOOLKITS ${CONTENT_LINE} PARENT_SCOPE)
- endforeach()
-
- set (${TOOL_LIST} ${${TOOL_LIST}} PARENT_SCOPE)
-endfunction()
-
# Returns OCC version string from file Standard_Version.hxx (if available)
function (OCC_VERSION OCC_VERSION_MAJOR OCC_VERSION_MINOR OCC_VERSION_MAINTENANCE OCC_VERSION_DEVELOPMENT OCC_VERSION_STRING_EXT)
# script for each OCCT toolkit
+# filling some variables by default values(src) or using custom(tools, samples)
+set (RELATIVE_SOURCES_DIR "${RELATIVE_DIR}")
+if ("${RELATIVE_SOURCES_DIR}" STREQUAL "")
+ #if it is not defined, use default directory
+ set (RELATIVE_SOURCES_DIR "src")
+endif()
+
+set (OCC_MODULES_LIST "${MODULES_LIST}")
+if ("${OCC_MODULES_LIST}" STREQUAL "")
+ set (OCC_MODULES_LIST ${OCCT_MODULES})
+endif()
+
+set (OCC_TARGET_FOLDER "${TARGET_FOLDER}")
+if ("${OCC_TARGET_FOLDER}" STREQUAL "")
+ set (OCC_TARGET_FOLDER "Modules")
+endif()
+
+set (OCCT_TOOLKITS_NAME_SUFFIX "${TOOLKITS_NAME_SUFFIX}")
+if ("${OCCT_TOOLKITS_NAME_SUFFIX}" STREQUAL "")
+ set (OCCT_TOOLKITS_NAME_SUFFIX "TOOLKITS")
+endif()
+
# parce PACKAGES file
-if ("${PROJECT_NAME}" STREQUAL DRAWEXE)
- set (USED_PACKAGES DRAWEXE)
-else()
- FILE_TO_LIST ("src/${PROJECT_NAME}/PACKAGES" USED_PACKAGES)
+FILE_TO_LIST ("${RELATIVE_SOURCES_DIR}/${PROJECT_NAME}/PACKAGES" USED_PACKAGES)
+if ("${USED_PACKAGES}" STREQUAL "")
+ set (USED_PACKAGES ${PROJECT_NAME})
endif()
+if (USE_QT)
+ # Qt dependencies
+ OCCT_INCLUDE_CMAKE_FILE (adm/cmake/qt_macro)
+ FIND_QT_PACKAGE(PROJECT_LIBRARIES_DEBUG PROJECT_LIBRARIES_RELEASE PROJECT_INCLUDES)
+ include_directories("${PROJECT_INCLUDES}")
+endif(USE_QT)
+
set (PRECOMPILED_DEFS)
if (NOT BUILD_SHARED_LIBS)
endif()
# Get all used packages from toolkit
+UNSET(RESOURCE_FILES)
foreach (OCCT_PACKAGE ${USED_PACKAGES})
-
+
+ #remove part after "/" in the OCCT_PACKAGE variable if exists
+ string (FIND "${OCCT_PACKAGE}" "/" _index)
+ if (_index GREATER -1)
+ math (EXPR _index "${_index}")
+ string (SUBSTRING "${OCCT_PACKAGE}" 0 ${_index} OCCT_PACKAGE_NAME)
+ else()
+ set (OCCT_PACKAGE_NAME "${OCCT_PACKAGE}")
+ endif()
+
# TKService contains platform-dependent packages: Xw and WNT
if ((WIN32 AND "${OCCT_PACKAGE}" STREQUAL "Xw") OR (NOT WIN32 AND "${OCCT_PACKAGE}" STREQUAL "WNT"))
# do nothing
else()
-# if (WIN32)
-# list (APPEND PRECOMPILED_DEFS "-D__${OCCT_PACKAGE}_DLL")
-# endif()
+ if (WIN32)
+ list (APPEND PRECOMPILED_DEFS "-D__${OCCT_PACKAGE_NAME}_DLL")
+ endif()
set (SOURCE_FILES)
set (HEADER_FILES)
if (${BUILD_YACCLEX})
# flex files
- OCCT_ORIGIN_AND_PATCHED_FILES ("src/${OCCT_PACKAGE}" "*[.]lex" SOURCE_FILES_FLEX)
+ OCCT_ORIGIN_AND_PATCHED_FILES ("${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}" "*[.]lex" SOURCE_FILES_FLEX)
list (LENGTH SOURCE_FILES_FLEX SOURCE_FILES_FLEX_LEN)
# bison files
- OCCT_ORIGIN_AND_PATCHED_FILES ("src/${OCCT_PACKAGE}" "*[.]yacc" SOURCE_FILES_BISON)
+ OCCT_ORIGIN_AND_PATCHED_FILES ("${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}" "*[.]yacc" SOURCE_FILES_BISON)
list (LENGTH SOURCE_FILES_BISON SOURCE_FILES_BISON_LEN)
if (${SOURCE_FILES_FLEX_LEN} EQUAL ${SOURCE_FILES_BISON_LEN} AND NOT ${SOURCE_FILES_FLEX_LEN} EQUAL 0)
if (EXISTS "${CURRENT_FLEX_FILE}" AND EXISTS "${CURRENT_BISON_FILE}" AND ${ARE_FILES_EQUAL})
set (BISON_OUTPUT_FILE ${CURRENT_BISON_FILE_NAME}.tab.c)
set (FLEX_OUTPUT_FILE lex.${CURRENT_FLEX_FILE_NAME}.c)
- BISON_TARGET (Parser_${CURRENT_BISON_FILE_NAME} ${CURRENT_BISON_FILE} ${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/${BISON_OUTPUT_FILE} COMPILE_FLAGS "-p ${CURRENT_BISON_FILE_NAME}")
- FLEX_TARGET (Scanner_${CURRENT_FLEX_FILE_NAME} ${CURRENT_FLEX_FILE} ${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/${FLEX_OUTPUT_FILE} COMPILE_FLAGS "-P${CURRENT_FLEX_FILE_NAME}")
+ BISON_TARGET (Parser_${CURRENT_BISON_FILE_NAME} ${CURRENT_BISON_FILE} ${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${BISON_OUTPUT_FILE} COMPILE_FLAGS "-p ${CURRENT_BISON_FILE_NAME}")
+ FLEX_TARGET (Scanner_${CURRENT_FLEX_FILE_NAME} ${CURRENT_FLEX_FILE} ${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${FLEX_OUTPUT_FILE} COMPILE_FLAGS "-P${CURRENT_FLEX_FILE_NAME}")
ADD_FLEX_BISON_DEPENDENCY (Scanner_${CURRENT_FLEX_FILE_NAME} Parser_${CURRENT_BISON_FILE_NAME})
list (APPEND SOURCE_FILES ${BISON_OUTPUT_FILE} ${FLEX_OUTPUT_FILE})
endif()
# header files
- if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/src/${OCCT_PACKAGE}/FILES")
- file (STRINGS "${BUILD_PATCH}/src/${OCCT_PACKAGE}/FILES" HEADER_FILES_M REGEX ".+[.]h")
- file (STRINGS "${BUILD_PATCH}/src/${OCCT_PACKAGE}/FILES" HEADER_FILES_LXX REGEX ".+[.]lxx")
- file (STRINGS "${BUILD_PATCH}/src/${OCCT_PACKAGE}/FILES" HEADER_FILES_GXX REGEX ".+[.]gxx")
+ if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES")
+ file (STRINGS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" HEADER_FILES_M REGEX ".+[.]h")
+ file (STRINGS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" HEADER_FILES_LXX REGEX ".+[.]lxx")
+ file (STRINGS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" HEADER_FILES_GXX REGEX ".+[.]gxx")
- file (STRINGS "${BUILD_PATCH}/src/${OCCT_PACKAGE}/FILES" SOURCE_FILES_C REGEX ".+[.]c")
+ file (STRINGS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" SOURCE_FILES_C REGEX ".+[.]c")
if(APPLE)
- file (STRINGS "${BUILD_PATCH}/src/${OCCT_PACKAGE}/FILES" SOURCE_FILES_M REGEX ".+[.]mm")
+ file (STRINGS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" SOURCE_FILES_M REGEX ".+[.]mm")
endif()
else()
- file (STRINGS "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/FILES" HEADER_FILES_M REGEX ".+[.]h")
- file (STRINGS "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/FILES" HEADER_FILES_LXX REGEX ".+[.]lxx")
- file (STRINGS "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/FILES" HEADER_FILES_GXX REGEX ".+[.]gxx")
+ file (STRINGS "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" HEADER_FILES_M REGEX ".+[.]h")
+ file (STRINGS "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" HEADER_FILES_LXX REGEX ".+[.]lxx")
+ file (STRINGS "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" HEADER_FILES_GXX REGEX ".+[.]gxx")
- file (STRINGS "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/FILES" SOURCE_FILES_C REGEX ".+[.]c")
+ file (STRINGS "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" SOURCE_FILES_C REGEX ".+[.]c")
if(APPLE)
- file (STRINGS "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/FILES" SOURCE_FILES_M REGEX ".+[.]mm")
+ file (STRINGS "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" SOURCE_FILES_M REGEX ".+[.]mm")
endif()
endif()
endif()
foreach(HEADER_FILE ${HEADER_FILES})
- if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/src/${OCCT_PACKAGE}/${HEADER_FILE}")
- message (STATUS "Info: consider patched file: ${BUILD_PATCH}/src/${OCCT_PACKAGE}/${HEADER_FILE}")
- list (APPEND USED_INCFILES "${BUILD_PATCH}/src/${OCCT_PACKAGE}/${HEADER_FILE}")
- SOURCE_GROUP ("Header Files\\${OCCT_PACKAGE}" FILES "${BUILD_PATCH}/src/${OCCT_PACKAGE}/${HEADER_FILE}")
+ if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${HEADER_FILE}")
+ message (STATUS "Info: consider patched file: ${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${HEADER_FILE}")
+ list (APPEND USED_INCFILES "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${HEADER_FILE}")
+ SOURCE_GROUP ("Header Files\\${OCCT_PACKAGE_NAME}" FILES "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${HEADER_FILE}")
else()
- list (APPEND USED_INCFILES "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/${HEADER_FILE}")
- SOURCE_GROUP ("Header Files\\${OCCT_PACKAGE}" FILES "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/${HEADER_FILE}")
+ list (APPEND USED_INCFILES "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${HEADER_FILE}")
+ SOURCE_GROUP ("Header Files\\${OCCT_PACKAGE_NAME}" FILES "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${HEADER_FILE}")
endif()
endforeach()
foreach(SOURCE_FILE ${SOURCE_FILES})
- if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/src/${OCCT_PACKAGE}/${SOURCE_FILE}")
- message (STATUS "Info: consider patched file: ${BUILD_PATCH}/src/${OCCT_PACKAGE}/${SOURCE_FILE}")
- list (APPEND USED_SRCFILES "${BUILD_PATCH}/src/${OCCT_PACKAGE}/${SOURCE_FILE}")
- SOURCE_GROUP ("Source Files\\${OCCT_PACKAGE}" FILES "${BUILD_PATCH}/src/${OCCT_PACKAGE}/${SOURCE_FILE}")
+ if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${SOURCE_FILE}")
+ message (STATUS "Info: consider patched file: ${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${SOURCE_FILE}")
+ list (APPEND USED_SRCFILES "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${SOURCE_FILE}")
+ SOURCE_GROUP ("Source Files\\${OCCT_PACKAGE_NAME}" FILES "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${SOURCE_FILE}")
else()
- list (APPEND USED_SRCFILES "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/${SOURCE_FILE}")
- SOURCE_GROUP ("Source Files\\${OCCT_PACKAGE}" FILES "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/${SOURCE_FILE}")
+ list (APPEND USED_SRCFILES "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${SOURCE_FILE}")
+ SOURCE_GROUP ("Source Files\\${OCCT_PACKAGE_NAME}" FILES "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${SOURCE_FILE}")
endif()
endforeach()
+
+ if (USE_QT)
+ FIND_AND_INSTALL_QT_RESOURCES (${OCCT_PACKAGE} RESOURCE_FILES)
+ #message("Qt Resource files are: ${QT_RESOURCE_FILES} in ${OCCT_PACKAGE}")
+ endif(USE_QT)
+
+ #message("Resource files are: ${RESOURCE_FILES} in ${OCCT_PACKAGE}")
+ foreach(RESOURCE_FILE ${RESOURCE_FILES})
+ SOURCE_GROUP ("Resource Files\\${OCCT_PACKAGE_NAME}" FILES "${RESOURCE_FILE}")
+ endforeach()
endif()
endforeach()
string (REGEX REPLACE ";" " " PRECOMPILED_DEFS "${PRECOMPILED_DEFS}")
endif()
set (CURRENT_MODULE)
-foreach (OCCT_MODULE ${OCCT_MODULES})
- list (FIND ${OCCT_MODULE}_TOOLKITS ${PROJECT_NAME} CURRENT_PROJECT_IS_BUILT)
+foreach (OCCT_MODULE ${OCC_MODULES_LIST})
+ list (FIND ${OCCT_MODULE}_${OCCT_TOOLKITS_NAME_SUFFIX} ${PROJECT_NAME} CURRENT_PROJECT_IS_BUILT)
+
if (NOT ${CURRENT_PROJECT_IS_BUILT} EQUAL -1)
set (CURRENT_MODULE ${OCCT_MODULE})
endif()
OCCT_INSERT_CODE_FOR_TARGET ()
endif()
-if ("${PROJECT_NAME}" STREQUAL "DRAWEXE")
- add_executable (${PROJECT_NAME} ${USED_SRCFILES} ${USED_INCFILES} ${USED_RCFILE})
+if (USE_QT)
+ FIND_AND_WRAP_MOC_FILES("${USED_INCFILES}" "${PROJECT_NAME}_MOC_FILES")
+ #message("MOC files: ${${PROJECT_NAME}_MOC_FILES}")
+endif (USE_QT)
+
+if (EXECUTABLE_PROJECT)
+ add_executable (${PROJECT_NAME} ${USED_SRCFILES} ${USED_INCFILES} ${USED_RCFILE} ${RESOURCE_FILES} ${${PROJECT_NAME}_MOC_FILES})
install (TARGETS ${PROJECT_NAME}
DESTINATION "${INSTALL_DIR_BIN}\${OCCT_INSTALL_BIN_LETTER}")
else()
- add_library (${PROJECT_NAME} ${USED_SRCFILES} ${USED_INCFILES} ${USED_RCFILE})
+ add_library (${PROJECT_NAME} ${USED_SRCFILES} ${USED_INCFILES} ${USED_RCFILE} ${RESOURCE_FILES} ${${PROJECT_NAME}_MOC_FILES})
if (MSVC)
install (FILES ${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin\${OCCT_INSTALL_BIN_LETTER}/${PROJECT_NAME}.pdb
endif()
if (CURRENT_MODULE)
- set_target_properties (${PROJECT_NAME} PROPERTIES FOLDER "Modules/${CURRENT_MODULE}")
+ set_target_properties (${PROJECT_NAME} PROPERTIES FOLDER "${OCC_TARGET_FOLDER}/${CURRENT_MODULE}")
set_target_properties (${PROJECT_NAME} PROPERTIES MODULE "${CURRENT_MODULE}")
if (APPLE)
if (NOT "${INSTALL_NAME_DIR}" STREQUAL "")
set (USED_EXTERNAL_LIBS_BY_CURRENT_PROJECT)
# parce EXTERNLIB file
-FILE_TO_LIST ("src/${PROJECT_NAME}/EXTERNLIB" USED_EXTERNLIB_AND_TOOLKITS)
+FILE_TO_LIST ("${RELATIVE_SOURCES_DIR}/${PROJECT_NAME}/EXTERNLIB" USED_EXTERNLIB_AND_TOOLKITS)
foreach (USED_ITEM ${USED_EXTERNLIB_AND_TOOLKITS})
string (REGEX MATCH "^ *#" COMMENT_FOUND ${USED_ITEM})
if (NOT COMMENT_FOUND)
target_link_libraries (${PROJECT_NAME} ${USED_TOOLKITS_BY_CURRENT_PROJECT} ${USED_EXTERNAL_LIBS_BY_CURRENT_PROJECT})
endif()
+if (USE_QT)
+ foreach (PROJECT_LIBRARY_DEBUG ${PROJECT_LIBRARIES_DEBUG})
+ target_link_libraries (${PROJECT_NAME} debug ${PROJECT_LIBRARY_DEBUG})
+ endforeach()
+ foreach (PROJECT_LIBRARY_RELEASE ${PROJECT_LIBRARIES_RELEASE})
+ target_link_libraries (${PROJECT_NAME} optimized ${PROJECT_LIBRARY_RELEASE})
+ endforeach()
+endif()
+
# suppress deprecation warnings inside OCCT itself for old gcc versions with unavailable Standard_DISABLE_DEPRECATION_WARNINGS
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.6.0)
--- /dev/null
+if ("${TARGET_FOLDER}" STREQUAL "")
+ set (EXECUTABLE_PROJECT ON)
+ set (USE_QT ON)
+
+ set (RELATIVE_DIR "samples/qt")
+ set (MODULES_LIST ${OCCT_SAMPLES})
+ set (TARGET_FOLDER "Samples")
+ set (TOOLKITS_NAME_SUFFIX "SAMPLES_TOOLKITS")
+
+ include_directories("${CMAKE_BINARY_DIR}/${INSTALL_DIR_INCLUDE}/${RELATIVE_DIR}")
+else()
+ unset (USE_QT)
+ unset (RELATIVE_DIR)
+ unset (EXECUTABLE_PROJECT)
+ unset (MODULES_LIST)
+ unset (TARGET_FOLDER)
+ unset (TOOLKITS_NAME_SUFFIX)
+endif("${TARGET_FOLDER}" STREQUAL "")
--- /dev/null
+if ("${TARGET_FOLDER}" STREQUAL "")
+ set (USE_QT ON)
+ set (RELATIVE_DIR "tools")
+ set (MODULES_LIST ${OCCT_TOOLS})
+ set (TARGET_FOLDER "Tools")
+ set (TOOLKITS_NAME_SUFFIX "TOOL_TOOLKITS")
+else()
+ unset (USE_QT)
+ unset (RELATIVE_DIR)
+ unset (MODULES_LIST)
+ unset (TARGET_FOLDER)
+ unset (TOOLKITS_NAME_SUFFIX)
+endif("${TARGET_FOLDER}" STREQUAL "")
+++ /dev/null
-# script for each OCCT tool toolkit
-
-# Qt dependencies
-OCCT_INCLUDE_CMAKE_FILE (adm/cmake/qt_macro)
-
-FIND_QT_PACKAGE(PROJECT_LIBRARIES_DEBUG PROJECT_LIBRARIES_RELEASE PROJECT_INCLUDES)
-include_directories("${PROJECT_INCLUDES}"
- "${CMAKE_BINARY_DIR}/${INSTALL_DIR_INCLUDE}/tools")
-
-FILE_TO_LIST ("tools/${PROJECT_NAME}/PACKAGES" USED_PACKAGES)
-# parce PACKAGES file
-
-if ("${PROJECT_NAME}" STREQUAL TInspectorEXE)
- set (USED_PACKAGES ${PROJECT_NAME})
- set (PACKAGE_PREFIX_DIR "samples/tools")
- include_directories("${PROJECT_INCLUDES}"
- "${CMAKE_SOURCE_DIR}/${PACKAGE_PREFIX_DIR}/${PROJECT_NAME}")
-else()
- FILE_TO_LIST ("tools/${PROJECT_NAME}/PACKAGES" USED_PACKAGES)
- set (PACKAGE_PREFIX_DIR "tools")
-endif()
-
-
-SET (RCC_FILES)
-foreach (OCCT_PACKAGE ${USED_PACKAGES})
- #message("Dir is ${CMAKE_SOURCE_DIR}/${PACKAGE_PREFIX_DIR}/${OCCT_PACKAGE}/${OCCT_PACKAGE}.qrc")
- FIND_AND_WRAP_RESOURCE_FILE("${CMAKE_SOURCE_DIR}/${PACKAGE_PREFIX_DIR}/${OCCT_PACKAGE}/${OCCT_PACKAGE}.qrc" RCC_FILES)
-endforeach()
-#message("RCC_FILES for ${PROJECT_NAME} are ${RCC_FILES}")
-
-set (PRECOMPILED_DEFS)
-
-if (NOT BUILD_SHARED_LIBS)
- list (APPEND PRECOMPILED_DEFS "-DOCCT_NO_PLUGINS")
- if (WIN32)
- list (APPEND PRECOMPILED_DEFS "-DOCCT_STATIC_BUILD")
- endif()
-endif()
-
-# Get all used packages from toolkit
-foreach (OCCT_PACKAGE ${USED_PACKAGES})
-
- ADD_DEFINITIONS(-D${OCCT_PACKAGE}_EXPORTS)
-
- # TKService contains platform-dependent packages: Xw and WNT
- if ((WIN32 AND "${OCCT_PACKAGE}" STREQUAL "Xw") OR (NOT WIN32 AND "${OCCT_PACKAGE}" STREQUAL "WNT"))
- # do nothing
- else()
-
-# if (WIN32)
-# list (APPEND PRECOMPILED_DEFS "-D__${OCCT_PACKAGE}_DLL")
-# endif()
-
- set (SOURCE_FILES)
- set (HEADER_FILES)
-
- # Generate Flex and Bison files
- if (${BUILD_YACCLEX})
-
- # flex files
- OCCT_ORIGIN_AND_PATCHED_FILES ("tools/${OCCT_PACKAGE}" "*[.]lex" SOURCE_FILES_FLEX)
- list (LENGTH SOURCE_FILES_FLEX SOURCE_FILES_FLEX_LEN)
-
- # bison files
- OCCT_ORIGIN_AND_PATCHED_FILES ("tools/${OCCT_PACKAGE}" "*[.]yacc" SOURCE_FILES_BISON)
- list (LENGTH SOURCE_FILES_BISON SOURCE_FILES_BISON_LEN)
-
- if (${SOURCE_FILES_FLEX_LEN} EQUAL ${SOURCE_FILES_BISON_LEN} AND NOT ${SOURCE_FILES_FLEX_LEN} EQUAL 0)
-
- list (SORT SOURCE_FILES_FLEX)
- list (SORT SOURCE_FILES_BISON)
-
- math (EXPR SOURCE_FILES_FLEX_LEN "${SOURCE_FILES_FLEX_LEN} - 1")
- foreach (FLEX_FILE_INDEX RANGE ${SOURCE_FILES_FLEX_LEN})
-
- list (GET SOURCE_FILES_FLEX ${FLEX_FILE_INDEX} CURRENT_FLEX_FILE)
- get_filename_component (CURRENT_FLEX_FILE_NAME ${CURRENT_FLEX_FILE} NAME_WE)
-
- list (GET SOURCE_FILES_BISON ${FLEX_FILE_INDEX} CURRENT_BISON_FILE)
- get_filename_component (CURRENT_BISON_FILE_NAME ${CURRENT_BISON_FILE} NAME_WE)
-
- string (COMPARE EQUAL ${CURRENT_FLEX_FILE_NAME} ${CURRENT_BISON_FILE_NAME} ARE_FILES_EQUAL)
-
- if (EXISTS "${CURRENT_FLEX_FILE}" AND EXISTS "${CURRENT_BISON_FILE}" AND ${ARE_FILES_EQUAL})
- set (BISON_OUTPUT_FILE ${CURRENT_BISON_FILE_NAME}.tab.c)
- set (FLEX_OUTPUT_FILE lex.${CURRENT_FLEX_FILE_NAME}.c)
- BISON_TARGET (Parser_${CURRENT_BISON_FILE_NAME} ${CURRENT_BISON_FILE} ${CMAKE_SOURCE_DIR}/tools/${OCCT_PACKAGE}/${BISON_OUTPUT_FILE} COMPILE_FLAGS "-p ${CURRENT_BISON_FILE_NAME}")
- FLEX_TARGET (Scanner_${CURRENT_FLEX_FILE_NAME} ${CURRENT_FLEX_FILE} ${CMAKE_SOURCE_DIR}/tools/${OCCT_PACKAGE}/${FLEX_OUTPUT_FILE} COMPILE_FLAGS "-P${CURRENT_FLEX_FILE_NAME}")
- ADD_FLEX_BISON_DEPENDENCY (Scanner_${CURRENT_FLEX_FILE_NAME} Parser_${CURRENT_BISON_FILE_NAME})
-
- list (APPEND SOURCE_FILES ${BISON_OUTPUT_FILE} ${FLEX_OUTPUT_FILE})
- endif()
- endforeach()
- endif()
- endif()
-
- # header files
- if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/tools/${OCCT_PACKAGE}/FILES")
- file (STRINGS "${BUILD_PATCH}/tools/${OCCT_PACKAGE}/FILES" HEADER_FILES_M REGEX ".+[.]h")
- file (STRINGS "${BUILD_PATCH}/tools/${OCCT_PACKAGE}/FILES" HEADER_FILES_LXX REGEX ".+[.]lxx")
- file (STRINGS "${BUILD_PATCH}/tools/${OCCT_PACKAGE}/FILES" HEADER_FILES_GXX REGEX ".+[.]gxx")
-
- file (STRINGS "${BUILD_PATCH}/tools/${OCCT_PACKAGE}/FILES" SOURCE_FILES_C REGEX ".+[.]c")
- if(APPLE)
- file (STRINGS "${BUILD_PATCH}/tools/${OCCT_PACKAGE}/FILES" SOURCE_FILES_M REGEX ".+[.]mm")
- endif()
- else()
- file (STRINGS "${CMAKE_SOURCE_DIR}/${PACKAGE_PREFIX_DIR}/${OCCT_PACKAGE}/FILES" HEADER_FILES_M REGEX ".+[.]h")
- file (STRINGS "${CMAKE_SOURCE_DIR}/${PACKAGE_PREFIX_DIR}/${OCCT_PACKAGE}/FILES" HEADER_FILES_LXX REGEX ".+[.]lxx")
- file (STRINGS "${CMAKE_SOURCE_DIR}/${PACKAGE_PREFIX_DIR}/${OCCT_PACKAGE}/FILES" HEADER_FILES_GXX REGEX ".+[.]gxx")
-
- file (STRINGS "${CMAKE_SOURCE_DIR}/${PACKAGE_PREFIX_DIR}/${OCCT_PACKAGE}/FILES" SOURCE_FILES_C REGEX ".+[.]c")
- if(APPLE)
- file (STRINGS "${CMAKE_SOURCE_DIR}/${PACKAGE_PREFIX_DIR}/${OCCT_PACKAGE}/FILES" SOURCE_FILES_M REGEX ".+[.]mm")
- endif()
- endif()
-
-
-
- list (APPEND HEADER_FILES ${HEADER_FILES_M} ${HEADER_FILES_LXX} ${SOURCE_FILES_GXX})
- list (APPEND SOURCE_FILES ${SOURCE_FILES_C})
- if(APPLE)
- list (APPEND SOURCE_FILES ${SOURCE_FILES_M})
- endif()
-
- foreach(HEADER_FILE ${HEADER_FILES})
- if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/tools/${OCCT_PACKAGE}/${HEADER_FILE}")
- message (STATUS "Info: consider patched file: ${BUILD_PATCH}/tools/${OCCT_PACKAGE}/${HEADER_FILE}")
- list (APPEND USED_INCFILES "${BUILD_PATCH}/tools/${OCCT_PACKAGE}/${HEADER_FILE}")
- SOURCE_GROUP ("Header Files\\${OCCT_PACKAGE}" FILES "${BUILD_PATCH}/tools/${OCCT_PACKAGE}/${HEADER_FILE}")
- else()
- list (APPEND USED_INCFILES "${CMAKE_SOURCE_DIR}/${PACKAGE_PREFIX_DIR}/${OCCT_PACKAGE}/${HEADER_FILE}")
- SOURCE_GROUP ("Header Files\\${OCCT_PACKAGE}" FILES "${CMAKE_SOURCE_DIR}/${PACKAGE_PREFIX_DIR}/${OCCT_PACKAGE}/${HEADER_FILE}")
- endif()
- endforeach()
-
-
- foreach(SOURCE_FILE ${SOURCE_FILES})
- if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/tools/${OCCT_PACKAGE}/${SOURCE_FILE}")
- message (STATUS "Info: consider patched file: ${BUILD_PATCH}/tools/${OCCT_PACKAGE}/${SOURCE_FILE}")
- list (APPEND USED_SRCFILES "${BUILD_PATCH}/tools/${OCCT_PACKAGE}/${SOURCE_FILE}")
- SOURCE_GROUP ("Source Files\\${OCCT_PACKAGE}" FILES "${BUILD_PATCH}/tools/${OCCT_PACKAGE}/${SOURCE_FILE}")
- else()
- list (APPEND USED_SRCFILES "${CMAKE_SOURCE_DIR}/${PACKAGE_PREFIX_DIR}/${OCCT_PACKAGE}/${SOURCE_FILE}")
- SOURCE_GROUP ("Source Files\\${OCCT_PACKAGE}" FILES "${CMAKE_SOURCE_DIR}/${PACKAGE_PREFIX_DIR}/${OCCT_PACKAGE}/${SOURCE_FILE}")
- endif()
- endforeach()
- endif()
-endforeach()
-string (REGEX REPLACE ";" " " PRECOMPILED_DEFS "${PRECOMPILED_DEFS}")
-
-set (USED_RCFILE "")
-if (MSVC)
- set (USED_RCFILE "${CMAKE_BINARY_DIR}/resources/${PROJECT_NAME}.rc")
-
- if (APPLY_OCCT_PATCH_DIR AND EXISTS "${APPLY_OCCT_PATCH_DIR}/adm/templates/occt_toolkit.rc.in")
- configure_file("${APPLY_OCCT_PATCH_DIR}/adm/templates/occt_toolkit.rc.in" "${USED_RCFILE}" @ONLY)
- else()
- configure_file("${CMAKE_SOURCE_DIR}/adm/templates/occt_toolkit.rc.in" "${USED_RCFILE}" @ONLY)
- endif()
-endif()
-
-set (CURRENT_MODULE)
-foreach (OCCT_MODULE ${OCCT_TOOLS})
- list (FIND ${OCCT_MODULE}_TOOL_TOOLKITS ${PROJECT_NAME} CURRENT_PROJECT_IS_BUILT)
- if (NOT ${CURRENT_PROJECT_IS_BUILT} EQUAL -1)
- set (CURRENT_MODULE ${OCCT_MODULE})
- endif()
-endforeach()
-
-if (WIN32)
- OCCT_INSERT_CODE_FOR_TARGET ()
-endif()
-
-FIND_AND_WRAP_MOC_FILES("${USED_INCFILES}" "${PROJECT_NAME}_MOC_FILES")
-#message("MOC files: ${${PROJECT_NAME}_MOC_FILES}")
-
-if ("${PROJECT_NAME}" STREQUAL TInspectorEXE)
- add_executable (${PROJECT_NAME} ${USED_SRCFILES} ${USED_INCFILES} ${USED_RCFILE} ${RCC_FILES} ${${PROJECT_NAME}_MOC_FILES})
-
- install (TARGETS ${PROJECT_NAME}
- DESTINATION "${INSTALL_DIR_BIN}\${OCCT_INSTALL_BIN_LETTER}")
-else()
- add_library (${PROJECT_NAME} ${USED_SRCFILES} ${USED_INCFILES} ${USED_RCFILE} ${RCC_FILES} ${${PROJECT_NAME}_MOC_FILES})
-
- if (MSVC)
- install (FILES ${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin\${OCCT_INSTALL_BIN_LETTER}/${PROJECT_NAME}.pdb
- CONFIGURATIONS Debug RelWithDebInfo
- DESTINATION "${INSTALL_DIR_BIN}\${OCCT_INSTALL_BIN_LETTER}")
- endif()
-
- if (BUILD_SHARED_LIBS AND NOT "${BUILD_SHARED_LIBRARY_NAME_POSTFIX}" STREQUAL "")
- set (CMAKE_SHARED_LIBRARY_SUFFIX_DEFAULT ${CMAKE_SHARED_LIBRARY_SUFFIX})
- set (CMAKE_SHARED_LIBRARY_SUFFIX "${BUILD_SHARED_LIBRARY_NAME_POSTFIX}${CMAKE_SHARED_LIBRARY_SUFFIX}")
- endif()
-
- install (TARGETS ${PROJECT_NAME}
- EXPORT OpenCASCADE${CURRENT_MODULE}Targets
- RUNTIME DESTINATION "${INSTALL_DIR_BIN}\${OCCT_INSTALL_BIN_LETTER}"
- ARCHIVE DESTINATION "${INSTALL_DIR_LIB}\${OCCT_INSTALL_BIN_LETTER}"
- LIBRARY DESTINATION "${INSTALL_DIR_LIB}\${OCCT_INSTALL_BIN_LETTER}")
-
-
- if (NOT WIN32)
- if (BUILD_SHARED_LIBS AND NOT "${BUILD_SHARED_LIBRARY_NAME_POSTFIX}" STREQUAL "")
- set (LINK_NAME "${INSTALL_DIR}/${INSTALL_DIR_LIB}\${OCCT_INSTALL_BIN_LETTER}/lib${PROJECT_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX_DEFAULT}/tools")
- set (LIBRARY_NAME "${INSTALL_DIR}/${INSTALL_DIR_LIB}\${OCCT_INSTALL_BIN_LETTER}/lib${PROJECT_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}/tools")
- OCCT_CREATE_SYMLINK_TO_FILE (${LIBRARY_NAME} ${LINK_NAME})
- endif()
- endif()
-endif()
-
-if (CURRENT_MODULE)
- set_target_properties (${PROJECT_NAME} PROPERTIES FOLDER "Tools/${CURRENT_MODULE}")
- set_target_properties (${PROJECT_NAME} PROPERTIES MODULE "${CURRENT_MODULE}")
- if (APPLE)
- if (NOT "${INSTALL_NAME_DIR}" STREQUAL "")
- set_target_properties (${PROJECT_NAME} PROPERTIES BUILD_WITH_INSTALL_RPATH 1 INSTALL_NAME_DIR "${INSTALL_NAME_DIR}")
- endif()
- endif()
-endif()
-
-get_property (OCC_VERSION_MAJOR GLOBAL PROPERTY OCC_VERSION_MAJOR)
-get_property (OCC_VERSION_MINOR GLOBAL PROPERTY OCC_VERSION_MINOR)
-get_property (OCC_VERSION_MAINTENANCE GLOBAL PROPERTY OCC_VERSION_MAINTENANCE)
-
-if (ANDROID)
- # do not append version to the filename
- set_target_properties (${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${PRECOMPILED_DEFS}")
-else()
- set_target_properties (${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${PRECOMPILED_DEFS}"
- SOVERSION "${OCC_VERSION_MAJOR}"
- VERSION "${OCC_VERSION_MAJOR}.${OCC_VERSION_MINOR}.${OCC_VERSION_MAINTENANCE}")
-endif()
-
-set (USED_TOOLKITS_BY_CURRENT_PROJECT)
-set (USED_EXTERNAL_LIBS_BY_CURRENT_PROJECT)
-
-# parce EXTERNLIB file
-FILE_TO_LIST ("${PACKAGE_PREFIX_DIR}/${PROJECT_NAME}/EXTERNLIB" USED_EXTERNLIB_AND_TOOLKITS)
-foreach (USED_ITEM ${USED_EXTERNLIB_AND_TOOLKITS})
- string (REGEX MATCH "^ *#" COMMENT_FOUND ${USED_ITEM})
- if (NOT COMMENT_FOUND)
- string (REGEX MATCH "^TK" TK_FOUND ${USED_ITEM})
- string (REGEX MATCH "^vtk" VTK_FOUND ${USED_ITEM})
-
- if (NOT "${TK_FOUND}" STREQUAL "" OR NOT "${VTK_FOUND}" STREQUAL "")
- list (APPEND USED_TOOLKITS_BY_CURRENT_PROJECT ${USED_ITEM})
- if (NOT "${VTK_FOUND}" STREQUAL "" AND BUILD_SHARED_LIBS AND INSTALL_VTK AND COMMAND OCCT_INSTALL_VTK)
- OCCT_INSTALL_VTK(${USED_ITEM})
- endif()
- else()
- string (REGEX MATCH "^CSF_" CSF_FOUND ${USED_ITEM})
- if ("${CSF_FOUND}" STREQUAL "")
- message (STATUS "Info: ${USED_ITEM} from ${PROJECT_NAME} skipped due to it is empty")
- else() # get CSF_ value
- set (CURRENT_CSF ${${USED_ITEM}})
- if (NOT "x${CURRENT_CSF}" STREQUAL "x")
- # prepare a list from a string with whitespaces
- separate_arguments (CURRENT_CSF)
- list (APPEND USED_EXTERNAL_LIBS_BY_CURRENT_PROJECT ${CURRENT_CSF})
- endif()
- endif()
- endif()
- endif()
-endforeach()
-
-if (APPLE)
- list (FIND USED_EXTERNAL_LIBS_BY_CURRENT_PROJECT X11 IS_X11_FOUND)
- if (NOT ${IS_X11_FOUND} EQUAL -1)
- find_package (X11 COMPONENTS X11 Xext Xmu Xi)
- if (NOT X11_FOUND)
- message (STATUS "Warning: X11 is not found. It's required to install The XQuartz project: http://www.xquartz.org")
- endif()
- endif()
-endif()
-
-# Update list of used VTK libraries if OpenGL2 Rendering BackEnd is used.
-# Add VTK_OPENGL2_BACKEND definition.
-if("${VTK_RENDERING_BACKEND}" STREQUAL "OpenGL2")
- add_definitions(-DVTK_OPENGL2_BACKEND)
- foreach (VTK_EXCLUDE_LIBRARY vtkRenderingOpenGL vtkRenderingFreeTypeOpenGL)
- list (FIND USED_TOOLKITS_BY_CURRENT_PROJECT "${VTK_EXCLUDE_LIBRARY}" IS_VTK_OPENGL_FOUND)
- if (NOT ${IS_VTK_OPENGL_FOUND} EQUAL -1)
- list (REMOVE_ITEM USED_TOOLKITS_BY_CURRENT_PROJECT ${VTK_EXCLUDE_LIBRARY})
- if (${VTK_EXCLUDE_LIBRARY} STREQUAL vtkRenderingOpenGL)
- list (APPEND USED_TOOLKITS_BY_CURRENT_PROJECT vtkRenderingOpenGL2)
- endif()
- endif()
- endforeach()
-endif()
-
-if (BUILD_SHARED_LIBS)
- target_link_libraries (${PROJECT_NAME} ${USED_TOOLKITS_BY_CURRENT_PROJECT} ${USED_EXTERNAL_LIBS_BY_CURRENT_PROJECT})
-endif()
-
-# Set Qt dependencies
-target_link_libraries(${PROJECT_NAME} "${PROJECT_LIBRARIES}")
-
-target_link_libraries(${PROJECT_NAME} debug "${PROJECT_LIBRARIES_DEBUG}")
-target_link_libraries(${PROJECT_NAME} optimized "${PROJECT_LIBRARIES_RELEASE}")
-
# Now we can apply standard CMake finder for Qt5. We do this mostly
# to have qt5_wrap_cpp() function available
- find_package(Qt5 QUIET COMPONENTS Widgets PATHS ${3RDPARTY_QT_DIR} NO_DEFAULT_PATH)
+ find_package(Qt5 QUIET COMPONENTS Widgets Quick PATHS ${3RDPARTY_QT_DIR} NO_DEFAULT_PATH)
if (${Qt5_FOUND})
#message (STATUS "Qt5 cmake configuration")
- set(PROJECT_INCLUDES "${Qt5Widgets_INCLUDE_DIRS}")
- set(PROJECT_LIBRARIES_DEBUG "${Qt5Widgets_LIBRARIES}")
- set(PROJECT_LIBRARIES_RELEASE "${Qt5Widgets_LIBRARIES}")
+ set(PROJECT_INCLUDES "${Qt5Widgets_INCLUDE_DIRS}" "${Qt5Quick_INCLUDE_DIRS}")
+ set(PROJECT_LIBRARIES_DEBUG "${Qt5Widgets_LIBRARIES}" "${Qt5Quick_LIBRARIES}")
+ set(PROJECT_LIBRARIES_RELEASE "${Qt5Widgets_LIBRARIES}" "${Qt5Quick_LIBRARIES}")
+
+ # processing *.ts files to generate *.qm
+ find_package(Qt5LinguistTools)
+ get_target_property(QT_LRELEASE_EXECUTABLE Qt5::lrelease LOCATION)
+ mark_as_advanced(QT_LRELEASE_EXECUTABLE)
+
+ GET_FILENAME_COMPONENT(QT_BINARY_DIR ${QT_LRELEASE_EXECUTABLE} DIRECTORY)
+ MARK_AS_ADVANCED(QT_BINARY_DIR)
else()
# Now we can apply standard CMake finder for Qt. We do this mostly
# to have qt4_wrap_cpp() function available
set(PROJECT_LIBRARIES_DEBUG "${3RDPARTY_QT_DIR}/lib/libQtCore.so;${3RDPARTY_QT_DIR}/lib/libQtGui.so")
set(PROJECT_LIBRARIES_RELEASE "${3RDPARTY_QT_DIR}/lib/libQtCore.so;${3RDPARTY_QT_DIR}/lib/libQtGui.so")
endif(WIN32)
+ find_program(QT_LRELEASE_EXECUTABLE lrelease)
endif()
endmacro()
endif()
endif()
endmacro()
+
+macro (FIND_AND_INSTALL_TS_FILE RESOURCE_FILE_NAME TARGET_FOLDER QM_FILES)
+ if(EXISTS "${RESOURCE_FILE_NAME}")
+ GET_FILENAME_COMPONENT(_name ${RESOURCE_FILE_NAME} NAME_WE)
+ SET(_output ${CMAKE_CURRENT_BINARY_DIR}/${_name}.qm)
+ SET(_cmd_${_name} ${QT_LRELEASE_EXECUTABLE} ${RESOURCE_FILE_NAME} -qm ${_output})
+
+ set(TARGET_NAME ${_name}_resources)
+
+ if (NOT TARGET "${TARGET_NAME}")
+ add_custom_target(${TARGET_NAME} ALL COMMAND ${_cmd_${_name}} DEPENDS ${RESOURCE_FILE_NAME})
+ set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "${TARGET_FOLDER}")
+
+ list (APPEND ${QM_FILES} "${_output}")
+ endif()
+ endif()
+endmacro()
+
+macro (FIND_AND_INSTALL_QT_RESOURCES OCCT_PACKAGE RESOURCE_FILES)
+ file (STRINGS "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" TS_FILES REGEX ".+[.]ts")
+ file (STRINGS "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" QRC_FILES REGEX ".+[.]qrc")
+
+ string (FIND "${OCCT_PACKAGE}" "/" _index)
+ if (_index GREATER -1)
+ math (EXPR _index "${_index}")
+ string (SUBSTRING "${OCCT_PACKAGE}" 0 ${_index} OCCT_PACKAGE_NAME)
+ else()
+ set (OCCT_PACKAGE_NAME "${OCCT_PACKAGE}")
+ endif(_index GREATER -1)
+
+ #message("QRC files are: ${QRC_FILES} in ${OCCT_PACKAGE}")
+ foreach (QRC_FILE ${QRC_FILES})
+ set (QRC_FILE_RELATIVE "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${QRC_FILE}")
+ if (EXISTS ${QRC_FILE_RELATIVE})
+ FIND_AND_WRAP_RESOURCE_FILE(${QRC_FILE_RELATIVE} RCC_FILES)
+ list (APPEND ${RESOURCE_FILES} "${RCC_FILES}")
+ endif()
+ endforeach()
+
+ #message("TS files are: ${TS_FILES} in ${OCCT_PACKAGE}")
+ foreach (TS_FILE ${TS_FILES})
+ set (TS_FILE_RELATIVE "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${TS_FILE}")
+ FIND_AND_INSTALL_TS_FILE(${TS_FILE_RELATIVE} "${TARGET_FOLDER}/${CURRENT_MODULE}" QM_FILES)
+ if (EXISTS ${TS_FILE_RELATIVE})
+ list (APPEND ${RESOURCE_FILES} "${TS_FILE_RELATIVE}")
+ endif()
+ endforeach()
+
+ foreach (QM_FILE ${QM_FILES})
+ INSTALL(FILES ${QM_FILE} DESTINATION "${INSTALL_DIR_RESOURCE}/samples")
+ #message("install *.qm files (${QM_FILE}) to: ${INSTALL_DIR_RESOURCE}/samples")
+ endforeach (QM_FILE ${QM_FILES})
+endmacro()
+
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_QtSamples_DESCR
+"Indicates whether OCCT Qt samples should be built together with OCCT.
+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_Inspector_DESCR
"Indicates whether OCCT inspector should be built together with OCCT.
This inspector provides functionality to interactively inspect low-level content
echo HLR
echo Animation
echo Convert
+ echo AndroidQt
+ echo FuncDemo
+ echo IESample
+ echo Tutorial
PAUSE
exit /B
)
+++ /dev/null
-// Copyright (c) 2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <AndroidQt_Window.h>
-#include <AndroidQt.h>
-#include <AndroidQt_UserInteractionParameters.h>
-
-#include <AIS_Shape.hxx>
-#include <BRepTools.hxx>
-#include <BRep_Builder.hxx>
-#include <OpenGl_GraphicDriver.hxx>
-#include <Quantity_Color.hxx>
-#include <Standard_ErrorHandler.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Face.hxx>
-#include <TopoDS_Shape.hxx>
-#include <UnitsAPI.hxx>
-
-#include <EGL/egl.h>
-#include <QFileInfo>
-
-// =======================================================================
-// function : AndroidQt
-// purpose :
-// =======================================================================
-AndroidQt::AndroidQt()
-: myFitAllAction (false)
-{
- connect (this, SIGNAL(windowChanged(QQuickWindow*)), this, SLOT(handleWindowChanged(QQuickWindow*)));
-
- // set shaders location variable
- QByteArray aDataRoot = "/data/data/org.qtproject.example.AndroidQt/files/opencascade/shared";
- qputenv ("CSF_ShadersDirectory", aDataRoot + "/Shaders");
-}
-
-// =======================================================================
-// function : ReadShapeFromFile
-// purpose :
-// =======================================================================
-bool AndroidQt::ReadShapeFromFile (QString theFilePath)
-{
- QUrl aFileUrl (theFilePath);
- QString aFilePath = theFilePath;
- if (aFileUrl.isLocalFile())
- {
- aFilePath = QUrl (theFilePath).toLocalFile();
- }
-
- if (!QFile (aFilePath).exists())
- {
- return false;
- }
-
- TopoDS_Shape aShape;
- BRep_Builder aBuildTool;
- try
- {
- OCC_CATCH_SIGNALS
-
- if (!BRepTools::Read (aShape, aFilePath.toStdString().c_str(), aBuildTool))
- {
- return false;
- }
-
- if (!myContext.IsNull())
- {
- myContext->EraseAll (Standard_False);
-
- Handle(AIS_Shape) aShapePrs = new AIS_Shape (aShape);
- aShapePrs->SetColor (Quantity_Color(1.0, 0.73, 0.2, Quantity_TOC_RGB));
-
- myContext->Display (aShapePrs, Standard_False);
- myContext->SetDisplayMode (aShapePrs, AIS_Shaded, Standard_False);
- }
-
- myMutex.lock();
- myFitAllAction = true;
- myMutex.unlock();
-
- if (window())
- {
- window()->update();
- }
- }
- catch (Standard_Failure)
- {
- return false;
- }
-
- return true;
-}
-
-// =======================================================================
-// function : InitTouch
-// purpose :
-// =======================================================================
-void AndroidQt::InitTouch (const double theX,
- const double theY)
-{
- myMutex.lock();
- myTouchPoint.SetStarts (theX, theY);
- myMutex.unlock();
-}
-
-// =======================================================================
-// function : UpdateTouch
-// purpose :
-// =======================================================================
-void AndroidQt::UpdateTouch (const double theX,
- const double theY)
-{
- myMutex.lock();
- myTouchPoint.SetEnds (theX, theY);
- myMutex.unlock();
-
- if (window())
- window()->update();
-}
-
-// =======================================================================
-// function : handleWindowChanged
-// purpose :
-// =======================================================================
-void AndroidQt::handleWindowChanged (QQuickWindow* theWin)
-{
- if (theWin == NULL)
- {
- return;
- }
-
- connect(theWin, SIGNAL(beforeSynchronizing()), this, SLOT(sync()), Qt::DirectConnection);
-
- theWin->setClearBeforeRendering (false);
-}
-
-// =======================================================================
-// function : sync
-// purpose :
-// =======================================================================
-void AndroidQt::sync()
-{
- myViewportSize = window()->size() * window()->devicePixelRatio();
-
- if (myViewer.IsNull())
- {
- initViewer();
- connect (window(), SIGNAL(beforeRendering()), this, SLOT(paint()), Qt::DirectConnection);
- }
- else
- {
- Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast (myViewer->Driver());
- if (aDriver->getRawGlContext() != eglGetCurrentContext())
- {
- initViewer();
- }
- else
- {
- Handle(AndroidQt_Window) aWindow = Handle(AndroidQt_Window)::DownCast (myView->Window());
- aWindow->SetSize (myViewportSize.width(), myViewportSize.height());
- //myView->MustBeResized(); // can be used instead of SetWindow() when EGLsurface has not been changed
-
- EGLContext anEglContext = eglGetCurrentContext();
- myView->SetWindow (aWindow, (Aspect_RenderingContext )anEglContext);
- }
- }
-}
-
-// =======================================================================
-// function : paint
-// purpose :
-// =======================================================================
-void AndroidQt::paint()
-{
- myMutex.lock();
-
- if (Abs(myTouchPoint.DevX()) + Abs(myTouchPoint.DevY()) > 1)
- {
- myView->StartRotation (myTouchPoint.X().first, myTouchPoint.Y().first);
- myView->Rotation (myTouchPoint.X().second, myTouchPoint.Y().second);
-
- myTouchPoint.ClearDev();
- }
-
- if (myFitAllAction)
- {
- myView->FitAll();
- myFitAllAction = false;
- }
-
- myMutex.unlock();
-
- myView->Redraw();
-}
-
-// =======================================================================
-// function : initViewer
-// purpose :
-// =======================================================================
-bool AndroidQt::initViewer()
-{
- EGLint aCfgId = 0;
- int aWidth = 0, aHeight = 0;
- EGLDisplay anEglDisplay = eglGetCurrentDisplay();
- EGLContext anEglContext = eglGetCurrentContext();
- EGLSurface anEglSurf = eglGetCurrentSurface (EGL_DRAW);
-
- if (anEglDisplay == EGL_NO_DISPLAY
- || anEglContext == EGL_NO_CONTEXT
- || anEglSurf == EGL_NO_SURFACE)
- {
- release();
- return false;
- }
-
- eglQuerySurface (anEglDisplay, anEglSurf, EGL_WIDTH, &aWidth);
- eglQuerySurface (anEglDisplay, anEglSurf, EGL_HEIGHT, &aHeight);
- eglQuerySurface (anEglDisplay, anEglSurf, EGL_CONFIG_ID, &aCfgId);
-
- const EGLint aConfigAttribs[] = { EGL_CONFIG_ID, aCfgId, EGL_NONE };
- EGLint aNbConfigs = 0;
- void* anEglConfig = NULL;
-
- if (eglChooseConfig (anEglDisplay, aConfigAttribs, &anEglConfig, 1, &aNbConfigs) != EGL_TRUE)
- {
- release();
- return false;
- }
-
- if (!myViewer.IsNull())
- {
- Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast (myViewer->Driver());
- Handle(AndroidQt_Window) aWindow = Handle(AndroidQt_Window)::DownCast (myView->Window());
- if (!aDriver->InitEglContext (anEglDisplay, anEglContext, anEglConfig))
- {
- release();
- return false;
- }
-
- aWindow->SetSize (aWidth, aHeight);
- myView->SetWindow (aWindow, (Aspect_RenderingContext )anEglContext);
- }
-
- Handle(OpenGl_GraphicDriver) aDriver = new OpenGl_GraphicDriver (NULL, Standard_False);
- aDriver->ChangeOptions().buffersNoSwap = Standard_True;
- //aDriver->ChangeOptions().glslWarnings = Standard_True; // for GLSL shaders debug
-
- if (!aDriver->InitEglContext (anEglDisplay, anEglContext, anEglConfig))
- {
- release();
- return false;
- }
-
- // create viewer
- myViewer = new V3d_Viewer (aDriver);
- myViewer->SetDefaultBackgroundColor (AndroidQt_UserInteractionParameters::BgColor.Name());
- myViewer->SetDefaultLights();
- myViewer->SetLightOn();
-
- // create AIS context
- myContext = new AIS_InteractiveContext (myViewer);
- myContext->SetDisplayMode (AIS_Shaded, false);
-
- Handle(AndroidQt_Window) aWindow = new AndroidQt_Window (aWidth, aHeight);
- myView = myViewer->CreateView();
-
- myView->SetWindow (aWindow, (Aspect_RenderingContext )anEglContext);
- myView->TriedronDisplay (Aspect_TOTP_RIGHT_LOWER, Quantity_NOC_WHITE, 0.08, V3d_ZBUFFER);
-
- return true;
-}
-
-// =======================================================================
-// function : release
-// purpose :
-// =======================================================================
-void AndroidQt::release()
-{
- myContext.Nullify();
- myView.Nullify();
- myViewer.Nullify();
-}
+++ /dev/null
-// Copyright (c) 2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef ANDROIDQT_H
-#define ANDROIDQT_H
-
-#include <OpenGl_Context.hxx>
-
-// workaround broken definitions in Qt
-#define GLdouble GLdouble
-
-#include <QtQuick/qquickwindow.h>
-#include <QtQuick/QQuickItem>
-
-#undef GLdouble
-
-#include <AIS_InteractiveContext.hxx>
-#include <V3d_View.hxx>
-
-#include <QMutex>
-
-#include <AndroidQt_TouchParameters.h>
-
-//! QML item with embedded OCCT viewer.
-class AndroidQt : public QQuickItem
-{
- Q_OBJECT
-
-public:
- //! Default constructor.
- AndroidQt();
-
- //! Display shape from file.
- Q_INVOKABLE bool ReadShapeFromFile (QString theFilePath);
-
- //! Handle touch event.
- Q_INVOKABLE void InitTouch (const double theX,
- const double theY);
-
- //! Handle touch event.
- Q_INVOKABLE void UpdateTouch (const double theX,
- const double theY);
-
-public slots:
-
- //! Handle OpenGL context creation and window resize events.
- void sync();
-
- //! Redraw OCCT viewer and handle pending viewer events in rendering thread.
- void paint();
-
-private slots:
-
- //! Handle window change event.
- void handleWindowChanged (QQuickWindow* theWin);
-
-private:
-
- //! (Re-)initialize viewer on OpenGL context change.
- bool initViewer();
-
- //! Close viewer
- void release();
-
-private:
-
- Handle(V3d_Viewer) myViewer; //!< 3D viewer
- Handle(V3d_View) myView; //!< 3D view
- Handle(AIS_InteractiveContext) myContext; //!< interactive context
-
- QMutex myMutex; //!< mutex for interconnection with rendering thread
- QSize myViewportSize; //!< QML item size
- AndroidQt_TouchParameters myTouchPoint; //!< cached state of touch event
- bool myFitAllAction; //!< queued viewer FitALL event
-
-};
-
-#endif // ANDROIDQT_H
QT += qml quick widgets
-SOURCES += Main.cxx \
- AndroidQt.cxx \
- AndroidQt_Window.cxx \
- AndroidQt_TouchParameters.cxx
+SOURCES += src/Main.cxx \
+ src/AndroidQt.cxx \
+ src/AndroidQt_Window.cxx \
+ src/AndroidQt_TouchParameters.cxx
-RESOURCES += AndroidQt.qrc
+RESOURCES += ./src/AndroidQt.qrc
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
include(Deployment.pri)
HEADERS += \
- AndroidQt.h \
- AndroidQt_Window.h \
- AndroidQt_TouchParameters.h \
- AndroidQt_UserInteractionParameters.h
+ src/AndroidQt.h \
+ src/AndroidQt_Window.h \
+ src/AndroidQt_TouchParameters.h \
+ src/AndroidQt_UserInteractionParameters.h
+
+INCLUDEPATH += $$_PRO_FILE_PWD_/src
+DEPENDPATH += $$_PRO_FILE_PWD_/src
OTHER_FILES += \
android/src/org/qtproject/example/AndroidQt/AndroidQt.java \
+++ /dev/null
-<RCC>
- <qresource prefix="/">
- <file>res/qml/main.qml</file>
- </qresource>
- <qresource prefix="/icons">
- <file>res/icons/ic_action_collection.png</file>
- </qresource>
-</RCC>
+++ /dev/null
-// Copyright (c) 2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <AndroidQt_TouchParameters.h>
-
-// =======================================================================
-// function : AndroidQt_TouchParameters
-// purpose :
-// =======================================================================
-AndroidQt_TouchParameters::AndroidQt_TouchParameters()
-: myXStart (0.0),
- myXEnd (0.0),
- myYStart (0.0),
- myYEnd (0.0)
-{
-}
-
-// =======================================================================
-// function : AndroidQt_TouchParameters
-// purpose :
-// =======================================================================
-AndroidQt_TouchParameters::AndroidQt_TouchParameters (const double theX,
- const double theY)
-: myXStart (theX),
- myXEnd (theX),
- myYStart (theY),
- myYEnd (theY)
-{
-}
-
-// =======================================================================
-// function : X
-// purpose :
-// =======================================================================
-QPair<double, double> AndroidQt_TouchParameters::X() const
-{
- return qMakePair(myXStart, myXEnd);
-}
-
-// =======================================================================
-// function : DevX
-// purpose :
-// =======================================================================
-double AndroidQt_TouchParameters::DevX() const
-{
- return myXEnd - myXStart;
-}
-
-// =======================================================================
-// function : Y
-// purpose :
-// =======================================================================
-QPair<double, double> AndroidQt_TouchParameters::Y() const
-{
- return qMakePair(myYStart, myYEnd);
-}
-
-// =======================================================================
-// function : DevY
-// purpose :
-// =======================================================================
-double AndroidQt_TouchParameters::DevY() const
-{
- return myYEnd - myYStart;
-}
-
-// =======================================================================
-// function : SetStarts
-// purpose :
-// =======================================================================
-void AndroidQt_TouchParameters::SetStarts (const double theXStart,
- const double theYStart)
-{
- myXStart = theXStart;
- myYStart = theYStart;
-}
-
-// =======================================================================
-// function : SetEnds
-// purpose :
-// =======================================================================
-void AndroidQt_TouchParameters::SetEnds (const double theXEnd,
- const double theYEnd)
-{
- myXEnd = theXEnd;
- myYEnd = theYEnd;
-}
-
-// =======================================================================
-// function : ClearDev
-// purpose :
-// =======================================================================
-void AndroidQt_TouchParameters::ClearDev()
-{
- myXStart = myXEnd;
- myYStart = myYEnd;
-}
+++ /dev/null
-// Copyright (c) 2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef ANDROIDQT_TOUCHPARAMETERS_H
-#define ANDROIDQT_TOUCHPARAMETERS_H
-
-#include <QPair>
-
-//! Class holding touch event state.
-class AndroidQt_TouchParameters
-{
-
-public:
-
- //! Empty constructor.
- AndroidQt_TouchParameters();
-
- //! Default constructor.
- AndroidQt_TouchParameters (const double theX,
- const double theY);
-
- //! x coord
- QPair<double, double> X() const;
- double DevX() const;
-
- //! y coord
- QPair<double, double> Y() const;
- double DevY() const;
-
- //! Start coords
- void SetStarts (const double theXStart,
- const double theYStart);
-
- //! End coords
- void SetEnds (const double theXEnd,
- const double theYEnd);
-
- void ClearDev();
-
-private:
-
- double myXStart;
- double myXEnd;
-
- double myYStart;
- double myYEnd;
-
-};
-
-#endif // ANDROIDQT_TOUCHPARAMETERS_H
+++ /dev/null
-// Copyright (c) 2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef ANDROIDQT_USERINTERACTIONPARAMETERS_H
-#define ANDROIDQT_USERINTERACTIONPARAMETERS_H
-
-#include <Quantity_Color.hxx>
-
-namespace AndroidQt_UserInteractionParameters
-{
- const double RotationThreshold = 2; // [pixel]
- const double PanThreshold = 4; // [pixel]
- const double ZoomThreshold = 6; // [pixel]
- const double ZoomRatio = 0.13; // distance ratio
- const Quantity_Color BgColor = Quantity_Color(0.145, 0.145, 0.145, Quantity_TOC_RGB); // color of viewer's background
-}
-
-#endif // USERINTERACTIONPARAMETERS_H
+++ /dev/null
-// Copyright (c) 2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <AndroidQt_Window.h>
-
-IMPLEMENT_STANDARD_RTTIEXT(AndroidQt_Window, Aspect_Window)
-
-// =======================================================================
-// function : AndroidQt_Window
-// purpose :
-// =======================================================================
-AndroidQt_Window::AndroidQt_Window (const int theWidth, const int theHeight,
- const int theX1, const int theX2,
- const int theY1, const int theY2)
-: myWidth (theWidth), myHeight(theHeight),
- myX1 (theX1), myX2 (theX2),
- myY1 (theY1), myY2 (theY2)
-{
- if (myX1 == -1) myX1 = 0;
- if (myX2 == -1) myX2 = myWidth;
-
- if (myY1 == -1) myY1 = 0;
- if (myY2 == -1) myY2 = myHeight;
-}
-
-// =======================================================================
-// function : Position
-// purpose :
-// =======================================================================
-void AndroidQt_Window::Position (Standard_Integer& theX1,
- Standard_Integer& theY1,
- Standard_Integer& theX2,
- Standard_Integer& theY2) const
-{
- theX1 = myX1;
- theX2 = myX2;
- theY1 = myY1;
- theY2 = myY2;
-}
-
-// =======================================================================
-// function : SetPosition
-// purpose :
-// =======================================================================
-void AndroidQt_Window::SetPosition (const Standard_Integer theX1,
- const Standard_Integer theY1,
- const Standard_Integer theX2,
- const Standard_Integer theY2)
-{
- myX1 = theX1;
- myX2 = theX2;
- myY1 = theY1;
- myY2 = theY2;
-}
-
-// =======================================================================
-// function : Size
-// purpose :
-// =======================================================================
-void AndroidQt_Window::Size (Standard_Integer& theWidth,
- Standard_Integer& theHeight) const
-{
- theWidth = myWidth;
- theHeight = myHeight;
-}
-
-// =======================================================================
-// function : SetSize
-// purpose :
-// =======================================================================
-void AndroidQt_Window::SetSize (const Standard_Integer theWidth,
- const Standard_Integer theHeight)
-{
- myWidth = theWidth;
- myHeight = theHeight;
-}
+++ /dev/null
-// Copyright (c) 2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef ANDROIDQT_WINDOW_H
-#define ANDROIDQT_WINDOW_H
-
-#include <Aspect_Window.hxx>
-
-//! This class defines dummy window.
-//! The main functionality is viewport dimensions.
-class AndroidQt_Window : public Aspect_Window
-{
- DEFINE_STANDARD_RTTIEXT(AndroidQt_Window, Aspect_Window)
-public:
-
- //! Creates a wrapper over existing Window handle
- AndroidQt_Window(const int theWidth, const int theHeight,
- const int theX1 = -1, const int theX2 = -1,
- const int theY1 = -1, const int theY2 = -1);
-
- //! Returns native Window handle
- virtual Aspect_Drawable NativeHandle() const { return 0; }
-
- //! Returns parent of native Window handle.
- virtual Aspect_Drawable NativeParentHandle() const { return 0; }
-
- //! Returns native Window FB config (GLXFBConfig on Xlib)
- virtual Aspect_FBConfig NativeFBConfig() const { return 0; }
-
- //! Opens the window <me>
- virtual void Map() const {}
-
- //! Closes the window <me>
- virtual void Unmap() const {}
-
- //! Applies the resizing to the window <me>
- virtual Aspect_TypeOfResize DoResize() const { return Aspect_TOR_UNKNOWN; }
-
- //! Apply the mapping change to the window <me>
- virtual Standard_Boolean DoMapping() const { return Standard_True; }
-
- //! Returns True if the window <me> is opened
- virtual Standard_Boolean IsMapped() const { return Standard_True; }
-
- //! Returns The Window RATIO equal to the physical WIDTH/HEIGHT dimensions
- virtual Standard_Real Ratio() const { return 1.0; }
-
- //! Returns The Window POSITION in PIXEL
- virtual void Position (Standard_Integer& theX1,
- Standard_Integer& theY1,
- Standard_Integer& theX2,
- Standard_Integer& theY2) const;
-
- //! Set The Window POSITION in PIXEL
- virtual void SetPosition (const Standard_Integer theX1,
- const Standard_Integer theY1,
- const Standard_Integer theX2,
- const Standard_Integer theY2);
-
- //! Returns The Window SIZE in PIXEL
- virtual void Size (Standard_Integer& theWidth,
- Standard_Integer& theHeight) const;
-
- //! Set The Window SIZE in PIXEL
- virtual void SetSize (const Standard_Integer theWidth,
- const Standard_Integer theHeight);
-
-private:
-
- int myWidth;
- int myHeight;
-
- int myX1;
- int myX2;
- int myY1;
- int myY2;
-
-};
-
-#endif // ANDROIDQT_WINDOW_H
--- /dev/null
+project(AndroidQt)
+
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_sample)
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_sample)
+
+ADD_DEFINITIONS(-DNO_Common_EXPORTS)
+
+
--- /dev/null
+TKernel
+TKMath
+TKG2d
+TKG3d
+TKGeomBase
+TKBRep
+TKGeomAlgo
+TKTopAlgo
+TKShHealing
+TKService
+TKMesh
+TKHLR
+TKV3d
+TKOpenGl
+CSF_FreeImagePlus
+CSF_FREETYPE
+CSF_OpenGlLibs
--- /dev/null
+EXTERNLIB
+PACKAGES
+++ /dev/null
-// Copyright (c) 2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <QApplication>
-#include <QQmlApplicationEngine>
-
-#include <AndroidQt.h>
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
-
- qmlRegisterType<AndroidQt>("AndroidQt", 1, 0, "AndroidQt");
-
- QQmlApplicationEngine engine;
- engine.load (QUrl (QStringLiteral ("qrc:///res/qml/main.qml")));
-
- return app.exec();
-}
--- /dev/null
+AndroidQt/src
* Android SDK from 2014.07.02 or newer
* Android NDK r9d or newer
* Apache Ant 1.9.4 or higher
-
-Configure project for building sample:
+* OCCT compiled under Android platform and placed in directories:
+ * occt\libs\armeabi-v7a\*.so and occt\inc\*.hxx (libraries and include files of OCCT install)
+ * android\assets\opencascade\shared\Shaders\* (Shaders folder of OCCT install: \share\opencascade\resources\Shaders)
+ * 3rdparty\include\freetype2\*, 3rdparty\include\FreeImage.h and 3rdparty\libs\armeabi-v7a\libFreeImage.so and 3rdparty\libs\armeabi-v7a\libfreetype.so
+
+It is also possible to to correct OCCT.pri file an get resources from another tree of directories.
+
+When AndroidQt will be started, it may be helpful to have some default data files(BRep) on Device for opening in AndroidQt.
+Copy these files into "android\assets\opencascade\shared" and it will be installed to device during compilation procedure.
+
+Having prepared all these products, configure AndroidQt project for building sample:
In QtCreator, open AndroidQt.pro project-file:
~~~~
* In JDK location specify path to Java Development Kit
* In Android SDK location specify path to Android SDK
* In Android NDK location specify path to Android NDK
+(During this location definition, warning is possible and OK:
+ "Qt version for architecture mips is missing. To add the Qt version, select Options > Build & Run > Qt Versins.")
* In Ant executable specify path to ant.bat file located in Apache Ant bin directory
-Make sure that "Android for armeabi-v7a" kit has been detected
+Make sure that "Android for armeabi-v7a" kit has been detected (present in the list).
~~~~
Tools->Options->Build & Run
~~~~
-The paths to OCCT and 3rdparty libraries are specified in "OCCT.pri" file:
+also or it can be checked or corrected in:
+~~~~
+Projects->Android for armeabi-v7a option should be checked
+~~~~
+
+Switch On device, connect it to PC and define it in Qt Creator:
+~~~~
+Projects->Manage Kits...->Devices->Device: Run on Android
+~~~~
+Check that "Current state" is "Ready to use" on this page.
+
+~~~~
+Projects->Build Settings->General: Shadow build is switched OFF
+~~~~
+
+Start configuration:
+
+~~~~
+Call Build -> Run qmake
+~~~~
+Check content of "Compile Output" view.
-the paths to the headers:
+In order to perform qmake correctly, for example if you have the following error:
~~~~
-INCLUDEPATH += /occt/inc /3rdparty/include
-DEPENDPATH += /occt/inc /3rdparty/include
+Running steps for project AndroidQt...
+Could not start process "<qt_dir>\android_armv7\bin\qmake.exe" <occt_dir>\samples\qt\AndroidQt\AndroidQt.pro -r -spec android-g++ "CONFIG+=debug" "CONFIG+=declarative_debug" "CONFIG+=qml_debug"
+Error while building/deploying project AndroidQt (kit: Android for armeabi-v7a (GCC 4.9, Qt 5.3.2))
+When executing step "qmake"
~~~~
-the libraries location:
~~~~
-LIBS += -L/occt/libs/armeabi-v7a
+Projects->Build Settings->General: switch OFF Shadow build
+Build->Build Project "Android Qt"
+Build->Run
~~~~
-OCCT resources (Shaders, SHMessage, StdResource, TObj, UnitsAPI and XSMessage folder) should be copied to androidqt_dir/android/assets/opencascade/shared/ directory. Current sample requires at least Shaders folder.
+Dialog to "Select Android Device" is shown. Select Compatible Device, Ok.
+In case of any error, see log in "Application Output" view.
-Select build configuration: Debug or Release and click Build->Build Project "AndroidQt" or (Ctrl + B).
After successful build the application can be deployed to device or emulator.
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
- source: "qrc:///icons/res/icons/ic_action_collection.png"
+ source: "qrc:/ic_action_collection.png"
}
MouseArea {
--- /dev/null
+// Copyright (c) 2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <AndroidQt_Window.h>
+#include <AndroidQt.h>
+#include <AndroidQt_UserInteractionParameters.h>
+
+#include <AIS_Shape.hxx>
+#include <BRepTools.hxx>
+#include <BRep_Builder.hxx>
+#include <OpenGl_GraphicDriver.hxx>
+#include <Quantity_Color.hxx>
+#include <Standard_ErrorHandler.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Shape.hxx>
+#include <UnitsAPI.hxx>
+
+#include <EGL/egl.h>
+#include <QFileInfo>
+
+// =======================================================================
+// function : AndroidQt
+// purpose :
+// =======================================================================
+AndroidQt::AndroidQt()
+: myFitAllAction (false)
+{
+ connect (this, SIGNAL(windowChanged(QQuickWindow*)), this, SLOT(handleWindowChanged(QQuickWindow*)));
+
+ // set shaders location variable
+ QByteArray aDataRoot = "/data/data/org.qtproject.example.AndroidQt/files/opencascade/shared";
+ qputenv ("CSF_ShadersDirectory", aDataRoot + "/Shaders");
+}
+
+// =======================================================================
+// function : ReadShapeFromFile
+// purpose :
+// =======================================================================
+bool AndroidQt::ReadShapeFromFile (QString theFilePath)
+{
+ QUrl aFileUrl (theFilePath);
+ QString aFilePath = theFilePath;
+ if (aFileUrl.isLocalFile())
+ {
+ aFilePath = QUrl (theFilePath).toLocalFile();
+ }
+
+ if (!QFile (aFilePath).exists())
+ {
+ return false;
+ }
+
+ TopoDS_Shape aShape;
+ BRep_Builder aBuildTool;
+ try
+ {
+ OCC_CATCH_SIGNALS
+
+ if (!BRepTools::Read (aShape, aFilePath.toStdString().c_str(), aBuildTool))
+ {
+ return false;
+ }
+
+ if (!myContext.IsNull())
+ {
+ myContext->EraseAll (Standard_False);
+
+ Handle(AIS_Shape) aShapePrs = new AIS_Shape (aShape);
+ aShapePrs->SetColor (Quantity_Color(1.0, 0.73, 0.2, Quantity_TOC_RGB));
+
+ myContext->Display (aShapePrs, Standard_False);
+ myContext->SetDisplayMode (aShapePrs, AIS_Shaded, Standard_False);
+ }
+
+ myMutex.lock();
+ myFitAllAction = true;
+ myMutex.unlock();
+
+ if (window())
+ {
+ window()->update();
+ }
+ }
+ catch (Standard_Failure)
+ {
+ return false;
+ }
+
+ return true;
+}
+
+// =======================================================================
+// function : InitTouch
+// purpose :
+// =======================================================================
+void AndroidQt::InitTouch (const double theX,
+ const double theY)
+{
+ myMutex.lock();
+ myTouchPoint.SetStarts (theX, theY);
+ myMutex.unlock();
+}
+
+// =======================================================================
+// function : UpdateTouch
+// purpose :
+// =======================================================================
+void AndroidQt::UpdateTouch (const double theX,
+ const double theY)
+{
+ myMutex.lock();
+ myTouchPoint.SetEnds (theX, theY);
+ myMutex.unlock();
+
+ if (window())
+ window()->update();
+}
+
+// =======================================================================
+// function : handleWindowChanged
+// purpose :
+// =======================================================================
+void AndroidQt::handleWindowChanged (QQuickWindow* theWin)
+{
+ if (theWin == NULL)
+ {
+ return;
+ }
+
+ connect(theWin, SIGNAL(beforeSynchronizing()), this, SLOT(sync()), Qt::DirectConnection);
+
+ theWin->setClearBeforeRendering (false);
+}
+
+// =======================================================================
+// function : sync
+// purpose :
+// =======================================================================
+void AndroidQt::sync()
+{
+ myViewportSize = window()->size() * window()->devicePixelRatio();
+
+ if (myViewer.IsNull())
+ {
+ initViewer();
+ connect (window(), SIGNAL(beforeRendering()), this, SLOT(paint()), Qt::DirectConnection);
+ }
+ else
+ {
+ Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast (myViewer->Driver());
+ if (aDriver->getRawGlContext() != eglGetCurrentContext())
+ {
+ initViewer();
+ }
+ else
+ {
+ Handle(AndroidQt_Window) aWindow = Handle(AndroidQt_Window)::DownCast (myView->Window());
+ aWindow->SetSize (myViewportSize.width(), myViewportSize.height());
+ //myView->MustBeResized(); // can be used instead of SetWindow() when EGLsurface has not been changed
+
+ EGLContext anEglContext = eglGetCurrentContext();
+ myView->SetWindow (aWindow, (Aspect_RenderingContext )anEglContext);
+ }
+ }
+}
+
+// =======================================================================
+// function : paint
+// purpose :
+// =======================================================================
+void AndroidQt::paint()
+{
+ myMutex.lock();
+
+ if (Abs(myTouchPoint.DevX()) + Abs(myTouchPoint.DevY()) > 1)
+ {
+ myView->StartRotation (myTouchPoint.X().first, myTouchPoint.Y().first);
+ myView->Rotation (myTouchPoint.X().second, myTouchPoint.Y().second);
+
+ myTouchPoint.ClearDev();
+ }
+
+ if (myFitAllAction)
+ {
+ myView->FitAll();
+ myFitAllAction = false;
+ }
+
+ myMutex.unlock();
+
+ myView->Redraw();
+}
+
+// =======================================================================
+// function : initViewer
+// purpose :
+// =======================================================================
+bool AndroidQt::initViewer()
+{
+ EGLint aCfgId = 0;
+ int aWidth = 0, aHeight = 0;
+ EGLDisplay anEglDisplay = eglGetCurrentDisplay();
+ EGLContext anEglContext = eglGetCurrentContext();
+ EGLSurface anEglSurf = eglGetCurrentSurface (EGL_DRAW);
+
+ if (anEglDisplay == EGL_NO_DISPLAY
+ || anEglContext == EGL_NO_CONTEXT
+ || anEglSurf == EGL_NO_SURFACE)
+ {
+ release();
+ return false;
+ }
+
+ eglQuerySurface (anEglDisplay, anEglSurf, EGL_WIDTH, &aWidth);
+ eglQuerySurface (anEglDisplay, anEglSurf, EGL_HEIGHT, &aHeight);
+ eglQuerySurface (anEglDisplay, anEglSurf, EGL_CONFIG_ID, &aCfgId);
+
+ const EGLint aConfigAttribs[] = { EGL_CONFIG_ID, aCfgId, EGL_NONE };
+ EGLint aNbConfigs = 0;
+ void* anEglConfig = NULL;
+
+ if (eglChooseConfig (anEglDisplay, aConfigAttribs, &anEglConfig, 1, &aNbConfigs) != EGL_TRUE)
+ {
+ release();
+ return false;
+ }
+
+ if (!myViewer.IsNull())
+ {
+ Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast (myViewer->Driver());
+ Handle(AndroidQt_Window) aWindow = Handle(AndroidQt_Window)::DownCast (myView->Window());
+ if (!aDriver->InitEglContext (anEglDisplay, anEglContext, anEglConfig))
+ {
+ release();
+ return false;
+ }
+
+ aWindow->SetSize (aWidth, aHeight);
+ myView->SetWindow (aWindow, (Aspect_RenderingContext )anEglContext);
+ }
+
+ Handle(OpenGl_GraphicDriver) aDriver = new OpenGl_GraphicDriver (NULL, Standard_False);
+ aDriver->ChangeOptions().buffersNoSwap = Standard_True;
+ //aDriver->ChangeOptions().glslWarnings = Standard_True; // for GLSL shaders debug
+
+ if (!aDriver->InitEglContext (anEglDisplay, anEglContext, anEglConfig))
+ {
+ release();
+ return false;
+ }
+
+ // create viewer
+ myViewer = new V3d_Viewer (aDriver);
+ myViewer->SetDefaultBackgroundColor (AndroidQt_UserInteractionParameters::BgColor.Name());
+ myViewer->SetDefaultLights();
+ myViewer->SetLightOn();
+
+ // create AIS context
+ myContext = new AIS_InteractiveContext (myViewer);
+ myContext->SetDisplayMode (AIS_Shaded, false);
+
+ Handle(AndroidQt_Window) aWindow = new AndroidQt_Window (aWidth, aHeight);
+ myView = myViewer->CreateView();
+
+ myView->SetWindow (aWindow, (Aspect_RenderingContext )anEglContext);
+ myView->TriedronDisplay (Aspect_TOTP_RIGHT_LOWER, Quantity_NOC_WHITE, 0.08, V3d_ZBUFFER);
+
+ return true;
+}
+
+// =======================================================================
+// function : release
+// purpose :
+// =======================================================================
+void AndroidQt::release()
+{
+ myContext.Nullify();
+ myView.Nullify();
+ myViewer.Nullify();
+}
--- /dev/null
+// Copyright (c) 2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef ANDROIDQT_H
+#define ANDROIDQT_H
+
+#include <OpenGl_Context.hxx>
+
+// workaround broken definitions in Qt
+#define GLdouble GLdouble
+
+#include <QtQuick/qquickwindow.h>
+#include <QtQuick/QQuickItem>
+
+#undef GLdouble
+
+#include <AIS_InteractiveContext.hxx>
+#include <V3d_View.hxx>
+
+#include <QMutex>
+
+#include <AndroidQt_TouchParameters.h>
+
+//! QML item with embedded OCCT viewer.
+class AndroidQt : public QQuickItem
+{
+ Q_OBJECT
+
+public:
+ //! Default constructor.
+ AndroidQt();
+
+ //! Display shape from file.
+ Q_INVOKABLE bool ReadShapeFromFile (QString theFilePath);
+
+ //! Handle touch event.
+ Q_INVOKABLE void InitTouch (const double theX,
+ const double theY);
+
+ //! Handle touch event.
+ Q_INVOKABLE void UpdateTouch (const double theX,
+ const double theY);
+
+public slots:
+
+ //! Handle OpenGL context creation and window resize events.
+ void sync();
+
+ //! Redraw OCCT viewer and handle pending viewer events in rendering thread.
+ void paint();
+
+private slots:
+
+ //! Handle window change event.
+ void handleWindowChanged (QQuickWindow* theWin);
+
+private:
+
+ //! (Re-)initialize viewer on OpenGL context change.
+ bool initViewer();
+
+ //! Close viewer
+ void release();
+
+private:
+
+ Handle(V3d_Viewer) myViewer; //!< 3D viewer
+ Handle(V3d_View) myView; //!< 3D view
+ Handle(AIS_InteractiveContext) myContext; //!< interactive context
+
+ QMutex myMutex; //!< mutex for interconnection with rendering thread
+ QSize myViewportSize; //!< QML item size
+ AndroidQt_TouchParameters myTouchPoint; //!< cached state of touch event
+ bool myFitAllAction; //!< queued viewer FitALL event
+
+};
+
+#endif // ANDROIDQT_H
--- /dev/null
+<RCC>
+ <qresource prefix="/">
+ <file alias="main.qml">../res/qml/main.qml</file>
+ </qresource>
+ <qresource prefix="/">
+ <file alias="ic_action_collection.png">../res/icons/ic_action_collection.png</file>
+ </qresource>
+</RCC>
--- /dev/null
+// Copyright (c) 2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <AndroidQt_TouchParameters.h>
+
+// =======================================================================
+// function : AndroidQt_TouchParameters
+// purpose :
+// =======================================================================
+AndroidQt_TouchParameters::AndroidQt_TouchParameters()
+: myXStart (0.0),
+ myXEnd (0.0),
+ myYStart (0.0),
+ myYEnd (0.0)
+{
+}
+
+// =======================================================================
+// function : AndroidQt_TouchParameters
+// purpose :
+// =======================================================================
+AndroidQt_TouchParameters::AndroidQt_TouchParameters (const double theX,
+ const double theY)
+: myXStart (theX),
+ myXEnd (theX),
+ myYStart (theY),
+ myYEnd (theY)
+{
+}
+
+// =======================================================================
+// function : X
+// purpose :
+// =======================================================================
+QPair<double, double> AndroidQt_TouchParameters::X() const
+{
+ return qMakePair(myXStart, myXEnd);
+}
+
+// =======================================================================
+// function : DevX
+// purpose :
+// =======================================================================
+double AndroidQt_TouchParameters::DevX() const
+{
+ return myXEnd - myXStart;
+}
+
+// =======================================================================
+// function : Y
+// purpose :
+// =======================================================================
+QPair<double, double> AndroidQt_TouchParameters::Y() const
+{
+ return qMakePair(myYStart, myYEnd);
+}
+
+// =======================================================================
+// function : DevY
+// purpose :
+// =======================================================================
+double AndroidQt_TouchParameters::DevY() const
+{
+ return myYEnd - myYStart;
+}
+
+// =======================================================================
+// function : SetStarts
+// purpose :
+// =======================================================================
+void AndroidQt_TouchParameters::SetStarts (const double theXStart,
+ const double theYStart)
+{
+ myXStart = theXStart;
+ myYStart = theYStart;
+}
+
+// =======================================================================
+// function : SetEnds
+// purpose :
+// =======================================================================
+void AndroidQt_TouchParameters::SetEnds (const double theXEnd,
+ const double theYEnd)
+{
+ myXEnd = theXEnd;
+ myYEnd = theYEnd;
+}
+
+// =======================================================================
+// function : ClearDev
+// purpose :
+// =======================================================================
+void AndroidQt_TouchParameters::ClearDev()
+{
+ myXStart = myXEnd;
+ myYStart = myYEnd;
+}
--- /dev/null
+// Copyright (c) 2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef ANDROIDQT_TOUCHPARAMETERS_H
+#define ANDROIDQT_TOUCHPARAMETERS_H
+
+#include <QPair>
+
+//! Class holding touch event state.
+class AndroidQt_TouchParameters
+{
+
+public:
+
+ //! Empty constructor.
+ AndroidQt_TouchParameters();
+
+ //! Default constructor.
+ AndroidQt_TouchParameters (const double theX,
+ const double theY);
+
+ //! x coord
+ QPair<double, double> X() const;
+ double DevX() const;
+
+ //! y coord
+ QPair<double, double> Y() const;
+ double DevY() const;
+
+ //! Start coords
+ void SetStarts (const double theXStart,
+ const double theYStart);
+
+ //! End coords
+ void SetEnds (const double theXEnd,
+ const double theYEnd);
+
+ void ClearDev();
+
+private:
+
+ double myXStart;
+ double myXEnd;
+
+ double myYStart;
+ double myYEnd;
+
+};
+
+#endif // ANDROIDQT_TOUCHPARAMETERS_H
--- /dev/null
+// Copyright (c) 2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef ANDROIDQT_USERINTERACTIONPARAMETERS_H
+#define ANDROIDQT_USERINTERACTIONPARAMETERS_H
+
+#include <Quantity_Color.hxx>
+
+namespace AndroidQt_UserInteractionParameters
+{
+ const double RotationThreshold = 2; // [pixel]
+ const double PanThreshold = 4; // [pixel]
+ const double ZoomThreshold = 6; // [pixel]
+ const double ZoomRatio = 0.13; // distance ratio
+ const Quantity_Color BgColor = Quantity_Color(0.145, 0.145, 0.145, Quantity_TOC_RGB); // color of viewer's background
+}
+
+#endif // USERINTERACTIONPARAMETERS_H
--- /dev/null
+// Copyright (c) 2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <AndroidQt_Window.h>
+
+IMPLEMENT_STANDARD_RTTIEXT(AndroidQt_Window, Aspect_Window)
+
+// =======================================================================
+// function : AndroidQt_Window
+// purpose :
+// =======================================================================
+AndroidQt_Window::AndroidQt_Window (const int theWidth, const int theHeight,
+ const int theX1, const int theX2,
+ const int theY1, const int theY2)
+: myWidth (theWidth), myHeight(theHeight),
+ myX1 (theX1), myX2 (theX2),
+ myY1 (theY1), myY2 (theY2)
+{
+ if (myX1 == -1) myX1 = 0;
+ if (myX2 == -1) myX2 = myWidth;
+
+ if (myY1 == -1) myY1 = 0;
+ if (myY2 == -1) myY2 = myHeight;
+}
+
+// =======================================================================
+// function : Position
+// purpose :
+// =======================================================================
+void AndroidQt_Window::Position (Standard_Integer& theX1,
+ Standard_Integer& theY1,
+ Standard_Integer& theX2,
+ Standard_Integer& theY2) const
+{
+ theX1 = myX1;
+ theX2 = myX2;
+ theY1 = myY1;
+ theY2 = myY2;
+}
+
+// =======================================================================
+// function : SetPosition
+// purpose :
+// =======================================================================
+void AndroidQt_Window::SetPosition (const Standard_Integer theX1,
+ const Standard_Integer theY1,
+ const Standard_Integer theX2,
+ const Standard_Integer theY2)
+{
+ myX1 = theX1;
+ myX2 = theX2;
+ myY1 = theY1;
+ myY2 = theY2;
+}
+
+// =======================================================================
+// function : Size
+// purpose :
+// =======================================================================
+void AndroidQt_Window::Size (Standard_Integer& theWidth,
+ Standard_Integer& theHeight) const
+{
+ theWidth = myWidth;
+ theHeight = myHeight;
+}
+
+// =======================================================================
+// function : SetSize
+// purpose :
+// =======================================================================
+void AndroidQt_Window::SetSize (const Standard_Integer theWidth,
+ const Standard_Integer theHeight)
+{
+ myWidth = theWidth;
+ myHeight = theHeight;
+}
--- /dev/null
+// Copyright (c) 2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef ANDROIDQT_WINDOW_H
+#define ANDROIDQT_WINDOW_H
+
+#include <Aspect_Window.hxx>
+
+//! This class defines dummy window.
+//! The main functionality is viewport dimensions.
+class AndroidQt_Window : public Aspect_Window
+{
+ DEFINE_STANDARD_RTTIEXT(AndroidQt_Window, Aspect_Window)
+public:
+
+ //! Creates a wrapper over existing Window handle
+ AndroidQt_Window(const int theWidth, const int theHeight,
+ const int theX1 = -1, const int theX2 = -1,
+ const int theY1 = -1, const int theY2 = -1);
+
+ //! Returns native Window handle
+ virtual Aspect_Drawable NativeHandle() const { return 0; }
+
+ //! Returns parent of native Window handle.
+ virtual Aspect_Drawable NativeParentHandle() const { return 0; }
+
+ //! Returns native Window FB config (GLXFBConfig on Xlib)
+ virtual Aspect_FBConfig NativeFBConfig() const { return 0; }
+
+ //! Opens the window <me>
+ virtual void Map() const {}
+
+ //! Closes the window <me>
+ virtual void Unmap() const {}
+
+ //! Applies the resizing to the window <me>
+ virtual Aspect_TypeOfResize DoResize() const { return Aspect_TOR_UNKNOWN; }
+
+ //! Apply the mapping change to the window <me>
+ virtual Standard_Boolean DoMapping() const { return Standard_True; }
+
+ //! Returns True if the window <me> is opened
+ virtual Standard_Boolean IsMapped() const { return Standard_True; }
+
+ //! Returns The Window RATIO equal to the physical WIDTH/HEIGHT dimensions
+ virtual Standard_Real Ratio() const { return 1.0; }
+
+ //! Returns The Window POSITION in PIXEL
+ virtual void Position (Standard_Integer& theX1,
+ Standard_Integer& theY1,
+ Standard_Integer& theX2,
+ Standard_Integer& theY2) const;
+
+ //! Set The Window POSITION in PIXEL
+ virtual void SetPosition (const Standard_Integer theX1,
+ const Standard_Integer theY1,
+ const Standard_Integer theX2,
+ const Standard_Integer theY2);
+
+ //! Returns The Window SIZE in PIXEL
+ virtual void Size (Standard_Integer& theWidth,
+ Standard_Integer& theHeight) const;
+
+ //! Set The Window SIZE in PIXEL
+ virtual void SetSize (const Standard_Integer theWidth,
+ const Standard_Integer theHeight);
+
+private:
+
+ int myWidth;
+ int myHeight;
+
+ int myX1;
+ int myX2;
+ int myY1;
+ int myY2;
+
+};
+
+#endif // ANDROIDQT_WINDOW_H
--- /dev/null
+AndroidQt.cxx
+AndroidQt.h
+AndroidQt.qrc
+AndroidQt_TouchParameters.cxx
+AndroidQt_TouchParameters.h
+AndroidQt_UserInteractionParameters.h
+AndroidQt_Window.cxx
+AndroidQt_Window.h
+Main.cxx
--- /dev/null
+// Copyright (c) 2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <QApplication>
+#include <QQmlApplicationEngine>
+
+#include <AndroidQt.h>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ qmlRegisterType<AndroidQt>("AndroidQt", 1, 0, "AndroidQt");
+
+ QQmlApplicationEngine engine;
+ engine.load (QUrl (QStringLiteral ("qrc:/main.qml")));
+
+ return app.exec();
+}
#include <Graphic3d_GraphicDriver.hxx>
#include <OpenGl_GraphicDriver.hxx>
+#include <OSD_Environment.hxx>
#include <stdlib.h>
QString ApplicationCommonWindow::getResourceDir()
{
static QString aResourceDir =
- QString::fromUtf8 (qgetenv ("CSF_ResourcesDefaults").constData());
-
+ QString (OSD_Environment ("CSF_ResourcesDefaults").Value().ToCString());
+ if (aResourceDir.isEmpty())
+ aResourceDir = QString (OSD_Environment ("CSF_OCCTResourcePath").Value().ToCString()) + "/samples";
+
return aResourceDir;
}
#include <AIS_InteractiveObject.hxx>
#include <Graphic3d_NameOfMaterial.hxx>
#include <OpenGl_GraphicDriver.hxx>
+#if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
+#include <OSD_Environment.hxx>
+#endif
#include <TCollection_AsciiString.hxx>
// =======================================================================
{
Handle(Aspect_DisplayConnection) aDisplayConnection;
#if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
- aDisplayConnection = new Aspect_DisplayConnection (qgetenv ("DISPLAY").constData());
+ aDisplayConnection = new Aspect_DisplayConnection (OSD_Environment ("DISPLAY").Value());
#endif
aGraphicDriver = new OpenGl_GraphicDriver (aDisplayConnection);
}
--- /dev/null
+ApplicationCommon.cxx
+ApplicationCommon.h
+Common-icon.ts
+Common-string.ts
+CommonSample.h
+DocumentCommon.cxx
+DocumentCommon.h
+Material.cxx
+Material.h
+MDIWindow.cxx
+MDIWindow.h
+OcctWindow.cxx
+OcctWindow.h
+Transparency.cxx
+Transparency.h
+View.cxx
+View.h
void MDIWindow::dump()
{
- QString datadir = (QString(qgetenv ("CSF_OCCTDataPath").constData()) + "/images");
QString filter = "Images Files (*.bmp *.ppm *.png *.jpg *.tiff *.tga *.gif *.exr)";
QFileDialog fd ( 0 );
fd.setModal( true );
--- /dev/null
+project(FuncDemo)
+
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_sample)
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_sample)
--- /dev/null
+TKBO
+TKBRep
+TKCAF
+TKCDF
+TKG2d
+TKG3d
+TKGeomAlgo
+TKGeomBase
+TKernel
+TKLCAF
+TKMath
+TKMesh
+TKPrim
+TKTopAlgo
--- /dev/null
+EXTERNLIB
+PACKAGES
DEFINES = $$split(OCCT_DEFINES, ;)
+RESOURCES += ./src/FuncDemo.qrc
+
unix {
UNAME = $$system(uname -s)
LIBLIST = $$(LD_LIBRARY_PATH)
--- /dev/null
+FuncDemo/src
\ No newline at end of file
call "custom.bat" %1 %2 %3
-set "PATH=%QTDIR%/bin;%PATH%"
-set "QT_QPA_PLATFORM_PLUGIN_PATH=%QTDIR%\plugins\platforms"
\ No newline at end of file
+set "PATH=%QTDIR%/bin;%PATH%"
\ No newline at end of file
--- /dev/null
+BaseDriver.cpp
+BaseDriver.h
+CircleDriver.cpp
+CircleDriver.h
+ConeDriver.cpp
+ConeDriver.h
+CylinderDriver.cpp
+CylinderDriver.h
+edge.cpp
+edge.h
+FILES
+FThread.cpp
+FThread.h
+graphwidget.cpp
+graphwidget.h
+main.cpp
+mainwindow.cpp
+mainwindow.h
+node.cpp
+node.h
+PointDriver.cpp
+PointDriver.h
+PrismDriver.cpp
+PrismDriver.h
+ShapeSaverDriver.cpp
+ShapeSaverDriver.h
+SimpleDriver.cpp
+SimpleDriver.h
--- /dev/null
+<RCC>\r
+ <qresource prefix="/">\r
+ <file alias="new.png">../images/new.png</file>\r
+ <file alias="open.png">../images/open.png</file>\r
+ <file alias="save.png">../images/save.png</file>\r
+ </qresource>\r
+</RCC>\r
#include <QApplication>
#include "mainwindow.h"
+#include <OSD_Environment.hxx>
+
int main(int argc, char *argv[])
{
+#if QT_VERSION > 0x050000
+ TCollection_AsciiString aPlugindsDirName = OSD_Environment ("QTDIR").Value();
+ if (!aPlugindsDirName.IsEmpty())
+ QApplication::addLibraryPath (QString (aPlugindsDirName.ToCString()) + "/plugins");
+#endif
QApplication app(argc, argv);
MainWindow mainWin;
mainWin.show();
--- /dev/null
+project(IESample)
+
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_sample)
+include_directories("${CMAKE_SOURCE_DIR}/${RELATIVE_DIR}/Interface/src")
+include_directories("${CMAKE_SOURCE_DIR}/${RELATIVE_DIR}/Common/src")
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_sample)
+
+ADD_DEFINITIONS(-DNO_COMMONSAMPLE_EXPORTS -DNO_IESAMPLE_EXPORTS)
+
+
--- /dev/null
+TKBRep
+TKBool
+TKBO
+TKCDF
+TKFillet
+TKG2d
+TKG3d
+TKGeomAlgo
+TKGeomBase
+TKHLR
+TKIGES
+TKernel
+TKMath
+TKMesh
+TKOffset
+TKOpenGl
+TKPrim
+TKShHealing
+TKService
+TKSTEP
+TKSTEP209
+TKSTEPAttr
+TKSTEPBase
+TKSTL
+TKTopAlgo
+TKV3d
+TKVRML
+TKXSBase
+
--- /dev/null
+EXTERNLIB
+PACKAGES
--- /dev/null
+IESample/src
+Common/src
+Interface/src
\ No newline at end of file
set "CSF_IEResourcesDefaults=%RES_DIR%"
set "PATH=%QTDIR%/bin;%PATH%"
-set "QT_QPA_PLATFORM_PLUGIN_PATH=%QTDIR%\plugins\platforms"
\ No newline at end of file
--- /dev/null
+Main.cxx
\ No newline at end of file
#include "Application.h"
+#include <OSD_Environment.hxx>
+
#include <QApplication>
#include <QTranslator>
#include <QPixmap>
#include <QLocale>
-
int main ( int argc, char* argv[] )
{
-
+#if QT_VERSION > 0x050000
+ TCollection_AsciiString aPlugindsDirName = OSD_Environment ("QTDIR").Value();
+ if (!aPlugindsDirName.IsEmpty())
+ QApplication::addLibraryPath (QString (aPlugindsDirName.ToCString()) + "/plugins");
+#endif
QApplication a( argc, argv );
QString resDir = ApplicationCommonWindow::getResourceDir();
#include <stdlib.h>
#include <QMdiSubWindow>
+#include <OSD_Environment.hxx>
+
ApplicationWindow::ApplicationWindow()
: ApplicationCommonWindow( ),
myImportPopup( 0 ),
QString ApplicationWindow::getIEResourceDir()
{
static QString aResourceDir =
- QString::fromUtf8 (qgetenv ("CSF_IEResourcesDefaults").constData());
-
+ QString (OSD_Environment ("CSF_IEResourcesDefaults").Value().ToCString());
+ if (aResourceDir.isEmpty())
+ aResourceDir = QString (OSD_Environment ("CSF_OCCTResourcePath").Value().ToCString()) + "/samples";
+
return aResourceDir;
}
--- /dev/null
+Application.cxx
+Application.h
+IESample.h
+Interface-string.ts
+Translate.cxx
+Translate.h
--- /dev/null
+project(Tutorial)
+
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_sample)
+include_directories("${CMAKE_SOURCE_DIR}/${RELATIVE_DIR}/Interface/src")
+include_directories("${CMAKE_SOURCE_DIR}/${RELATIVE_DIR}/Common/src")
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_sample)
+
+ADD_DEFINITIONS(-DNO_COMMONSAMPLE_EXPORTS -DNO_IESAMPLE_EXPORTS)
+
+
--- /dev/null
+TKBRep
+TKBool
+TKBO
+TKCDF
+TKFillet
+TKG2d
+TKG3d
+TKGeomAlgo
+TKGeomBase
+TKernel
+TKHLR
+TKIGES
+TKMath
+TKMesh
+TKOffset
+TKOpenGl
+TKPrim
+TKService
+TKShHealing
+TKSTEP
+TKSTEP209
+TKSTEPAttr
+TKSTEPBase
+TKSTL
+TKTopAlgo
+TKV3d
+TKVRML
+TKXSBase
+
--- /dev/null
+EXTERNLIB
+PACKAGES
--- /dev/null
+Tutorial/src
+Common/src
\ No newline at end of file
set "CSF_TutorialResourcesDefaults=%RES_DIR%"
set "PATH=%QTDIR%/bin;%PATH%"
-set "QT_QPA_PLATFORM_PLUGIN_PATH=%QTDIR%\plugins\platforms"
\ No newline at end of file
#include "ApplicationTut.h"
#include "DocumentTut.h"
+#include <OSD_Environment.hxx>
+
#include <QFileDialog>
#include <QStatusBar>
#include <QMdiSubWindow>
QString ApplicationTut::getTutResourceDir()
{
- static QString resDir (qgetenv ("CSF_TutorialResourcesDefaults").constData());
+ static QString resDir (OSD_Environment ("CSF_TutorialResourcesDefaults").Value().ToCString());
+ if (resDir.isEmpty())
+ resDir = QString (OSD_Environment ("CSF_OCCTResourcePath").Value().ToCString()) + "/samples";
return resDir;
}
-
--- /dev/null
+ApplicationTut.cxx
+ApplicationTut.h
+DocumentTut.cxx
+DocumentTut.h
+Main.cxx
+MakeBottle.cxx
+Tutorial-icon.ts
+Tutorial-string.ts
#include "ApplicationTut.h"
+#include <OSD_Environment.hxx>
+
#include <QApplication>
#include <QTranslator>
int main ( int argc, char* argv[] )
{
+#if QT_VERSION > 0x050000
+ TCollection_AsciiString aPlugindsDirName = OSD_Environment ("QTDIR").Value();
+ if (!aPlugindsDirName.IsEmpty())
+ QApplication::addLibraryPath (QString (aPlugindsDirName.ToCString()) + "/plugins");
+#endif
QApplication a( argc, argv );
QString resDir = ApplicationCommonWindow::getResourceDir();
project(TInspectorEXE)
-OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_tool)
-
-set_property (TARGET ${PROJECT_NAME} PROPERTY FOLDER Samples)
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_sample)
+set (RELATIVE_DIR "samples/tools")
+include_directories("${CMAKE_SOURCE_DIR}/${RELATIVE_DIR}/TInspectorEXE/src")
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_sample)
-TInspectorEXE.cxx
-TInspectorEXE_OpenFileDialog.cxx
-TInspectorEXE_OpenFileDialog.hxx
-TInspectorEXE_OpenFileViewModel.cxx
-TInspectorEXE_OpenFileViewModel.hxx
+EXTERNLIB
+PACKAGES
--- /dev/null
+TInspectorEXE/src
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-
-#include <TInspectorEXE_OpenFileDialog.hxx>
-
-#include <inspector/TInspector_Communicator.hxx>
-
-#include <OSD_Environment.hxx>
-
-#include <QAction>
-#include <QApplication>
-#include <QDir>
-#include <QMainWindow>
-#include <QToolBar>
-
-#include <set>
-
-// =======================================================================
-// function : fileNameInDataDir
-// purpose :
-// =======================================================================
-TCollection_AsciiString fileNameInDataDir(const TCollection_AsciiString& theEnvironmentDir,
- const TCollection_AsciiString& theName)
-{
- OSD_Environment anEnvironment(theEnvironmentDir);
-
- TCollection_AsciiString aFileName = anEnvironment.Value();
- aFileName += TCollection_AsciiString("/") + theName;
-
- return aFileName;
-}
-
-// =======================================================================
-// function : setPluginSampleDirectory
-// purpose :
-// =======================================================================
-void setPluginSampleDirectory (const TCollection_AsciiString& theName, TInspector_Communicator* theCommunicator,
- TInspectorEXE_OpenButton* theButtonControl)
-{
- if (theName.IsEqual ("TKDFBrowser"))
- {
- theCommunicator->OpenFile (theName, fileNameInDataDir ("CSF_OCCTDataPath", "step/screw.step"));
- theButtonControl->SetPluginDir (theName, fileNameInDataDir ("CSF_OCCTDataPath", "step"));
- }
- else if (theName.IsEqual ("TKShapeView"))
- {
- theCommunicator->OpenFile (theName, fileNameInDataDir ("CSF_OCCTDataPath", "occ/hammer.brep"));
- theButtonControl->SetPluginDir (theName, fileNameInDataDir ("CSF_OCCTDataPath", "occ"));
- }
- else if (theName.IsEqual ("TKVInspector"))
- {
- theCommunicator->OpenFile (theName, fileNameInDataDir ("CSF_OCCTDataPath", "occ/face1.brep"));
- theCommunicator->OpenFile (theName, fileNameInDataDir ("CSF_OCCTDataPath", "occ/face2.brep"));
- theButtonControl->SetPluginDir (theName, fileNameInDataDir ("CSF_OCCTDataPath", "occ"));
- }
-}
-
-// =======================================================================
-// function : main
-// purpose :
-// =======================================================================
-int main (int argc, char** argv)
-{
- OSD_Environment anEnvironment ("QTDIR");
- TCollection_AsciiString aPlugindsDirName = anEnvironment.Value();
- if (aPlugindsDirName.IsEmpty())
- {
- std::cout << "QTDIR is not defined" << std::endl;
- return 0;
- }
- aPlugindsDirName += "/plugins";
- QApplication::addLibraryPath (aPlugindsDirName.ToCString());
- QApplication anApp (argc, argv);
-
- std::set<TCollection_AsciiString> aPlugins;
- for (int anArgId = 1; anArgId < argc; anArgId++ )
- {
- if (!strcmp (argv[anArgId], "dfbrowser"))
- aPlugins.insert ("TKDFBrowser");
-
- if (!strcmp (argv[anArgId], "shapeview"))
- aPlugins.insert ("TKShapeView");
-
- if (!strcmp (argv[anArgId], "vinspector"))
- aPlugins.insert ("TKVInspector");
- }
- NCollection_List<Handle(Standard_Transient)> aParameters;
-
- // Create tool communicator
- TInspector_Communicator* aCommunicator = TInspectorEXE_OpenFileDialog::Communicator();
- if (!aCommunicator)
- {
- std::cout << "Communicator can not be created" << std::endl;
- return 0;
- }
-
- TInspectorEXE_OpenButton* aButtonControl = new TInspectorEXE_OpenButton (0);
- TCollection_AsciiString anActivatedPluginName;
- if (aPlugins.empty())
- {
- aPlugins.insert("TKDFBrowser");
- aPlugins.insert("TKShapeView");
- aPlugins.insert("TKVInspector");
-
- anActivatedPluginName = "TKDFBrowser";
- }
- else
- anActivatedPluginName = *aPlugins.rbegin();
-
- for (std::set<TCollection_AsciiString>::const_iterator aPluginIt = aPlugins.begin(); aPluginIt != aPlugins.end(); aPluginIt++)
- {
- TCollection_AsciiString aName = *aPluginIt;
- aCommunicator->RegisterPlugin (aName);
- aCommunicator->Init (aName, aParameters);
- setPluginSampleDirectory (aName, aCommunicator, aButtonControl);
- }
- aCommunicator->Activate (anActivatedPluginName);
-
- aCommunicator->SetVisible (true);
- aCommunicator->SetOpenButton (aButtonControl->StartButton());
-
- return anApp.exec();
-}
+++ /dev/null
-<!DOCTYPE RCC><RCC version="1.0">
- <qresource>
- <file>icons/folder_open.png</file>
- <file>icons/folder_import.png</file>
- </qresource>
-</RCC>
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <TInspectorEXE_OpenFileDialog.hxx>
-#include <TInspectorEXE_OpenFileViewModel.hxx>
-
-#include <inspector/TInspector_Communicator.hxx>
-
-#include <QApplication>
-#include <QCompleter>
-#include <QDir>
-#include <QFileDialog>
-#include <QFileSystemModel>
-#include <QItemSelectionModel>
-#include <QGroupBox>
-#include <QHBoxLayout>
-#include <QHeaderView>
-#include <QLabel>
-#include <QLineEdit>
-#include <QScrollBar>
-#include <QTableView>
-#include <QToolButton>
-#include <QPushButton>
-#include <QVBoxLayout>
-#include <QWidget>
-
-const int FONT_POINT_SIZE = 18;
-const int ICON_SIZE = 40;
-
-const int OPEN_DIALOG_WIDTH = 550;
-const int OPEN_DIALOG_HEIGHT = 200;
-
-const int MARGIN_DIALOG = 4;
-const int SPACING_DIALOG = 2;
-
-TInspector_Communicator* MyCommunicator;
-
-// =======================================================================
-// function : StartButton
-// purpose :
-// =======================================================================
-QPushButton* TInspectorEXE_OpenButton::StartButton()
-{
- if (!myStartButton)
- {
- myStartButton = new QPushButton();
- myStartButton->setIcon (QIcon (":/icons/folder_open.png"));
- connect (myStartButton, SIGNAL (clicked()), this, SLOT (onStartButtonClicked()));
- }
- return myStartButton;
-}
-
-// =======================================================================
-// function : onStartButtonClicked
-// purpose :
-// =======================================================================
-void TInspectorEXE_OpenButton::onStartButtonClicked()
-{
- QPushButton* aButton = (QPushButton*)sender();
- TCollection_AsciiString aPluginName (aButton->objectName().toStdString().c_str());
- if (aPluginName.IsEmpty())
- return;
-
- QString aDataDirName = QDir::currentPath();
- if (myDefaultDirs.IsBound (aPluginName))
- aDataDirName = myDefaultDirs.Find (aPluginName).ToCString();
-
- QString aFileName = TInspectorEXE_OpenFileDialog::OpenFile (0, aDataDirName);
- aFileName = QDir().toNativeSeparators (aFileName);
- if (!aFileName.isEmpty()) {
- QApplication::setOverrideCursor (Qt::WaitCursor);
- TInspectorEXE_OpenFileDialog::Communicator()->OpenFile (aPluginName, TCollection_AsciiString (aFileName.toUtf8().data()));
- QApplication::restoreOverrideCursor();
- }
-}
-
-// =======================================================================
-// function : changeMargins
-// purpose :
-// =======================================================================
-void changeMargins (QBoxLayout* theLayout)
-{
- theLayout->setContentsMargins (MARGIN_DIALOG, MARGIN_DIALOG, MARGIN_DIALOG, MARGIN_DIALOG);
- theLayout->setSpacing (SPACING_DIALOG);
-}
-
-// =======================================================================
-// function : Constructor
-// purpose :
-// =======================================================================
-TInspectorEXE_OpenFileDialog::TInspectorEXE_OpenFileDialog (QWidget* theParent, const QString& theDataDirName)
-: QDialog(theParent), myDataDir (theDataDirName)
-{
- setWindowTitle (theDataDirName);
-
- QVBoxLayout* aDialogLay = new QVBoxLayout (this);
- changeMargins (aDialogLay);
-
- // Title label
- QLabel* aTitleLabel = new QLabel (this);
- aTitleLabel->setText (tr ("Open File"));
- aDialogLay->addWidget (aTitleLabel);
-
- // Samples View
- QGroupBox* aSamplesBox = new QGroupBox (this);
- aSamplesBox->setTitle (tr ("Samples"));
- aDialogLay->addWidget (aSamplesBox);
- QVBoxLayout* aSampleLay = new QVBoxLayout (aSamplesBox);
- changeMargins (aSampleLay);
- mySamplesView = createTableView (readSampleNames());
- aSampleLay->addWidget (mySamplesView);
-
- // Select file
- QGroupBox* aSelectFileBox = new QGroupBox (this);
- aSelectFileBox->setTitle (tr ("Select file"));
- aDialogLay->addWidget (aSelectFileBox);
- QGridLayout* aSelectFileLay = new QGridLayout (aSelectFileBox);
- aSelectFileLay->setContentsMargins (MARGIN_DIALOG, MARGIN_DIALOG, MARGIN_DIALOG, MARGIN_DIALOG);
-
- mySelectedName = new QLineEdit (aSelectFileBox);
- QCompleter* aCompleter = new QCompleter();
- QFileSystemModel* aFileSystemModel = new QFileSystemModel;
- aFileSystemModel->setRootPath (QDir::rootPath());
- aCompleter->setModel (aFileSystemModel);
- mySelectedName->setCompleter (aCompleter);
- aSelectFileLay->addWidget (mySelectedName, 1, 0);
-
- QToolButton* aSelectFileBtn = new QToolButton (aSelectFileBox);
- aSelectFileBtn->setIcon (QIcon (":/icons/folder_open.png"));
- aSelectFileLay->addWidget (aSelectFileBtn, 1, 1);
-
- myFolderApplyOpen = new QToolButton (aSelectFileBox);
- myFolderApplyOpen->setIcon (QIcon (":/icons/folder_import.png"));
- myFolderApplyOpen->setIconSize (QSize (ICON_SIZE, ICON_SIZE));
- myFolderApplyOpen->setEnabled (false);
- aSelectFileLay->addWidget (myFolderApplyOpen, 0, 2, 2, 1);
-
- connect (mySelectedName, SIGNAL (textChanged (const QString&)),
- this, SLOT (onNameChanged (const QString&)));
- connect (aSelectFileBtn, SIGNAL (clicked()), this, SLOT (onSelectClicked()));
- connect (myFolderApplyOpen, SIGNAL (clicked()), this, SLOT (onApplySelectClicked()));
-
- resize (OPEN_DIALOG_WIDTH, OPEN_DIALOG_HEIGHT);
-}
-
-// =======================================================================
-// function : OpenFile
-// purpose :
-// =======================================================================
-QString TInspectorEXE_OpenFileDialog::OpenFile (QWidget* theParent, const QString& theDataDirName)
-{
- QString aFileName;
- TInspectorEXE_OpenFileDialog* aDialog = new TInspectorEXE_OpenFileDialog(theParent, theDataDirName);
- if (aDialog->exec() == QDialog::Accepted)
- aFileName = aDialog->GetFileName();
-
- return aFileName;
-}
-
-// =======================================================================
-// function : Communicator
-// purpose :
-// =======================================================================
-TInspector_Communicator* TInspectorEXE_OpenFileDialog::Communicator()
-{
- if (!MyCommunicator)
- MyCommunicator = new TInspector_Communicator();
- return MyCommunicator;
-}
-
-// =======================================================================
-// function : onSampleSelectionChanged
-// purpose :
-// =======================================================================
-void TInspectorEXE_OpenFileDialog::onSampleSelectionChanged (const QItemSelection& theSelected,
- const QItemSelection&)
-{
- QItemSelectionModel* aSelectionModel = (QItemSelectionModel*)sender();
- if (!aSelectionModel)
- return;
- if (theSelected.isEmpty())
- return;
-
- QModelIndex anIndex = theSelected.first().indexes().first();
- if (!anIndex.isValid())
- return;
-
- myFileName = aSelectionModel->model()->data (anIndex, Qt::ToolTipRole).toString();
- accept();
-}
-
-// =======================================================================
-// function : onNameChanged
-// purpose :
-// =======================================================================
-void TInspectorEXE_OpenFileDialog::onNameChanged (const QString& theText)
-{
- QFileInfo aFileInfo (theText);
- bool anExists = aFileInfo.exists() && aFileInfo.isFile();
- myFolderApplyOpen->setEnabled (anExists);
-}
-
-// =======================================================================
-// function : onSelectClicked
-// purpose :
-// =======================================================================
-void TInspectorEXE_OpenFileDialog::onSelectClicked()
-{
- QString anEnteredPath;
- QString aDirName = mySelectedName->text();
- if (!aDirName.isEmpty())
- {
- QDir aDir (aDirName);
- if (aDir.exists())
- anEnteredPath = aDirName;
- }
-
- QString aFileName = QFileDialog::getOpenFileName (0, "Open document", anEnteredPath);
-
- if (aFileName.isEmpty())
- return; // do nothing, left the previous value
-
- mySelectedName->setText (aFileName);
- onNameChanged (aFileName);
-}
-
-// =======================================================================
-// function : onApplySelectClicked
-// purpose :
-// =======================================================================
-void TInspectorEXE_OpenFileDialog::onApplySelectClicked()
-{
- myFileName = mySelectedName->text();
- accept();
-}
-
-// =======================================================================
-// function : createTableView
-// purpose :
-// =======================================================================
-QTableView* TInspectorEXE_OpenFileDialog::createTableView (const QStringList& theFileNames)
-{
- QTableView* aTableView = new QTableView (this);
- aTableView->setFrameStyle (QFrame::NoFrame);
- QPalette aPalette = aTableView->viewport()->palette();
- QColor aWindowColor = aPalette.color (QPalette::Window);
- aPalette.setBrush (QPalette::Base, aWindowColor);
- aTableView->viewport()->setPalette (aPalette);
-
- aTableView->horizontalHeader()->setVisible (false);
- aTableView->verticalHeader()->setVisible (false);
- aTableView->setGridStyle (Qt::NoPen);
- aTableView->setModel (createModel (theFileNames));
- aTableView->setItemDelegateForRow (0, new TInspectorEXE_OpenFileItemDelegate (aTableView,
- aPalette.color (QPalette::Highlight)));
- aTableView->viewport()->setAttribute (Qt::WA_Hover);
- int aCellHeight = ICON_SIZE + aTableView->verticalHeader()->defaultSectionSize();
- aTableView->setRowHeight (0, aCellHeight);
- int aScrollHeight = aTableView->horizontalScrollBar()->sizeHint().height();
- aTableView->setMinimumHeight (aCellHeight + aScrollHeight);
- QItemSelectionModel* aSelectionModel = new QItemSelectionModel (aTableView->model());
- connect (aSelectionModel, SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
- this, SLOT (onSampleSelectionChanged (const QItemSelection&, const QItemSelection&)));
- aTableView->setSelectionModel (aSelectionModel);
-
- return aTableView;
-}
-
-// =======================================================================
-// function : createModel
-// purpose :
-// =======================================================================
-QAbstractItemModel* TInspectorEXE_OpenFileDialog::createModel (const QStringList& theFileNames)
-{
- TInspectorEXE_OpenFileViewModel* aModel = new TInspectorEXE_OpenFileViewModel (this);
- aModel->Init (theFileNames);
- return aModel;
-}
-
-// =======================================================================
-// function : readSampleNames
-// purpose :
-// =======================================================================
-QStringList TInspectorEXE_OpenFileDialog::readSampleNames()
-{
- QStringList aNames;
-
- QDir aDir(myDataDir);
- aDir.setSorting(QDir::Name);
-
- QFileInfoList aDirEntries = aDir.entryInfoList();
- for (int aDirId = 0; aDirId < aDirEntries.size(); ++aDirId)
- {
- QFileInfo aFileInfo = aDirEntries.at(aDirId);
- if (aFileInfo.isFile())
- aNames.append (aFileInfo.absoluteFilePath());
- }
- return aNames;
-}
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef TInspectorEXE_OpenFileDialog_H
-#define TInspectorEXE_OpenFileDialog_H
-
-#include <NCollection_DataMap.hxx>
-#include <TCollection_AsciiString.hxx>
-
-#ifdef _MSC_VER
-#pragma warning(disable : 4127) // conditional expression is constant
-#endif
-#include <QDialog>
-#include <QItemSelection>
-#include <QStringList>
-
-#include <map>
-
-class TInspector_Communicator;
-
-class QAbstractItemModel;
-class QLineEdit;
-class QPushButton;
-class QTableView;
-class QToolButton;
-class QWidget;
-
-//! \class TInspectorEXE_OpenButton
-//! Class that contains push button and the button processing. It obtains a file name from the default or current
-//! directory and gives the name into TInspector communicator
-//! Object name of the button is the name of the plugin to get the default directory, or the current directory is used.
-class TInspectorEXE_OpenButton : public QObject
-{
- Q_OBJECT
-
-public:
-
- //! Constructor
- TInspectorEXE_OpenButton (QObject* theParent) : QObject (theParent), myStartButton (0) {}
-
- //! Destructor
- virtual ~TInspectorEXE_OpenButton() {}
-
- //! Returns the start button, if this is the first call, it creates the button and connect it to the slot
- QPushButton* StartButton();
-
- //! Sets the default directory of plugin.
- void SetPluginDir (const TCollection_AsciiString& thePluginName, const TCollection_AsciiString& theDefaultDir)
- { myDefaultDirs.Bind (thePluginName, theDefaultDir); }
-
-private slots:
-
- //! Processes the button click, open default/current directory to select open file, calls OpenFile of communicator
- void onStartButtonClicked();
-
-private:
-
- QPushButton* myStartButton; //!< processed button
- NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString> myDefaultDirs; //!< plugins default directories
-};
-
-//! \class TInspectorEXE_OpenFileDialog
-//! Control that contains table view of samples and line to select a file name from other directory.
-//! Click on element of samples table view calls this sample opening else after entering(or opening) file name
-//! the import becomes active. Click on the button will open selected file if it is possible
-class TInspectorEXE_OpenFileDialog : public QDialog
-{
- Q_OBJECT
-private:
-
- //! Constructor
- TInspectorEXE_OpenFileDialog (QWidget* theParent, const QString& theDataDirName);
-
-public:
-
- //! Destructor
- virtual ~TInspectorEXE_OpenFileDialog() Standard_OVERRIDE {}
-
- //! Opens this file dialog using for samples view the given directory and try to open new file
- //! \param theParent a parent for the new dialog
- //! \param theDataDirName path to default samples directory
- //! \returns a file name from the open file dialog
- static QString OpenFile (QWidget* theParent, const QString& theDataDirName);
-
- //! Returns selection name from the dialog
- QString GetFileName() const { return myFileName; }
-
- //! Returns communicator, if this is the first call, create a communicator instance
- static TInspector_Communicator* Communicator();
-
-private slots:
-
- //! Stores name of selected sample file
- void onSampleSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
-
- //! Updates enabling state of Open file button, it is enabled if the file by the entered path exists
- //! \param theText a file name text in line edit
- void onNameChanged (const QString& theText);
-
- //! Open file dialog to select a file name. Fills file name line, enable import button
- void onSelectClicked();
-
- //! Accepts open file dialog
- void onApplySelectClicked();
-
-private:
-
- //! Creates view of file names in samples directory
- //! \param theFileNames a container of names
- //! \return table view
- QTableView* createTableView (const QStringList& theFileNames);
-
- //! Creates view model and fills it by the file names
- //! \param theFileNames a container of names
- //! \return model
- QAbstractItemModel* createModel (const QStringList& theFileNames);
-
- //! Generates container of file names in samples directory
- //! \return container of names
- QStringList readSampleNames();
-
-private:
-
- QString myDataDir; //!< samples directory
- QString myFileName; //!< result file name
- QTableView* mySamplesView; //! <view of sample file names
- QLineEdit* mySelectedName; //!< alternative control to open file
- QToolButton* myFolderApplyOpen; //! button to open file
-};
-
-#endif
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <TInspectorEXE_OpenFileViewModel.hxx>
-
-#include <QApplication>
-#include <QFileInfo>
-#include <QIcon>
-#include <QPainter>
-
-const int ICON_SIZE = 40;
-
-// =======================================================================
-// function : paint
-// purpose :
-// =======================================================================
-void TInspectorEXE_OpenFileItemDelegate::paint (QPainter* thePainter, const QStyleOptionViewItem& theOption,
- const QModelIndex& theIndex) const
-{
- // highlight cell
- if (theOption.state & QStyle::State_MouseOver)
- thePainter->fillRect (theOption.rect, myColor);
-
- // action icon for all indices before the last one
- QIcon anIcon (":/icons/folder_import.png");
- QSize anIconSize (ICON_SIZE, ICON_SIZE);
- int aWidth = theOption.rect.width();
- int aCenter = aWidth / 2.;
- int aHalf = anIconSize.width() / 2.;
- int aMargin = qApp->style()->pixelMetric (QStyle::PM_HeaderMargin);
- thePainter->drawPixmap (QRect (theOption.rect.left() + (aCenter - aHalf),
- theOption.rect.top() + aMargin,
- anIconSize.width(),
- anIconSize.height()),
- anIcon.pixmap(anIconSize.width(), anIconSize.height()));
- // default paint
- QItemDelegate::paint (thePainter, theOption, theIndex);
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-void TInspectorEXE_OpenFileViewModel::Init (const QStringList& theValues)
-{
- myValues = theValues;
-}
-
-// =======================================================================
-// function : data
-// purpose :
-// =======================================================================
-QVariant TInspectorEXE_OpenFileViewModel::data (const QModelIndex& theIndex, int theRole) const
-{
- switch (theRole)
- {
- case Qt::DisplayRole: return QFileInfo (myValues[theIndex.column()]).fileName();
- case Qt::ToolTipRole: return myValues[theIndex.column()];
- case Qt::TextAlignmentRole: return QVariant (Qt::AlignBottom | Qt::AlignHCenter);
- default: break;
- }
- return QVariant();
-}
+++ /dev/null
-// Created on: 2017-06-16
-// Created by: Natalia ERMOLAEVA
-// Copyright (c) 2017 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef TInspectorEXE_OpenFileViewModel_H
-#define TInspectorEXE_OpenFileViewModel_H
-
-#include <Standard_Macro.hxx>
-
-#ifdef _MSC_VER
-#pragma warning(disable : 4127) // conditional expression is constant
-#endif
-#include <QAbstractTableModel>
-#include <QStringList>
-#include <QItemDelegate>
-
-class QObject;
-class QPainter;
-
-//! \class TInspectorEXE_OpenFileItemDelegate
-//! Draws large(40x40) icons in cell. The icon background in colored in highlight when mouse is over button
-class TInspectorEXE_OpenFileItemDelegate : public QItemDelegate
-{
-
-public:
-
- //! Constructor
- TInspectorEXE_OpenFileItemDelegate (QObject* theParent, const QColor& theHighlightColor)
- : QItemDelegate (theParent), myColor(theHighlightColor) {}
-
- //! Destructor
- virtual ~TInspectorEXE_OpenFileItemDelegate() {}
-
- //! Draw an icon in the cell
- //! \param thePainter a painter
- //! \param theOption a paint options
- //! \param theIndex a view index
- virtual void paint (QPainter* thePainter, const QStyleOptionViewItem& theOption,
- const QModelIndex& theIndex) const Standard_OVERRIDE;
-
-private:
-
- QColor myColor; //!< highlight color
-};
-
-//! \class TInspectorEXE_OpenFileViewModel
-//! Table model that visualizes container of string values (file names)
-//! Table orientation is horizontal, it has 1 row, number of columns equals to number of values
-class TInspectorEXE_OpenFileViewModel : public QAbstractTableModel
-{
-
-public:
-
- //! Constructor
- TInspectorEXE_OpenFileViewModel (QObject* theParent = 0) : QAbstractTableModel (theParent) {}
-
- //! Destructor
- virtual ~TInspectorEXE_OpenFileViewModel() {}
-
- //! Store values
- //! \param theValues a container of values to fill model
- void Init (const QStringList& theValues);
-
- //! Returns content of the model index for the given role, it is obtained from internal container of values
- //! It returns value only for DisplayRole.
- //! \param theIndex a model index
- //! \param theRole a view role
- //! \return value intepreted depending on the given role
- virtual QVariant data (const QModelIndex& theIndex, int theRole = Qt::DisplayRole) const Standard_OVERRIDE;
-
- //! Returns number of rows
- //! \param theParent an index of the parent item
- //! \return an integer value
- virtual int rowCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
- { (void)theParent; return 1; }
-
- //! Returns number of columns
- //! \param theParent an index of the parent item
- //! \return an integer value
- virtual int columnCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
- { (void)theParent; return myValues.size(); }
-
-private:
-
- QStringList myValues; //!< file names
-};
-
-#endif
--- /dev/null
+TInspectorEXE.cxx
+TInspectorEXE_OpenFileDialog.cxx
+TInspectorEXE_OpenFileDialog.hxx
+TInspectorEXE_OpenFileViewModel.cxx
+TInspectorEXE_OpenFileViewModel.hxx
+TInspectorEXE.qrc
\ No newline at end of file
--- /dev/null
+// Created on: 2017-06-16
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2017 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+
+#include <TInspectorEXE_OpenFileDialog.hxx>
+
+#include <inspector/TInspector_Communicator.hxx>
+
+#include <OSD_Environment.hxx>
+
+#include <QAction>
+#include <QApplication>
+#include <QDir>
+#include <QMainWindow>
+#include <QToolBar>
+
+#include <set>
+
+// =======================================================================
+// function : fileNameInDataDir
+// purpose :
+// =======================================================================
+TCollection_AsciiString fileNameInDataDir(const TCollection_AsciiString& theEnvironmentDir,
+ const TCollection_AsciiString& theName)
+{
+ OSD_Environment anEnvironment(theEnvironmentDir);
+
+ TCollection_AsciiString aFileName = anEnvironment.Value();
+ aFileName += TCollection_AsciiString("/") + theName;
+
+ return aFileName;
+}
+
+// =======================================================================
+// function : setPluginSampleDirectory
+// purpose :
+// =======================================================================
+void setPluginSampleDirectory (const TCollection_AsciiString& theName, TInspector_Communicator* theCommunicator,
+ TInspectorEXE_OpenButton* theButtonControl)
+{
+ if (theName.IsEqual ("TKDFBrowser"))
+ {
+ theCommunicator->OpenFile (theName, fileNameInDataDir ("CSF_OCCTDataPath", "step/screw.step"));
+ theButtonControl->SetPluginDir (theName, fileNameInDataDir ("CSF_OCCTDataPath", "step"));
+ }
+ else if (theName.IsEqual ("TKShapeView"))
+ {
+ theCommunicator->OpenFile (theName, fileNameInDataDir ("CSF_OCCTDataPath", "occ/hammer.brep"));
+ theButtonControl->SetPluginDir (theName, fileNameInDataDir ("CSF_OCCTDataPath", "occ"));
+ }
+ else if (theName.IsEqual ("TKVInspector"))
+ {
+ theCommunicator->OpenFile (theName, fileNameInDataDir ("CSF_OCCTDataPath", "occ/face1.brep"));
+ theCommunicator->OpenFile (theName, fileNameInDataDir ("CSF_OCCTDataPath", "occ/face2.brep"));
+ theButtonControl->SetPluginDir (theName, fileNameInDataDir ("CSF_OCCTDataPath", "occ"));
+ }
+}
+
+// =======================================================================
+// function : main
+// purpose :
+// =======================================================================
+int main (int argc, char** argv)
+{
+#if QT_VERSION > 0x050000
+ TCollection_AsciiString aPlugindsDirName = OSD_Environment ("QTDIR").Value();
+ if (!aPlugindsDirName.IsEmpty())
+ QApplication::addLibraryPath (QString (aPlugindsDirName.ToCString()) + "/plugins");
+#endif
+ QApplication anApp (argc, argv);
+
+ std::set<TCollection_AsciiString> aPlugins;
+ for (int anArgId = 1; anArgId < argc; anArgId++ )
+ {
+ if (!strcmp (argv[anArgId], "dfbrowser"))
+ aPlugins.insert ("TKDFBrowser");
+
+ if (!strcmp (argv[anArgId], "shapeview"))
+ aPlugins.insert ("TKShapeView");
+
+ if (!strcmp (argv[anArgId], "vinspector"))
+ aPlugins.insert ("TKVInspector");
+ }
+ NCollection_List<Handle(Standard_Transient)> aParameters;
+
+ // Create tool communicator
+ TInspector_Communicator* aCommunicator = TInspectorEXE_OpenFileDialog::Communicator();
+ if (!aCommunicator)
+ {
+ std::cout << "Communicator can not be created" << std::endl;
+ return 0;
+ }
+
+ TInspectorEXE_OpenButton* aButtonControl = new TInspectorEXE_OpenButton (0);
+ TCollection_AsciiString anActivatedPluginName;
+ if (aPlugins.empty())
+ {
+ aPlugins.insert("TKDFBrowser");
+ aPlugins.insert("TKShapeView");
+ aPlugins.insert("TKVInspector");
+
+ anActivatedPluginName = "TKDFBrowser";
+ }
+ else
+ anActivatedPluginName = *aPlugins.rbegin();
+
+ for (std::set<TCollection_AsciiString>::const_iterator aPluginIt = aPlugins.begin(); aPluginIt != aPlugins.end(); aPluginIt++)
+ {
+ TCollection_AsciiString aName = *aPluginIt;
+ aCommunicator->RegisterPlugin (aName);
+ aCommunicator->Init (aName, aParameters);
+ setPluginSampleDirectory (aName, aCommunicator, aButtonControl);
+ }
+ aCommunicator->Activate (anActivatedPluginName);
+
+ aCommunicator->SetVisible (true);
+ aCommunicator->SetOpenButton (aButtonControl->StartButton());
+
+ return anApp.exec();
+}
--- /dev/null
+<!DOCTYPE RCC><RCC version="1.0">
+ <qresource prefix="/">
+ <file alias="folder_open.png">../icons/folder_open.png</file>
+ <file alias="folder_import.png">../icons/folder_import.png</file>
+ </qresource>
+</RCC>
--- /dev/null
+// Created on: 2017-06-16
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2017 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <TInspectorEXE_OpenFileDialog.hxx>
+#include <TInspectorEXE_OpenFileViewModel.hxx>
+
+#include <inspector/TInspector_Communicator.hxx>
+
+#include <QApplication>
+#include <QCompleter>
+#include <QDir>
+#include <QFileDialog>
+#include <QFileSystemModel>
+#include <QItemSelectionModel>
+#include <QGroupBox>
+#include <QHBoxLayout>
+#include <QHeaderView>
+#include <QLabel>
+#include <QLineEdit>
+#include <QScrollBar>
+#include <QTableView>
+#include <QToolButton>
+#include <QPushButton>
+#include <QVBoxLayout>
+#include <QWidget>
+
+const int FONT_POINT_SIZE = 18;
+const int ICON_SIZE = 40;
+
+const int OPEN_DIALOG_WIDTH = 550;
+const int OPEN_DIALOG_HEIGHT = 200;
+
+const int MARGIN_DIALOG = 4;
+const int SPACING_DIALOG = 2;
+
+TInspector_Communicator* MyCommunicator;
+
+// =======================================================================
+// function : StartButton
+// purpose :
+// =======================================================================
+QPushButton* TInspectorEXE_OpenButton::StartButton()
+{
+ if (!myStartButton)
+ {
+ myStartButton = new QPushButton();
+ myStartButton->setIcon (QIcon (":folder_open.png"));
+ connect (myStartButton, SIGNAL (clicked()), this, SLOT (onStartButtonClicked()));
+ }
+ return myStartButton;
+}
+
+// =======================================================================
+// function : onStartButtonClicked
+// purpose :
+// =======================================================================
+void TInspectorEXE_OpenButton::onStartButtonClicked()
+{
+ QPushButton* aButton = (QPushButton*)sender();
+ TCollection_AsciiString aPluginName (aButton->objectName().toStdString().c_str());
+ if (aPluginName.IsEmpty())
+ return;
+
+ QString aDataDirName = QDir::currentPath();
+ if (myDefaultDirs.IsBound (aPluginName))
+ aDataDirName = myDefaultDirs.Find (aPluginName).ToCString();
+
+ QString aFileName = TInspectorEXE_OpenFileDialog::OpenFile (0, aDataDirName);
+ aFileName = QDir().toNativeSeparators (aFileName);
+ if (!aFileName.isEmpty()) {
+ QApplication::setOverrideCursor (Qt::WaitCursor);
+ TInspectorEXE_OpenFileDialog::Communicator()->OpenFile (aPluginName, TCollection_AsciiString (aFileName.toUtf8().data()));
+ QApplication::restoreOverrideCursor();
+ }
+}
+
+// =======================================================================
+// function : changeMargins
+// purpose :
+// =======================================================================
+void changeMargins (QBoxLayout* theLayout)
+{
+ theLayout->setContentsMargins (MARGIN_DIALOG, MARGIN_DIALOG, MARGIN_DIALOG, MARGIN_DIALOG);
+ theLayout->setSpacing (SPACING_DIALOG);
+}
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+TInspectorEXE_OpenFileDialog::TInspectorEXE_OpenFileDialog (QWidget* theParent, const QString& theDataDirName)
+: QDialog(theParent), myDataDir (theDataDirName)
+{
+ setWindowTitle (theDataDirName);
+
+ QVBoxLayout* aDialogLay = new QVBoxLayout (this);
+ changeMargins (aDialogLay);
+
+ // Title label
+ QLabel* aTitleLabel = new QLabel (this);
+ aTitleLabel->setText (tr ("Open File"));
+ aDialogLay->addWidget (aTitleLabel);
+
+ // Samples View
+ QGroupBox* aSamplesBox = new QGroupBox (this);
+ aSamplesBox->setTitle (tr ("Samples"));
+ aDialogLay->addWidget (aSamplesBox);
+ QVBoxLayout* aSampleLay = new QVBoxLayout (aSamplesBox);
+ changeMargins (aSampleLay);
+ mySamplesView = createTableView (readSampleNames());
+ aSampleLay->addWidget (mySamplesView);
+
+ // Select file
+ QGroupBox* aSelectFileBox = new QGroupBox (this);
+ aSelectFileBox->setTitle (tr ("Select file"));
+ aDialogLay->addWidget (aSelectFileBox);
+ QGridLayout* aSelectFileLay = new QGridLayout (aSelectFileBox);
+ aSelectFileLay->setContentsMargins (MARGIN_DIALOG, MARGIN_DIALOG, MARGIN_DIALOG, MARGIN_DIALOG);
+
+ mySelectedName = new QLineEdit (aSelectFileBox);
+ QCompleter* aCompleter = new QCompleter();
+ QFileSystemModel* aFileSystemModel = new QFileSystemModel;
+ aFileSystemModel->setRootPath (QDir::rootPath());
+ aCompleter->setModel (aFileSystemModel);
+ mySelectedName->setCompleter (aCompleter);
+ aSelectFileLay->addWidget (mySelectedName, 1, 0);
+
+ QToolButton* aSelectFileBtn = new QToolButton (aSelectFileBox);
+ aSelectFileBtn->setIcon (QIcon (":folder_open.png"));
+ aSelectFileLay->addWidget (aSelectFileBtn, 1, 1);
+
+ myFolderApplyOpen = new QToolButton (aSelectFileBox);
+ myFolderApplyOpen->setIcon (QIcon (":folder_import.png"));
+ myFolderApplyOpen->setIconSize (QSize (ICON_SIZE, ICON_SIZE));
+ myFolderApplyOpen->setEnabled (false);
+ aSelectFileLay->addWidget (myFolderApplyOpen, 0, 2, 2, 1);
+
+ connect (mySelectedName, SIGNAL (textChanged (const QString&)),
+ this, SLOT (onNameChanged (const QString&)));
+ connect (aSelectFileBtn, SIGNAL (clicked()), this, SLOT (onSelectClicked()));
+ connect (myFolderApplyOpen, SIGNAL (clicked()), this, SLOT (onApplySelectClicked()));
+
+ resize (OPEN_DIALOG_WIDTH, OPEN_DIALOG_HEIGHT);
+}
+
+// =======================================================================
+// function : OpenFile
+// purpose :
+// =======================================================================
+QString TInspectorEXE_OpenFileDialog::OpenFile (QWidget* theParent, const QString& theDataDirName)
+{
+ QString aFileName;
+ TInspectorEXE_OpenFileDialog* aDialog = new TInspectorEXE_OpenFileDialog(theParent, theDataDirName);
+ if (aDialog->exec() == QDialog::Accepted)
+ aFileName = aDialog->GetFileName();
+
+ return aFileName;
+}
+
+// =======================================================================
+// function : Communicator
+// purpose :
+// =======================================================================
+TInspector_Communicator* TInspectorEXE_OpenFileDialog::Communicator()
+{
+ if (!MyCommunicator)
+ MyCommunicator = new TInspector_Communicator();
+ return MyCommunicator;
+}
+
+// =======================================================================
+// function : onSampleSelectionChanged
+// purpose :
+// =======================================================================
+void TInspectorEXE_OpenFileDialog::onSampleSelectionChanged (const QItemSelection& theSelected,
+ const QItemSelection&)
+{
+ QItemSelectionModel* aSelectionModel = (QItemSelectionModel*)sender();
+ if (!aSelectionModel)
+ return;
+ if (theSelected.isEmpty())
+ return;
+
+ QModelIndex anIndex = theSelected.first().indexes().first();
+ if (!anIndex.isValid())
+ return;
+
+ myFileName = aSelectionModel->model()->data (anIndex, Qt::ToolTipRole).toString();
+ accept();
+}
+
+// =======================================================================
+// function : onNameChanged
+// purpose :
+// =======================================================================
+void TInspectorEXE_OpenFileDialog::onNameChanged (const QString& theText)
+{
+ QFileInfo aFileInfo (theText);
+ bool anExists = aFileInfo.exists() && aFileInfo.isFile();
+ myFolderApplyOpen->setEnabled (anExists);
+}
+
+// =======================================================================
+// function : onSelectClicked
+// purpose :
+// =======================================================================
+void TInspectorEXE_OpenFileDialog::onSelectClicked()
+{
+ QString anEnteredPath;
+ QString aDirName = mySelectedName->text();
+ if (!aDirName.isEmpty())
+ {
+ QDir aDir (aDirName);
+ if (aDir.exists())
+ anEnteredPath = aDirName;
+ }
+
+ QString aFileName = QFileDialog::getOpenFileName (0, "Open document", anEnteredPath);
+
+ if (aFileName.isEmpty())
+ return; // do nothing, left the previous value
+
+ mySelectedName->setText (aFileName);
+ onNameChanged (aFileName);
+}
+
+// =======================================================================
+// function : onApplySelectClicked
+// purpose :
+// =======================================================================
+void TInspectorEXE_OpenFileDialog::onApplySelectClicked()
+{
+ myFileName = mySelectedName->text();
+ accept();
+}
+
+// =======================================================================
+// function : createTableView
+// purpose :
+// =======================================================================
+QTableView* TInspectorEXE_OpenFileDialog::createTableView (const QStringList& theFileNames)
+{
+ QTableView* aTableView = new QTableView (this);
+ aTableView->setFrameStyle (QFrame::NoFrame);
+ QPalette aPalette = aTableView->viewport()->palette();
+ QColor aWindowColor = aPalette.color (QPalette::Window);
+ aPalette.setBrush (QPalette::Base, aWindowColor);
+ aTableView->viewport()->setPalette (aPalette);
+
+ aTableView->horizontalHeader()->setVisible (false);
+ aTableView->verticalHeader()->setVisible (false);
+ aTableView->setGridStyle (Qt::NoPen);
+ aTableView->setModel (createModel (theFileNames));
+ aTableView->setItemDelegateForRow (0, new TInspectorEXE_OpenFileItemDelegate (aTableView,
+ aPalette.color (QPalette::Highlight)));
+ aTableView->viewport()->setAttribute (Qt::WA_Hover);
+ int aCellHeight = ICON_SIZE + aTableView->verticalHeader()->defaultSectionSize();
+ aTableView->setRowHeight (0, aCellHeight);
+ int aScrollHeight = aTableView->horizontalScrollBar()->sizeHint().height();
+ aTableView->setMinimumHeight (aCellHeight + aScrollHeight);
+ QItemSelectionModel* aSelectionModel = new QItemSelectionModel (aTableView->model());
+ connect (aSelectionModel, SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
+ this, SLOT (onSampleSelectionChanged (const QItemSelection&, const QItemSelection&)));
+ aTableView->setSelectionModel (aSelectionModel);
+
+ return aTableView;
+}
+
+// =======================================================================
+// function : createModel
+// purpose :
+// =======================================================================
+QAbstractItemModel* TInspectorEXE_OpenFileDialog::createModel (const QStringList& theFileNames)
+{
+ TInspectorEXE_OpenFileViewModel* aModel = new TInspectorEXE_OpenFileViewModel (this);
+ aModel->Init (theFileNames);
+ return aModel;
+}
+
+// =======================================================================
+// function : readSampleNames
+// purpose :
+// =======================================================================
+QStringList TInspectorEXE_OpenFileDialog::readSampleNames()
+{
+ QStringList aNames;
+
+ QDir aDir(myDataDir);
+ aDir.setSorting(QDir::Name);
+
+ QFileInfoList aDirEntries = aDir.entryInfoList();
+ for (int aDirId = 0; aDirId < aDirEntries.size(); ++aDirId)
+ {
+ QFileInfo aFileInfo = aDirEntries.at(aDirId);
+ if (aFileInfo.isFile())
+ aNames.append (aFileInfo.absoluteFilePath());
+ }
+ return aNames;
+}
--- /dev/null
+// Created on: 2017-06-16
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2017 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef TInspectorEXE_OpenFileDialog_H
+#define TInspectorEXE_OpenFileDialog_H
+
+#include <NCollection_DataMap.hxx>
+#include <TCollection_AsciiString.hxx>
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4127) // conditional expression is constant
+#endif
+#include <QDialog>
+#include <QItemSelection>
+#include <QStringList>
+
+#include <map>
+
+class TInspector_Communicator;
+
+class QAbstractItemModel;
+class QLineEdit;
+class QPushButton;
+class QTableView;
+class QToolButton;
+class QWidget;
+
+//! \class TInspectorEXE_OpenButton
+//! Class that contains push button and the button processing. It obtains a file name from the default or current
+//! directory and gives the name into TInspector communicator
+//! Object name of the button is the name of the plugin to get the default directory, or the current directory is used.
+class TInspectorEXE_OpenButton : public QObject
+{
+ Q_OBJECT
+
+public:
+
+ //! Constructor
+ TInspectorEXE_OpenButton (QObject* theParent) : QObject (theParent), myStartButton (0) {}
+
+ //! Destructor
+ virtual ~TInspectorEXE_OpenButton() {}
+
+ //! Returns the start button, if this is the first call, it creates the button and connect it to the slot
+ QPushButton* StartButton();
+
+ //! Sets the default directory of plugin.
+ void SetPluginDir (const TCollection_AsciiString& thePluginName, const TCollection_AsciiString& theDefaultDir)
+ { myDefaultDirs.Bind (thePluginName, theDefaultDir); }
+
+private slots:
+
+ //! Processes the button click, open default/current directory to select open file, calls OpenFile of communicator
+ void onStartButtonClicked();
+
+private:
+
+ QPushButton* myStartButton; //!< processed button
+ NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString> myDefaultDirs; //!< plugins default directories
+};
+
+//! \class TInspectorEXE_OpenFileDialog
+//! Control that contains table view of samples and line to select a file name from other directory.
+//! Click on element of samples table view calls this sample opening else after entering(or opening) file name
+//! the import becomes active. Click on the button will open selected file if it is possible
+class TInspectorEXE_OpenFileDialog : public QDialog
+{
+ Q_OBJECT
+private:
+
+ //! Constructor
+ TInspectorEXE_OpenFileDialog (QWidget* theParent, const QString& theDataDirName);
+
+public:
+
+ //! Destructor
+ virtual ~TInspectorEXE_OpenFileDialog() Standard_OVERRIDE {}
+
+ //! Opens this file dialog using for samples view the given directory and try to open new file
+ //! \param theParent a parent for the new dialog
+ //! \param theDataDirName path to default samples directory
+ //! \returns a file name from the open file dialog
+ static QString OpenFile (QWidget* theParent, const QString& theDataDirName);
+
+ //! Returns selection name from the dialog
+ QString GetFileName() const { return myFileName; }
+
+ //! Returns communicator, if this is the first call, create a communicator instance
+ static TInspector_Communicator* Communicator();
+
+private slots:
+
+ //! Stores name of selected sample file
+ void onSampleSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
+
+ //! Updates enabling state of Open file button, it is enabled if the file by the entered path exists
+ //! \param theText a file name text in line edit
+ void onNameChanged (const QString& theText);
+
+ //! Open file dialog to select a file name. Fills file name line, enable import button
+ void onSelectClicked();
+
+ //! Accepts open file dialog
+ void onApplySelectClicked();
+
+private:
+
+ //! Creates view of file names in samples directory
+ //! \param theFileNames a container of names
+ //! \return table view
+ QTableView* createTableView (const QStringList& theFileNames);
+
+ //! Creates view model and fills it by the file names
+ //! \param theFileNames a container of names
+ //! \return model
+ QAbstractItemModel* createModel (const QStringList& theFileNames);
+
+ //! Generates container of file names in samples directory
+ //! \return container of names
+ QStringList readSampleNames();
+
+private:
+
+ QString myDataDir; //!< samples directory
+ QString myFileName; //!< result file name
+ QTableView* mySamplesView; //! <view of sample file names
+ QLineEdit* mySelectedName; //!< alternative control to open file
+ QToolButton* myFolderApplyOpen; //! button to open file
+};
+
+#endif
--- /dev/null
+// Created on: 2017-06-16
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2017 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <TInspectorEXE_OpenFileViewModel.hxx>
+
+#include <QApplication>
+#include <QFileInfo>
+#include <QIcon>
+#include <QPainter>
+
+const int ICON_SIZE = 40;
+
+// =======================================================================
+// function : paint
+// purpose :
+// =======================================================================
+void TInspectorEXE_OpenFileItemDelegate::paint (QPainter* thePainter, const QStyleOptionViewItem& theOption,
+ const QModelIndex& theIndex) const
+{
+ // highlight cell
+ if (theOption.state & QStyle::State_MouseOver)
+ thePainter->fillRect (theOption.rect, myColor);
+
+ // action icon for all indices before the last one
+ QIcon anIcon (":/icons/folder_import.png");
+ QSize anIconSize (ICON_SIZE, ICON_SIZE);
+ int aWidth = theOption.rect.width();
+ int aCenter = aWidth / 2.;
+ int aHalf = anIconSize.width() / 2.;
+ int aMargin = qApp->style()->pixelMetric (QStyle::PM_HeaderMargin);
+ thePainter->drawPixmap (QRect (theOption.rect.left() + (aCenter - aHalf),
+ theOption.rect.top() + aMargin,
+ anIconSize.width(),
+ anIconSize.height()),
+ anIcon.pixmap(anIconSize.width(), anIconSize.height()));
+ // default paint
+ QItemDelegate::paint (thePainter, theOption, theIndex);
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void TInspectorEXE_OpenFileViewModel::Init (const QStringList& theValues)
+{
+ myValues = theValues;
+}
+
+// =======================================================================
+// function : data
+// purpose :
+// =======================================================================
+QVariant TInspectorEXE_OpenFileViewModel::data (const QModelIndex& theIndex, int theRole) const
+{
+ switch (theRole)
+ {
+ case Qt::DisplayRole: return QFileInfo (myValues[theIndex.column()]).fileName();
+ case Qt::ToolTipRole: return myValues[theIndex.column()];
+ case Qt::TextAlignmentRole: return QVariant (Qt::AlignBottom | Qt::AlignHCenter);
+ default: break;
+ }
+ return QVariant();
+}
--- /dev/null
+// Created on: 2017-06-16
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2017 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef TInspectorEXE_OpenFileViewModel_H
+#define TInspectorEXE_OpenFileViewModel_H
+
+#include <Standard_Macro.hxx>
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4127) // conditional expression is constant
+#endif
+#include <QAbstractTableModel>
+#include <QStringList>
+#include <QItemDelegate>
+
+class QObject;
+class QPainter;
+
+//! \class TInspectorEXE_OpenFileItemDelegate
+//! Draws large(40x40) icons in cell. The icon background in colored in highlight when mouse is over button
+class TInspectorEXE_OpenFileItemDelegate : public QItemDelegate
+{
+
+public:
+
+ //! Constructor
+ TInspectorEXE_OpenFileItemDelegate (QObject* theParent, const QColor& theHighlightColor)
+ : QItemDelegate (theParent), myColor(theHighlightColor) {}
+
+ //! Destructor
+ virtual ~TInspectorEXE_OpenFileItemDelegate() {}
+
+ //! Draw an icon in the cell
+ //! \param thePainter a painter
+ //! \param theOption a paint options
+ //! \param theIndex a view index
+ virtual void paint (QPainter* thePainter, const QStyleOptionViewItem& theOption,
+ const QModelIndex& theIndex) const Standard_OVERRIDE;
+
+private:
+
+ QColor myColor; //!< highlight color
+};
+
+//! \class TInspectorEXE_OpenFileViewModel
+//! Table model that visualizes container of string values (file names)
+//! Table orientation is horizontal, it has 1 row, number of columns equals to number of values
+class TInspectorEXE_OpenFileViewModel : public QAbstractTableModel
+{
+
+public:
+
+ //! Constructor
+ TInspectorEXE_OpenFileViewModel (QObject* theParent = 0) : QAbstractTableModel (theParent) {}
+
+ //! Destructor
+ virtual ~TInspectorEXE_OpenFileViewModel() {}
+
+ //! Store values
+ //! \param theValues a container of values to fill model
+ void Init (const QStringList& theValues);
+
+ //! Returns content of the model index for the given role, it is obtained from internal container of values
+ //! It returns value only for DisplayRole.
+ //! \param theIndex a model index
+ //! \param theRole a view role
+ //! \return value intepreted depending on the given role
+ virtual QVariant data (const QModelIndex& theIndex, int theRole = Qt::DisplayRole) const Standard_OVERRIDE;
+
+ //! Returns number of rows
+ //! \param theParent an index of the parent item
+ //! \return an integer value
+ virtual int rowCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
+ { (void)theParent; return 1; }
+
+ //! Returns number of columns
+ //! \param theParent an index of the parent item
+ //! \return an integer value
+ virtual int columnCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
+ { (void)theParent; return myValues.size(); }
+
+private:
+
+ QStringList myValues; //!< file names
+};
+
+#endif
add_definitions(-D__WIN32__)
add_definitions(-DWNT)
-add_definitions(-D${PROJECT_NAME}_EXPORTS)
+add_definitions(-D__${PROJECT_NAME}_DLL)
# parce EXTERNLIB file
FILE_TO_LIST ("src/${PROJECT_NAME}/EXTERNLIB" USED_EXTERNLIB_AND_TOOLKITS)
project(DRAWEXE)
+set (EXECUTABLE_PROJECT ON)
OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
+unset (EXECUTABLE_PROJECT)
#ifndef DFBROWSERPANE_H
#define DFBROWSERPANE_H
-#ifdef DFBrowserPane_EXPORTS
+#ifdef __DFBrowserPane_DLL
#ifdef _WIN32
#define DFBROWSERPANE_EXPORT __declspec(dllexport)
#else
static int argc = 1;
static char* argv[] = { (char*)"", 0 };
#if QT_VERSION > 0x050000
- OSD_Environment anEnvironment ("QTDIR");
- TCollection_AsciiString aPlugindsDirName = anEnvironment.Value();
- aPlugindsDirName += "/plugins";
- QApplication::addLibraryPath (aPlugindsDirName.ToCString());
+ TCollection_AsciiString aPlugindsDirName = OSD_Environment ("QTDIR").Value();
+ if (!aPlugindsDirName.IsEmpty())
+ QApplication::addLibraryPath (QString (aPlugindsDirName.ToCString()) + "/plugins");
#endif
new QApplication (argc, argv);
}
project(TKDFBrowser)
-OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_tool)
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool)
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool)
project(TKShapeView)
-OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_tool)
\ No newline at end of file
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool)
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool)
set (INSTALL_API ON)
-OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_tool)
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool)
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool)
unset (INSTALL_API)
SET (TOOL_API_LIBRARY ON)
-OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_tool)
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool)
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool)
UNSET (TOOL_API_LIBRARY)
project(TKToolsDraw)
-OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_tool)
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool)
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool)
project(TKTreeModel)
-OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_tool)
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool)
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool)
project(TKVInspector)
-OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_tool)
\ No newline at end of file
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool)
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool)
project(TKView)
-OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_tool)
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool)
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool)