set (USE_D3D OFF CACHE BOOL "${USE_D3D_DESCR}")
endif()
+set (USE_QT_TOOLS OFF CACHE BOOL "${USE_QT_TOOLS_DESCR}")
+set (USE_QT4 ON CACHE BOOL "${USE_QT4}")
+
# Enable/Disable the floating point exceptions (FPE) during runtime.
if (NOT BUILD_ENABLE_FPE_SIGNAL_HANDLER)
set (BUILD_ENABLE_FPE_SIGNAL_HANDLER OFF CACHE BOOL "${BUILD_ENABLE_FPE_SIGNAL_HANDLER_DESCR}" FORCE)
endif()
# include <cmake binary folder>/inc
-include_directories (${CMAKE_BINARY_DIR}/inc)
+include_directories (${CMAKE_BINARY_DIR}/${INSTALL_DIR_INCLUDE})
if (3RDPARTY_LIBRARY_DIRS AND BUILD_SHARED_LIBS)
list (REMOVE_DUPLICATES 3RDPARTY_LIBRARY_DIRS)
message (STATUS "\nInfo: \(${CURRENT_TIME}\) Start collecting all OCCT header files into ${CMAKE_BINARY_DIR}/inc ...")
# collect all the headers to <binary dir>/inc folder
-COLLECT_AND_INSTALL_OCCT_HEADER_FILES ("${CMAKE_BINARY_DIR}" "${BUILD_TOOLKITS}")
+COLLECT_AND_INSTALL_OCCT_HEADER_FILES ("${CMAKE_BINARY_DIR}" "${BUILD_TOOLKITS}" "${CMAKE_SOURCE_DIR}/src" "${INSTALL_DIR_INCLUDE}")
string(TIMESTAMP CURRENT_TIME "%H:%M:%S")
message (STATUS "Info: \(${CURRENT_TIME}\) End the collecting")
set (SCRIPT_EXT sh)
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 USE_QT_TOOLS)
+ 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)
+ foreach (OCCT_TOOL ${OCCT_TOOLS})
+ list (APPEND BUILD_TOOL_TOOLKITS ${${OCCT_TOOL}_TOOL_TOOLKITS})
+ endforeach()
+
+ # collect all the headers to <binary dir>/inc 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 ...")
+ COLLECT_AND_INSTALL_OCCT_HEADER_FILES ("${CMAKE_BINARY_DIR}/${INSTALL_DIR_INCLUDE}" "${BUILD_TOOL_TOOLKITS}" "${CMAKE_SOURCE_DIR}/tools" "tools")
+ include_directories (${CMAKE_BINARY_DIR}/${INSTALL_DIR_INCLUDE}/tools)
+
+
+ # check qt 3rdparty path
+ add_definitions (-DHAVE_QT)
+ OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/qt5")
+ message (STATUS "Info: Qt is used by OCCT")
+endif()
+
# OCCT samples
# get absolute path from INSTALL_DIR
set (INSTALL_DIR_ABSOLUTE "${INSTALL_DIR}")
endif()
endif()
-message (STATUS "Info: \(${CURRENT_TIME}\) OCCT toolkits processed")
+# include patched toolkit projects or original ones
+if (BUILD_TOOL_TOOLKITS)
+ foreach (BUILD_TOOL_TOOLKIT ${BUILD_TOOL_TOOLKITS})
+ OCCT_ADD_SUBDIRECTORY ("tools/${BUILD_TOOL_TOOLKIT}")
+ endforeach()
+endif()
+message (STATUS "Info: \(${CURRENT_TIME}\) OCCT toolkits processed")
# samples do not support patch usage
if (BUILD_MODULE_MfcSamples)
set (OCCT_ROOT ${CMAKE_SOURCE_DIR})
add_subdirectory(samples/xaml)
endif()
+if (BUILD_TOOL_TOOLKITS)
+ # copy tinspector script to install script folder
+ if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/adm/templates/dfbrowser.${SCRIPT_EXT}")
+ install (FILES "${BUILD_PATCH}/adm/templates/dfbrowser.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SCRIPT}"
+ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE)
+ else()
+ install (FILES "${CMAKE_SOURCE_DIR}/adm/templates/dfbrowser.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SCRIPT}"
+ 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()
+endif()
+
# Prepare variables for configuration of OpenCASCADE cmake config file
set (OCCT_MODULES_ENABLED)
set (OCCT_LIBRARIES)
--- /dev/null
+TModelingData TKShapeView
+TVisualization TKView TKVInspector
+TApplicationFramework TKTreeModel TKTInspectorAPI TKDFBrowser
+TTool TKTInspector TKToolsDraw
\ No newline at end of file
PATH_SUFFIXES ${${PRODUCT_NAME}_PATH_SUFFIXES}
CMAKE_FIND_ROOT_PATH_BOTH
NO_DEFAULT_PATH)
+ if ("${3RDPARTY_${PRODUCT_NAME}_LIBRARY_${LIBRARY_NAME_SUFFIX}}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_LIBRARY_${LIBRARY_NAME_SUFFIX}-NOTFOUND")
+ # find directory recursive
+ FIND_SUBDIRECTORY (${3RDPARTY_${PRODUCT_NAME}_DIR} "${${PRODUCT_NAME}_PATH_SUFFIXES}" SUBDIR_NAME)
+ if (NOT "${SUBDIR_NAME}" STREQUAL "")
+ find_library (3RDPARTY_${PRODUCT_NAME}_LIBRARY_${LIBRARY_NAME_SUFFIX} NAMES ${LIBRARY_NAME_SUFFIX}
+ PATHS "${SUBDIR_NAME}"
+ PATH_SUFFIXES ${${PRODUCT_NAME}_PATH_SUFFIXES}
+ CMAKE_FIND_ROOT_PATH_BOTH
+ NO_DEFAULT_PATH)
+ endif()
+ endif()
else()
find_library (3RDPARTY_${PRODUCT_NAME}_LIBRARY_${LIBRARY_NAME_SUFFIX} NAMES ${LIBRARY_NAME}
PATH_SUFFIXES ${${PRODUCT_NAME}_PATH_SUFFIXES}
PATHS "${3RDPARTY_${PRODUCT_NAME}_DIR}"
PATH_SUFFIXES bin win${COMPILER_BITNESS}/${COMPILER}/bin
NO_DEFAULT_PATH)
+ if (3RDPARTY_${PRODUCT_NAME}_DLL_${LIBRARY_NAME_SUFFIX} STREQUAL "3RDPARTY_${PRODUCT_NAME}_DLL_${LIBRARY_NAME_SUFFIX}-NOTFOUND")
+ # find directory recursive
+ FIND_SUBDIRECTORY (${3RDPARTY_${PRODUCT_NAME}_DIR} bin SUBDIR_NAME)
+ if (NOT "${SUBDIR_NAME}" STREQUAL "")
+ find_library (3RDPARTY_${PRODUCT_NAME}_DLL_${LIBRARY_NAME_SUFFIX} NAMES ${LIBRARY_NAME_SUFFIX}
+ PATHS "${SUBDIR_NAME}"
+ PATH_SUFFIXES bin
+ NO_DEFAULT_PATH)
+ endif()
+ endif()
else()
find_library (3RDPARTY_${PRODUCT_NAME}_DLL_${LIBRARY_NAME_SUFFIX} NAMES ${LIBRARY_NAME} PATH_SUFFIXES bin)
endif()
string (REPLACE "." "" LIBRARY_NAME_SUFFIX "${LIBRARY_NAME}")
if (WIN32)
set (3RDPARTY_${PRODUCT_NAME}_DLL_DIRS "${3RDPARTY_${PRODUCT_NAME}_DLL_DIR_${LIBRARY_NAME_SUFFIX}};${3RDPARTY_${PRODUCT_NAME}_DLL_DIRS}")
+ set (3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIRS "${3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR_${LIBRARY_NAME_SUFFIX}}")
else()
set (3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIRS "${3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR_${LIBRARY_NAME_SUFFIX}}:${3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIRS}")
endif()
set (${RESULT} ${LOCAL_RESULT} PARENT_SCOPE)
endfunction()
+function (FIND_SUBDIRECTORY ROOT_DIRECTORY DIRECTORY_SUFFIX SUBDIRECTORY_NAME)
+ #message("Trying to find directory with suffix ${DIRECTORY_SUFFIX} in ${ROOT_DIRECTORY}")
+ SUBDIRECTORY_NAMES ("${ROOT_DIRECTORY}" SUBDIR_NAME_LIST)
+ #message("Subdirectories: ${SUBDIR_NAME_LIST}")
+
+ #set(${SUBDIRECTORY_NAME} "${SUBDIR_NAME_LIST}" PARENT_SCOPE)
+
+ foreach (SUBDIR_NAME ${SUBDIR_NAME_LIST})
+ #message("Subdir: ${SUBDIR_NAME}, ${DIRECTORY_SUFFIX}")
+ # REGEX failed if the directory name contains '++' combination, so we replace it
+ string(REPLACE "++" "\\+\\+" SUBDIR_NAME_ESCAPED ${SUBDIR_NAME})
+ string (REGEX MATCH "${SUBDIR_NAME_ESCAPED}" DOES_PATH_CONTAIN "${DIRECTORY_SUFFIX}")
+ if (DOES_PATH_CONTAIN)
+ set(${SUBDIRECTORY_NAME} "${ROOT_DIRECTORY}/${SUBDIR_NAME}" PARENT_SCOPE)
+ #message("Subdirectory is found: ${SUBDIRECTORY_NAME}")
+ BREAK()
+ else()
+ #message("Check directory: ${ROOT_DIRECTORY}/${SUBDIR_NAME}")
+ FIND_SUBDIRECTORY ("${ROOT_DIRECTORY}/${SUBDIR_NAME}" "${DIRECTORY_SUFFIX}" SUBDIR_REC_NAME)
+ if (NOT "${SUBDIR_REC_NAME}" STREQUAL "")
+ set(${SUBDIRECTORY_NAME} "${SUBDIR_REC_NAME}" PARENT_SCOPE)
+ #message("Subdirectory is found: ${SUBDIRECTORY_NAME}")
+ BREAK()
+ endif()
+ endif()
+ endforeach()
+endfunction()
+
function (OCCT_ORIGIN_AND_PATCHED_FILES RELATIVE_PATH SEARCH_TEMPLATE RESULT)
if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/${RELATIVE_PATH}")
install(FILES "${OCCT_BINARY_DIR}/${BUILD_NAME}" DESTINATION "${DESTINATION_PATH}" RENAME ${INSTALL_NAME})
endmacro()
-macro (COLLECT_AND_INSTALL_OCCT_HEADER_FILES ROOT_TARGET_OCCT_DIR OCCT_BUILD_TOOLKITS)
+macro (COLLECT_AND_INSTALL_OCCT_HEADER_FILES ROOT_TARGET_OCCT_DIR OCCT_BUILD_TOOLKITS OCCT_COLLECT_SOURCE_DIR OCCT_INSTALL_DIR_PREFIX)
set (OCCT_USED_PACKAGES)
# consider patched header.in template
set (OCCT_TOOLKIT_PACKAGES)
if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/src/${OCCT_USED_TOOLKIT}/PACKAGES")
file (STRINGS "${BUILD_PATCH}/src/${OCCT_USED_TOOLKIT}/PACKAGES" OCCT_TOOLKIT_PACKAGES)
- elseif (EXISTS "${CMAKE_SOURCE_DIR}/src/${OCCT_USED_TOOLKIT}/PACKAGES")
- file (STRINGS "${CMAKE_SOURCE_DIR}/src/${OCCT_USED_TOOLKIT}/PACKAGES" OCCT_TOOLKIT_PACKAGES)
+ elseif (EXISTS "${OCCT_COLLECT_SOURCE_DIR}/${OCCT_USED_TOOLKIT}/PACKAGES")
+ file (STRINGS "${OCCT_COLLECT_SOURCE_DIR}/${OCCT_USED_TOOLKIT}/PACKAGES" OCCT_TOOLKIT_PACKAGES)
endif()
list (APPEND OCCT_USED_PACKAGES ${OCCT_TOOLKIT_PACKAGES})
foreach (OCCT_PACKAGE ${OCCT_USED_PACKAGES})
if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/src/${OCCT_PACKAGE}/FILES")
file (STRINGS "${BUILD_PATCH}/src/${OCCT_PACKAGE}/FILES" OCCT_ALL_FILE_NAMES)
- elseif (EXISTS "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/FILES")
- file (STRINGS "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/FILES" OCCT_ALL_FILE_NAMES)
+ elseif (EXISTS "${OCCT_COLLECT_SOURCE_DIR}/${OCCT_PACKAGE}/FILES")
+ file (STRINGS "${OCCT_COLLECT_SOURCE_DIR}/${OCCT_PACKAGE}/FILES" OCCT_ALL_FILE_NAMES)
else()
- message (WARNING "FILES has not been found in ${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}")
+ message (WARNING "FILES has not been found in ${OCCT_COLLECT_SOURCE_DIR}/${OCCT_PACKAGE}")
continue()
endif()
math (EXPR ALL_FILES_NB "${ALL_FILES_NB} - 1" )
# emit warnings if there is unprocessed headers
- file (GLOB OCCT_ALL_FILES_IN_DIR "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/*.*")
+ file (GLOB OCCT_ALL_FILES_IN_DIR "${OCCT_COLLECT_SOURCE_DIR}/${OCCT_PACKAGE}/*.*")
file (GLOB OCCT_ALL_FILES_IN_PATCH_DIR "${BUILD_PATCH}/src/${OCCT_PACKAGE}/*.*")
# use patched header files
foreach (OCCT_FILE_IN_PATCH_DIR ${OCCT_ALL_FILES_IN_PATCH_DIR})
get_filename_component (OCCT_FILE_IN_PATCH_DIR_NAME ${OCCT_FILE_IN_PATCH_DIR} NAME)
- list (REMOVE_ITEM OCCT_ALL_FILES_IN_DIR "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/${OCCT_FILE_IN_PATCH_DIR_NAME}")
+ list (REMOVE_ITEM OCCT_ALL_FILES_IN_DIR "${OCCT_COLLECT_SOURCE_DIR}/${OCCT_PACKAGE}/${OCCT_FILE_IN_PATCH_DIR_NAME}")
list (APPEND OCCT_ALL_FILES_IN_DIR "${OCCT_FILE_IN_PATCH_DIR}")
endforeach()
endforeach()
if (NOT OCCT_FILE_IN_DIR_STATUS)
- message (STATUS "Warning. File ${OCCT_FILE_IN_DIR} is not listed in ${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/FILES")
+ message (STATUS "Warning. File ${OCCT_FILE_IN_DIR} is not listed in ${OCCT_COLLECT_SOURCE_DIR}/${OCCT_PACKAGE}/FILES")
string (REGEX MATCH ".+\\.[hlg]xx|.+\\.h$" IS_HEADER_FOUND "${OCCT_FILE_NAME}")
if (IS_HEADER_FOUND)
foreach (OCCT_HEADER_FILE ${OCCT_HEADER_FILES_COMPLETE})
get_filename_component (HEADER_FILE_NAME ${OCCT_HEADER_FILE} NAME)
set (OCCT_HEADER_FILE_CONTENT "#include \"${OCCT_HEADER_FILE}\"")
- configure_file ("${TEMPLATE_HEADER_PATH}" "${ROOT_TARGET_OCCT_DIR}/inc/${HEADER_FILE_NAME}" @ONLY)
+ configure_file ("${TEMPLATE_HEADER_PATH}" "${ROOT_TARGET_OCCT_DIR}/${OCCT_INSTALL_DIR_PREFIX}/${HEADER_FILE_NAME}" @ONLY)
endforeach()
- install (FILES ${OCCT_HEADER_FILES_COMPLETE} DESTINATION "${INSTALL_DIR_INCLUDE}")
+ install (FILES ${OCCT_HEADER_FILES_COMPLETE} DESTINATION "${INSTALL_DIR}/${OCCT_INSTALL_DIR_PREFIX}")
string(TIMESTAMP CURRENT_TIME "%H:%M:%S")
message (STATUS "Info: \(${CURRENT_TIME}\) Checking headers in inc folder...")
list (FIND OCCT_USED_PACKAGES ${PACKAGE_NAME} IS_HEADER_FOUND)
if (NOT ${IS_HEADER_FOUND} EQUAL -1)
- if (NOT EXISTS "${CMAKE_SOURCE_DIR}/src/${PACKAGE_NAME}/${HEADER_FILE_NAME}")
+ if (NOT EXISTS "${OCCT_COLLECT_SOURCE_DIR}/${PACKAGE_NAME}/${HEADER_FILE_NAME}")
message (STATUS "Warning. ${OCCT_HEADER_FILE_OLD} is not presented in the sources and will be removed from ${ROOT_TARGET_OCCT_DIR}/inc")
file (REMOVE "${OCCT_HEADER_FILE_OLD}")
else()
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)
--- /dev/null
+# script for each OCCT tool toolkit
+
+# Qt dependencies
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/qt5_macro)
+
+FIND_QT5_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})
+ file (STRINGS "${CMAKE_SOURCE_DIR}/${PACKAGE_PREFIX_DIR}/${OCCT_PACKAGE}/FILES" SOURCE_FILES_C REGEX ".+[.]c")
+
+ #message("Sources are ${SOURCE_FILES_C}")
+ FIND_AND_WRAP_MOC_FILES("${SOURCE_FILES_C}")
+
+ #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")
+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 (NOT SINGLE_GENERATOR)
+ OCCT_INSERT_CODE_FOR_TARGET ()
+endif()
+
+if ("${PROJECT_NAME}" STREQUAL TInspectorEXE)
+ add_executable (${PROJECT_NAME} ${USED_SRCFILES} ${USED_INCFILES} ${USED_RCFILE} ${RCC_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})
+
+ if (MSVC)
+ install (FILES ${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bind/${PROJECT_NAME}.pdb
+ CONFIGURATIONS Debug
+ 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})
+ 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}")
+
--- /dev/null
+#qt
+
+#looking for 3RDPARTY_QT_DIR variable used later in qt5_macro.cmake
+if (${USE_QT4})
+ SET(CSF_QtCore "QtCore")
+ THIRDPARTY_PRODUCT("QT" "" "CSF_QtCore" "d")
+else()
+ SET(CSF_Qt5Core "Qt5Core")
+ THIRDPARTY_PRODUCT("QT" "" "CSF_Qt5Core" "d")
+endif()
+
+list (REMOVE_ITEM 3RDPARTY_NOT_INCLUDED "3RDPARTY_QT_INCLUDE_DIR")
+list (REMOVE_ITEM 3RDPARTY_NOT_INCLUDED "3RDPARTY_QT_LIBRARY_DIR")
+list (REMOVE_ITEM 3RDPARTY_NOT_INCLUDED "3RDPARTY_QT_DLL_DIR")
+
+UNSET (${3RDPARTY_QT_DLL} CACHE)
+UNSET (${3RDPARTY_QT_DLL_DIR} CACHE)
+UNSET (${3RDPARTY_QT_INCLUDE_DIR} CACHE)
+UNSET (${3RDPARTY_QT_LIBRARY} CACHE)
+UNSET (${3RDPARTY_QT_LIBRARY_DIR} CACHE)
+
+set (USED_3RDPARTY_QT_DIR "${3RDPARTY_QT_DIR}")
--- /dev/null
+#qt
+
+macro (FIND_QT5_PACKAGE PROJECT_LIBRARIES_DEBUG PROJECT_LIBRARIES_RELEASE PROJECT_INCLUDES)
+
+ if ("${3RDPARTY_QT_DIR}" STREQUAL "")
+ message (FATAL_ERROR "Empty Qt dir")
+ endif()
+
+ # Now set CMAKE_PREFIX_PATH to point to local Qt installation.
+ # Without this setting find_package() will not work
+ set(CMAKE_PREFIX_PATH ${3RDPARTY_QT_DIR})
+ if (USE_QT4)
+ # Now we can apply standard CMake finder for Qt. We do this mostly
+ # to have qt5_wrap_cpp() function available
+ find_package(Qt4)
+ #message (STATUS "Qt cmake configuration at directory ${Qt4DIR}")
+
+ set(PROJECT_INCLUDES ${QT_INCLUDES})
+ if (WIN32)
+ set(PROJECT_LIBRARIES_DEBUG "${3RDPARTY_QT_DIR}/lib/QtCored4.lib;${3RDPARTY_QT_DIR}/lib/QtGuid4.lib")
+ set(PROJECT_LIBRARIES_RELEASE "${3RDPARTY_QT_DIR}/lib/QtCore4.lib;${3RDPARTY_QT_DIR}/lib/QtGui4.lib")
+ else()
+ 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)
+ else()
+ # Now we can apply standard CMake finder for Qt4. We do this mostly
+ # to have qt5_wrap_cpp() function available
+ find_package(Qt5 REQUIRED COMPONENTS Widgets)
+ #message (STATUS "Qt cmake configuration at directory ${Qt5DIR}")
+
+ set(PROJECT_INCLUDES "${Qt5Widgets_INCLUDE_DIRS}")
+ set(PROJECT_LIBRARIES_DEBUG "${Qt5Widgets_LIBRARIES}")
+ set(PROJECT_LIBRARIES_RELEASE "${Qt5Widgets_LIBRARIES}")
+ endif()
+endmacro()
+
+
+macro (FIND_AND_WRAP_MOC_FILES SOURCE_FILES)
+ SET(CMAKE_AUTOMOC ON)
+
+ foreach (FILE ${SOURCE_FILES})
+ set (src_files ${src_files} ${FILE})
+ unset (MOC_FILE)
+ if (USE_QT4)
+ qt4_wrap_cpp(MOC_FILE ${FILE})
+ else()
+ qt5_wrap_cpp(MOC_FILE ${FILE})
+ endif()
+ #message (STATUS "... Info: next MOC file ${MOC_FILE}")
+
+ endforeach (FILE)
+
+endmacro()
+
+macro (FIND_AND_WRAP_RESOURCE_FILE RESOURCE_FILE_NAME RCC_FILES)
+ if(EXISTS "${RESOURCE_FILE_NAME}")
+ if (USE_QT4)
+ qt4_add_resources(RCC_FILES "${RESOURCE_FILE_NAME}")
+ # suppress some GCC warnings coming from source files generated from .qrc resources
+ if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-variable")
+ endif()
+ else()
+ qt5_add_resources(RCC_FILES "${RESOURCE_FILE_NAME}")
+ endif()
+ endif()
+endmacro()
set (USE_D3D_DESCR "Indicates whether optional Direct3D wrapper in OCCT visualization module should be build or not")
+set (BUILD_QT_TOOLS_DESCR "Indicates whether OCCT tools should be build or not")
+
+set (USE_QT_TOOLS_DESCR "Indicates whether OCCT tools should be used or not
+The tools will be searched in third-party directory or may be set manually")
+
macro (BUILD_MODULE MODULE_NAME)
set (ENABLE_MODULE TRUE)
set (BUILD_MODULE_${MODULE_NAME} ${ENABLE_MODULE} CACHE BOOL "${BUILD_MODULE_${MODULE_NAME}_DESCR}")
set aLibsMap(CSF_TclLibs) ""
set aFrmsMap(CSF_TclTkLibs) "Tk"
set aLibsMap(CSF_TclTkLibs) ""
+ set aLibsMap(CSF_QT) "QtCore QtGui"
} else {
if { "$theOS" == "qnx" } {
# CSF_ThreadLibs - pthread API is part of libc on QNX
set "TBB_DIR=@3RDPARTY_TBB_DLL_DIR@"
set "VTK_DIR=@3RDPARTY_VTK_DLL_DIR@"
+ if not "@3RDPARTY_QT_DIR@" == "" (
+ set "QTDIR=@3RDPARTY_QT_DIR@"
+ )
set "TCL_VERSION_WITH_DOT=@3RDPARTY_TCL_LIBRARY_VERSION_WITH_DOT@"
set "TK_VERSION_WITH_DOT=@3RDPARTY_TK_LIBRARY_VERSION_WITH_DOT@"
export TBB_DIR="@3RDPARTY_TBB_LIBRARY_DIR@"
export VTK_DIR="@3RDPARTY_VTK_LIBRARY_DIR@"
+ if [ "x@3RDPARTY_QT_DIR" != "x" ]; then
+ export QTDIR="@3RDPARTY_QT_DIR@"
+ fi
+
export TCL_VERSION_WITH_DOT="@3RDPARTY_TCL_LIBRARY_VERSION_WITH_DOT@"
export TK_VERSION_WITH_DOT="@3RDPARTY_TK_LIBRARY_VERSION_WITH_DOT@"
set "TBB_DIR=@USED_3RDPARTY_TBB_DIR@"
set "VTK_DIR=@USED_3RDPARTY_VTK_DIR@"
+ if not "@USED_3RDPARTY_QT_DIR@" == "" (
+ set "QTDIR=@USED_3RDPARTY_QT_DIR@"
+ )
set "TCL_VERSION_WITH_DOT=@3RDPARTY_TCL_LIBRARY_VERSION_WITH_DOT@"
set "TK_VERSION_WITH_DOT=@3RDPARTY_TK_LIBRARY_VERSION_WITH_DOT@"
export TBB_DIR="@USED_3RDPARTY_TBB_DIR@"
export VTK_DIR="@USED_3RDPARTY_VTK_DIR@"
+ if [ "x@USED_3RDPARTY_QT_DIR@" != "x" ]; then
+ export QTDIR="@USED_3RDPARTY_QT_DIR@"
+ fi
+
export TCL_VERSION_WITH_DOT="@3RDPARTY_TCL_LIBRARY_VERSION_WITH_DOT@"
export TK_VERSION_WITH_DOT="@3RDPARTY_TK_LIBRARY_VERSION_WITH_DOT@"
--- /dev/null
+@echo off
+
+rem Setup environment and launch TInspector
+call "%~dp0env.bat" %1 %2 %3
+
+TInspectorEXE.exe --dfbrowser
+
--- /dev/null
+#!/bin/bash
+
+aCurrentPath="$PWD"
+aScriptPath=${BASH_SOURCE%/*}; if [ -d "${aScriptPath}" ]; then cd "$aScriptPath"; fi; aScriptPath="$PWD";
+
+source "${aScriptPath}/env.sh" "$1"
+
+cd ${aCurrentPath}
+TInspectorEXE --dfbrowser
if not ["%GL2PS_DIR%"] == [""] set "PATH=%GL2PS_DIR%;%PATH%"
if not ["%TBB_DIR%"] == [""] set "PATH=%TBB_DIR%;%PATH%"
if not ["%VTK_DIR%"] == [""] set "PATH=%VTK_DIR%;%PATH%"
+if not ["%QTDIR%"] == [""] set "PATH=%QTDIR%/bin;%PATH%"
rem ----- Set path to 3rd party and OCCT libraries -----
if not "%CSF_OCCTBinPath%" == "" (
THRDPARTY_PATH="${VTK_DIR}:${THRDPARTY_PATH}"
fi
+if [ "$QTDIR" != "" ]; then
+ THRDPARTY_PATH="${QTDIR}/lib:${THRDPARTY_PATH}"
+fi
+
if [ "$TK_DIR" != "$TCL_DIR" ]; then
if [ "$TK_DIR" != "" ]; then
export TK_LIBRARY="${TK_DIR}/../lib/tk${TK_VERSION_WITH_DOT}"
--- /dev/null
+project(TInspectorEXE)
+
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_tool)
+
+set_property (TARGET ${PROJECT_NAME} PROPERTY FOLDER Samples)
--- /dev/null
+TKTInspector
\ No newline at end of file
--- /dev/null
+TInspectorEXE.cxx
+TInspectorEXE_OpenFileDialog.cxx
+TInspectorEXE_OpenFileDialog.hxx
+TInspectorEXE_OpenFileViewModel.cxx
+TInspectorEXE_OpenFileViewModel.hxx
--- /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 <OSD_Environment.hxx>
+#include <TInspectorEXE_OpenFileDialog.hxx>
+#include <TInspector_Communicator.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 <TInspector_Communicator.hxx>
+#include <TInspectorEXE_OpenFileViewModel.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
+cmake_minimum_required (VERSION 2.8.12 FATAL_ERROR)
+project (TStandalone)
+
+set (CASROOT "" CACHE PATH "Third party OpenCascade dir" )
+set (3RDPARTY_DIR "" CACHE PATH "Third party dir" )
+set (INSTALL_DIR "" CACHE PATH "Where to install" )
+
+set (USE_QT4 ON CACHE BOOL "${USE_QT4}")
+
+if (NOT "$ENV{CASROOT}" STREQUAL "" AND EXISTS "$ENV{CASROOT}")
+ set (CASROOT "$ENV{CASROOT}")
+ #set (3RDPARTY_OCCT_DIR "${CASROOT}")
+ #message("Environment CASROOT: ${CASROOT}")
+ #message("Environment 3RDPARTY_OCCT_DIR: ${CASROOT}")
+endif()
+
+if (NOT "$ENV{THIRDPARTY_DIR}" STREQUAL "" AND EXISTS "$ENV{THIRDPARTY_DIR}")
+ set (3RDPARTY_DIR "$ENV{THIRDPARTY_DIR}")
+ message("Environment THIRDPARTY_DIR: ${3RDPARTY_DIR}")
+endif()
+
+if (NOT "$ENV{INSTALL_DIR}" STREQUAL "")
+ set (INSTALL_DIR "$ENV{INSTALL_DIR}")
+ message("Environment INSTALL_DIR: ${INSTALL_DIR}")
+endif()
+
+# Define the next variable to has defined 3rdParties DLL dir variables
+set (BUILD_SHARED_LIBS ON)
+
+set (CASROOT_SOURCE_FILES "${CMAKE_SOURCE_DIR}/../../.." CACHE PATH "OCCT sources dir to find tools packages" )
+if ("${CASROOT}" STREQUAL "")
+ set (CASROOT "${CASROOT_SOURCE_FILES}/work/install" CACHE PATH "OCCT sources dir to find tools packages" )
+endif()
+
+macro (OCCT_INCLUDE_CMAKE_FILE BEING_INCLUDED_FILE)
+ include (${CASROOT_SOURCE_FILES}/${BEING_INCLUDED_FILE}.cmake)
+endmacro()
+
+macro (OCCT_INCLUDE_CMAKE_FILE_STANDALONE BEING_INCLUDED_FILE)
+ include (${CMAKE_SOURCE_DIR}/${BEING_INCLUDED_FILE}.cmake)
+endmacro()
+
+set (ADDITIONAL_DLL_DIR "" CACHE PATH "Additional paths that should be included into PATH" )
+if (NOT "$ENV{ADDITIONAL_DLL_DIR}" STREQUAL "")
+ set (ADDITIONAL_DLL_DIR "$ENV{ADDITIONAL_DLL_DIR}")
+ message("Environment ADDITIONAL_DLL_DIR: ${ADDITIONAL_DLL_DIR}")
+endif()
+
+set (CMAKE_CONFIGURATION_TYPES Release Debug RelWithDebInfo CACHE INTERNAL "" FORCE)
+
+OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/3rdparty_macro")
+OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_macros")
+
+OCCT_INCLUDE_CMAKE_FILE_STANDALONE("adm/cmake/occt")
+if (OCCT_LIBRARY_NOT_FOUND)
+ message (FATAL_ERROR "Could NOT find OCCT Library in : ${3RDPARTY_OCCT_LIBRARY_DIR}" )
+endif()
+
+OCCT_MAKE_OS_WITH_BITNESS()
+OCCT_MAKE_COMPILER_SHORT_NAME()
+
+set (CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "" FORCE )
+set (INSTALL_API_DIR "${INSTALL_DIR}/api" CACHE PATH "" FORCE)
+set (INSTALL_DIR_BIN "${OS_WITH_BIT}/${COMPILER}/bin" CACHE PATH "" FORCE)
+set (INSTALL_DIR_LIB "${OS_WITH_BIT}/${COMPILER}/lib" CACHE PATH "" FORCE)
+set (INSTALL_DIR_INCLUDE "inc" CACHE PATH "")
+
+OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/freetype")
+OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/freeimage")
+OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/gl2ps")
+OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/tbb")
+OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/qt5")
+OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_macros")
+
+#include (${CMAKE_SOURCE_DIR}/adm/cmake/3rdparty.cmake)
+
+set (3RDPARTY_DLL_PATH "${USED_3RDPARTY_OCCT_DIRS};\
+${USED_3RDPARTY_FREETYPE_DIR};\
+${USED_3RDPARTY_FREEIMAGE_DIRS};\
+${USED_3RDPARTY_GL2PS_DIRS};\
+${3RDPARTY_QT_DIR}/bin;\
+${3RDPARTY_TBB_DLL_DIR}")
+
+if (ADDITIONAL_DLL_DIR)
+ set (3RDPARTY_DLL_PATH "${3RDPARTY_DLL_PATH};\
+${ADDITIONAL_DLL_DIR}")
+endif()
+
+set (3RDPARTY_DLL_DEB_PATH "${3RDPARTY_DLL_PATH}")
+
+
+set (BUILD_TOOLKITS
+ TKTInspectorAPI
+ TKView
+ TKTreeModel
+ TKDFBrowser
+ TKVInspector
+ TKShapeView
+ TKTInspector
+ TKToolsDraw
+)
+
+string(TIMESTAMP CURRENT_TIME "%H:%M:%S")
+message (STATUS "\nInfo: \(${CURRENT_TIME}\) Start collecting all header files into ${CMAKE_BINARY_DIR}/inc ...")
+# collect all the headers to <binary dir>/inc folder
+COLLECT_AND_INSTALL_OCCT_HEADER_FILES ("${CMAKE_BINARY_DIR}" "${BUILD_TOOLKITS}" "${CASROOT_SOURCE_FILES}/tools" "${INSTALL_DIR_INCLUDE}")
+
+OCCT_INCLUDE_CMAKE_FILE_STANDALONE ("adm/cmake/standalone_macros")
+OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/qt5_macro")
+
+set (BUILD_PROJECTS
+ TInspectorAPI
+ View
+ TreeModel
+ DFBrowserPane
+ DFBrowserPaneXDE
+ DFBrowser
+ ShapeView
+ VInspector
+ TInspector
+ TInspectorEXE
+ ToolsDraw
+)
+# include patched toolkit projects or original ones
+foreach (PROJECT_ITEM ${BUILD_PROJECTS})
+ OCCT_ADD_SUBDIRECTORY ("src/${PROJECT_ITEM}")
+endforeach()
--- /dev/null
+#freeimage
+
+if(NOT "${CASROOT}" STREQUAL "")
+ #message(FATAL_ERROR, "Empty OCCT dir")
+ #return()
+ #set("3RDPARTY_OCCT_DIR ${CASROOT}")
+endif()
+
+#set(3RDPARTY_OCC_DIR ${CASROOT})
+#message("3RDPARTY_OCC_DIR: ${3RDPARTY_OCC_DIR}")
+#set("3RDPARTY_OCC_DIR ${3RDPARTY_OCCT_DIR}")
+#message("3RDPARTY_OCC_DIR: ${3RDPARTY_OCC_DIR}")
+
+set(CSF_TKernel "TKernel")
+THIRDPARTY_PRODUCT("OCCT" "Standard.hxx" "CSF_TKernel" "")
+
+set(3RDPARTY_OCCT_DIR ${3RDPARTY_OCC_DIR} CACHE PATH "OCCT dir")
+
+OCCT_MAKE_OS_WITH_BITNESS()
+OCCT_MAKE_COMPILER_SHORT_NAME()
+
+SET(3RDPARTY_OCCT_INCLUDE_DIR "${3RDPARTY_OCC_INCLUDE_DIR}" CACHE PATH "OCCT include dir")
+SET(3RDPARTY_OCCT_LIBRARY_DIR "${3RDPARTY_OCC_LIBRARY_DIR}" CACHE PATH "OCCT library dir")
+SET(3RDPARTY_OCCT_DLL_DIR "${3RDPARTY_OCC_DLL_DIR}" CACHE PATH "OCCT dll dir")
+
+SET(CSF_StandardDefaults_DIR ${CASROOT}/src/StdResource CACHE PATH "OCCT Standard Resource")
+SET(CSF_XCAFDefaults_DIR ${CASROOT}/src/StdResource CACHE PATH "OCCT XCAF Defaults")
+SET(CSF_PluginDefaults_DIR ${CASROOT}/src/StdResource CACHE PATH "OCCT Plugin Defaults")
+
+message (STATUS "... OCCT dir: ${3RDPARTY_OCCT_DIR}")
+message (STATUS "... OCCT Include dirs: ${3RDPARTY_OCCT_INCLUDE_DIR}")
+message (STATUS "... OCCT Library dirs: ${3RDPARTY_OCCT_LIBRARY_DIRS}")
+message (STATUS "... OCCT Binary dirs: ${3RDPARTY_OCCT_DLL_DIRS}")
+
+SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${3RDPARTY_OCCT_LIBRARY_DIRS}")
+
+find_library(TKernel TKernel PATHS "${3RDPARTY_OCCT_LIBRARY_DIRS}"
+ PATH_SUFFIXES lib
+ NO_DEFAULT_PATH)
+
+if ("${TKernel}" STREQUAL "TKernel-NOTFOUND")
+ set (OCCT_LIBRARY_NOT_FOUND ON)
+endif()
+
+find_library(TKMath TKMath)
+
+find_library(TKCAF TKCAF)
+find_library(TKCDF TKCDF)
+find_library(TKLCAF TKLCAF)
+find_library(TKVCAF TKVCAF)
+
+find_library(TKBRep TKBRep)
+find_library(TKService TKService)
+
+find_library(TKOpenGl TKOpenGl)
+find_library(TKV3d TKV3d)
+
+find_library(TKXCAF TKXCAF)
+find_library(TKXSBase TKXSBase)
+find_library(TKXDESTEP TKXDESTEP)
+find_library(TKXmlXCAF TKXmlXCAF)
+find_library(TKXml TKXml)
+
+find_library(TKBin TKBin)
+find_library(TKBinL TKBinL)
+find_library(TKBinXCAF TKBinXCAF)
+
+find_library(TKStd TKStd)
+find_library(TKXmlL TKXmlL)
+find_library(TKStdL TKStdL)
+# VInspector additionally:
+find_library(TKBO TKBO)
+# ShapeView additionally:
+find_library(TKGeomBase TKGeomBase)
+find_library(TKG3d TKG3d)
--- /dev/null
+# script for each OCCT toolkit
+
+#Qt dependencies
+#message ("Project is ${PROJECT_NAME}")
+if (EXECUTABLE_PROJECT)
+ set (PACKAGE_PREFIX_DIR "samples/tools")
+ SET(SOURCE_DIR ${CMAKE_SOURCE_DIR}/../${PROJECT_NAME})
+ include_directories("${SOURCE_DIR}")
+ #message("Inc dir: ${CMAKE_SOURCE_DIR}/../${PROJECT_NAME}")
+else()
+ set (PACKAGE_PREFIX_DIR "tools")
+ SET(SOURCE_DIR ${CASROOT_SOURCE_FILES}/${PACKAGE_PREFIX_DIR}/${PROJECT_NAME})
+endif()
+
+FIND_SOURCES_AND_HEADERS_FILES(${SOURCE_DIR} SOURCE_FILES HEADER_FILES)
+
+#message ("Source dir is ${SOURCE_DIR}")
+#message ("Sources are ${SOURCE_FILES}")
+
+unset(RCC_FILES)
+if (USE_QT)
+ FIND_QT5_PACKAGE(PROJECT_LIBRARIES_DEBUG PROJECT_LIBRARIES_RELEASE PROJECT_INCLUDES)
+
+ FIND_AND_WRAP_MOC_FILES("${SOURCE_FILES}")
+ FIND_AND_WRAP_RESOURCE_FILE("${SOURCE_DIR}/${PROJECT_NAME}.qrc" RCC_FILES)
+
+endif()
+
+if (TOOLKIT_NAME)
+ set(TARGET_NAME TK${PROJECT_NAME})
+else ()
+ set(TARGET_NAME ${PROJECT_NAME})
+endif()
+
+if (EXECUTABLE_PROJECT)
+ add_executable (${TARGET_NAME} ${SOURCE_FILES} ${HEADER_FILES})
+else()
+ add_library(${TARGET_NAME} SHARED ${SOURCE_FILES} ${HEADER_FILES})
+endif()
+
+
+include_directories(
+ ${PROJECT_INCLUDES}
+ ${SOURCE_DIR}
+ ${3RDPARTY_OCCT_INCLUDE_DIR}
+ "${CMAKE_BINARY_DIR}/inc")
+
+add_definitions(-D__WIN32__)
+add_definitions(-DWNT)
+add_definitions(-D${PROJECT_NAME}_EXPORTS)
+
+# parce EXTERNLIB file
+FILE_TO_LIST ("src/${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)
+ set (LIB_ITEM ${USED_ITEM})
+ set (LIB_PARSED_ITEM ${${USED_ITEM}})
+
+ if (LIB_PARSED_ITEM)
+ list (APPEND USED_TOOLKITS_BY_CURRENT_PROJECT ${${USED_ITEM}})
+ #message("Append external lib: ${${USED_ITEM}}")
+ else ()
+ list (APPEND USED_TOOLKITS_BY_CURRENT_PROJECT ${USED_ITEM})
+ #message("Append lib: ${USED_ITEM}")
+ endif()
+
+ endif()
+endforeach()
+
+
+target_link_libraries (${TARGET_NAME} ${USED_TOOLKITS_BY_CURRENT_PROJECT})
+
+if (USE_QT)
+ target_link_libraries (${TARGET_NAME} debug ${PROJECT_LIBRARIES_DEBUG})
+ target_link_libraries (${TARGET_NAME} optimized ${PROJECT_LIBRARIES_RELEASE})
+
+ if (NOT "${RCC_FILES}" STREQUAL "")
+ #message("RCC files: ${RCC_FILES}")
+ target_sources(${TARGET_NAME} PRIVATE ${RCC_FILES})
+ endif()
+endif()
+
+if (EXECUTABLE_PROJECT)
+ INSTALL(TARGETS ${TARGET_NAME} DESTINATION "${INSTALL_DIR_BIN}")
+else()
+ if (MSVC)
+ install (DIRECTORY ${PROJECT_BINARY_DIR}/Debug/
+ DESTINATION "${INSTALL_DIR_BIN}"
+ FILES_MATCHING PATTERN *.pdb)
+ if (INSTALL_API_DIR)
+ install (DIRECTORY ${PROJECT_BINARY_DIR}/Debug/
+ DESTINATION "${INSTALL_API_DIR}/bin"
+ FILES_MATCHING PATTERN *.pdb)
+ endif()
+ endif()
+ install (TARGETS ${TARGET_NAME}
+ RUNTIME DESTINATION "${INSTALL_DIR_BIN}"
+ ARCHIVE DESTINATION "${INSTALL_DIR_LIB}"
+ LIBRARY DESTINATION "${INSTALL_DIR_LIB}")
+
+ if (INSTALL_API_DIR)
+ install (TARGETS ${TARGET_NAME}
+ RUNTIME DESTINATION "${INSTALL_API_DIR}/bin")
+
+ if (INSTALL_API)
+ INSTALL(FILES ${HEADER_FILES} DESTINATION "${INSTALL_API_DIR}/${INSTALL_DIR_INCLUDE}")
+
+ install (DIRECTORY ${PROJECT_BINARY_DIR}/Debug/
+ DESTINATION "${INSTALL_API_DIR}/lib"
+ FILES_MATCHING PATTERN *.lib)
+ endif()
+ endif()
+
+endif()
--- /dev/null
+#freeimage
+
+macro (FIND_SOURCES_AND_HEADERS_FILES CURRENT_SOURCES_DIR SOURCE_FILES HEADER_FILES)
+ if (EXISTS "${CURRENT_SOURCES_DIR}/FILES")
+ file (STRINGS "${CURRENT_SOURCES_DIR}/FILES" HEADER_FILES_H REGEX ".+[.]h")
+ file (STRINGS "${CURRENT_SOURCES_DIR}/FILES" SOURCE_FILES_C REGEX ".+[.]c")
+
+ if (NOT "${HEADER_FILES_H}" STREQUAL "")
+ foreach (ORIGIN_FILE ${HEADER_FILES_H})
+ list (APPEND HEADER_FILES_ ${CURRENT_SOURCES_DIR}/${ORIGIN_FILE})
+ endforeach()
+
+ #message("${HEADER_FILES_}")
+ set(${HEADER_FILES} ${HEADER_FILES_})
+ endif()
+
+ if(NOT "${SOURCE_FILES_C}" STREQUAL "")
+ foreach (ORIGIN_FILE ${SOURCE_FILES_C})
+ list (APPEND SOURCE_FILES_ ${CURRENT_SOURCES_DIR}/${ORIGIN_FILE})
+ endforeach()
+
+ #message("${SOURCE_FILES_}")
+ set(${SOURCE_FILES} ${SOURCE_FILES_})
+ endif()
+
+ #set(${HEADER_FILES} ${HEADER_FILES_H})
+ #set(${SOURCE_FILES} ${SOURCE_FILES_C})
+
+ else()
+ message(WARNING "file FILES is absent in $TARGET")
+ endif()
+
+endmacro()
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <LocalDebuggerEnvironment>PATH=@3RDPARTY_DLL_DEB_PATH@;@CMAKE_INSTALL_PREFIX@/@INSTALL_DIR_BIN@;%PATH%
+DATA_DIR=@INSTALL_DIR@/data
+QTDIR=@3RDPARTY_QT_DIR@
+CSF_OCCTDataPath=@3RDPARTY_OCCT_DIR@/data
+ </LocalDebuggerEnvironment>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <LocalDebuggerEnvironment>PATH=@3RDPARTY_DLL_DEB_PATH@;@CMAKE_INSTALL_PREFIX@/@INSTALL_DIR_BIN@;%PATH%
+DATA_DIR=@INSTALL_DIR@/data
+QTDIR=@3RDPARTY_QT_DIR@
+CSF_OCCTDataPath=@3RDPARTY_OCCT_DIR@/data
+ </LocalDebuggerEnvironment>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <LocalDebuggerEnvironment>PATH=@3RDPARTY_DLL_DEB_PATH@;@CMAKE_INSTALL_PREFIX@/@INSTALL_DIR_BIN@;%PATH%
+DATA_DIR=@INSTALL_DIR@/data
+QTDIR=@3RDPARTY_QT_DIR@
+CSF_OCCTDataPath=@3RDPARTY_OCCT_DIR@/data
+CSF_ShadersDirectory=@CASROOT@/src/Shaders
+ </LocalDebuggerEnvironment>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|x64'" Label="Configuration">
+ </PropertyGroup>
+</Project>
--- /dev/null
+@OCCT_HEADER_FILE_CONTENT@
--- /dev/null
+project(DFBrowser)
+
+ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
+
+set (USE_QT ON)
+set (TOOLKIT_NAME ON)
+
+OCCT_INCLUDE_CMAKE_FILE_STANDALONE ("adm/cmake/occt_toolkit_standalone")
+
+unset (USE_QT)
+unset (TOOLKIT_NAME)
--- /dev/null
+DFBrowserPane
+DFBrowserPaneXDE
+TKBRep
+TKMath
+TKV3d
+TKBRep
+TKBin
+TKBinL
+TKBinXCAF
+TKCAF
+TKCDF
+TKernel
+TKLCAF
+TKMath
+TKOpenGl
+TKService
+TKStd
+TKStdL
+TKTInspector
+TKTInspectorAPI
+TKTreeModel
+TKV3d
+TKView
+TKXSBase
+TKXCAF
+TKXDESTEP
+TKXmlXCAF
+TKXml
+TKXmlL
--- /dev/null
+project(DFBrowserPane)
+
+set (USE_QT ON)
+OCCT_INCLUDE_CMAKE_FILE_STANDALONE ("adm/cmake/occt_toolkit_standalone")
+unset (USE_QT)
--- /dev/null
+TKG3d
+TKTInspectorAPI
+TKTreeModel
+TKernel
+TKMath
+TKService
+TKV3d
+TKVCAF
+TKCDF
+TKCAF
+TKLCAF
+TKBRep
--- /dev/null
+project(DFBrowserPaneXDE)
+
+set (USE_QT ON)
+OCCT_INCLUDE_CMAKE_FILE_STANDALONE ("adm/cmake/occt_toolkit_standalone")
+unset (USE_QT)
--- /dev/null
+DFBrowserPane
+TKernel
+TKTInspectorAPI
+TKXSBase
+TKXDESTEP
+TKBRep
+TKXCAF
--- /dev/null
+project(ShapeView)
+
+set (USE_QT ON)
+set (TOOLKIT_NAME ON)
+
+OCCT_INCLUDE_CMAKE_FILE_STANDALONE ("adm/cmake/occt_toolkit_standalone")
+
+unset (USE_QT)
+unset (TOOLKIT_NAME)
+
+
--- /dev/null
+TKBRep
+TKGeomBase
+TKG3d
+TKMath
+TKTInspectorAPI
+TKTreeModel
+TKService
+TKView
--- /dev/null
+project(TInspector)
+
+set (USE_QT ON)
+set (TOOLKIT_NAME ON)
+set (INSTALL_API ON)
+
+OCCT_INCLUDE_CMAKE_FILE_STANDALONE ("adm/cmake/occt_toolkit_standalone")
+
+unset (USE_QT)
+unset (TOOLKIT_NAME)
+unset (INSTALL_API)
--- /dev/null
+TKernel
+TKTInspectorAPI
--- /dev/null
+project(TInspectorAPI)
+
+set (TOOLKIT_NAME ON)
+set (INSTALL_API ON)
+
+OCCT_INCLUDE_CMAKE_FILE_STANDALONE ("adm/cmake/occt_toolkit_standalone")
+
+unset (TOOLKIT_NAME)
+unset (INSTALL_API)
+
--- /dev/null
+TKernel
+TKLCAF
--- /dev/null
+project(TInspectorEXE)
+
+set (USE_QT ON)
+set (EXECUTABLE_PROJECT ON)
+
+OCCT_INCLUDE_CMAKE_FILE_STANDALONE ("adm/cmake/occt_toolkit_standalone")
+
+unset (USE_QT)
+unset (EXECUTABLE_PROJECT)
+
+configure_file(${CMAKE_SOURCE_DIR}/adm/templates/${PROJECT_NAME}.vcxproj.user.in
+ ${${PROJECT_NAME}_BINARY_DIR}/${PROJECT_NAME}.vcxproj.user @ONLY)
+
--- /dev/null
+TKBRep
+TKG3d
+TKService
+TKTInspector
+TKXCAF
+TKXDESTEP
+TKXSBase
+TKView
--- /dev/null
+project(TreeModel)
+
+set (USE_QT ON)
+set (TOOLKIT_NAME ON)
+
+OCCT_INCLUDE_CMAKE_FILE_STANDALONE ("adm/cmake/occt_toolkit_standalone")
+
+unset (USE_QT)
+
+
--- /dev/null
+project(VInspector)
+
+set (USE_QT ON)
+set (TOOLKIT_NAME ON)
+
+OCCT_INCLUDE_CMAKE_FILE_STANDALONE ("adm/cmake/occt_toolkit_standalone")
+
+unset (USE_QT)
+unset (TOOLKIT_NAME)
--- /dev/null
+TKBO
+TKBRep
+TKG3d
+TKernel
+TKMath
+TKTInspectorAPI
+TKTreeModel
+TKService
+TKV3d
+TKView
--- /dev/null
+project(View)
+
+set (USE_QT ON)
+set (TOOLKIT_NAME ON)
+
+OCCT_INCLUDE_CMAKE_FILE_STANDALONE ("adm/cmake/occt_toolkit_standalone")
+
+unset (USE_QT)
+
--- /dev/null
+TKernel
+TKMath
+TKService
+TKOpenGl
+TKV3d
DFBROWSER : TKDFBrowser
QAcommands : TKQADraw
VIS : TKIVtkDraw
+TOOLS : TKToolsDraw
--- /dev/null
+if { [array get Draw_Groups "TOOLS Check commands"] == "" } {
+ pload TOOLS
+}
--- /dev/null
+pload DCAF
+pload TOOLS
+
+NewDocument Doc BinOcaf
+
+set aSetAttr1 100
+set aLabel 0:2
+SetInteger Doc ${aLabel} ${aSetAttr1}
+
+tinspector -dfbrowser
+tinspector -update
+
--- /dev/null
+pload DCAF
+pload VISUALIZATION
+pload TOOLS
+
+chrono qat start
+# Create a new document and set UndoLimit
+NewDocument D BinOcaf
+tinspector -dfbrowser
+
+#NewDocument D
+cpulimit 300
+UndoLimit D 100
+
+# Open a transaction
+NewCommand D
+
+#1 - create box using more flexible set of commands
+NewCommand D
+# add object
+set B2 [AddObject D]
+# add function
+set F2 [AddFunction D $B2 Box]
+# set argumets of this function
+BoxDX D $B2 190
+BoxDY D $B2 290
+BoxDZ D $B2 390
+# initialize (clean) internal maps of labels
+InitLogBook D
+AddDriver D Box Attach Cyl
+# compute the function
+ComputeFun D $F2
+
+# check result
+set IsDone [catch {GetShape D $F2:2 Box2} aResult]
+if { ${IsDone} != 0 } {
+ puts "Error: Get a value of TNaming_NamedShape attribute from restoring document"
+} else {
+ puts "OK: Value of TNaming_NamedShape attribute from restoring document was got"
+}
+if { [regexp "SOLID FORWARD" [whatis Box2] ] != 1 } {
+ puts "Error: Box2 is not a solid forward"
+} else {
+ puts "OK: Box2 is a solid forward"
+}
+
+# referes to result NS
+GetReference D $B2;
+
+tinspector -update
+vinit
+vdisplay Box2
+vfit
+checkview -screenshot -3d -path ${imagedir}/${test_image}.png
\ No newline at end of file
--- /dev/null
+# to end a test script
+puts "TEST COMPLETED"
--- /dev/null
+001 dfbrowser
--- /dev/null
+FAILED /\bFaulty\b/ bad shape
+OK /Relative error of mass computation/ message from vprops
\ No newline at end of file
--- /dev/null
+<!DOCTYPE RCC><RCC version="1.0">
+ <qresource>
+ <file>icons/item_type_folder.png</file>
+ <file>icons/item_type_folder_40x40.png</file>
+ <file>icons/level_change.png</file>
+ <file>icons/search.png</file>
+ <file>icons/search_cancel.png</file>
+ <file>icons/treeline_backward.png</file>
+ <file>icons/treeline_forward.png</file>
+ <file>icons/treeline_update.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 <DFBrowser_AttributePaneStack.hxx>
+
+#include <DFBrowserPane_AttributePaneAPI.hxx>
+#include <DFBrowserPane_AttributePaneSelector.hxx>
+#include <DFBrowser_Item.hxx>
+#include <DFBrowser_Module.hxx>
+#include <DFBrowser_Tools.hxx>
+#include <DFBrowser_TreeLevelView.hxx>
+#include <DFBrowser_TreeModel.hxx>
+#include <DFBrowser_SearchView.hxx>
+#include <DFBrowser_Window.hxx>
+
+#include <TDF_Attribute.hxx>
+
+#include <QItemSelectionModel>
+#include <QMap>
+#include <QStackedWidget>
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowser_AttributePaneStack::DFBrowser_AttributePaneStack (QObject* theParent)
+: QObject (theParent), myCurrentPane (0), myAttributesStack (0), myModule (0), myTreeLevelView (0),
+ mySearchView (0), myEmptyWidget (0), myPaneMode (DFBrowser_AttributePaneType_ItemView)
+{
+ myPaneSelector = new DFBrowserPane_AttributePaneSelector (theParent);
+}
+
+// =======================================================================
+// function : CreateWidget
+// purpose :
+// =======================================================================
+void DFBrowser_AttributePaneStack::CreateWidget (QWidget* theParent)
+{
+ myAttributesStack = new QStackedWidget (theParent);
+ DFBrowser_Window::SetWhiteBackground (myAttributesStack);
+ myEmptyWidget = new QWidget (theParent);
+ DFBrowser_Window::SetWhiteBackground (myEmptyWidget);
+
+ myAttributesStack->addWidget (myEmptyWidget);
+
+ myTreeLevelView = new DFBrowser_TreeLevelView (theParent);
+ myAttributesStack->addWidget (myTreeLevelView->GetControl());
+
+ mySearchView = new DFBrowser_SearchView (theParent);
+ myAttributesStack->addWidget (mySearchView->GetControl());
+
+ myAttributesStack->setCurrentWidget (myEmptyWidget);
+}
+
+// =======================================================================
+// function : SetPaneMode
+// purpose :
+// =======================================================================
+void DFBrowser_AttributePaneStack::SetPaneMode (const DFBrowser_AttributePaneType& theMode)
+{
+ if (myPaneMode == theMode)
+ return;
+
+ myPaneMode = theMode;
+ if (myPaneMode == DFBrowser_AttributePaneType_SearchView)
+ {
+ //! clear highlight in tree model
+ DFBrowser_TreeModel* aModel = dynamic_cast<DFBrowser_TreeModel*> (myModule->GetOCAFViewModel());
+ if (aModel && aModel->HasHighlighted())
+ aModel->SetHighlighted (QModelIndexList());
+ myAttributesStack->setCurrentWidget (mySearchView->GetControl());
+ }
+ else
+ {
+ QItemSelectionModel* aSelectionModel = myModule->GetOCAFViewSelectionModel();
+ QModelIndex anIndex = DFBrowser_Window::SingleSelected (aSelectionModel->selectedIndexes(), 0);
+ SetCurrentItem (anIndex);
+ }
+}
+
+// =======================================================================
+// function : SetCurrentItem
+// purpose :
+// =======================================================================
+void DFBrowser_AttributePaneStack::SetCurrentItem (const QModelIndex& theIndex)
+{
+ if (myPaneMode != DFBrowser_AttributePaneType_ItemView)
+ return;
+
+ //! clear highlight in tree model
+ DFBrowser_TreeModel* aModel = dynamic_cast<DFBrowser_TreeModel*> (myModule->GetOCAFViewModel());
+ if (aModel && aModel->HasHighlighted())
+ aModel->SetHighlighted (QModelIndexList());
+
+ myCurrentPane = 0;
+ QWidget* aWidget = 0;
+ TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (theIndex);
+ if (!anItemBase)
+ return;
+
+ if (DFBrowser_TreeLevelView::ProcessItem (theIndex))
+ aWidget = myTreeLevelView->GetControl();
+ else
+ {
+ DFBrowser_ItemPtr anItem = itemDynamicCast<DFBrowser_Item> (anItemBase);
+ if (!anItem)
+ return;
+
+ if (myAttributesStack->currentWidget() == myTreeLevelView->GetControl())
+ myTreeLevelView->ClearSelection();
+ Handle(TDF_Attribute) anAttribute = anItem->GetAttribute();
+ myCurrentPane = myModule->GetAttributePane (anAttribute);
+
+ if (myCurrentPane)
+ {
+ aWidget = myCurrentPane->GetWidget (myAttributesStack, true);
+ if (aWidget)
+ {
+ int aWidgetIndex = myAttributesStack->indexOf (aWidget);
+ if (aWidgetIndex < 0)
+ myAttributesStack->addWidget (aWidget);
+ }
+ myCurrentPane->Init (anAttribute);
+
+ std::list<QItemSelectionModel*> aSelectionModels = myCurrentPane->GetSelectionModels();
+ myPaneSelector->SetCurrentSelectionModels (aSelectionModels);
+ }
+ }
+ myAttributesStack->setCurrentWidget (aWidget != NULL ? aWidget : myEmptyWidget);
+}
--- /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 DFBrowser_AttributePaneStack_H
+#define DFBrowser_AttributePaneStack_H
+
+#include <DFBrowser_AttributePaneType.hxx>
+#include <Standard.hxx>
+#include <TreeModel_ItemBase.hxx>
+
+#include <QMap>
+#include <QItemSelection>
+#include <QStackedWidget>
+#include <QWidget>
+
+class DFBrowserPane_AttributePaneAPI;
+class DFBrowserPane_AttributePaneSelector;
+class DFBrowser_Module;
+class DFBrowser_SearchView;
+class DFBrowser_TreeLevelView;
+
+class QStackedWidget;
+class QWidget;
+
+//! \class DFBrowser_AttributePaneStack
+//! \brief Provides work to stacked widget where the current attribute pane is shown.
+class DFBrowser_AttributePaneStack : public QObject
+{
+public:
+
+ //! Constructor
+ Standard_EXPORT DFBrowser_AttributePaneStack (QObject* theParent);
+
+ //! Destructor
+ virtual ~DFBrowser_AttributePaneStack() {}
+
+ //! Creates a stacked widget
+ //! \param theParent a parent widget
+ Standard_EXPORT virtual void CreateWidget (QWidget* theParent);
+
+ //! \return the stacked widget
+ QWidget* GetWidget() const { return myAttributesStack; }
+
+ //! Fills stackk with the information
+ //! \param theAttributeTypes a map of attribute type name to information pane
+ void SetModule (DFBrowser_Module* theModule) { myModule = theModule; }
+
+ //! Sets the current widget in the stacked control either attribute pane or search view
+ //! \param theMode an active mode
+ Standard_EXPORT void SetPaneMode (const DFBrowser_AttributePaneType& theMode);
+
+ //! \return an attribute pane, which corresponds the current widget of the stacked widget control
+ DFBrowserPane_AttributePaneAPI* GetCurrentPane() const { return myCurrentPane; }
+
+ //! \return tree level view
+ DFBrowser_TreeLevelView* GetTreeLevelView() const { return myTreeLevelView; }
+
+ //! \return the search view
+ DFBrowser_SearchView* GetSearchView() const { return mySearchView; }
+
+ //! \return the pane selector
+ DFBrowserPane_AttributePaneSelector* GetPaneSelector() const { return myPaneSelector; }
+
+ //! Sets an active widget of attribute pane if the pane mode is item view mode.
+ //! Gets selection models of this pane and set the models into pane selector
+ Standard_EXPORT void SetCurrentItem (const QModelIndex& theIndex);
+
+protected:
+
+ DFBrowserPane_AttributePaneAPI* myCurrentPane; //!< active pane if mode is item view mode
+ DFBrowserPane_AttributePaneSelector* myPaneSelector; //!< pane selector filled by the active pane
+ QStackedWidget* myAttributesStack; //!< container of already created panes
+ DFBrowser_Module* myModule; //!< the current module
+ DFBrowser_TreeLevelView* myTreeLevelView; //!< view of objects from one level of tree view
+ DFBrowser_SearchView* mySearchView; //!< view of search control
+ QWidget* myEmptyWidget; //!< an empty widget when nothing is selected in tree view
+ DFBrowser_AttributePaneType myPaneMode; //!< the current pane mode, either item view or search view
+};
+
+#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.
+
+#ifndef DFBrowser_AttributePaneType_H
+#define DFBrowser_AttributePaneType_H
+
+//! Type of view shown in attribute pane stack
+enum DFBrowser_AttributePaneType
+{
+ DFBrowser_AttributePaneType_ItemView, //!< attribute pane stack shows either TreeLevelView or attribute pane
+ DFBrowser_AttributePaneType_SearchView //!< attribute pane stack shows search view
+};
+
+#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 <DFBrowser_Communicator.hxx>
+
+#include <CDF_Session.hxx>
+#include <DFBrowser_Module.hxx>
+#include <DFBrowser_Window.hxx>
+
+// =======================================================================
+// function : CreateCommunicator
+// purpose : Creates a communicator by the library loading
+// =======================================================================
+Standard_EXPORTEXTERNC TInspectorAPI_Communicator* CreateCommunicator()
+{
+ return new DFBrowser_Communicator();
+}
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowser_Communicator::DFBrowser_Communicator()
+ : TInspectorAPI_Communicator(), myWindow (0)
+{
+ myWindow = new DFBrowser_Window();
+}
+
+// =======================================================================
+// function : SetParameters
+// purpose :
+// =======================================================================
+void DFBrowser_Communicator::SetParameters (const Handle(TInspectorAPI_PluginParameters)& theParameters)
+{
+ myWindow->SetParameters (theParameters);
+ myWindow->UpdateContent();
+}
--- /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 DFBrowser_Communicator_H
+#define DFBrowser_Communicator_H
+
+#include <DFBrowser_Window.hxx>
+#include <Standard.hxx>
+#include <Standard_Macro.hxx>
+#include <TInspectorAPI_Communicator.hxx>
+
+#include <QObject>
+
+class DFBrowser_Window;
+
+//! \class DFBrowser_Communicator.
+//! \brief This is a connector from TInspector application to DFBrowser view
+class DFBrowser_Communicator : public QObject, public TInspectorAPI_Communicator
+{
+public:
+
+ //! Constructor
+ Standard_EXPORT DFBrowser_Communicator();
+
+ //! Destructor
+ virtual ~DFBrowser_Communicator() Standard_OVERRIDE {}
+
+ //! Provides the container with a parent where this container should be inserted.
+ //! If Qt implementation, it should be QWidget with QLayout set inside
+ //! \param theParent a parent class
+ virtual void SetParent (void* theParent) Standard_OVERRIDE { myWindow->SetParent (theParent); }
+
+ //! Sets parameters container, it should be used when the plugin is initialized or in update content
+ //! \param theParameters a parameters container
+ Standard_EXPORT virtual void SetParameters (const Handle(TInspectorAPI_PluginParameters)& theParameters) Standard_OVERRIDE;
+
+ //! Updates content of the current window
+ virtual void UpdateContent() Standard_OVERRIDE { myWindow->UpdateContent(); }
+
+private:
+
+ DFBrowser_Window* myWindow; //!< the current window
+};
+
+#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 <DFBrowser_DumpView.hxx>
+
+#include <DFBrowser_Item.hxx>
+#include <DFBrowser_Window.hxx>
+#include <DFBrowser_TreeLevelView.hxx>
+#include <OSD_OpenFile.hxx>
+#include <TreeModel_ModelBase.hxx>
+
+#include <QAbstractItemModel>
+#include <QDir>
+#include <QFile>
+#include <QPlainTextEdit>
+#include <QTextStream>
+#include <QWidget>
+
+// =======================================================================
+// function : onSelectionChanged
+// purpose :
+// =======================================================================
+void DFBrowser_DumpView::OnTreeViewSelectionChanged (const QItemSelection& theSelected,
+ const QItemSelection&)
+{
+ myTextEdit->setVisible (false);
+ myTextEdit->clear();
+
+ QModelIndexList aSelectedIndices = theSelected.indexes();
+ QModelIndexList aFirstColumnSelectedIndices;
+ for (QModelIndexList::const_iterator aSelIt = aSelectedIndices.begin(); aSelIt != aSelectedIndices.end(); aSelIt++)
+ {
+ QModelIndex anIndex = *aSelIt;
+ if (anIndex.column() == 0)
+ aFirstColumnSelectedIndices.append (anIndex);
+ }
+ if (aFirstColumnSelectedIndices.size() != 1)
+ return;
+
+ QString aDumpInfo;
+ const QModelIndex& anIndex = aFirstColumnSelectedIndices.first();
+ TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex);
+//#define REQUIRE_OCAF_REVIEW:18 : start
+ DFBrowser_ItemPtr anItem;
+ if (anItemBase)
+ anItem = itemDynamicCast<DFBrowser_Item> (anItemBase);
+
+ if (!anItem)
+ return;
+
+ TCollection_AsciiString aFileName = DFBrowser_Window::TmpDirectory();
+ aFileName += "/dfbrowser.txt";
+ // print dump to file(not in a string stream because result might be too long)
+ std::ofstream aFileStream;
+ OSD_OpenStream(aFileStream, aFileName, ios::out);
+ if (anItem->HasAttribute())
+ {
+ Handle(TDF_Attribute) anAttribute = anItem->GetAttribute();
+ if (!anAttribute.IsNull())
+ anAttribute->Dump(aFileStream);
+ }
+ else if (anItem->HasLabel())
+ anItem->GetLabel().Dump(aFileStream);
+ aFileStream.close();
+
+ // read dumped file to fill view
+ QFile aFile (aFileName.ToCString());
+ if (!aFile.open (QIODevice::ReadOnly | QIODevice::Text))
+ return;
+ QTextStream aStream (&aFile);
+ while (!aStream.atEnd())
+ {
+ aDumpInfo.append (QString ("%1\n").arg (aStream.readLine()));
+ }
+ aFile.close();
+ QDir aDir;
+ aDir.remove (aFileName.ToCString());
+//#define REQUIRE_OCAF_REVIEW:18 : end
+ if (!aDumpInfo.isEmpty())
+ {
+ myTextEdit->setVisible (true);
+ myTextEdit->setPlainText (aDumpInfo);
+ }
+}
--- /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 DFBrowser_DumpView_H
+#define DFBrowser_DumpView_H
+
+#include <Standard.hxx>
+#include <Standard_Macro.hxx>
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4127) // conditional expression is constant
+#endif
+#include <QObject>
+#include <QItemSelection>
+#include <QPlainTextEdit>
+
+class QWidget;
+
+//! \class DFBrowser_DumpView
+//! \brief View to display result of Dump() method of a TDF_Attribute
+class DFBrowser_DumpView : public QObject
+{
+ Q_OBJECT
+public:
+
+ //! Constructor
+ DFBrowser_DumpView (QWidget* theParent) : QObject(theParent), myTextEdit( new QPlainTextEdit(theParent) ) {}
+
+ //! Destructor
+ virtual ~DFBrowser_DumpView() Standard_OVERRIDE {}
+
+ //! \return the text edit control
+ QWidget* GetControl() const { return myTextEdit; }
+
+public slots:
+
+ //! Slots listen selection change and update the current control content by selection
+ //! \param theSelected container of selected items
+ //! \param theDeselected container of items that become deselected
+ Standard_EXPORT void OnTreeViewSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
+
+private:
+
+ QPlainTextEdit* myTextEdit; //!< information view
+};
+#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 <DFBrowser_HighlightDelegate.hxx>
+
+#include <DFBrowser_Window.hxx>
+#include <QPainter>
+
+// =======================================================================
+// function : paint
+// purpose :
+// =======================================================================
+void DFBrowser_HighlightDelegate::paint (QPainter* thePainter, const QStyleOptionViewItem& theOption,
+ const QModelIndex& theIndex) const
+{
+ // highlight cell
+ if (theOption.state & QStyle::State_MouseOver)
+ {
+ QColor aHighlightColor = DFBrowser_Window::LightHighlightColor();
+ thePainter->fillRect (theOption.rect, aHighlightColor);
+ }
+ // default paint
+ QItemDelegate::paint (thePainter, theOption, theIndex);
+}
+
--- /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 DFBrowser_HighlightDelegate_H
+#define DFBrowser_HighlightDelegate_H
+
+#include <Standard.hxx>
+#include <Standard_Macro.hxx>
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4127) // conditional expression is constant
+#endif
+#include <QItemDelegate>
+
+//! \class DFBrowser_HighlightDelegate
+//! \brief An item delegate to paint in highlight color the cell when the mouse cursor is over it
+class DFBrowser_HighlightDelegate : public QItemDelegate
+{
+public:
+
+ //! Constructor
+ DFBrowser_HighlightDelegate (QObject* theParent = 0) : QItemDelegate (theParent) {}
+
+ //! Destructor
+ virtual ~DFBrowser_HighlightDelegate() Standard_OVERRIDE {}
+
+ //! Redefine of the parent virtual method to color the cell rectangle in highlight style
+ //! \param thePainter a painter
+ //! \param theOption a paint options
+ //! \param theIndex a view index
+ Standard_EXPORT virtual void paint (QPainter* thePainter, const QStyleOptionViewItem& theOption,
+ const QModelIndex& theIndex) const Standard_OVERRIDE;
+};
+#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 <DFBrowser_Item.hxx>
+
+#include <DFBrowser_ItemRole.hxx>
+#include <DFBrowser_Module.hxx>
+#include <DFBrowser_Tools.hxx>
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <DFBrowserPane_ItemRole.hxx>
+#include <DFBrowserPane_Tools.hxx>
+
+#include <TDF_AttributeIterator.hxx>
+#include <TDF_ChildIterator.hxx>
+
+#include <QIcon>
+#include <QObject>
+
+const int INFO_LENGHT = 60;
+
+//#define REQUIRE_OCAF_REVIEW:23
+// =======================================================================
+// function : hasAttribute
+// purpose :
+// =======================================================================
+bool DFBrowser_Item::HasAttribute() const
+{
+ initItem();
+ return myAttributeGUID != Standard_GUID();
+}
+
+// =======================================================================
+// function : getAttribute
+// purpose :
+// =======================================================================
+Handle(TDF_Attribute) DFBrowser_Item::GetAttribute() const
+{
+ initItem();
+ Handle(TDF_Attribute) anAttribute;
+ GetLabel().FindAttribute (myAttributeGUID, anAttribute);
+ return anAttribute;
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void DFBrowser_Item::Init()
+{
+ DFBrowser_ItemBasePtr aParentItem = itemDynamicCast<DFBrowser_ItemBase> (Parent());
+ if (!aParentItem)
+ return;
+ TDF_Label aParentLabel = aParentItem->GetLabel();
+ // items can exist only by items with not empty label
+ if (aParentLabel.IsNull())
+ return;
+
+ int aNbAttributes = aParentLabel.NbAttributes();
+ int aRowId = Row();
+ if (aRowId < aNbAttributes)
+ {
+ Handle(TDF_Attribute) anAttribute;
+ int anAttributeId = 0;
+ for (TDF_AttributeIterator anAttrIt (aParentLabel); anAttrIt.More(); anAttrIt.Next(), anAttributeId++)
+ {
+ if (anAttributeId == aRowId)
+ anAttribute = anAttrIt.Value();
+ }
+ SetAttribute (anAttribute);
+ }
+ else {
+ int aCurrentId = aRowId - aNbAttributes;
+ TDF_ChildIterator aLabelsIt (aParentLabel);
+ TDF_Label aLabel;
+ for (int aLabelId = 0; aLabelsIt.More(); aLabelsIt.Next(), aLabelId++)
+ {
+ if (aLabelId < aCurrentId)
+ continue;
+ aLabel = aLabelsIt.Value();
+ break;
+ }
+ if (!aLabel.IsNull())
+ setLabel (aLabel);
+ }
+ TreeModel_ItemBase::Init();
+}
+
+// =======================================================================
+// function : reset
+// purpose :
+// =======================================================================
+void DFBrowser_Item::Reset()
+{
+ SetAttribute (Handle(TDF_Attribute)());
+
+ DFBrowser_ItemBase::Reset();
+}
+
+// =======================================================================
+// function : initRowCount
+// purpose :
+// =======================================================================
+int DFBrowser_Item::initRowCount() const
+{
+ return HasAttribute() ? 0 : DFBrowser_ItemBase::initRowCount();
+}
+
+// =======================================================================
+// function : initValue
+// purpose :
+// =======================================================================
+QVariant DFBrowser_Item::initValue (const int theItemRole) const
+{
+ if (!HasAttribute())
+ return DFBrowser_ItemBase::initValue (theItemRole);
+
+ if (theItemRole == DFBrowserPane_ItemRole_DisplayExtended || theItemRole == DFBrowserPane_ItemRole_ToolTipExtended)
+ {
+ int aRole = theItemRole == DFBrowserPane_ItemRole_DisplayExtended ? Qt::DisplayRole : Qt::ToolTipRole;
+ QVariant aValue = DFBrowser_Module::GetAttributeInfo (GetAttribute(), GetModule(), aRole, Column());
+ QString anAdditionalInfo = DFBrowser_Module::GetAttributeInfo (GetAttribute(), GetModule(),
+ DFBrowser_ItemRole_AdditionalInfo, Column()).toString();
+ if (!anAdditionalInfo.isEmpty())
+ {
+ if (theItemRole == DFBrowserPane_ItemRole_DisplayExtended && anAdditionalInfo.length() > INFO_LENGHT)
+ anAdditionalInfo = anAdditionalInfo.mid (0, INFO_LENGHT - 3) + "...";
+ if (!anAdditionalInfo.isEmpty())
+ aValue = QVariant (aValue.toString() + QString (" [%1]").arg (anAdditionalInfo));
+ //if (aRole == Qt::ToolTipRole)
+ // aValue = wrapTextByWords(aValue.toString().toStdString(), INFO_LENGHT).c_str();
+ }
+ return aValue;
+ }
+
+ return DFBrowser_Module::GetAttributeInfo (GetAttribute(), GetModule(), theItemRole, Column());
+}
+
+// =======================================================================
+// function : GetAttributeInfo
+// purpose :
+// =======================================================================
+QVariant DFBrowser_Item::GetAttributeInfo (int theRole) const
+{
+ initItem();
+ return cachedValue (theRole);
+}
+
+// =======================================================================
+// function : initItem
+// purpose :
+// =======================================================================
+void DFBrowser_Item::initItem() const
+{
+ if (IsInitialized())
+ return;
+
+ const_cast<DFBrowser_Item*>(this)->Init();
+}
+
+// =======================================================================
+// function : SetAttribute
+// purpose :
+// =======================================================================
+void DFBrowser_Item::SetAttribute (Handle(TDF_Attribute) theAttribute)
+{
+ if (!theAttribute.IsNull())
+ {
+ setLabel (theAttribute->Label());
+ myAttributeGUID = theAttribute->ID();
+ }
+ else
+ {
+ setLabel (TDF_Label());
+ myAttributeGUID = Standard_GUID();
+ }
+}
--- /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 DFBrowser_Item_H
+#define DFBrowser_Item_H
+
+#include <DFBrowser_ItemBase.hxx>
+
+#include <TDF_Attribute.hxx>
+#include <Standard.hxx>
+#include <Standard_GUID.hxx>
+
+#include <QMap>
+#include <QList>
+#include <QVariant>
+
+class DFBrowser_Item;
+typedef QExplicitlySharedDataPointer<DFBrowser_Item> DFBrowser_ItemPtr;
+
+//! \class DFBrowser_Item
+//! \brief Declaration of the tree model root item.
+class DFBrowser_Item : public DFBrowser_ItemBase
+{
+public:
+
+ //! Creates an item wrapped by a shared pointer
+ //! \param theRow the item row positition in the parent item
+ //! \param theColumn the item column positition in the parent item
+ //! \return the pointer to the created item
+ static DFBrowser_ItemPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ { return DFBrowser_ItemPtr (new DFBrowser_Item (theParent, theRow, theColumn)); }
+
+ //! Destructor
+ virtual ~DFBrowser_Item() Standard_OVERRIDE {};
+
+ //! \return true if the attribute is set in the item, otherwise it is initialized by a label
+ Standard_EXPORT bool HasAttribute() const;
+
+ //! \return the item attribute
+ Standard_EXPORT Handle(TDF_Attribute) GetAttribute() const;
+
+ //! Finds int parent item attribute or label by this item row and store it in a field of this item.
+ Standard_EXPORT virtual void Init() Standard_OVERRIDE;
+
+ //! Resets the cached item values, set null attribute and calls reset of the parent class
+ Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
+
+ //! Init item and calls cachedValue() for the role
+ //! \param theItemRole a value role
+ //! \return the value
+ Standard_EXPORT QVariant GetAttributeInfo(int theRole) const;
+
+protected:
+
+ //! \return number of children.
+ virtual int initRowCount() const Standard_OVERRIDE;
+
+ //! Return data value for the role:
+ //! - if content is label, calls DFBrowser_ItemBase;
+ //! - if content is attribute, if the fole is extended display, asks additional info text or ask module about info
+ //! \param theItemRole a value role
+ //! \return the value
+ virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
+
+ //! Constructor
+ //! param theParent a parent item
+ //! \param theRow the item row positition in the parent item
+ //! \param theColumn the item column positition in the parent item
+ DFBrowser_Item (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ : DFBrowser_ItemBase (theParent, theRow, theColumn) {}
+
+ //! Initialize the current item. It creates a backup of the specific item information
+ void initItem() const;
+
+ //! Sets the item attribute
+ //! \param theAttribute an item attribute
+ void SetAttribute (Handle(TDF_Attribute) theAttribute);
+
+private:
+
+ Standard_GUID myAttributeGUID; //!< if attribute, stores GUID of the attibute because label can contain only one attribute of a kind
+};
+
+#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 <DFBrowser_ItemApplication.hxx>
+
+#include <DFBrowser_Item.hxx>
+#include <DFBrowser_ItemDocument.hxx>
+#include <DFBrowser_Module.hxx>
+#include <DFBrowser_Tools.hxx>
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <DFBrowserPane_ItemRole.hxx>
+
+#include <QObject>
+
+//#define REQUIRE_OCAF_REVIEW:21
+
+// =======================================================================
+// function : createChild
+// purpose :
+// =======================================================================
+TreeModel_ItemBasePtr DFBrowser_ItemApplication::createChild (int theRow, int theColumn)
+{
+ TreeModel_ItemBasePtr anItem = DFBrowser_ItemDocument::CreateItem (currentItem(), theRow, theColumn);
+ DFBrowser_ItemBasePtr aBaseItem = itemDynamicCast<DFBrowser_ItemBase> (anItem);
+ aBaseItem->SetModule (GetModule());
+
+ return anItem;
+}
+
+// =======================================================================
+// function : initRowCount
+// purpose :
+// =======================================================================
+int DFBrowser_ItemApplication::initRowCount() const
+{
+ if (myApplication.IsNull())
+ return 0;
+
+ return myApplication->NbDocuments();
+}
+
+// =======================================================================
+// function : initValue
+// purpose :
+// =======================================================================
+QVariant DFBrowser_ItemApplication::initValue (const int theItemRole) const
+{
+ if (theItemRole == Qt::DisplayRole ||
+ theItemRole == Qt::EditRole ||
+ theItemRole == Qt::ToolTipRole ||
+ theItemRole == DFBrowserPane_ItemRole_DisplayExtended ||
+ theItemRole == DFBrowserPane_ItemRole_ToolTipExtended)
+ {
+ return "TDocStd_Application";
+ }
+ 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 DFBrowser_ItemApplication_H
+#define DFBrowser_ItemApplication_H
+
+#include <DFBrowser_ItemBase.hxx>
+#include <TDocStd_Application.hxx>
+
+class DFBrowser_ItemApplication;
+typedef QExplicitlySharedDataPointer<DFBrowser_ItemApplication> DFBrowser_ItemApplicationPtr;
+
+//! \class DFBrowser_ItemApplication
+//! \brief Declaration of the tree model root item.
+//! This item is connected to the main label of the document.
+class DFBrowser_ItemApplication : public DFBrowser_ItemBase
+{
+public:
+
+ //! Creates an item wrapped by a shared pointer
+ static DFBrowser_ItemApplicationPtr CreateItem (TreeModel_ItemBasePtr theParent)
+ { return DFBrowser_ItemApplicationPtr (new DFBrowser_ItemApplication (theParent)); }
+
+ //! Destructor
+ virtual ~DFBrowser_ItemApplication() Standard_OVERRIDE {};
+
+ //! Sets the item label
+ //! \param theLabel an object where the child items structure is found
+ void SetApplication (const Handle(TDocStd_Application)& theApplication) { myApplication = theApplication; }
+
+ //! Returns the current label
+ //! \return a label
+ const Handle(TDocStd_Application)& GetApplication() const { return myApplication; }
+
+protected:
+
+ //! Returns number of documents if the application is not NULL
+ //! \return rows count
+ virtual int initRowCount() const Standard_OVERRIDE;
+
+ //! Returns fixed item text or empty.
+ //! \param theItemRole a value role
+ //! \return the value
+ virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
+
+protected:
+
+ //! Creates a child item in the given position.
+ //! \param theRow the child row position
+ //! \param theColumn the child column position
+ //! \return the created item
+ virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
+
+private:
+
+ //! Constructor
+ //! param theParent a parent item
+ DFBrowser_ItemApplication(TreeModel_ItemBasePtr theParent) : DFBrowser_ItemBase(theParent, 0, 0) {}
+
+private:
+
+ Handle(TDocStd_Application) myApplication; //!<! OCAF application
+};
+
+#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 <DFBrowser_ItemBase.hxx>
+
+#include <DFBrowser_Item.hxx>
+#include <DFBrowser_Module.hxx>
+#include <DFBrowser_Tools.hxx>
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <DFBrowserPane_ItemRole.hxx>
+#include <DFBrowserPane_Tools.hxx>
+
+#include <TDataStd_Name.hxx>
+#include <TDF_ChildIterator.hxx>
+
+#include <QColor>
+#include <QIcon>
+#include <QVariant>
+
+//#define REQUIRE_OCAF_REVIEW:20
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowser_ItemBase::DFBrowser_ItemBase (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+: TreeModel_ItemBase (theParent, theRow, theColumn), myModule (0), myIsUseAdditionalInfo (true)
+{
+}
+
+// =======================================================================
+// function : reset
+// purpose :
+// =======================================================================
+void DFBrowser_ItemBase::Reset()
+{
+ setLabel (TDF_Label());
+ TreeModel_ItemBase::Reset();
+}
+
+// =======================================================================
+// function : GetLabel
+// purpose :
+// =======================================================================
+TDF_Label DFBrowser_ItemBase::GetLabel() const
+{
+ initItem();
+ return myLabel;
+}
+
+// =======================================================================
+// function : data
+// purpose :
+// =======================================================================
+QVariant DFBrowser_ItemBase::data (const QModelIndex& theIndex, int theRole) const
+{
+ int aRole = theRole;
+ if (Column() == 0 && useAdditionalInfo())
+ {
+ switch (theRole)
+ {
+ case Qt::DisplayRole: { aRole = DFBrowserPane_ItemRole_DisplayExtended; break; }
+ case Qt::ToolTipRole: { aRole = DFBrowserPane_ItemRole_ToolTipExtended; break; }
+ }
+ }
+ return TreeModel_ItemBase::data (theIndex, aRole);
+}
+
+// =======================================================================
+// function : initRowCount
+// purpose :
+// =======================================================================
+int DFBrowser_ItemBase::initRowCount() const
+{
+ TDF_Label aLabel = GetLabel();
+ if (aLabel.IsNull())
+ return 0;
+
+ return aLabel.NbChildren() + aLabel.NbAttributes();
+}
+
+// =======================================================================
+// function : initValue
+// purpose :
+// =======================================================================
+QVariant DFBrowser_ItemBase::initValue (const int theItemRole) const
+{
+ switch (theItemRole)
+ {
+ case Qt::DisplayRole:
+ case Qt::EditRole:
+ case Qt::ToolTipRole:
+ return DFBrowser_Tools::GetLabelInfo (myLabel, false);
+ case DFBrowserPane_ItemRole_DisplayExtended:
+ case DFBrowserPane_ItemRole_ToolTipExtended:
+ return DFBrowser_Tools::GetLabelInfo (myLabel, true);
+ case Qt::ForegroundRole:
+ {
+ QVariant aValue = QColor (Qt::black);
+ if (DFBrowser_Tools::IsEmptyLabel(GetLabel()))
+ aValue = QColor (Qt::lightGray);
+ else
+ { //! TEMPORARY HERE : should be moved in the pane of TDataStd_Name kind of attribute
+ Handle(TDataStd_Name) aName;
+ if (useAdditionalInfo() && myLabel.FindAttribute (TDataStd_Name::GetID(), aName))
+ aValue = QColor (Qt::darkGreen);
+ }
+ return aValue;
+ }
+ case Qt::DecorationRole: return DFBrowser_Tools::GetLabelIcon (myLabel);
+ default: break;
+ }
+ return QVariant();
+}
+
+// =======================================================================
+// function : createChild
+// purpose :
+// =======================================================================
+TreeModel_ItemBasePtr DFBrowser_ItemBase::createChild (int theRow, int theColumn)
+{
+ TreeModel_ItemBasePtr anItem = DFBrowser_Item::CreateItem (currentItem(), theRow, theColumn);
+ DFBrowser_ItemBasePtr aBaseItem = itemDynamicCast<DFBrowser_ItemBase> (anItem);
+ aBaseItem->SetModule (GetModule());
+
+ return anItem;
+}
+
+// =======================================================================
+// function : SetUseAdditionalInfo
+// purpose :
+// =======================================================================
+bool DFBrowser_ItemBase::SetUseAdditionalInfo (const bool theValue)
+{
+ bool aPreviousValue = myIsUseAdditionalInfo;
+ myIsUseAdditionalInfo = theValue;
+ return aPreviousValue;
+}
+
--- /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 DFBrowser_ItemBase_H
+#define DFBrowser_ItemBase_H
+
+#include <Standard.hxx>
+#include <TreeModel_ItemBase.hxx>
+#include <TDF_Label.hxx>
+
+class DFBrowser_ItemBase;
+class DFBrowser_Module;
+typedef QExplicitlySharedDataPointer<DFBrowser_ItemBase> DFBrowser_ItemBasePtr;
+
+//! \class DFBrowser_ItemBase
+//! \brief Declaration of the tree model base item.
+//! This item provide method to process a TDF label.
+class DFBrowser_ItemBase : public TreeModel_ItemBase
+{
+public:
+
+ //! Sets the module to have an access to attribute information
+ //! \param theModule a current loaded application module
+ void SetModule (DFBrowser_Module* theModule) { myModule = theModule; }
+
+ //! Resets the cached item values
+ Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
+
+ //! \return true if the current label is not null
+ bool HasLabel() const { return !GetLabel().IsNull(); }
+
+ //! \return the current label
+ Standard_EXPORT virtual TDF_Label GetLabel() const;
+
+ //! \return the current module
+ DFBrowser_Module* GetModule() const { return myModule; }
+
+ //! Change using of additional information in item. It it does not use additional info,
+ //! it will not return extended text in initValue().
+ //! \param theValue a new value
+ //! \return the previous value
+ Standard_EXPORT bool SetUseAdditionalInfo (const bool theValue);
+
+ //! Returns the data stored under the given role for the current item
+ //! \param theIndex the item model index
+ //! \param theRole the item model role
+ Standard_EXPORT virtual QVariant data (const QModelIndex& theIndex, int theRole) const Standard_OVERRIDE;
+
+protected:
+
+ //! Sets the item label
+ //! \param theLabel an object where the child items structure is found
+ void setLabel(TDF_Label theLabel) { myLabel = theLabel; }
+
+ //! Returns if additional information is shown in item for Display and ToolTip values
+ //! \return boolean value
+ bool useAdditionalInfo() const { return myIsUseAdditionalInfo; }
+
+ //! Returns sum of label children and attributes
+ //! \return rows count
+ virtual int initRowCount() const Standard_OVERRIDE;
+
+ //! Returns label information like text, icon or background(if it contains TDataStd_Name attribute)
+ //! \param theItemRole a value role
+ //! \return the value
+ virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
+
+ //! Creates a child item in the given position.
+ //! \param theRow the child row position
+ //! \param theColumn the child column position
+ //! \return the created item
+ virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
+
+ //! Initialize the current item. It creates a backup of the specific item information
+ virtual void initItem() const {};
+
+protected:
+
+ //! Constructor
+ //! param theParent a parent item
+ //! \param theRow the item row positition in the parent item
+ //! \param theColumn the item column positition in the parent item
+ DFBrowser_ItemBase (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn);
+
+private:
+
+ TDF_Label myLabel; //!< a label of the document, which contains child labels and attributes
+ DFBrowser_Module* myModule; //!< the current module
+ bool myIsUseAdditionalInfo; //!< if true, additional item info is shown in square brackets
+};
+
+#endif
\ 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 <DFBrowser_ItemDocument.hxx>
+
+#include <DFBrowser_Item.hxx>
+#include <DFBrowser_ItemApplication.hxx>
+#include <DFBrowser_ItemDocument.hxx>
+#include <DFBrowser_Tools.hxx>
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <DFBrowserPane_ItemRole.hxx>
+
+#include <QIcon>
+#include <QLabel>
+#include <QObject>
+
+//#define REQUIRE_OCAF_REVIEW:22
+
+// =======================================================================
+// function : GetLabel
+// purpose :
+// =======================================================================
+TDF_Label DFBrowser_ItemDocument::GetLabel() const
+{
+ TDF_Label aLabel;
+ if (myDocument.IsNull())
+ getDocument();
+
+ if (!myDocument.IsNull())
+ aLabel = myDocument->Main().Root();
+
+ if (!aLabel.IsNull())
+ aLabel = aLabel.Root();
+
+ return aLabel;
+}
+
+// =======================================================================
+// function : getDocument
+// purpose :
+// =======================================================================
+const Handle(TDocStd_Document)& DFBrowser_ItemDocument::getDocument() const
+{
+ initItem();
+ return myDocument;
+}
+
+// =======================================================================
+// function : initValue
+// purpose :
+// =======================================================================
+QVariant DFBrowser_ItemDocument::initValue (const int theItemRole) const
+{
+ if (theItemRole == Qt::DisplayRole ||
+ theItemRole == Qt::EditRole ||
+ theItemRole == DFBrowserPane_ItemRole_DisplayExtended ||
+ theItemRole == DFBrowserPane_ItemRole_ToolTipExtended)
+ return DFBrowser_Tools::GetLabelInfo (GetLabel());
+ if (theItemRole == Qt::DecorationRole)
+ return DFBrowser_Tools::GetLabelIcon (GetLabel());
+
+ return QVariant();
+}
+
+// =======================================================================
+// function : createChild
+// purpose :
+// =======================================================================
+TreeModel_ItemBasePtr DFBrowser_ItemDocument::createChild (int theRow, int theColumn)
+{
+ TreeModel_ItemBasePtr anItem = DFBrowser_Item::CreateItem (currentItem(), theRow, theColumn);
+ DFBrowser_ItemBasePtr aBaseItem = itemDynamicCast<DFBrowser_ItemBase> (anItem);
+ aBaseItem->SetModule (GetModule());
+
+ return anItem;
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void DFBrowser_ItemDocument::Init()
+{
+ DFBrowser_ItemApplicationPtr aParentItem = itemDynamicCast<DFBrowser_ItemApplication> (Parent());
+ if (!aParentItem)
+ return;
+
+ const Handle(TDocStd_Application)& anApplication = aParentItem->GetApplication();
+ // items can exist only by items with not empty label
+ if (anApplication.IsNull())
+ return;
+
+ int aRowId = Row();
+
+ int aDocumentId = -1;
+ for (Standard_Integer aDocId = 1, aNbDoc = anApplication->NbDocuments(); aDocId <= aNbDoc && aDocumentId < 0; aDocId++)
+ {
+ if (aDocId - 1 == aRowId)
+ aDocumentId = aDocId;
+ }
+ if (aDocumentId > 0)
+ {
+ Handle(TDocStd_Document) aDocument;
+ anApplication->GetDocument (aDocumentId, aDocument);
+ setDocument (aDocument);
+ }
+ else
+ setDocument (Handle(TDocStd_Document)());
+
+ TreeModel_ItemBase::Init();
+}
+
+// =======================================================================
+// function : reset
+// purpose :
+// =======================================================================
+void DFBrowser_ItemDocument::Reset()
+{
+ Handle(TDocStd_Document) aDocument;
+ setDocument (aDocument);
+
+ DFBrowser_ItemBase::Reset();
+}
+
+// =======================================================================
+// function : initItem
+// purpose :
+// =======================================================================
+void DFBrowser_ItemDocument::initItem() const
+{
+ if (IsInitialized())
+ return;
+
+ const_cast<DFBrowser_ItemDocument*>(this)->Init();
+}
--- /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 DFBrowser_ItemDocument_H
+#define DFBrowser_ItemDocument_H
+
+#include <DFBrowser_ItemBase.hxx>
+#include <Standard.hxx>
+#include <TDocStd_Document.hxx>
+
+class DFBrowser_ItemDocument;
+typedef QExplicitlySharedDataPointer<DFBrowser_ItemDocument> DFBrowser_ItemDocumentPtr;
+
+//! \class DFBrowser_ItemDocument
+//! \brief Declaration of the tree model document item.
+//! This item is connected to the OCAF document. Parent item is application, children are either labels or attributes
+class DFBrowser_ItemDocument : public DFBrowser_ItemBase
+{
+public:
+
+ //! Creates an item wrapped by a shared pointer
+ //! \param theRow the item row positition in the parent item
+ //! \param theColumn the item column positition in the parent item
+ //! \return the pointer to the created item
+ static DFBrowser_ItemDocumentPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ { return DFBrowser_ItemDocumentPtr (new DFBrowser_ItemDocument (theParent, theRow, theColumn)); }
+
+ //! Destructor
+ virtual ~DFBrowser_ItemDocument() Standard_OVERRIDE {};
+
+ //! Returns the current label
+ //! \return a label
+ Standard_EXPORT virtual TDF_Label GetLabel() const Standard_OVERRIDE;
+
+ //! Sets the item document
+ //! \param theLabel an object where the child items structure is found
+ void setDocument (const Handle(TDocStd_Document)& theDocument) { myDocument = theDocument; }
+
+ //! Returns true if the current document is not null
+ //! \return a boolean value
+ bool hasDocument() const { return !getDocument().IsNull(); }
+
+ //! Returns the current document
+ //! \return a label
+ Standard_EXPORT const Handle(TDocStd_Document)& getDocument() const;
+
+ //! Inits the item, fills internal containers
+ Standard_EXPORT virtual void Init() Standard_OVERRIDE;
+
+ //! Resets the cached item values
+ Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
+
+protected:
+
+ //! Initialize the current item. It is empty because Reset() is also empty.
+ virtual void initItem() const Standard_OVERRIDE;
+
+ //!
+ virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
+
+protected:
+
+ //! Creates a child item in the given position.
+ //! \param theRow the child row position
+ //! \param theColumn the child column position
+ //! \return the created item
+ virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
+
+private:
+
+ //! Constructor
+ //! param theParent a parent item
+ DFBrowser_ItemDocument(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ : DFBrowser_ItemBase (theParent, theRow, theColumn) {}
+
+private:
+
+ Handle(TDocStd_Document) myDocument; //!< cached application document by the row index of the item
+};
+
+#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.
+
+#ifndef DFBrowser_ItemRole_H
+#define DFBrowser_ItemRole_H
+
+#include <Qt>
+
+//! Additional data item role for DFBrowser tree item
+enum DFBrowser_ItemRole
+{
+ DFBrowser_ItemRole_AdditionalInfo = Qt::UserRole + 1 //!< an attribute additional information
+};
+
+#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 <DFBrowser_Module.hxx>
+
+#include <DFBrowser_Item.hxx>
+#include <DFBrowser_ItemApplication.hxx>
+#include <DFBrowser_ItemBase.hxx>
+#include <DFBrowser_ItemRole.hxx>
+#include <DFBrowser_Tools.hxx>
+#include <DFBrowser_TreeModel.hxx>
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <DFBrowserPane_AttributePaneCreator.hxx>
+#include <DFBrowserPane_ItemRole.hxx>
+#include <DFBrowserPane_Tools.hxx>
+
+#include <DFBrowserPaneXDE_AttributePaneCreator.hxx>
+#include <DFBrowserPaneXDE_Tools.hxx>
+
+#include <XCAFApp_Application.hxx>
+
+#include <QItemSelectionModel>
+#include <QMessageBox>
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowser_Module::DFBrowser_Module()
+: myOCAFViewModel (0)
+{
+ RegisterPaneCreator (new DFBrowserPane_AttributePaneCreator());
+}
+
+// =======================================================================
+// function : CreateViewModel
+// purpose :
+// =======================================================================
+void DFBrowser_Module::CreateViewModel (void* theParent)
+{
+ myOCAFViewModel = new DFBrowser_TreeModel ((QWidget*)theParent, this);
+}
+
+// =======================================================================
+// function : SetApplication
+// purpose :
+// =======================================================================
+void DFBrowser_Module::SetApplication (const Handle(TDocStd_Application)& theApplication)
+{
+ myOCAFViewModel->Init (theApplication);
+
+ myPaneCreators.clear();
+ RegisterPaneCreator (new DFBrowserPane_AttributePaneCreator());
+ if (!theApplication.IsNull() && DFBrowserPaneXDE_Tools::IsXDEApplication (theApplication))
+ RegisterPaneCreator (new DFBrowserPaneXDE_AttributePaneCreator (myPaneCreators[0]));
+}
+
+// =======================================================================
+// function : SetExternalContext
+// purpose :
+// =======================================================================
+void DFBrowser_Module::SetExternalContext (const Handle(Standard_Transient)& theContext)
+{
+ myExternalContext = Handle(AIS_InteractiveContext)::DownCast (theContext);
+}
+
+// =======================================================================
+// function : GetTDocStdApplication
+// purpose :
+// =======================================================================
+Handle(TDocStd_Application) DFBrowser_Module::GetTDocStdApplication() const
+{
+ return myOCAFViewModel->GetTDocStdApplication();
+}
+
+// =======================================================================
+// function : UpdateTreeModel
+// purpose :
+// =======================================================================
+void DFBrowser_Module::UpdateTreeModel()
+{
+ QAbstractItemModel* aModel = GetOCAFViewModel();
+ QItemSelectionModel* aSelectionModel = GetOCAFViewSelectionModel();
+ if (!aModel || !aSelectionModel)
+ return;
+ aSelectionModel->clearSelection();
+
+ emit beforeUpdateTreeModel();
+ myOCAFViewModel->Reset();
+ myOCAFViewModel->EmitLayoutChanged();
+
+ SetInitialTreeViewSelection();
+}
+
+// =======================================================================
+// function : SetInitialTreeViewSelection
+// purpose :
+// =======================================================================
+void DFBrowser_Module::SetInitialTreeViewSelection()
+{
+ QAbstractItemModel* aModel = GetOCAFViewModel();
+ QItemSelectionModel* aSelectionModel = GetOCAFViewSelectionModel();
+ if (!aModel || !aSelectionModel)
+ return;
+
+ // select a parent(aplication) item
+ aSelectionModel->select (aModel->index (0, 0), QItemSelectionModel::ClearAndSelect);
+}
+
+// =======================================================================
+// function : FindAttribute
+// purpose :
+// =======================================================================
+Handle(TDF_Attribute) DFBrowser_Module::FindAttribute (const QModelIndex& theIndex)
+{
+ TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (theIndex);
+ if (!anItemBase)
+ return Handle(TDF_Attribute)();
+
+ DFBrowser_ItemPtr anItem = itemDynamicCast<DFBrowser_Item> (anItemBase);
+ return (anItem && anItem->HasAttribute()) ? anItem->GetAttribute() : Handle(TDF_Attribute)();
+}
+
+// =======================================================================
+// function : GetAttributePane
+// purpose :
+// =======================================================================
+DFBrowserPane_AttributePaneAPI* DFBrowser_Module::GetAttributePane (Handle(TDF_Attribute) theAttribute)
+{
+ DFBrowserPane_AttributePaneAPI* aPane = 0;
+ if (theAttribute.IsNull())
+ return aPane;
+ return GetAttributePane (theAttribute->DynamicType()->Name());
+}
+
+// =======================================================================
+// function : GetAttributePane
+// purpose :
+// =======================================================================
+DFBrowserPane_AttributePaneAPI* DFBrowser_Module::GetAttributePane (const Standard_CString& theAttributeName)
+{
+ DFBrowserPane_AttributePaneAPI* aPane = 0;
+
+ if (!myAttributeTypes.contains (theAttributeName))
+ {
+ aPane = CreateAttributePane (theAttributeName);
+ if (aPane)
+ myAttributeTypes[theAttributeName] = aPane;
+ }
+ else
+ aPane = myAttributeTypes[theAttributeName];
+
+ return aPane;
+}
+
+// =======================================================================
+// function : GetAttributeInfo
+// purpose :
+// =======================================================================
+QVariant DFBrowser_Module::GetAttributeInfo (Handle(TDF_Attribute) theAttribute, DFBrowser_Module* theModule,
+ int theRole, int theColumnId)
+{
+ DFBrowserPane_AttributePane* anAttributePane = 0;
+ if (!theAttribute.IsNull())
+ {
+ DFBrowserPane_AttributePaneAPI* anAPIPane = theModule->GetAttributePane (theAttribute);
+ if (anAPIPane)
+ anAttributePane = dynamic_cast<DFBrowserPane_AttributePane*> (anAPIPane);
+ }
+
+ QVariant aValue;
+ if (anAttributePane)
+ aValue = anAttributePane->GetAttributeInfo (theAttribute,
+ theRole == DFBrowser_ItemRole_AdditionalInfo ? DFBrowserPane_ItemRole_ShortInfo : theRole,
+ theColumnId);
+ else
+ aValue = DFBrowserPane_AttributePane::GetAttributeInfoByType (theAttribute->DynamicType()->Name(), theRole, theColumnId);
+ return aValue;
+}
+
+// =======================================================================
+// function : GetAttributeInfo
+// purpose :
+// =======================================================================
+QVariant DFBrowser_Module::GetAttributeInfo (const Standard_CString& theAttributeName, DFBrowser_Module* theModule,
+ int theRole, int theColumnId)
+{
+ DFBrowserPane_AttributePane* anAttributePane = 0;
+ DFBrowserPane_AttributePaneAPI* anAPIPane = theModule->GetAttributePane (theAttributeName);
+ if (anAPIPane)
+ anAttributePane = dynamic_cast<DFBrowserPane_AttributePane*> (anAPIPane);
+
+ QVariant aValue;
+ if (anAttributePane)
+ {
+ Handle(TDF_Attribute) anAttribute;
+ aValue = anAttributePane->GetAttributeInfo (anAttribute,
+ theRole == DFBrowser_ItemRole_AdditionalInfo ? DFBrowserPane_ItemRole_ShortInfo : theRole, theColumnId);
+ }
+ else
+ aValue = DFBrowserPane_AttributePane::GetAttributeInfoByType (theAttributeName, theRole, theColumnId);
+ return aValue;
+
+}
+
+// =======================================================================
+// function : CreateAttributePane
+// purpose :
+// =======================================================================
+DFBrowserPane_AttributePaneAPI* DFBrowser_Module::CreateAttributePane (const Standard_CString& theAttributeName)
+{
+ DFBrowserPane_AttributePaneAPI* aPane = 0;
+ // iteration should be performed from the tail of the list, as latest added creator has
+ // larger priority
+ for (int aPaneCreatorId = myPaneCreators.size()-1; aPaneCreatorId >= 0 && !aPane; aPaneCreatorId--)
+ aPane = myPaneCreators[aPaneCreatorId]->CreateAttributePane (theAttributeName);
+ return aPane;
+}
--- /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 DFBrowser_Module_H
+#define DFBrowser_Module_H
+
+#include <AIS_InteractiveContext.hxx>
+#include <DFBrowser_TreeModel.hxx>
+#include <NCollection_Map.hxx>
+#include <Standard.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TDF_Attribute.hxx>
+#include <TDocStd_Application.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TreeModel_ItemBase.hxx>
+
+#include <QObject>
+
+class DFBrowserPane_AttributePaneAPI;
+class DFBrowserPane_AttributePaneCreatorAPI;
+
+class QAbstractItemModel;
+class QItemSelectionModel;
+
+//! \class DFBrowser_Module
+//! The class is a container of current components of DFBrowser:
+//! - OCAF view model
+//! - OCAF selection model
+//! - container of attribute panes into attribute name
+//! - acceptable attribute pane creators
+//! - external AIS interactive context
+//! It has general attribute pane creator, if the application is XDE, it uses XDE attribute pane creator.
+//! It fills container of created attribute pane.
+class DFBrowser_Module : public QObject
+{
+ Q_OBJECT
+public:
+
+ //! Constructor
+ Standard_EXPORT DFBrowser_Module();
+
+ //! Destructor
+ virtual ~DFBrowser_Module() Standard_OVERRIDE {};
+
+ //! Creates tree model for OCAF application
+ Standard_EXPORT void CreateViewModel (void* theParent);
+
+ //! Fills tree model by the application and register pane creator
+ //! \param theApplication a current application
+ Standard_EXPORT void SetApplication (const Handle(TDocStd_Application)& theApplication);
+
+ //! Fills viewer by the context
+ //! \param theContext a current context where presentations should be visualized
+ Standard_EXPORT void SetExternalContext (const Handle(Standard_Transient)& theContext);
+
+ //! Returns external context or NULL
+ const Handle(AIS_InteractiveContext)& GetExternalContext() const { return myExternalContext; }
+
+ //! Returns a view model with the OCAF structure content
+ QAbstractItemModel* GetOCAFViewModel() { return myOCAFViewModel; }
+
+ //! Sets selection model of tree view
+ void SetOCAFViewSelectionModel(QItemSelectionModel* theSelectionModel)
+ { myOCAFViewSelectionModel = theSelectionModel; }
+
+ //! Returns selection model of tree view
+ QItemSelectionModel* GetOCAFViewSelectionModel() const { return myOCAFViewSelectionModel; }
+
+ //! Returns an OCAF application or NULL
+ //! \return an application instance
+ Standard_EXPORT Handle(TDocStd_Application) GetTDocStdApplication() const;
+
+ //! Rebuild an OCAF tree view model
+ Standard_EXPORT void UpdateTreeModel();
+
+ //! Sets initial selection in OCAF tree view, it is an application(root) item
+ Standard_EXPORT void SetInitialTreeViewSelection();
+
+ //! Returns attibute placed on the parameter index in the OCAF tree view or NULL
+ //! \param theIndex an index in OCAF tree view.
+ //! \return an attribute
+ Standard_EXPORT Handle(TDF_Attribute) FindAttribute (const QModelIndex& theIndex);
+
+ //! Append creator of a pane by attribute type
+ //! \param thePaneCreator
+ void RegisterPaneCreator (DFBrowserPane_AttributePaneCreatorAPI* thePaneCreator)
+ { myPaneCreators.append (thePaneCreator); }
+
+ //! Returns an attribute pane for the attribute: create a new if it is not exist in
+ //! internal map and the module processes this kind of attribute
+ //! \param theAttributeGUID an attribute key
+ //! \return attribute pane
+ Standard_EXPORT DFBrowserPane_AttributePaneAPI* GetAttributePane (Handle(TDF_Attribute) theAttribute);
+
+ //! Returns an attribute pane for the attribute GUID: create a new if it is not exist in
+ //! internal map and the module processes this kind of attribute
+ //! \param theAttributeGUID an attribute key
+ //! \return attribute pane
+ Standard_EXPORT DFBrowserPane_AttributePaneAPI* GetAttributePane (const Standard_CString& theAttributeName);
+
+ //! Finds the attribute pane according to the give attribute and returns its information
+ //! \param theAttribute a source attribute
+ //! \param theModule to provide a map of attribute id to attribute pane
+ //! \param theRole an attribute role in the tree view, includes: text, icon, color roles
+ //! \param theColumnId a column index
+ Standard_EXPORT static QVariant GetAttributeInfo (Handle(TDF_Attribute) theAttribute, DFBrowser_Module* theModule,
+ int theRole, int theColumnId);
+
+ //! Returns information for the given attribute type name
+ //! \param theAttributeName a current attribute type name
+ //! \param theModule a current module
+ //! \param theRole a role of information, used by tree model (e.g. DisplayRole, icon, background and so on)
+ //! \param theColumnId a tree model column
+ //! \return value, interpreted by tree model depending on the role
+ Standard_EXPORT static QVariant GetAttributeInfo (const Standard_CString& theAttributeName, DFBrowser_Module* theModule,
+ int theRole, int theColumnId);
+signals:
+
+ //! Emits signal about updating tree model
+ void beforeUpdateTreeModel();
+
+protected:
+
+ //! Tries to create attribute pane for the attribute name using registered attribute pane creators
+ //! \param theAttributeName a source attribute
+ //! \return attribute pane or NULL
+ DFBrowserPane_AttributePaneAPI* CreateAttributePane (const Standard_CString& theAttributeName);
+
+private:
+
+ DFBrowser_TreeModel* myOCAFViewModel; //!< the tree view abstract model
+ QItemSelectionModel* myOCAFViewSelectionModel; //!< selection model over OCAF tree view
+ QMap<TCollection_AsciiString, DFBrowserPane_AttributePaneAPI*> myAttributeTypes; //!< container of created panes
+ QList<DFBrowserPane_AttributePaneCreatorAPI*> myPaneCreators; //!< pane creators
+ Handle(AIS_InteractiveContext) myExternalContext; //!< context that comes in initialize parameters
+};
+
+#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 <DFBrowser_OpenApplication.hxx>
+
+#include <BinDrivers.hxx>
+#include <BinLDrivers.hxx>
+#include <BinXCAFDrivers.hxx>
+#include <PCDM_ReadWriter.hxx>
+#include <Standard_Version.hxx>
+#include <StdDrivers.hxx>
+#include <StdLDrivers.hxx>
+#include <STEPCAFControl_Reader.hxx>
+#include <STEPCAFControl_Controller.hxx>
+#include <TPrsStd_DriverTable.hxx>
+#include <XCAFApp_Application.hxx>
+#include <XCAFPrs_Driver.hxx>
+#include <XmlDrivers.hxx>
+#include <XmlLDrivers.hxx>
+#include <XmlXCAFDrivers.hxx>
+#include <UTL.hxx>
+
+//#define REQUIRE_OCAF_REVIEW:24
+namespace DFBrowser_OpenApplication
+{
+
+ // =======================================================================
+ // function : OpenApplication
+ // purpose :
+ // =======================================================================
+ Handle(TDocStd_Application) OpenApplication (const TCollection_AsciiString& theFileName, bool& isSTEPFile)
+ {
+ Handle(TDocStd_Application) anApplication = CreateApplicationBySTEPFile (theFileName);
+ if (!anApplication.IsNull())
+ {
+ isSTEPFile = true;
+ return anApplication;
+ }
+
+#if OCC_VERSION_HEX > 0x060901
+ // Load static variables for STEPCAF (ssv; 16.08.2012)
+ STEPCAFControl_Controller::Init();
+
+ anApplication = new TDocStd_Application();
+ // Initialize standard document formats at creation - they should
+ // be available even if this DRAW plugin is not loaded by pload command
+ StdLDrivers::DefineFormat (anApplication);
+ BinLDrivers::DefineFormat (anApplication);
+ XmlLDrivers::DefineFormat (anApplication);
+ StdDrivers::DefineFormat (anApplication);
+ BinDrivers::DefineFormat (anApplication);
+ XmlDrivers::DefineFormat (anApplication);
+
+ // Initialize XCAF formats
+ BinXCAFDrivers::DefineFormat (anApplication);
+ XmlXCAFDrivers::DefineFormat (anApplication);
+
+ // Register driver in global table for displaying XDE documents
+ // in 3d viewer using OCAF mechanics
+ TPrsStd_DriverTable::Get()->AddDriver (XCAFPrs_Driver::GetID(), new XCAFPrs_Driver);
+
+ Handle(TDocStd_Document) aDocument;
+ PCDM_ReaderStatus aStatus = anApplication->Open (theFileName, aDocument);
+ if (aStatus != PCDM_RS_OK)
+ return Handle(TDocStd_Application)();
+#endif
+ return anApplication;
+ }
+
+ // =======================================================================
+ // function : CreateApplicationBySTEPFile
+ // purpose :
+ // =======================================================================
+ Handle(TDocStd_Application) CreateApplicationBySTEPFile (const TCollection_AsciiString& theFileName)
+ {
+ if (!theFileName.EndsWith (".step") && !theFileName.EndsWith (".stp"))
+ return Handle(TDocStd_Application)();
+
+ Handle(TDocStd_Application) aTmpApplication = XCAFApp_Application::GetApplication();
+ STEPCAFControl_Reader aStepReader;
+
+ const TCollection_AsciiString aStr (theFileName);
+ IFSelect_ReturnStatus aStatus = aStepReader.ReadFile (aStr.ToCString());
+ if (aStatus != IFSelect_RetDone)
+ return Handle(TDocStd_Application)();
+
+ aStepReader.SetColorMode (Standard_True);
+ aStepReader.SetLayerMode (Standard_True);
+ aStepReader.SetNameMode (Standard_True);
+
+ Handle(TDocStd_Document) aDocument;
+ aTmpApplication->NewDocument ("BinOcaf", aDocument);
+ return aStepReader.Transfer (aDocument) ? aTmpApplication : Handle(TDocStd_Application)();
+ }
+}
--- /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 DFBrowser_OpenApplication_H
+#define DFBrowser_OpenApplication_H
+
+#include <Standard.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TDocStd_Application.hxx>
+
+//! \namespace DFBrowser_OpenApplication
+namespace DFBrowser_OpenApplication
+{
+
+ //! Open the application by the name.
+ //! \param theFileName a name of the file initialized the application
+ //! \param isSTEPFile an output parameter, true if the file name is a STEP file
+ //! \return an opened application
+ Standard_EXPORT Handle(TDocStd_Application) OpenApplication (const TCollection_AsciiString& theFileName,
+ bool& isSTEPFile);
+
+ //! Creates a new application if the name contains "stp" or "step" extension. The application is "BinOcaf",
+ //! STEP reader transfers the file into the application
+ //! \param theFileName a name of the file initialized the application
+ //! \return a new application
+ Standard_EXPORT Handle(TDocStd_Application) CreateApplicationBySTEPFile (const TCollection_AsciiString& theFileName);
+}
+
+#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 <DFBrowser_PropertyPanel.hxx>
+
+#include <DFBrowser_AttributePaneStack.hxx>
+#include <DFBrowser_Item.hxx>
+#include <DFBrowser_SearchView.hxx>
+#include <DFBrowser_Window.hxx>
+#include <DFBrowser_TreeLevelView.hxx>
+
+#include <QAbstractItemModel>
+#include <QGridLayout>
+#include <QItemSelectionModel>
+#include <QWidget>
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowser_PropertyPanel::DFBrowser_PropertyPanel (QWidget* theParent)
+: QObject (theParent), myAttributesStack (0)
+{
+ myMainWindow = new QWidget (theParent);
+ DFBrowser_Window::SetWhiteBackground (myMainWindow);
+
+ QGridLayout* aLayout = new QGridLayout (myMainWindow);
+ aLayout->setContentsMargins (0, 0, 0, 0);
+
+ myAttributesStack = new DFBrowser_AttributePaneStack (this);
+ myAttributesStack->CreateWidget (myMainWindow);
+ aLayout->addWidget (myAttributesStack->GetWidget(), 0, 0);
+}
+
+// =======================================================================
+// function : UpdateBySelectionChanged
+// purpose :
+// =======================================================================
+void DFBrowser_PropertyPanel::UpdateBySelectionChanged (const QItemSelection& theSelected,
+ const QItemSelection&)
+{
+ GetAttributesStack()->GetSearchView()->Reset();
+
+ QModelIndex anIndex = DFBrowser_Window::SingleSelected (theSelected.indexes(), 0);
+ myAttributesStack->SetCurrentItem (anIndex);
+}
--- /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 DFBrowser_PropertyPanel_H
+#define DFBrowser_PropertyPanel_H
+
+#include <Standard.hxx>
+#include <TreeModel_ItemBase.hxx>
+
+#include <QItemSelection>
+#include <QObject>
+
+class DFBrowser_AttributePaneStack;
+
+class QAbstractItemModel;
+class QWidget;
+
+//! \class DFBrowser_PropertyPanel
+//! Control that contains attribute pane stack
+class DFBrowser_PropertyPanel : public QObject
+{
+ Q_OBJECT
+public:
+
+ //! Constructor
+ Standard_EXPORT DFBrowser_PropertyPanel (QWidget* theParent);
+
+ //! Destructor
+ virtual ~DFBrowser_PropertyPanel() Standard_OVERRIDE {}
+
+ //! Returns main control
+ QWidget* GetControl() const { return myMainWindow; }
+
+ //! Returns instance of attributes stack
+ //! \return stack
+ DFBrowser_AttributePaneStack* GetAttributesStack() { return myAttributesStack; }
+
+ //! Fills attributes stack by selected index
+ //! \param theSelected selected items
+ //! \param theDeselected deselected items
+ Standard_EXPORT void UpdateBySelectionChanged (const QItemSelection& theSelected,
+ const QItemSelection& theDeselected);
+private:
+
+ QWidget* myMainWindow; //! < parent of attribute stack control
+ DFBrowser_AttributePaneStack* myAttributesStack; //! < panes stack
+};
+#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.
+
+#ifndef DFBrowser_SearchItemInfo_H
+#define DFBrowser_SearchItemInfo_H
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4127) // conditional expression is constant
+#endif
+#include <QVariant>
+#include <QStringList>
+#include <QString>
+
+//! \class DFBrowser_SearchItemInfo
+//! Information of item in search model
+class DFBrowser_SearchItemInfo
+{
+public:
+
+ //! Constructor
+ DFBrowser_SearchItemInfo() {}
+
+ //! Constructor
+ DFBrowser_SearchItemInfo (const QVariant& theIcon, const QString& theName,
+ const QStringList& thePath, const QString& theSeparator)
+ : myIcon (theIcon), myPath (thePath)
+ { myPathUnited = QString ("%1 \n%2").arg (theName).arg (myPath.join (theSeparator)); }
+
+ //! Destructor
+ virtual ~DFBrowser_SearchItemInfo() {}
+
+ //! Returns the item icon
+ const QVariant& Icon() const { return myIcon; }
+
+ //! Returns path to the item.
+ const QStringList& Path() const { return myPath; }
+
+ //! Returns united path to the item.
+ const QString& PathUnited() const { return myPathUnited; }
+
+private:
+
+ QVariant myIcon; //!< item icon
+ QStringList myPath; //!< item path
+ QString myPathUnited; //!< item name and item path
+};
+
+#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 <DFBrowser_SearchLine.hxx>
+#include <DFBrowser_SearchLineModel.hxx>
+#include <DFBrowser_Window.hxx>
+
+#include <DFBrowserPane_Tools.hxx>
+#include <DFBrowser_Module.hxx>
+
+#include <TDocStd_Application.hxx>
+#include <TDocStd_Document.hxx>
+#include <TDF_AttributeIterator.hxx>
+#include <TDF_ChildIterator.hxx>
+
+#include <QStringList>
+#include <QWidget>
+#include <QHBoxLayout>
+#include <QLineEdit>
+#include <QToolButton>
+#include <QCompleter>
+#include <QIcon>
+#include <QPaintEvent>
+#include <QPainter>
+#include <QStyle>
+
+//! class DFBrowser_LineEdit
+//! Extension of Qt line edit to visualize help text until the line edit control has not been filled yet
+class DFBrowser_LineEdit : public QLineEdit
+{
+public:
+
+ //! Constructor
+ DFBrowser_LineEdit (QWidget* theParent) : QLineEdit(theParent) {}
+
+ //! Destructor
+ virtual ~DFBrowser_LineEdit() {}
+
+ //! Sets text that is shown in line edit it the text of this control is empty
+ //! \param theText a string value
+ void setPlaneHolder (const QString& theText) { myPlaceHolder = theText; }
+
+ //! Draws the line edit context, put plane holder if text is empty
+ //! \param theEvent a paint event
+ virtual void paintEvent (QPaintEvent* theEvent) Standard_OVERRIDE
+ {
+ QLineEdit::paintEvent (theEvent);
+ if (!text().isEmpty())
+ return;
+
+ QPainter aPainter (this);
+ QFontMetrics aFontMetrics = fontMetrics();
+ QRect aLineRect = rect();
+ Qt::Alignment anAlignment = QStyle::visualAlignment (layoutDirection(), Qt::AlignLeft);
+
+ QColor aColor = palette().text().color();
+ aColor.setAlpha (128);
+ QPen anOldpen = aPainter.pen();
+ aPainter.setPen (aColor);
+ aLineRect.adjust (4, 4, 0, 0);
+ QString anElidedText = aFontMetrics.elidedText (myPlaceHolder, Qt::ElideRight, aLineRect.width());
+ aPainter.drawText (aLineRect, anAlignment, anElidedText);
+ aPainter.setPen (anOldpen);
+ }
+
+private:
+
+ QString myPlaceHolder; //!< text of filling line edit content if the text is empty
+};
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowser_SearchLine::DFBrowser_SearchLine (QWidget* theParent)
+: QFrame (theParent)
+{
+ QHBoxLayout* aLayout = new QHBoxLayout (this);
+ aLayout->setContentsMargins (0, 0, 0, 0);
+ aLayout->setSpacing (0);
+
+ myLineControl = new DFBrowser_LineEdit (this);
+ ((DFBrowser_LineEdit*)myLineControl)->setPlaneHolder (QString (tr ("Scanning application ...")));
+ mySearchButton = new QToolButton (this);
+ mySearchButton->setIcon (QIcon (":/icons/search.png"));
+
+ QCompleter* aCompleter = new QCompleter (this);
+ aCompleter->setCaseSensitivity (Qt::CaseInsensitive);
+ myLineControl->setCompleter (aCompleter);
+
+ aLayout->addWidget (myLineControl);
+ aLayout->addWidget (mySearchButton);
+
+ connect (myLineControl, SIGNAL (textChanged (const QString&)), this, SLOT (onTextChanged (const QString&)));
+ connect (myLineControl, SIGNAL (returnPressed()), this, SLOT (onReturnPressed()));
+ connect (mySearchButton, SIGNAL (clicked()), this, SLOT (onSearchButtonClicked()));
+
+ DFBrowser_Window::SetWhiteBackground (this);
+}
+
+// =======================================================================
+// function : SetModule
+// purpose :
+// =======================================================================
+void DFBrowser_SearchLine::SetModule (DFBrowser_Module* theModule)
+{
+ DFBrowser_SearchLineModel* aModel = new DFBrowser_SearchLineModel (myLineControl, theModule);
+ myLineControl->completer()->setModel (aModel);
+}
+
+// =======================================================================
+// function : GetModule
+// purpose :
+// =======================================================================
+DFBrowser_Module* DFBrowser_SearchLine::GetModule()
+{
+ DFBrowser_SearchLineModel* aModel = dynamic_cast<DFBrowser_SearchLineModel*> (GetModel());
+ return aModel->GetModule();
+}
+
+// =======================================================================
+// function : SetValues
+// purpose :
+// =======================================================================
+void DFBrowser_SearchLine::SetValues (const QMap<int, QMap<QString, DFBrowser_SearchItemInfo > >& theDocumentValues,
+ const QMap<int, QStringList>& theDocumentInfoValues)
+{
+ DFBrowser_SearchLineModel* aModel = dynamic_cast<DFBrowser_SearchLineModel*> (GetModel());
+ aModel->SetValues (theDocumentValues, theDocumentInfoValues);
+
+ QString aFirstValue = !theDocumentInfoValues.empty() ? theDocumentInfoValues.begin().value().first() : "";
+ DFBrowser_LineEdit* aLineEdit = dynamic_cast<DFBrowser_LineEdit*> (myLineControl);
+ aLineEdit->setPlaneHolder (QString (tr ("Search : %1")).arg (aFirstValue));
+}
+
+// =======================================================================
+// function : ClearValues
+// purpose :
+// =======================================================================
+void DFBrowser_SearchLine::ClearValues()
+{
+ DFBrowser_SearchLineModel* aModel = dynamic_cast<DFBrowser_SearchLineModel*> (GetModel());
+ aModel->ClearValues();
+
+ DFBrowser_LineEdit* aLineEdit = dynamic_cast<DFBrowser_LineEdit*> (myLineControl);
+ aLineEdit->setPlaneHolder(QString (tr ("Scanning application ...")));
+}
+
+// =======================================================================
+// function : onTextChanged
+// purpose :
+// =======================================================================
+void DFBrowser_SearchLine::onTextChanged (const QString& theText)
+{
+ mySearchButton->setIcon (theText.isEmpty() ? QIcon (":/icons/search.png")
+ : QIcon (":/icons/search_cancel.png"));
+ emit searchActivated();
+}
+
+// =======================================================================
+// function : onSearchButtonClicked
+// purpose :
+// =======================================================================
+void DFBrowser_SearchLine::onSearchButtonClicked()
+{
+ if (!Text().isEmpty())
+ SetText (QString());
+}
--- /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 DFBrowser_SearchLine_H
+#define DFBrowser_SearchLine_H
+
+#include <DFBrowser_SearchLineModel.hxx> // to include DFBrowser_SearchItemInfo
+#include <Standard.hxx>
+#include <TDocStd_Application.hxx>
+#include <TDF_Label.hxx>
+
+#include <QCompleter>
+#include <QFrame>
+#include <QLineEdit>
+
+class DFBrowser_Module;
+class DFBrowser_SearchLineModel;
+
+class QAbstractItemModel;
+class QLineEdit;
+class QToolButton;
+class QStringList;
+
+//! \class DFBrowser_SearchLine
+//! It contains a line edit control with auto completion and search button
+class DFBrowser_SearchLine : public QFrame
+{
+ Q_OBJECT
+public:
+
+ //! Constructor
+ Standard_EXPORT DFBrowser_SearchLine (QWidget* theParent);
+
+ //! Destructor
+ virtual ~DFBrowser_SearchLine() Standard_OVERRIDE {}
+
+ //! Creates search line model filled by the module. It is necessary for auto completion of line edit
+ //! \param theModule a current module
+ Standard_EXPORT void SetModule (DFBrowser_Module* theModule);
+
+ //! Returns the current module
+ Standard_EXPORT DFBrowser_Module* GetModule();
+
+ //! Fills the search line model by OCAF document values
+ //! \param theDocumentValues container of document index to container of entry/attribute name to item information
+ //! \param theDocumentInfoValues container of a document index to entry/attribute name
+ Standard_EXPORT void SetValues (const QMap<int, QMap<QString, DFBrowser_SearchItemInfo > >& theDocumentValues,
+ const QMap<int, QStringList>& theDocumentInfoValues);
+
+ //! Clears cache of values in search line model
+ Standard_EXPORT void ClearValues();
+
+ //! Returns completer model
+ Standard_EXPORT QAbstractItemModel* GetModel() { return myLineControl->completer()->model(); }
+
+ //! Returns completion completer model
+ Standard_EXPORT QAbstractItemModel* GetCompletionModel() { return myLineControl->completer()->completionModel(); }
+
+ //! Returns the current line edit text
+ QString Text() const { return myLineControl->text(); }
+
+ //! Sets the current text value
+ //! \param theValue a string value
+ void SetText (const QString& theValue) { myLineControl->setText (theValue); }
+
+signals:
+
+ //! Signals that is emitted by text changed in line edit control
+ void searchActivated();
+
+private slots:
+
+ //! Updates icon of search button depending on text is empty and emits searchActivated signal
+ void onTextChanged (const QString& theText);
+ //! Set completion prefix in completer model
+ void onReturnPressed() { myLineControl->completer()->setCompletionPrefix (myLineControl->text()); }
+ //! Set empty text if the current text is not empty: new search is started
+ void onSearchButtonClicked();
+
+private:
+
+ QLineEdit* myLineControl; //!< line editor control
+ QToolButton* mySearchButton; //! < search button
+};
+
+#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 <DFBrowser_SearchLineModel.hxx>
+
+#include <DFBrowser_Module.hxx>
+#include <DFBrowser_Tools.hxx>
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <DFBrowserPane_ItemRole.hxx>
+#include <DFBrowserPane_Tools.hxx>
+
+#include <QDir>
+#include <QIcon>
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowser_SearchLineModel::DFBrowser_SearchLineModel (QObject* theParent, DFBrowser_Module* theModule)
+: QAbstractTableModel (theParent), myModule (theModule), myRowCount (0)
+{
+}
+
+// =======================================================================
+// function : SetValues
+// purpose :
+// =======================================================================
+void DFBrowser_SearchLineModel::SetValues (const QMap<int, QMap<QString, DFBrowser_SearchItemInfo > >& theDocumentValues,
+ const QMap<int, QStringList>& theDocumentInfoValues)
+{
+ myAdditionalValues = theDocumentValues;
+ myDocumentInfoValues = theDocumentInfoValues;
+
+ myRowCount = 0;
+ for (QMap<int, QStringList>::const_iterator aValuesIt = myDocumentInfoValues.begin();
+ aValuesIt != myDocumentInfoValues.end(); aValuesIt++)
+ myRowCount += aValuesIt.value().size();
+}
+
+// =======================================================================
+// function : ClearValues
+// purpose :
+// =======================================================================
+void DFBrowser_SearchLineModel::ClearValues()
+{
+ myAdditionalValues.clear();
+ myDocumentInfoValues.clear();
+ myRowCount = 0;
+}
+
+// =======================================================================
+// function : GetPath
+// purpose :
+// =======================================================================
+QStringList DFBrowser_SearchLineModel::GetPath (const QModelIndex& theIndex) const
+{
+ int aRowInDocument;
+ int aDocumentId = getDocumentId (theIndex.row(), aRowInDocument);
+ if (aDocumentId < 0)
+ return QStringList();
+
+ const QMap<QString, DFBrowser_SearchItemInfo>& anAdditionalValues = myAdditionalValues[aDocumentId];
+ const QStringList& anInfoValues = myDocumentInfoValues[aDocumentId];
+
+ return anAdditionalValues[anInfoValues[aRowInDocument] ].Path();
+}
+
+// =======================================================================
+// function : GetValue
+// purpose :
+// =======================================================================
+QString DFBrowser_SearchLineModel::GetValue (const QModelIndex& theIndex) const
+{
+ int aRowInDocument;
+ int aDocumentId = getDocumentId (theIndex.row(), aRowInDocument);
+ if (aDocumentId < 0)
+ return QString();
+ QString aValue = myDocumentInfoValues[aDocumentId][aRowInDocument];
+ return aValue.mid (0, aValue.indexOf (SplitSeparator()));
+}
+
+// =======================================================================
+// function : index
+// purpose :
+// =======================================================================
+QModelIndex DFBrowser_SearchLineModel::index (int theRow, int theColumn, const QModelIndex& theParent) const
+{
+ if (!hasIndex (theRow, theColumn, theParent))
+ return QModelIndex();
+ return createIndex (theRow, theColumn);
+}
+
+// =======================================================================
+// function : data
+// purpose :
+// =======================================================================
+QVariant DFBrowser_SearchLineModel::data (const QModelIndex& theIndex, int theRole) const
+{
+ switch (theIndex.column())
+ {
+ case 0:
+ {
+ if (theRole == Qt::DisplayRole || theRole == Qt::EditRole || theRole == Qt::ToolTipRole)
+ {
+ int aRowInDocument;
+ int aDocumentId = getDocumentId (theIndex.row(), aRowInDocument);
+ if (aDocumentId < 0)
+ return QVariant();
+ return myDocumentInfoValues[aDocumentId][aRowInDocument];
+ }
+ break;
+ }
+ case 1:
+ {
+ if (theRole == Qt::DecorationRole)
+ {
+ int aRowInDocument;
+ int aDocumentId = getDocumentId (theIndex.row(), aRowInDocument);
+ if (aDocumentId < 0)
+ return QVariant();
+ QString anInfoValue = myDocumentInfoValues[aDocumentId][aRowInDocument];
+ QVariant anIcon = myAdditionalValues[aDocumentId][anInfoValue].Icon();
+ if (anIcon.isNull())
+ {
+ QString anAttributeName = anInfoValue.mid (0, anInfoValue.indexOf (SplitSeparator()));
+ anIcon = DFBrowser_Module::GetAttributeInfo (anAttributeName.toUtf8().data(),
+ myModule, DFBrowserPane_ItemRole_Decoration_40x40, 0);
+ }
+ return anIcon;
+ }
+ if (theRole == Qt::SizeHintRole) return QSize (80, 80);
+ break;
+ }
+ case 2:
+ {
+ if (theRole == Qt::DisplayRole || theRole == Qt::EditRole)
+ {
+ int aRowInDocument;
+ int aDocumentId = getDocumentId (theIndex.row(), aRowInDocument);
+ if (aDocumentId < 0)
+ return QVariant();
+ QString anInfoValue = myDocumentInfoValues[aDocumentId][aRowInDocument];
+ return myAdditionalValues[aDocumentId][anInfoValue].PathUnited();
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ return QVariant();
+}
+
+// =======================================================================
+// function : emitLayoutChanged
+// purpose :
+// =======================================================================
+void DFBrowser_SearchLineModel::EmitLayoutChanged()
+{
+ emit layoutChanged();
+}
+
+// =======================================================================
+// function : getDocumentId
+// purpose :
+// =======================================================================
+int DFBrowser_SearchLineModel::getDocumentId (const int theRow, int& theRowInDocument) const
+{
+ theRowInDocument = 0;
+ int aDocumentId = -1;
+
+ int aCurrentRow = theRow;
+ for (int aValueId = 0, aSize = myDocumentInfoValues.size(); aValueId < aSize; aValueId++)
+ {
+ int aValueIndex = aValueId+1;
+ if (!myDocumentInfoValues.contains (aValueIndex))
+ continue;
+ QStringList aValues = myDocumentInfoValues[aValueIndex];
+ int aValuesSize = aValues.size();
+ if (aCurrentRow < aValuesSize)
+ {
+ aDocumentId = aValueIndex;
+ theRowInDocument= aCurrentRow;
+ }
+ else
+ aCurrentRow = aCurrentRow - aValuesSize;
+ }
+ return aDocumentId;
+}
--- /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 DFBrowser_SearchLineModel_H
+#define DFBrowser_SearchLineModel_H
+
+#include <DFBrowser_SearchItemInfo.hxx>
+#include <Standard.hxx>
+#include <TDF_Attribute.hxx>
+#include <TDF_Label.hxx>
+#include <TreeModel_ItemBase.hxx>
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4127) // conditional expression is constant
+#endif
+#include <QAbstractTableModel>
+#include <QMap>
+#include <QStringList>
+#include <QVariant>
+
+class QObject;
+class DFBrowser_Module;
+
+//! \class DFBrowser_SearchLineModel
+//! Table view model filled by OCAF labels and attributes. It contain information in the next form:
+//! <document index> into <document values container>
+//! <document values container> is key(attribute name or label entry) into item information
+//! The model contains 3 columns:
+//! - 0: information text
+//! - 1: icon size is [80, 80]
+//! - 2: information text that contains united path
+class DFBrowser_SearchLineModel : public QAbstractTableModel
+{
+public:
+
+ //! Constructor
+ Standard_EXPORT DFBrowser_SearchLineModel (QObject* theParent, DFBrowser_Module* theModule);
+
+ //! Destructor
+ virtual ~DFBrowser_SearchLineModel() Standard_OVERRIDE {}
+
+ //! Separator as attribute name is divided from the label entry in information text
+ static QString SplitSeparator() { return ": "; }
+
+ //! Returns the current module
+ DFBrowser_Module* GetModule() const { return myModule; }
+
+ //! Fills internal containers by the OCAF values. Updates number of rows value
+ //! \param theDocumentValues container of document index to container of entry/attribute name to item information
+ //! \param theDocumentInfoValues container of a document index to entry/attribute name
+ Standard_EXPORT void SetValues (const QMap<int, QMap<QString, DFBrowser_SearchItemInfo > >& theDocumentValues,
+ const QMap<int, QStringList>& theDocumentInfoValues);
+
+ //! Clears cache of values
+ Standard_EXPORT void ClearValues();
+
+ //! Returns path to attribute or label element of OCAF by the index.
+ //! \param theIndex a tree model index
+ Standard_EXPORT QStringList GetPath (const QModelIndex& theIndex) const;
+
+ //! Returns value(attribute name or label entry) of OCAF by the index
+ Standard_EXPORT QString GetValue (const QModelIndex& theIndex) const;
+
+ //! Emits the layoutChanged signal from outside of this class
+ Standard_EXPORT void EmitLayoutChanged();
+
+ //! Creates new model index
+ //! \param theRow the index row position
+ //! \param theColummn the index column position
+ //! \param theParent the parent index
+ //! \return the model index
+ Standard_EXPORT virtual QModelIndex index (int theRow, int theColumn,
+ const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE;
+
+ //! Returns the data stored under the given role for the item referred to by the index.
+ //! \param theIndex a model index
+ //! \param theRole an enumeration value of role for data obtaining
+
+ Standard_EXPORT virtual QVariant data (const QModelIndex& theIndex,
+ int theRole = Qt::DisplayRole) const Standard_OVERRIDE;
+ //! Returns the number of rows under the given parent.
+ //! \param theParent a parent model index
+ //! \return the number of rows
+
+ virtual int rowCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
+ { (void)theParent; return myRowCount; }
+ //! Returns the number of columns for the children of the given parent.
+ //! \param theParent a parent model index
+ //! \return the number of columns
+
+ virtual int columnCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
+ { (void)theParent; return 3; }
+
+protected:
+
+ //! Returns document index by a row index in table model
+ //! \param theRow a row index of a QModelIndex
+ //! \param theRowInDocument an output index, to obtain information from myDocumentInfoValues
+ int getDocumentId (const int theRow, int& theRowInDocument) const;
+
+private:
+
+ DFBrowser_Module* myModule; //!< the current module
+ //! a document index to container of entry/attribute name to item information
+ QMap<int, QMap<QString, DFBrowser_SearchItemInfo> > myAdditionalValues;
+ QMap<int, QStringList> myDocumentInfoValues; //!< a document index to entry/attribute name
+ int myRowCount; //!< number of rows in the model: summ of row counts in all documents
+};
+#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 <DFBrowser_SearchView.hxx>
+
+#include <DFBrowser_HighlightDelegate.hxx>
+#include <DFBrowser_SearchLine.hxx>
+#include <DFBrowser_SearchLineModel.hxx>
+#include <DFBrowser_Window.hxx>
+
+#include <DFBrowserPane_Tools.hxx>
+
+#include <QAbstractProxyModel>
+#include <QGridLayout>
+#include <QHeaderView>
+#include <QTableView>
+#include <QWidget>
+
+const int DEFAULT_COLUMN_WIDTH = 500;
+const int DEFAULT_ICON_SIZE = 40;
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowser_SearchView::DFBrowser_SearchView (QWidget* theParent)
+: QObject (theParent)
+{
+ myMainWindow = new QWidget (theParent);
+ QGridLayout* aLayout = new QGridLayout (myMainWindow);
+ aLayout->setContentsMargins (0, 0, 0, 0);
+
+ myTableView = new QTableView (myMainWindow);
+ myTableView->verticalHeader()->setVisible (false);
+ myTableView->verticalHeader()->setDefaultSectionSize (DEFAULT_ICON_SIZE + DFBrowserPane_Tools::HeaderSectionMargin());
+ myTableView->setIconSize (QSize (DEFAULT_ICON_SIZE, DEFAULT_ICON_SIZE));
+ myTableView->horizontalHeader()->setVisible (false);
+ myTableView->horizontalHeader()->setStretchLastSection (true);
+
+ myTableView->viewport()->setAttribute (Qt::WA_Hover);
+ myTableView->setItemDelegate (new DFBrowser_HighlightDelegate (myTableView));
+
+ aLayout->addWidget (myTableView);
+
+ DFBrowser_Window::SetWhiteBackground (myTableView);
+ myTableView->setGridStyle (Qt::NoPen);
+}
+
+// =======================================================================
+// function : InitModels
+// purpose :
+// =======================================================================
+void DFBrowser_SearchView::InitModels()
+{
+ QAbstractItemModel* aModel = mySearchLine->GetCompletionModel();
+ myTableView->setModel (aModel);
+ myTableView->setColumnWidth (0, 0); // to hide column
+ myTableView->setColumnWidth (1, DEFAULT_ICON_SIZE + DFBrowserPane_Tools::HeaderSectionMargin());
+
+ QItemSelectionModel* aSelectionModel = new QItemSelectionModel (aModel);
+ myTableView->setSelectionMode (QAbstractItemView::SingleSelection);
+ myTableView->setSelectionModel (aSelectionModel);
+ connect (aSelectionModel, SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
+ this, SLOT (onTableSelectionChanged (const QItemSelection&, const QItemSelection&)));
+ connect (myTableView, SIGNAL (doubleClicked (const QModelIndex&)),
+ this, SLOT (onTableDoubleClicked (const QModelIndex&)));
+}
+
+// =======================================================================
+// function : onTableSelectionChanged
+// purpose :
+// =======================================================================
+void DFBrowser_SearchView::onTableSelectionChanged (const QItemSelection& theSelected,
+ const QItemSelection&)
+{
+ QModelIndexList aSelectedIndices = theSelected.indexes();
+ QModelIndex aSelectedIndex = DFBrowser_Window::SingleSelected (aSelectedIndices, 2);
+ if (!aSelectedIndex.isValid())
+ return;
+ QAbstractProxyModel* aTableModel = dynamic_cast<QAbstractProxyModel*> (myTableView->model());
+ if (!aTableModel)
+ return;
+ DFBrowser_SearchLineModel* aSourceModel = dynamic_cast<DFBrowser_SearchLineModel*> (aTableModel->sourceModel());
+ if (!aSourceModel)
+ return;
+
+ QModelIndex aSourceSelectedIndex = aTableModel->mapToSource(aSelectedIndex);
+ emit pathSelected(aSourceModel->GetPath (aSourceSelectedIndex), aSourceModel->GetValue (aSourceSelectedIndex));
+}
+
+// =======================================================================
+// function : onTableDoubleClicked
+// purpose :
+// =======================================================================
+void DFBrowser_SearchView::onTableDoubleClicked (const QModelIndex& theIndex)
+{
+ QAbstractProxyModel* aTableModel = dynamic_cast<QAbstractProxyModel*> (myTableView->model());
+ if (!aTableModel)
+ return;
+ DFBrowser_SearchLineModel* aSourceModel = dynamic_cast<DFBrowser_SearchLineModel*> (aTableModel->sourceModel());
+ if (!aSourceModel)
+ return;
+
+ QModelIndex aSourceSelectedIndex = aTableModel->mapToSource(theIndex);
+ emit pathDoubleClicked (aSourceModel->GetPath (aSourceSelectedIndex), aSourceModel->GetValue (aSourceSelectedIndex));
+}
--- /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 DFBrowser_SearchView_H
+#define DFBrowser_SearchView_H
+
+#include <DFBrowser_SearchLine.hxx>
+#include <Standard.hxx>
+#include <TreeModel_ItemBase.hxx>
+
+#include <QItemSelection>
+#include <QObject>
+
+class DFBrowser_SearchLine;
+class QTableView;
+class QWidget;
+
+//! \class DFBrowser_SearchView
+//! Container of search result. It has a table of values
+class DFBrowser_SearchView : public QObject
+{
+ Q_OBJECT
+public:
+
+ //! Constructor
+ Standard_EXPORT DFBrowser_SearchView (QWidget* theParent);
+
+ //! Destructor
+ virtual ~DFBrowser_SearchView() Standard_OVERRIDE {}
+
+ //! Returns search parent control
+ QWidget* GetControl() const { return myMainWindow; }
+
+ //! Sets search line to connect to the search line completion model
+ void SetSearchLine (DFBrowser_SearchLine* theSearchLine) { mySearchLine = theSearchLine; }
+
+ //! Fills the table by values of search line completion model. The zero column of the table is hidden,
+ //! so it visualizes values of 1st and 2nd columns of this model. It creates selection model and connects
+ //! to selectionChanged and doubleClicked signals
+ Standard_EXPORT void InitModels();
+
+ //! Resets search line
+ void Reset() { mySearchLine->SetText (""); }
+
+signals:
+
+ //! Signal about selecting of an item in the view.
+ //! \param thePath path to the selected item (e.g. 0, 0:1, 0:1:1)
+ //! \param theValue value of the selected item (e.g. TDataStd_Name)
+ void pathSelected (const QStringList& thePath, const QString& theValue);
+
+ //! Signal about double click on an item in the view.
+ //! \param thePath path to the selected item (e.g. 0, 0:1, 0:1:1)
+ //! \param theValue value of the selected item (e.g. TDataStd_Name)
+ void pathDoubleClicked (const QStringList& thePath, const QString& theValue);
+
+protected slots:
+
+ //! Listens selection change and emits the pathSelected signal
+ //! \param theSelected selected items
+ //! \param theDeselected deselected items
+ void onTableSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
+
+ //! Listens double click signal on table view
+ //! \theIndex a model index of double clicked item
+ void onTableDoubleClicked (const QModelIndex& theIndex);
+
+private:
+
+ QWidget* myMainWindow; //!< control where table view is placed
+ QTableView* myTableView; //!< table view to visualize search values
+ DFBrowser_SearchLine* mySearchLine; //!< search line to have access to search model completor
+};
+#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 <DFBrowser_Shortcut.hxx>
+
+#include <DFBrowser_Module.hxx>
+
+#include <QApplication>
+#include <QKeyEvent>
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowser_Shortcut::DFBrowser_Shortcut (QObject* theParent)
+: QObject (theParent), myModule (0)
+{
+ qApp->installEventFilter (this);
+}
+
+// =======================================================================
+// function : eventFilter
+// purpose :
+// =======================================================================
+bool DFBrowser_Shortcut::eventFilter (QObject* theObject, QEvent* theEvent)
+{
+ if (!myModule || theEvent->type() != QEvent::KeyRelease)
+ return QObject::eventFilter (theObject, theEvent);
+
+ QKeyEvent* aKeyEvent = dynamic_cast<QKeyEvent*> (theEvent);
+ switch (aKeyEvent->key())
+ {
+ case Qt::Key_F5:
+ {
+ myModule->UpdateTreeModel();
+ return true;
+ }
+ default: break;
+ }
+ return QObject::eventFilter (theObject, theEvent);
+}
--- /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 DFBrowser_Shortcut_H
+#define DFBrowser_Shortcut_H
+
+#include <Standard.hxx>
+#include <Standard_Macro.hxx>
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4127) // conditional expression is constant
+#endif
+#include <QObject>
+
+class DFBrowser_Module;
+class QEvent;
+
+//! \class DFBrowser_Shortcut
+//! Listens application KeyRelease event. Processes key event:
+//! - <Key_F5>: updates tree view model
+class DFBrowser_Shortcut : public QObject
+{
+public:
+
+ //! Constructor
+ Standard_EXPORT DFBrowser_Shortcut (QObject* theParent);
+
+ //! Destructor
+ virtual ~DFBrowser_Shortcut() {}
+
+ //! Sets the current module
+ //! \param theModule a module
+ void SetModule (DFBrowser_Module* theModule) { myModule = theModule; }
+
+ //! Processes key release event to update view model, otherwise do usual QObject functionality
+ Standard_EXPORT virtual bool eventFilter (QObject *theObject, QEvent* theEvent) Standard_OVERRIDE;
+
+private:
+ DFBrowser_Module* myModule; //!< the current module
+};
+
+
+#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 <DFBrowser_Thread.hxx>
+#include <DFBrowser_ThreadItemSearch.hxx>
+#include <DFBrowser_ThreadItemUsedShapesMap.hxx>
+#include <DFBrowser_TreeLevelLine.hxx>
+#include <DFBrowser_SearchLine.hxx>
+
+#include <DFBrowser_Window.hxx>
+
+#include <QThread>
+
+//! \class DFBrowser_QThread
+//! Internal class to cover QThread in order to process ThreadItem.
+class DFBrowser_QThread : public QThread
+{
+public:
+
+ //! Constructor
+ DFBrowser_QThread (QObject* theParent) : QThread (theParent), myItem (0) {}
+
+ //! Destructor
+ virtual ~DFBrowser_QThread() Standard_OVERRIDE {}
+
+ //! Sets thread item to be processed
+ //! \param theItem a thread item
+ void setItem (DFBrowser_ThreadItem* theItem) { myItem = theItem; }
+
+ //! Returns the current processing thread item
+ DFBrowser_ThreadItem* getItem() const { return myItem; }
+
+protected:
+
+ //! Starts thread item
+ virtual void run() Standard_OVERRIDE
+ {
+ if (myItem)
+ myItem->Run();
+ }
+
+private:
+
+ DFBrowser_ThreadItem* myItem;
+};
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowser_Thread::DFBrowser_Thread (DFBrowser_Window* theWindow)
+: QObject (theWindow), myPostponedItem (0), myIsFinishProcessing (false)
+{
+ DFBrowser_SearchLine* aSearchLine = theWindow->GetTreeLevelLine()->GetSearchLine();
+ myItems.append (new DFBrowser_ThreadItemSearch(aSearchLine));
+ myItems.append (new DFBrowser_ThreadItemUsedShapesMap());
+}
+
+// =======================================================================
+// function : SetModule
+// purpose :
+// =======================================================================
+void DFBrowser_Thread::SetModule (DFBrowser_Module* theModule)
+{
+ for (int anItemId = 0, aSize = myItems.size(); anItemId < aSize; anItemId++)
+ {
+ DFBrowser_ThreadItemUsedShapesMap* aShapesItem = dynamic_cast<DFBrowser_ThreadItemUsedShapesMap*> (myItems[anItemId]);
+ if (aShapesItem)
+ aShapesItem->SetModule (theModule);
+ }
+}
+
+// =======================================================================
+// function : ProcessApplication
+// purpose :
+// =======================================================================
+void DFBrowser_Thread::ProcessApplication()
+{
+ for (int anItemId = 0, aSize = myItems.size(); anItemId < aSize; anItemId++)
+ startThread (myItems[anItemId]);
+}
+
+// =======================================================================
+// function : startThread
+// purpose :
+// =======================================================================
+void DFBrowser_Thread::startThread (DFBrowser_ThreadItem* theItem)
+{
+ DFBrowser_QThread* aThread = new DFBrowser_QThread (this);
+ aThread->setItem (theItem);
+ aThread->start();
+ connect (aThread, SIGNAL (finished()), this, SLOT (onFinished()), Qt::QueuedConnection);
+ myStartedThreads.append (aThread);
+}
+
+// =======================================================================
+// function : TerminateThread
+// purpose :
+// =======================================================================
+void DFBrowser_Thread::TerminateThread()
+{
+ for (int aThreadsId = 0, aCount = myStartedThreads.size(); aThreadsId < aCount; aThreadsId++)
+ {
+ QThread* aThread = myStartedThreads[aThreadsId];
+ if (aThread->isRunning())
+ aThread->terminate();
+ }
+}
+
+// =======================================================================
+// function : onFinished
+// purpose :
+// =======================================================================
+void DFBrowser_Thread::onFinished()
+{
+ DFBrowser_QThread* aThread = (DFBrowser_QThread*)(sender());
+ if (myIsFinishProcessing)
+ {
+ // if thread send signal when other finished signal is processed
+ if (aThread)
+ myPostponedItem = aThread->getItem();
+ return;
+ }
+
+ myIsFinishProcessing = true;
+ if (aThread)
+ {
+ myStartedThreads.removeAll (aThread);
+ DFBrowser_ThreadItem* anItem = aThread->getItem();
+ if (anItem)
+ anItem->ApplyValues();
+ }
+
+ myIsFinishProcessing = false;
+ if (myPostponedItem)
+ {
+ myPostponedItem->ApplyValues();
+ myPostponedItem = 0;
+ }
+}
--- /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 DFBrowser_Thread_H
+#define DFBrowser_Thread_H
+
+#include <Standard.hxx>
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4127) // conditional expression is constant
+#endif
+#include <QList>
+#include <QObject>
+
+class DFBrowser_Module;
+class DFBrowser_ThreadItem;
+class DFBrowser_Window;
+
+class QThread;
+
+//! /class DFBrowser_Thread
+//! Starts algorithm item in a separate thread and perform some functionality by the algorithm(thread) is finished
+class DFBrowser_Thread : public QObject
+{
+ Q_OBJECT
+public:
+
+ //! Constructor
+ Standard_EXPORT DFBrowser_Thread (DFBrowser_Window* theWindow);
+
+ //! Destructor
+ virtual ~DFBrowser_Thread() {}
+
+ //! Sets module to the started thread items
+ //! \param theModule a current module
+ Standard_EXPORT void SetModule (DFBrowser_Module* theModule);
+
+ //! Starts all candidate thread items
+ Standard_EXPORT void ProcessApplication();
+
+ //! Terminates all started threads.
+ Standard_EXPORT void TerminateThread();
+
+protected:
+
+ //! Creates new Qt thread and starts the item. Connects to finished signal of thread.
+ //! \param theItem a thread item
+ void startThread (DFBrowser_ThreadItem* theItem);
+
+protected slots:
+
+ //! Removes finished thread from the thread items and apply values of this thread
+ //! If this signal is come when another thread is processed, the current thread is stored in a cache and
+ //! is processed after the previous thread is processed.
+ void onFinished();
+
+private:
+
+ QList<DFBrowser_ThreadItem*> myItems; //!< candidates to be processed in a thread
+ QList<QThread*> myStartedThreads; //!< container of started threads
+ DFBrowser_ThreadItem* myPostponedItem; //!< currently processed item in onFinished()
+ bool myIsFinishProcessing; //!< blocking state if onFinished() is started but has not been finished yet
+};
+
+
+#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.
+
+#ifndef DFBrowser_ThreadItem_H
+#define DFBrowser_ThreadItem_H
+
+#include <Standard_Macro.hxx>
+
+//! \class DFBrowser_ThreadItem
+//! An abstract interface for candidates to be processed in a separate thread.
+//! To do this, new thread item should inherit this interface and be started in DFBrowser_Thread.
+class DFBrowser_ThreadItem
+{
+public:
+
+ //! Constructor
+ DFBrowser_ThreadItem() {}
+
+ //! Destructor
+ virtual ~DFBrowser_ThreadItem() {}
+
+ //! Algorithm of this item work. It will be performed only once
+ virtual void Run() = 0;
+
+ //! Applying values accepted by algorithm
+ virtual void ApplyValues() = 0;
+};
+
+
+#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 <DFBrowser_ThreadItemSearch.hxx>
+
+#include <DFBrowser_Module.hxx>
+#include <DFBrowser_Tools.hxx>
+#include <DFBrowser_TreeModel.hxx>
+#include <DFBrowser_SearchLine.hxx>
+#include <DFBrowserPane_Tools.hxx>
+
+#include <TDataStd_Comment.hxx>
+#include <TDataStd_Name.hxx>
+#include <TDataStd_UAttribute.hxx>
+#include <TDF_AttributeIterator.hxx>
+#include <TDF_ChildIterator.hxx>
+
+#include <QDir>
+
+// =======================================================================
+// function : Run
+// purpose :
+// =======================================================================
+void DFBrowser_ThreadItemSearch::Run()
+{
+ DFBrowser_TreeModel* aModel = dynamic_cast<DFBrowser_TreeModel*> (mySearchLine->GetModule()->GetOCAFViewModel());
+ Handle(TDocStd_Application) anApplication = aModel->GetTDocStdApplication();
+ if (anApplication.IsNull())
+ return;
+
+ myDocumentValues.clear();
+ myDocumentInfoValues.clear();
+
+ //#define REQUIRE_OCAF_REVIEW:25 : start
+ QMap<QString, DFBrowser_SearchItemInfo> anAdditionalValues;
+ QStringList anInfoValues;
+ QStringList aCurrentPath;
+ for (Standard_Integer aDocId = 1, aNbDoc = anApplication->NbDocuments(); aDocId <= aNbDoc; aDocId++)
+ {
+ Handle(TDocStd_Document) aDocument;
+ anApplication->GetDocument (aDocId, aDocument);
+ if (aDocument.IsNull())
+ continue;
+
+ anAdditionalValues.clear();
+ anInfoValues.clear();
+ aCurrentPath.clear();
+ getLabelLines (aDocument->Main().Root(), aCurrentPath, anAdditionalValues, anInfoValues);
+
+ myDocumentValues[aDocId] = anAdditionalValues;
+ myDocumentInfoValues[aDocId] = anInfoValues;
+ }
+ //#define REQUIRE_OCAF_REVIEW:25 : end
+}
+
+// =======================================================================
+// function : ApplyValues
+// purpose :
+// =======================================================================
+void DFBrowser_ThreadItemSearch::ApplyValues()
+{
+ mySearchLine->SetValues (myDocumentValues, myDocumentInfoValues);
+}
+
+// =======================================================================
+// function : ClearValues
+// purpose :
+// =======================================================================
+void DFBrowser_ThreadItemSearch::ClearValues (DFBrowser_SearchLine* theSearchLine)
+{
+ theSearchLine->ClearValues();
+}
+
+// =======================================================================
+// function : getLabelLines
+// purpose :
+// =======================================================================
+void DFBrowser_ThreadItemSearch::getLabelLines (const TDF_Label& theLabel, QStringList& theCurrentPath,
+ QMap<QString, DFBrowser_SearchItemInfo >& theValues,
+ QStringList& theInfoValues)
+{
+ addLabel (theLabel, theCurrentPath, theValues, theInfoValues);
+ theCurrentPath.append (DFBrowserPane_Tools::GetEntry (theLabel).ToCString());
+
+ int anId = 0;
+ for (TDF_AttributeIterator anAttrIt (theLabel); anAttrIt.More(); anAttrIt.Next(), anId++)
+ addAttribute(anAttrIt.Value(), theCurrentPath, theValues, theInfoValues);
+
+ for (TDF_ChildIterator aChildIt (theLabel); aChildIt.More(); aChildIt.Next())
+ getLabelLines(aChildIt.Value(), theCurrentPath, theValues, theInfoValues);
+
+ theCurrentPath.removeLast();
+}
+
+// =======================================================================
+// function : addLabel
+// purpose :
+// =======================================================================
+void DFBrowser_ThreadItemSearch::addLabel (const TDF_Label& theLabel, const QStringList& theCurrentPath,
+ QMap<QString, DFBrowser_SearchItemInfo>& theValues,
+ QStringList& theInfoValues)
+{
+ QString anEntry = DFBrowserPane_Tools::GetEntry (theLabel).ToCString();
+ if (!theValues.contains (anEntry))
+ {
+ theInfoValues.append (anEntry);
+ theValues[anEntry] = DFBrowser_SearchItemInfo (DFBrowser_Tools::GetLabelIcon (theLabel, false),
+ anEntry, theCurrentPath, QDir::separator());
+ }
+}
+
+// =======================================================================
+// function : addAttribute
+// purpose :
+// =======================================================================
+void DFBrowser_ThreadItemSearch::addAttribute (const Handle(TDF_Attribute)& theAttribute,
+ const QStringList& theCurrentPath,
+ QMap<QString, DFBrowser_SearchItemInfo >& theValues,
+ QStringList& theInfoValues)
+{
+ Standard_CString anAttributeKind = theAttribute->DynamicType()->Name();
+ // add element of attribute kind
+ QString anAttributeName = QString ("%1%2%3").arg (anAttributeKind)
+ .arg (DFBrowser_SearchLineModel::SplitSeparator())
+ .arg (DFBrowserPane_Tools::GetEntry (theAttribute->Label()).ToCString());
+
+ if (!theInfoValues.contains (anAttributeName))
+ {
+ theInfoValues.append (anAttributeName);
+ theValues[anAttributeName] = DFBrowser_SearchItemInfo (QVariant(), anAttributeName, theCurrentPath,
+ QDir::separator());
+ }
+
+ // add element of attribute value, e.g. Name or Comment string
+ QString anAttributeValue;
+ if (anAttributeKind == STANDARD_TYPE (TDataStd_Name)->Name())
+ {
+ Handle(TDataStd_Name) anAttribute = Handle(TDataStd_Name)::DownCast (theAttribute);
+ anAttributeValue = DFBrowserPane_Tools::ToString (anAttribute->Get());
+ }
+ else if (anAttributeKind == STANDARD_TYPE (TDataStd_Comment)->Name())
+ {
+ Handle(TDataStd_Comment) anAttribute = Handle(TDataStd_Comment)::DownCast (theAttribute);
+ anAttributeValue = DFBrowserPane_Tools::ToString (anAttribute->Get());
+ }
+ else
+ return;
+
+ if (anAttributeValue == "")
+ return;
+
+ // using attribute value in the name
+ QString anAttributeValueExt = QString ("%1%2%3").arg (anAttributeValue)
+ .arg (DFBrowser_SearchLineModel::SplitSeparator())
+ .arg (DFBrowserPane_Tools::GetEntry (theAttribute->Label()).ToCString());
+ if (!theInfoValues.contains (anAttributeValueExt))
+ {
+ theInfoValues.append (anAttributeValueExt);
+ theValues[anAttributeValueExt] = DFBrowser_SearchItemInfo (QVariant(), anAttributeValueExt,
+ theCurrentPath, QDir::separator());
+ }
+}
--- /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 DFBrowser_ThreadItemSearch_H
+#define DFBrowser_ThreadItemSearch_H
+
+#include <DFBrowser_ThreadItem.hxx>
+#include <DFBrowser_SearchLineModel.hxx> // to include DFBrowser_SearchItemInfo
+#include <Standard.hxx>
+#include <TDF_Label.hxx>
+
+#include <QAbstractItemModel>
+#include <QMap>
+#include <QStringList>
+
+class DFBrowser_Module;
+class DFBrowser_SearchLine;
+class DFBrowser_SearchLineModel;
+
+//! \class DFBrowser_ThreadItemSearch
+//! Iterates by OCAF application to fill internal containers with information necessary for search
+class DFBrowser_ThreadItemSearch : public DFBrowser_ThreadItem
+{
+public:
+
+ //! Constructor
+ DFBrowser_ThreadItemSearch (DFBrowser_SearchLine* theSearchLine) : mySearchLine (theSearchLine) {}
+
+ //! Destructor
+ virtual ~DFBrowser_ThreadItemSearch() {}
+
+ //! Obtains the curent OCAF application from the current module, iterates by all documents to fill
+ //! internal containers for search functionality
+ Standard_EXPORT virtual void Run() Standard_OVERRIDE;
+
+ //! Set filled containers into search line
+ Standard_EXPORT virtual void ApplyValues() Standard_OVERRIDE;
+
+ //! Clear search line values
+ Standard_EXPORT static void ClearValues (DFBrowser_SearchLine* theSearchLine);
+
+private:
+
+ //! Fills information containers by iterating through sub-labels and attributes
+ //! The method is recursive by labels.
+ //! \parm theLabel a current label, the label information is got and children and attributes information
+ //! \param theCurrentPath it contains the current path to the label (stores in container)
+ //! \param theValues container of document item values
+ //! \param theInfoValues container of document item values
+ void getLabelLines (const TDF_Label& theLabel, QStringList& theCurrentPath,
+ QMap<QString, DFBrowser_SearchItemInfo >& theValues, QStringList& theInfoValues);
+
+ //! Adds label information into container: search will be performed by label entry
+ //! \parm theLabel a current label
+ //! \param theCurrentPath it contains the current path to the label (stores in container)
+ //! \param theValues container of document item values
+ //! \param theInfoValues container of document item values
+ void addLabel (const TDF_Label& theLabel, const QStringList& theCurrentPath,
+ QMap<QString, DFBrowser_SearchItemInfo>& theValues, QStringList& theInfoValues);
+
+ //! Add attribute information, it is either attribute kind or attribure value for TDataStd_Name or TDataStd_Comment
+ //! \parm theAttribute a current attribute
+ //! \param theCurrentPath it contains the current path to the label (stores in container)
+ //! \param theValues container of document item values
+ //! \param theInfoValues container of document item values
+ void addAttribute (const Handle(TDF_Attribute)& theAttribute, const QStringList& theCurrentPath,
+ QMap<QString, DFBrowser_SearchItemInfo>& theValues, QStringList& theInfoValues);
+
+private:
+
+ DFBrowser_SearchLine* mySearchLine; //!< class that should be filled by apply of the thread item
+ //!< a document index to container of entry/attribute name to item information
+ QMap<int, QMap<QString, DFBrowser_SearchItemInfo > > myDocumentValues;
+ QMap<int, QStringList> myDocumentInfoValues; //!< a document index to entry/attribute name
+};
+
+
+#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 <DFBrowser_ThreadItemUsedShapesMap.hxx>
+
+#include <DFBrowser_Module.hxx>
+#include <DFBrowser_Tools.hxx>
+#include <DFBrowser_TreeModel.hxx>
+
+#include <DFBrowserPane_TNamingUsedShapes.hxx>
+#include <DFBrowserPane_Tools.hxx>
+
+#include <TNaming_DataMapIteratorOfDataMapOfShapePtrRefShape.hxx>
+#include <TNaming_PtrRefShape.hxx>
+#include <TNaming_RefShape.hxx>
+#include <TNaming_UsedShapes.hxx>
+
+#include <Standard_Type.hxx>
+#include <TDocStd_Document.hxx>
+
+// =======================================================================
+// function : Run
+// purpose :
+// =======================================================================
+void DFBrowser_ThreadItemUsedShapesMap::Run()
+{
+ if (!myModule)
+ return;
+ DFBrowser_TreeModel* aDFBrowserModel = dynamic_cast<DFBrowser_TreeModel*> (myModule->GetOCAFViewModel());
+ if (!aDFBrowserModel)
+ return;
+
+ Handle(TDocStd_Application) anApplication = aDFBrowserModel->GetTDocStdApplication();
+ if (anApplication.IsNull())
+ return;
+
+ for (Standard_Integer aDocId = 1, aNbDocuments = anApplication->NbDocuments(); aDocId <= aNbDocuments; aDocId++)
+ {
+ Handle(TDocStd_Document) aDocument;
+ anApplication->GetDocument (aDocId, aDocument);
+ if (aDocument.IsNull())
+ continue;
+
+ TDF_Label aLabel = aDocument->Main().Root();
+
+ Handle(TNaming_UsedShapes) anAttribute;
+ if (!aLabel.FindAttribute (TNaming_UsedShapes::GetID(), anAttribute))
+ continue;
+
+ std::list<TCollection_AsciiString> aReferences;
+ findReferences (anAttribute, aReferences);
+ if (!aReferences.empty())
+ myAttributeRefs.Bind (anAttribute, aReferences);
+ }
+}
+
+// =======================================================================
+// function : ApplyValues
+// purpose :
+// =======================================================================
+void DFBrowser_ThreadItemUsedShapesMap::ApplyValues()
+{
+ if (myAttributeRefs.IsEmpty())
+ return;
+
+ DFBrowserPane_AttributePaneAPI* aPane = myModule->GetAttributePane (STANDARD_TYPE (TNaming_UsedShapes)->Name());
+ if (aPane)
+ {
+ DFBrowserPane_TNamingUsedShapes* aUsedShapesPane = dynamic_cast<DFBrowserPane_TNamingUsedShapes*> (aPane);
+ aUsedShapesPane->SetSortedReferences (myAttributeRefs);
+ }
+ // update
+ DFBrowser_TreeModel* aDFBrowserModel = dynamic_cast<DFBrowser_TreeModel*> (myModule->GetOCAFViewModel());
+ for (NCollection_DataMap<Handle(TDF_Attribute), std::list<TCollection_AsciiString> >::Iterator aRefIt (myAttributeRefs);
+ aRefIt.More(); aRefIt.Next())
+ {
+ TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex
+ (aDFBrowserModel->FindIndexByAttribute (aRefIt.Key()));
+ if (anItemBase)
+ anItemBase->Init();
+ }
+ // clear cache
+ myAttributeRefs.Clear();
+}
+
+// =======================================================================
+// function : ClearSortedReferences
+// purpose :
+// =======================================================================
+void DFBrowser_ThreadItemUsedShapesMap::ClearSortedReferences (DFBrowser_Module* theModule)
+{
+ DFBrowserPane_AttributePaneAPI* aPane = theModule->GetAttributePane (STANDARD_TYPE (TNaming_UsedShapes)->Name());
+ if (!aPane)
+ return;
+
+ DFBrowserPane_TNamingUsedShapes* aUsedShapesPane = dynamic_cast<DFBrowserPane_TNamingUsedShapes*> (aPane);
+ aUsedShapesPane->ClearSortedReferences();
+
+ // update tree item state
+ DFBrowser_TreeModel* aDFBrowserModel = dynamic_cast<DFBrowser_TreeModel*> (theModule->GetOCAFViewModel());
+ if (!aDFBrowserModel)
+ return;
+ Handle(TDocStd_Application) anApplication = aDFBrowserModel->GetTDocStdApplication();
+ if (anApplication.IsNull())
+ return;
+
+ for (Standard_Integer aDocId = 1, aNbDocuments = anApplication->NbDocuments(); aDocId <= aNbDocuments; aDocId++)
+ {
+ Handle(TDocStd_Document) aDocument;
+ anApplication->GetDocument (aDocId, aDocument);
+ if (aDocument.IsNull())
+ continue;
+ TDF_Label aLabel = aDocument->Main().Root();
+ Handle(TNaming_UsedShapes) anAttribute;
+ if (aLabel.FindAttribute (TNaming_UsedShapes::GetID(), anAttribute))
+ {
+ TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex(
+ aDFBrowserModel->FindIndexByAttribute (anAttribute));
+ if (anItemBase)
+ anItemBase->Init();
+ }
+ }
+}
+
+// =======================================================================
+// function : isLessThan
+// purpose :
+// =======================================================================
+bool DFBrowser_ThreadItemUsedShapesMap::isLessThan (const QStringList& theLeft, const QStringList& theRight)
+{
+ int aState = 1; //! where 0 - less, 1 - equal, 2 - larger
+ int aLeftSize = theLeft.size();
+ int aRightSize = theRight.size();
+
+ for (int anItemId = 0; anItemId < aRightSize && anItemId < aLeftSize && aState == 1; anItemId++)
+ {
+ int aRightId = theRight[anItemId].toInt();
+ int aLeftId = theLeft[anItemId].toInt();
+ if (aLeftId == aRightId)
+ continue;
+ else if (aLeftId < aRightId)
+ aState = 0; // less
+ else if (aLeftId > aRightId)
+ aState = 2; // less
+ }
+ if (aState == 1)
+ { // equal in similar parts
+ if (aLeftSize < aRightSize)
+ aState = 0;
+ else if (aLeftSize > aRightSize)
+ aState = 2;
+ }
+ return aState == 0;
+}
+
+// =======================================================================
+// function : addValue
+// purpose :
+// =======================================================================
+void DFBrowser_ThreadItemUsedShapesMap::addValue (const TCollection_AsciiString& theEntry,
+ QList<QPair<TCollection_AsciiString, QStringList > >& theEntries)
+{
+ QStringList aSplit = QString (theEntry.ToCString()).split (":");
+
+ int aLessIndex = -1;
+ bool isInserted = false;
+ // looking for nearest smaller value from the end of the list
+ for (int anEntryId = theEntries.size() - 1; anEntryId >= 0 && !isInserted; anEntryId--)
+ {
+ if (isLessThan(aSplit, theEntries[anEntryId].second))
+ aLessIndex = anEntryId;
+ else
+ {
+ // if less than was found and now, the entry is greater than current entry
+ if (aLessIndex != -1)
+ {
+ theEntries.insert (aLessIndex, qMakePair (theEntry, aSplit));
+ isInserted = true;
+ }
+ break;
+ }
+ }
+ if (!isInserted)
+ {
+ if (aLessIndex != -1) // less than all, insert at this position
+ theEntries.insert (aLessIndex, qMakePair (theEntry, aSplit));
+ else
+ theEntries.append (qMakePair (theEntry, aSplit));
+ }
+}
+
+// =======================================================================
+// function : findReferences
+// purpose :
+// =======================================================================
+//#define REQUIRE_OCAF_REVIEW:26 : start
+void DFBrowser_ThreadItemUsedShapesMap::findReferences (Handle(TDF_Attribute) theAttribute,
+ std::list<TCollection_AsciiString>& theReferences)
+{
+ Handle(TNaming_UsedShapes) anAttribute = Handle(TNaming_UsedShapes)::DownCast (theAttribute);
+
+ QList<QPair<TCollection_AsciiString, QStringList> > anEntries;
+ for (TNaming_DataMapIteratorOfDataMapOfShapePtrRefShape aDataIt(anAttribute->Map()); aDataIt.More(); aDataIt.Next())
+ addValue(DFBrowserPane_Tools::GetEntry (aDataIt.Value()->Label()), anEntries);
+
+ for (QList<QPair<TCollection_AsciiString, QStringList> >::const_iterator anEntryIt = anEntries.begin();
+ anEntryIt != anEntries.end(); anEntryIt++)
+ theReferences.push_back (anEntryIt->first);
+}
+//#define REQUIRE_OCAF_REVIEW:26 : end
--- /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 DFBROWSER_ThreadItemUsedShapesMap_H
+#define DFBROWSER_ThreadItemUsedShapesMap_H
+
+#include <DFBrowser_ThreadItem.hxx>
+#include <NCollection_DataMap.hxx>
+#include <Standard.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TDF_Attribute.hxx>
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4127) // conditional expression is constant
+#endif
+#include <QStringList>
+#include <QPair>
+
+class DFBrowser_Module;
+
+//! \class DFBrowser_ThreadItemUsedShapesMap
+//! Collects and sorts map values of TNaming_UsedShape attributes. Applies values to the OCAF tree view model
+class DFBrowser_ThreadItemUsedShapesMap : public DFBrowser_ThreadItem
+{
+public:
+
+ //! Constructor
+ DFBrowser_ThreadItemUsedShapesMap() : myModule (0) {}
+
+ //! Destructor
+ virtual ~DFBrowser_ThreadItemUsedShapesMap() {}
+
+ //! Sets the current module
+ void SetModule (DFBrowser_Module* theModule) { myModule = theModule; }
+
+ //! Iterates by application documents and for TNaming_UsedShape attribute collects container of sorted values.
+ Standard_EXPORT virtual void Run() Standard_OVERRIDE;
+
+ //! Initialize tree view model of OCAF by internal container of sorted values.
+ Standard_EXPORT virtual void ApplyValues() Standard_OVERRIDE;
+
+ //! Set empty cache into tree view model of OCAF. Calls Init of these item by usual values (not sorted)
+ Standard_EXPORT static void ClearSortedReferences (DFBrowser_Module* theModule);
+
+private:
+
+ //! Collects sorted values of the attribute if the attribute has TNaming_UsedShape type
+ //! \param theAttribute a processed attribute
+ //! \param theReferences a output container of sorted references
+ void findReferences (Handle(TDF_Attribute) theAttribute, std::list<TCollection_AsciiString>& theReferences);
+
+ //! Checks whether the left path is less than the right path
+ //! \param theLeft path to label
+ //! \param theRight path to label
+ //! \returns true if the left path is less(not equal) than right path
+ static bool isLessThan (const QStringList& theLeft, const QStringList& theRight);
+
+ //! Insert entry into container of entries using sorting. It is split by ":" separator to perform soring
+ //! \param theEntry a label entry
+ //! \param theEntries a result container
+ void addValue (const TCollection_AsciiString& theEntry, QList<QPair<TCollection_AsciiString, QStringList > >& theEntries);
+
+private:
+
+ DFBrowser_Module* myModule; //!< the current module
+ NCollection_DataMap<Handle(TDF_Attribute), std::list<TCollection_AsciiString> > myAttributeRefs; //!< sorted references
+};
+
+#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 <DFBrowser_Tools.hxx>
+
+#include <DFBrowser_ItemBase.hxx>
+
+#include <DFBrowserPane_AttributePaneCreator.hxx>
+#include <DFBrowserPane_Tools.hxx>
+
+#include <TCollection_AsciiString.hxx>
+#include <TDF_Tool.hxx>
+#include <TDF_ChildIterator.hxx>
+#include <Standard_GUID.hxx>
+#include <TDataStd_Integer.hxx>
+#include <TDataStd_Real.hxx>
+#include <TDataStd_Name.hxx>
+
+#include <QColor>
+#include <QDir>
+#include <QPalette>
+#include <QWidget>
+
+//#define REQUIRE_OCAF_REVIEW:27
+
+namespace DFBrowser_Tools
+{
+ // =======================================================================
+ // function : IsEmptyLabel
+ // purpose :
+ // =======================================================================
+ bool IsEmptyLabel (const TDF_Label& theLabel)
+ {
+ if (theLabel.IsNull())
+ return true;
+
+ if (theLabel.IsRoot())
+ return false;
+
+ if (theLabel.NbAttributes() > 0)
+ return false;
+
+ for (TDF_ChildIterator aChildIt (theLabel); aChildIt.More(); aChildIt.Next())
+ {
+ if (!IsEmptyLabel (aChildIt.Value()))
+ return false;
+ }
+ return true;
+ }
+
+ // =======================================================================
+ // function : GetLabelInfo
+ // purpose :
+ // =======================================================================
+ QString GetLabelInfo (const TDF_Label& theLabel, const bool isUseShortInfo)
+ {
+ QString aValue = DFBrowserPane_Tools::GetEntry (theLabel).ToCString();
+ if (!isUseShortInfo)
+ return aValue;
+
+ Handle(TDataStd_Name) aName;
+ if (!theLabel.FindAttribute (TDataStd_Name::GetID(), aName))
+ return aValue;
+
+ aValue += " ";
+ aValue += DFBrowserPane_Tools::ToString (aName->Get());
+
+ return aValue;
+ }
+
+
+ enum DFBrowser_IconType
+ {
+ DFBrowser_IconType_16x16,
+ DFBrowser_IconType_40x40
+ };
+ static QMap<DFBrowser_IconType, QIcon> MyLabelIcons;
+
+ // =======================================================================
+ // function : GetLabelIcon
+ // purpose :
+ // =======================================================================
+ QIcon GetLabelIcon (const TDF_Label& theLabel, bool isStandard16x16)
+ {
+ (void)theLabel;
+ if (MyLabelIcons.empty())
+ {
+ MyLabelIcons[DFBrowser_IconType_16x16] = QIcon (":/icons/label_folder_16x16.png");
+ MyLabelIcons[DFBrowser_IconType_40x40] = QIcon (":/icons/label_folder_40x40.png");
+ }
+ return MyLabelIcons[isStandard16x16 ? DFBrowser_IconType_16x16 : DFBrowser_IconType_40x40];
+ }
+}
--- /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 DFBrowser_Tools_H
+#define DFBrowser_Tools_H
+
+#include <Standard.hxx>
+#include <Standard_GUID.hxx>
+#include <TreeModel_ItemBase.hxx>
+#include <TDocStd_Document.hxx>
+#include <TDF_Label.hxx>
+#include <TDF_Attribute.hxx>
+#include <TopoDS_Shape.hxx>
+
+#include <QAbstractItemModel>
+#include <QColor>
+#include <QMap>
+#include <QModelIndex>
+#include <QPixmap>
+#include <QString>
+#include <QIcon>
+
+class DFBrowserPane_AttributePaneAPI;
+
+//! \namespace DFBrowser_Tools
+//! The namespace that gives auxiliary methods for TDF elements manipulation
+namespace DFBrowser_Tools
+{
+
+ //! Returns true if the label is not root, has attribute or at least one sub-label with attribute
+ //! \param theLabel a label
+ //! \return boolean result
+ Standard_EXPORT bool IsEmptyLabel (const TDF_Label& theLabel);
+
+ //! Returns the label entry
+ //! \param isUseShortInfo boolean value if value of name attribute should be included to result
+ //! \return string value
+ Standard_EXPORT QString GetLabelInfo (const TDF_Label& theLabel, const bool isUseShortInfo = true);
+
+ //! Returns the label icon
+ Standard_EXPORT QIcon GetLabelIcon (const TDF_Label& theLabel, bool isStandard16x16 = true);
+}
+
+#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 <DFBrowser_TreeLevelLine.hxx>
+
+#include <DFBrowser_SearchLine.hxx>
+#include <DFBrowser_Window.hxx>
+#include <DFBrowser_TreeLevelLineDelegate.hxx>
+#include <DFBrowser_TreeLevelLineModel.hxx>
+
+#include <DFBrowserPane_Tools.hxx>
+
+#include <QAbstractItemModel>
+#include <QFrame>
+#include <QGridLayout>
+#include <QHeaderView>
+#include <QItemSelectionModel>
+#include <QPainter>
+#include <QScrollBar>
+#include <QTableView>
+#include <QToolButton>
+#include <QWidget>
+
+const int HISTORY_SIZE = 10;
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowser_TreeLevelLine::DFBrowser_TreeLevelLine (QWidget* theParent)
+: QObject (theParent), mySelectionProcessingBlocked (false), myCurrentHistoryIndex (-1)
+{
+ myMainWindow = new QWidget (theParent);
+ QGridLayout* aLayout = new QGridLayout (myMainWindow);
+ aLayout->setContentsMargins (0, 0, 0, 0);
+
+ myBackwardButton = new QToolButton (myMainWindow);
+ myBackwardButton->setIcon (QIcon (":/icons/treeline_backward.png"));
+ myBackwardButton->setToolTip (tr ("Backward"));
+ connect (myBackwardButton, SIGNAL (clicked()), this, SLOT (onActionClicked()));
+ aLayout->addWidget (myBackwardButton, 0, 0);
+
+ myForwardButton = new QToolButton (myMainWindow);
+ myForwardButton->setIcon (QIcon (":/icons/treeline_forward.png"));
+ myForwardButton->setToolTip (tr ("Forward"));
+ connect (myForwardButton, SIGNAL (clicked()), this, SLOT (onActionClicked()));
+ aLayout->addWidget (myForwardButton, 0, 1);
+
+ myTableView = new QTableView (myMainWindow);
+ myTableView->horizontalHeader()->setVisible (false);
+ QHeaderView* aVHeader = myTableView->verticalHeader();
+ aVHeader->setVisible (false);
+ int aDefCellSize = aVHeader->minimumSectionSize() + DFBrowserPane_Tools::HeaderSectionMargin();
+ aVHeader->setDefaultSectionSize (aDefCellSize);
+ aLayout->addWidget (myTableView, 0, 2, 2, 1);
+
+ int aScrollHeight = myTableView->horizontalScrollBar()->sizeHint().height();
+ myTableView->setFixedHeight (aDefCellSize + aScrollHeight);
+ myTableView->horizontalHeader()->setMinimumSectionSize (5); // it will be resized by context
+ myTableView->setHorizontalScrollMode (QAbstractItemView::ScrollPerItem);
+ myTableView->setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOn); //! TEMPORARY
+ myTableView->setShowGrid (false);
+
+ DFBrowser_TreeLevelLineModel* aHModel = new DFBrowser_TreeLevelLineModel (myTableView);
+ myTableView->setModel (aHModel);
+
+ QItemSelectionModel* aSelectionModel = new QItemSelectionModel (aHModel);
+ myTableView->setSelectionMode (QAbstractItemView::SingleSelection);
+ myTableView->setSelectionModel (aSelectionModel);
+ connect (aSelectionModel, SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
+ this, SLOT (onTableSelectionChanged (const QItemSelection&, const QItemSelection&)));
+
+ // highlight for items
+ myTableView->viewport()->setAttribute (Qt::WA_Hover);
+ myTableView->setItemDelegate (new DFBrowser_TreeLevelLineDelegate (myTableView));
+
+ aLayout->setColumnStretch (2, 1);
+
+ myUpdateButton = new QToolButton (myMainWindow);
+ myUpdateButton->setIcon (QIcon (":/icons/treeline_update.png"));
+ myUpdateButton->setToolTip (tr ("Update Tree Model"));
+ connect (myUpdateButton, SIGNAL (clicked()), this, SLOT (onActionClicked()));
+ aLayout->addWidget (myUpdateButton, 0, 3);
+
+ mySearchLine = new DFBrowser_SearchLine (myMainWindow);
+ aLayout->addWidget (mySearchLine, 0, 4);
+
+ updateActionsState();
+}
+
+// =======================================================================
+// function : clear
+// purpose :
+// =======================================================================
+void DFBrowser_TreeLevelLine::ClearHistory()
+{
+ myHistoryIndices.clear();
+ setCurrentHistoryIndex (-1);
+}
+
+// =======================================================================
+// function : onSelectionChanged
+// purpose :
+// =======================================================================
+void DFBrowser_TreeLevelLine::OnTreeViewSelectionChanged (const QItemSelection& theSelected,
+ const QItemSelection&)
+{
+ QModelIndexList aSelectedIndices = theSelected.indexes();
+ QModelIndex aSelectedIndex = DFBrowser_Window::SingleSelected (aSelectedIndices, 0);
+
+ if (!mySelectionProcessingBlocked) // we're processing action click
+ setForwardIndex (aSelectedIndex);
+
+ bool isBlocked = mySelectionProcessingBlocked;
+ // block selection processing in order to avoid circling by processing table selection changing
+ mySelectionProcessingBlocked = true;
+ DFBrowser_TreeLevelLineModel* aModel = dynamic_cast<DFBrowser_TreeLevelLineModel*> (myTableView->model());
+ aModel->Init (aSelectedIndex);
+ myTableView->selectionModel()->clearSelection();
+ myTableView->resizeColumnsToContents();
+
+ myTableView->scrollTo (myTableView->model()->index (0, myTableView->model()->columnCount()-1));
+
+ mySelectionProcessingBlocked = isBlocked;
+}
+
+// =======================================================================
+// function : onTableSelectionChanged
+// purpose :
+// =======================================================================
+void DFBrowser_TreeLevelLine::onTableSelectionChanged (const QItemSelection& theSelected,
+ const QItemSelection&)
+{
+ if (mySelectionProcessingBlocked)
+ return;
+
+ DFBrowser_TreeLevelLineModel* aTableModel = dynamic_cast<DFBrowser_TreeLevelLineModel*> (myTableView->model());
+ if (!aTableModel)
+ return;
+
+ QModelIndex aSelectedIndex = DFBrowser_Window::SingleSelected (theSelected.indexes(), 0, Qt::Vertical);
+ emit indexSelected (aTableModel->GetTreeViewIndex (aSelectedIndex));
+}
+
+// =======================================================================
+// function : onActionClicked
+// purpose :
+// =======================================================================
+void DFBrowser_TreeLevelLine::onActionClicked()
+{
+ QToolButton* aSender = (QToolButton*)sender();
+ if (aSender == myBackwardButton || aSender == myForwardButton)
+ {
+ bool aBlocked = mySelectionProcessingBlocked;
+ mySelectionProcessingBlocked = true;
+ QModelIndex anIndex;
+ if (aSender == myBackwardButton)
+ {
+ anIndex = getBackwardIndex();
+ if (anIndex.isValid())
+ setCurrentHistoryIndex (myCurrentHistoryIndex - 1);
+ }
+ else
+ {
+ anIndex = getForwardIndex();
+ if (anIndex.isValid())
+ setCurrentHistoryIndex (myCurrentHistoryIndex + 1);
+ }
+ if (anIndex.isValid())
+ emit indexSelected (anIndex);
+ mySelectionProcessingBlocked = aBlocked;
+ }
+ else if (aSender == myUpdateButton)
+ emit updateClicked();
+}
+
+// =======================================================================
+// function : getBackwardIndex
+// purpose :
+// =======================================================================
+QModelIndex DFBrowser_TreeLevelLine::getBackwardIndex()
+{
+ return myCurrentHistoryIndex > 0 ? myHistoryIndices[myCurrentHistoryIndex-1] : QModelIndex();
+}
+
+// =======================================================================
+// function : getForwardIndex
+// purpose :
+// =======================================================================
+QModelIndex DFBrowser_TreeLevelLine::getForwardIndex()
+{
+ return (myCurrentHistoryIndex >= 0 && myCurrentHistoryIndex + 1 < myHistoryIndices.count())
+ ? myHistoryIndices[myCurrentHistoryIndex + 1] : QModelIndex();
+}
+
+// =======================================================================
+// function : setForwardIndex
+// purpose :
+// =======================================================================
+void DFBrowser_TreeLevelLine::setForwardIndex (const QModelIndex& theIndex)
+{
+ while (myCurrentHistoryIndex != myHistoryIndices.count() - 1)
+ myHistoryIndices.removeLast();
+
+ myHistoryIndices.append (theIndex);
+ if (myHistoryIndices.size() > HISTORY_SIZE)
+ myHistoryIndices.removeFirst();
+
+ setCurrentHistoryIndex (myHistoryIndices.count() - 1);
+}
+
+// =======================================================================
+// function : setCurrentHistoryIndex
+// purpose :
+// =======================================================================
+void DFBrowser_TreeLevelLine::setCurrentHistoryIndex (const int theIndexId)
+{
+ myCurrentHistoryIndex = theIndexId;
+ updateActionsState();
+}
+
+// =======================================================================
+// function : updateActionsState
+// purpose :
+// =======================================================================
+void DFBrowser_TreeLevelLine::updateActionsState()
+{
+ if (myCurrentHistoryIndex < 0)
+ {
+ myBackwardButton->setEnabled (false);
+ myForwardButton->setEnabled (false);
+ }
+ else
+ {
+ myBackwardButton->setEnabled (myCurrentHistoryIndex > 0);
+ myForwardButton->setEnabled (myCurrentHistoryIndex < myHistoryIndices.size() - 1);
+ }
+}
--- /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 DFBrowser_TreeLevelLine_H
+#define DFBrowser_TreeLevelLine_H
+
+#include <Standard.hxx>
+#include <TreeModel_ItemBase.hxx>
+
+#include <QItemSelection>
+#include <QObject>
+#include <QMap>
+#include <QModelIndex>
+
+class DFBrowser_SearchLine;
+
+class QAbstractItemModel;
+class QToolButton;
+class QTableView;
+class QWidget;
+
+//! \class DFBrowser_TreeLevelLine
+//! This is a control to visualize the current selected item of OCAF tree view.
+//! It contains history of previous selected items.
+//! The structure of this control is the next:
+//! <back button> <forward button> <selected item line> <update button> <search line>
+//! - <back button> allows moving to previously selected item (if it exists)
+//! - <forward button> allows moving to next selected item (if it exists)
+//! - <selected item line> path to currently selected item in OCAF tree view. Click on any level will
+//! select the clicked item in tree view.
+//! - <update button> will update content of OCAF tree model
+//! - <search line> allows type label entry or attribute name and see in search view the available elements
+class DFBrowser_TreeLevelLine : public QObject
+{
+ Q_OBJECT
+public:
+
+ //! Constructor
+ Standard_EXPORT DFBrowser_TreeLevelLine (QWidget* theParent);
+
+ //! Destructor
+ virtual ~DFBrowser_TreeLevelLine() Standard_OVERRIDE {}
+
+ //! Clears history of selected items
+ Standard_EXPORT void ClearHistory();
+
+ //! Returns parent control
+ QWidget* GetControl() const { return myMainWindow; }
+
+ //! Returns current search line
+ DFBrowser_SearchLine* GetSearchLine() const { return mySearchLine; };
+
+signals:
+
+ //! Signal about selection of an item in tree level line
+ //! \param theIndex a tree view model index of selected item
+ void indexSelected (const QModelIndex& theIndex);
+
+ //! Signal about necessity to update OCAF tree model
+ void updateClicked();
+
+public slots:
+
+ //! Listens tree view selection model. Update tree level line by selected item. Stores
+ //! \param theSelected a list of selected items
+ //! \param theDeselected a list of deselected items
+ Standard_EXPORT void OnTreeViewSelectionChanged (const QItemSelection& theSelected,
+ const QItemSelection& theDeselected);
+
+private slots:
+
+ //! Listens table view selection model. Gets selected tree view model index and emit indexSelected signal.
+ //! \param theSelected a list of selected items
+ //! \param theDeselected a list of deselected items
+ void onTableSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
+
+ //! Listens actions and do the following:
+ //! - <backward>: moves history to the previous selection item, emits indexSelected signal
+ //! - <forward>: moves history to the next selection item, emits indexSelected signal
+ //! - <update>: emits updateClicked signal to update OCAF tree model
+ void onActionClicked();
+
+private:
+
+ //! Returns the previous index of history selection
+ QModelIndex getBackwardIndex();
+
+ //! Returns the next index of history selection
+ QModelIndex getForwardIndex();
+
+ //! Appends new history index, set it active, remove the first history index if the cache is out of range
+ //! \param theIndex a selected OCAF tree model index
+ void setForwardIndex (const QModelIndex& theIndex);
+
+ //! Updates enable state of backward/forward actions depending on the current item index
+ void updateActionsState();
+
+ //! Sets the current index and update actions state
+ //! \param theIndexId an item index, should be in range of history of indices
+ void setCurrentHistoryIndex (const int theIndexId);
+
+private:
+
+ bool mySelectionProcessingBlocked; //!< if true, table view selection is started but has not been finished yet
+ QList<QModelIndex> myHistoryIndices; //!< cached selected OCAF tree model indices
+ int myCurrentHistoryIndex; //!< an index of the current history selected index from myHistoryIndices
+
+ QWidget* myMainWindow; //!< parent widget for controls
+ QToolButton* myBackwardButton; //!< backward button, to select previous selected item
+ QToolButton* myForwardButton; //!< forward button, to select next selected item
+ QToolButton* myUpdateButton; //!< update button, like F5, to update OCAF tree model content
+ QTableView* myTableView; //!< container of path values to selected item, a path value is a label entry
+
+ DFBrowser_SearchLine* mySearchLine; //!< line of search
+};
+#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 <DFBrowser_TreeLevelLineDelegate.hxx>
+#include <DFBrowser_Window.hxx>
+
+#include <QPainter>
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowser_TreeLevelLineDelegate::DFBrowser_TreeLevelLineDelegate (QObject* theParent)
+: QItemDelegate (theParent)
+{
+}
+
+// =======================================================================
+// function : paint
+// purpose :
+// =======================================================================
+void DFBrowser_TreeLevelLineDelegate::paint (QPainter* thePainter, const QStyleOptionViewItem& theOption,
+ const QModelIndex& theIndex) const
+{
+ // highlight cell
+ if (theOption.state & QStyle::State_MouseOver)
+ thePainter->fillRect (theOption.rect, DFBrowser_Window::LightHighlightColor());
+
+ // action icon for all indices before the last one
+ if (theIndex.column() < theIndex.model()->columnCount()-1)
+ {
+ QIcon anIcon (":/icons/level_change.png");
+ QSize anIconSize (10, 20);
+ thePainter->drawPixmap (QRect (theOption.rect.right() - anIconSize.width(), theOption.rect.top(),
+ anIconSize.width(), anIconSize.height()),
+ anIcon.pixmap (anIconSize.width(), anIconSize.height()));
+ }
+ // default paint
+ QItemDelegate::paint (thePainter, theOption, theIndex);
+}
--- /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 DFBrowser_TreeLevelLineDelegate_H
+#define DFBrowser_TreeLevelLineDelegate_H
+
+#include <Standard.hxx>
+#include <Standard_Macro.hxx>
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4127) // conditional expression is constant
+#endif
+#include <QItemDelegate>
+
+//! \class DFBrowser_TreeLevelLineDelegate
+//! Extending standard item delegate by:
+//! - <level change.png> icon. It exists for all columns excepting the last column.
+//! - highlight cell by mouse move over the cell
+class DFBrowser_TreeLevelLineDelegate : public QItemDelegate
+{
+
+public:
+
+ //! Constructor
+ Standard_EXPORT DFBrowser_TreeLevelLineDelegate (QObject* theParent = 0);
+
+ //! Destructor
+ virtual ~DFBrowser_TreeLevelLineDelegate() {}
+
+ //! Draw an icon in the cell and highlight cell if mouse is over the cell
+ //! \param thePainter a painter
+ //! \param theOption a paint options
+ //! \param theIndex a view index
+ Standard_EXPORT virtual void paint (QPainter* thePainter, const QStyleOptionViewItem& theOption,
+ const QModelIndex& theIndex) const Standard_OVERRIDE;
+};
+
+#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 <DFBrowser_TreeLevelLineModel.hxx>
+
+#include <DFBrowser_ItemBase.hxx>
+#include <TreeModel_ModelBase.hxx>
+
+#include <QIcon>
+#include <QWidget>
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void DFBrowser_TreeLevelLineModel::Init (const QModelIndex& theTreeIndex)
+{
+ myTreeIndex = theTreeIndex;
+ myLevelItems.clear();
+
+ if (theTreeIndex.isValid())
+ {
+ myLevelItems.prepend (theTreeIndex);
+ QModelIndex aParent = theTreeIndex.parent();
+ while (aParent.isValid())
+ {
+ myLevelItems.prepend (aParent);
+ aParent = aParent.parent();
+ }
+ }
+ emit layoutChanged();
+}
+
+// =======================================================================
+// function : data
+// purpose :
+// =======================================================================
+QVariant DFBrowser_TreeLevelLineModel::data (const QModelIndex& theIndex, int theRole) const
+{
+ QVariant aValue;
+ int aColumns = theIndex.column();
+ if (aColumns < myLevelItems.size())
+ {
+ QModelIndex aTreeIndex = myLevelItems[aColumns];
+ if (theRole == Qt::DecorationRole) //! do not show icons presented in tree view
+ return aValue;
+ TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (aTreeIndex);
+ if (anItemBase)
+ {
+ DFBrowser_ItemBasePtr aDBrowserItem = itemDynamicCast<DFBrowser_ItemBase> (anItemBase);
+ bool aPrevValue = aDBrowserItem->SetUseAdditionalInfo (false);
+ aValue = aDBrowserItem->data (aTreeIndex, theRole);
+ aDBrowserItem->SetUseAdditionalInfo (aPrevValue);
+
+ }
+ if (theRole == Qt::DisplayRole)
+ aValue = aValue.toString() + " "; //! TEMPORARY to leave place for the action icon
+ }
+ return aValue;
+}
+
+// =======================================================================
+// function : headerData
+// purpose :
+// =======================================================================
+QVariant DFBrowser_TreeLevelLineModel::headerData (int theSection, Qt::Orientation theOrientation, int theRole) const
+{
+ QVariant aValue;
+ if (theOrientation == Qt::Horizontal && theSection < myLevelItems.size())
+ {
+ QModelIndex aTreeIndex = myLevelItems[theSection];
+ if (!aTreeIndex.isValid()) // level change action
+ {
+ if (theRole == Qt::SizeHintRole)
+ aValue = QSize (2, 2);
+ else if (theRole == Qt::DisplayRole)
+ aValue = "";
+ }
+ }
+ return aValue;
+}
--- /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 DFBrowser_TreeLevelLineModel_H
+#define DFBrowser_TreeLevelLineModel_H
+
+#include <Standard.hxx>
+#include <TreeModel_ItemBase.hxx>
+
+#include <QAbstractTableModel>
+#include <QObject>
+#include <QList>
+
+//! \class DFBrowser_TreeLevelLineModel
+//! Tree Model of tree line items. It is initialized by OCAF tree model index. Each element of the current model
+//! is an item of hierarchy of OCAF tree model index. So, on each level a label is presented, the last element may be
+//! an attribute. Information, presented for the item has no additional information (not as in OCAF tree model)
+class DFBrowser_TreeLevelLineModel : public QAbstractTableModel
+{
+public:
+
+ //! Constructor
+ DFBrowser_TreeLevelLineModel (QObject* theParent = 0) : QAbstractTableModel (theParent) {}
+
+ //! Destructor
+ virtual ~DFBrowser_TreeLevelLineModel() {}
+
+ //!
+ void Reset() { myLevelItems.clear(); }
+
+ //! Inits the model by the index
+ //! \param theTreeIndex an OCAF tree model index
+ Standard_EXPORT void Init (const QModelIndex& theTreeIndex);
+
+ //! Returns true if the tree model index is filled
+ bool IsInitialized() const { return myTreeIndex.isValid(); }
+
+ //! Return OCAF tree view model index on level defined by column of the parameter index
+ //! \param theIndex a tree level view model index
+ //! \return model index
+ const QModelIndex& GetTreeViewIndex (const QModelIndex& theIndex) const
+ { return myLevelItems[theIndex.column()]; }
+
+ //! Returns item information(short) for display role.
+ //! \param theIndex a model index
+ //! \param theRole a view role
+ //! \return value intepreted depending on the given role
+ Standard_EXPORT virtual QVariant data (const QModelIndex& theIndex,
+ int theRole = Qt::DisplayRole) const Standard_OVERRIDE;
+
+ //! Returns the header data for the given role and section in the header with the specified orientation.
+ //! \param theSection the header section. For horizontal headers - column number, for vertical headers - row number.
+ //! \param theOrientation a header orientation
+ //! \param theRole a data role
+ //! \return the header data
+ Standard_EXPORT virtual QVariant headerData (int theSection, Qt::Orientation theOrientation,
+ int theRole = Qt::DisplayRole) const Standard_OVERRIDE;
+
+ //! Returns number of tree level line items = colums in table view
+ virtual int columnCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
+ { (void)theParent; return myLevelItems.size(); }
+
+ //! Returns onlly one row in table view
+ virtual int rowCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
+ { (void)theParent; return 1; }
+
+private:
+
+ QModelIndex myTreeIndex; //!< the current OCAF tree view model index
+ QList<QModelIndex> myLevelItems; //! cached parent indices of myTreeIndex for quick access to item information
+};
+
+#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 <DFBrowser_TreeLevelView.hxx>
+
+#include <DFBrowser_Item.hxx>
+#include <DFBrowser_TreeLevelViewModel.hxx>
+#include <DFBrowser_Window.hxx>
+#include <DFBrowserPane_Tools.hxx>
+#include <TreeModel_ModelBase.hxx>
+
+#include <QItemSelectionModel>
+
+#include <QGridLayout>
+#include <QHeaderView>
+#include <QTableView>
+#include <QWidget>
+
+const int DEFAULT_COLUMN_WIDTH = 300;
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowser_TreeLevelView::DFBrowser_TreeLevelView (QWidget* theParent)
+: QObject (theParent)
+{
+ myMainWindow = new QWidget (theParent);
+ QGridLayout* aLayout = new QGridLayout (myMainWindow);
+ aLayout->setContentsMargins (0, 0, 0, 0);
+
+ myTableView = new QTableView (myMainWindow);
+ myTableView->setModel (new DFBrowser_TreeLevelViewModel (myTableView));
+ myTableView->setColumnWidth (0, DEFAULT_COLUMN_WIDTH);
+ myTableView->setEditTriggers (QAbstractItemView::DoubleClicked);
+ QHeaderView* aVHeader = myTableView->verticalHeader();
+ aVHeader->setVisible (false);
+ aVHeader->setDefaultSectionSize (aVHeader->minimumSectionSize() + DFBrowserPane_Tools::HeaderSectionMargin());
+ myTableView->horizontalHeader()->setStretchLastSection (true);
+ aLayout->addWidget (myTableView);
+
+ QItemSelectionModel* aSelectionModel = new QItemSelectionModel (myTableView->model());
+ myTableView->setSelectionMode (QAbstractItemView::SingleSelection);
+ myTableView->setSelectionModel (aSelectionModel);
+ myTableView->setSelectionBehavior (QAbstractItemView::SelectRows);
+ connect (aSelectionModel, SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
+ this, SLOT (onTableSelectionChanged (const QItemSelection&, const QItemSelection&)));
+ connect (myTableView, SIGNAL (doubleClicked (const QModelIndex&)),
+ this, SLOT (onTableDoubleClicked (const QModelIndex&)));
+
+ DFBrowser_Window::SetWhiteBackground (myTableView);
+ myTableView->setGridStyle (Qt::NoPen);
+}
+
+// =======================================================================
+// function : clearSelection
+// purpose :
+// =======================================================================
+void DFBrowser_TreeLevelView::ClearSelection()
+{
+ myTableView->selectionModel()->clearSelection();
+}
+
+// =======================================================================
+// function : ProcessItem
+// purpose :
+// =======================================================================
+bool DFBrowser_TreeLevelView::ProcessItem (const QModelIndex& theIndex)
+{
+ bool aResult = false;
+ TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (theIndex);
+ if (anItemBase) {
+ // use this view for attribute/document/label items
+ DFBrowser_ItemPtr anItem = itemDynamicCast<DFBrowser_Item> (anItemBase);
+ if (anItem)
+ aResult = anItem && !anItem->HasAttribute();
+ else
+ aResult = true; // attribute or document item
+ }
+ return aResult;
+}
+
+// =======================================================================
+// function : UpdateByTreeSelectionChanged
+// purpose :
+// =======================================================================
+void DFBrowser_TreeLevelView::UpdateByTreeSelectionChanged (const QItemSelection& theSelected,
+ const QItemSelection&)
+{
+ QModelIndexList aSelectedIndices = theSelected.indexes();
+ QModelIndexList aFirstColumnSelectedIndices;
+ for (QModelIndexList::const_iterator aSelIt = aSelectedIndices.begin(); aSelIt != aSelectedIndices.end(); aSelIt++)
+ {
+ QModelIndex anIndex = *aSelIt;
+ if (anIndex.column() == 0)
+ aFirstColumnSelectedIndices.append (anIndex);
+ }
+
+ if (aFirstColumnSelectedIndices.size() != 1)
+ return;
+
+ DFBrowser_TreeLevelViewModel* aModel = dynamic_cast<DFBrowser_TreeLevelViewModel*> (myTableView->model());
+ const QModelIndex& anIndex = aFirstColumnSelectedIndices.first();
+ if (DFBrowser_TreeLevelView::ProcessItem(anIndex)) // to Init
+ aModel->Init (anIndex);
+ else
+ aModel->Reset();
+}
+
+// =======================================================================
+// function : onTableSelectionChanged
+// purpose :
+// =======================================================================
+void DFBrowser_TreeLevelView::onTableSelectionChanged (const QItemSelection& theSelected,
+ const QItemSelection&)
+{
+ QModelIndexList aSelectedIndices = theSelected.indexes();
+ QModelIndex aSelectedIndex = DFBrowser_Window::SingleSelected (aSelectedIndices, 0);
+
+ DFBrowser_TreeLevelViewModel* aTableModel = dynamic_cast<DFBrowser_TreeLevelViewModel*> (myTableView->model());
+ if (aTableModel && aTableModel->IsInitialized())
+ {
+ const QModelIndex& aTreeViewIndex = aTableModel->GetTreeViewIndex (aSelectedIndex);
+ if (aTreeViewIndex.isValid())
+ emit indexSelected (aTreeViewIndex);
+ }
+}
+
+// =======================================================================
+// function : onTableDoubleClicked
+// purpose :
+// =======================================================================
+void DFBrowser_TreeLevelView::onTableDoubleClicked (const QModelIndex& theIndex)
+{
+ DFBrowser_TreeLevelViewModel* aTableModel = dynamic_cast<DFBrowser_TreeLevelViewModel*> (myTableView->model());
+ if (!aTableModel)
+ return;
+
+ const QModelIndex& aTreeViewIndex = aTableModel->GetTreeViewIndex (theIndex);
+ if (aTreeViewIndex.isValid())
+ emit indexDoubleClicked (aTreeViewIndex);
+}
--- /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 DFBrowser_TreeLevelView_H
+#define DFBrowser_TreeLevelView_H
+
+#include <Standard.hxx>
+#include <TreeModel_ItemBase.hxx>
+
+#include <QObject>
+#include <QItemSelection>
+
+class QWidget;
+class QTableView;
+
+//! \class DFBrowser_TreeLevelView
+//! This is a control to visualize the current selected item of OCAF tree view in table view.
+//! The table contains two colums: name and value. The information is similar the one OCAF tree view label
+//! content: children and attributes for the current label. Selection or double click of item emits
+//! signals about this event.
+class DFBrowser_TreeLevelView : public QObject
+{
+ Q_OBJECT
+public:
+
+ //! Constructor
+ Standard_EXPORT DFBrowser_TreeLevelView (QWidget* theParent);
+
+ //! Destructor
+ virtual ~DFBrowser_TreeLevelView() Standard_OVERRIDE {}
+
+ //! Returns parent control
+ QWidget* GetControl() const { return myMainWindow; }
+
+ //! Clear selection of the table view selection model
+ Standard_EXPORT void ClearSelection();
+
+ //! Returns true if this control may be filled by the index
+ //! It is possible if an item of the index is application, document or label
+ //! \param theIndex OCAF tree view model index
+ //! \return boolean result
+ Standard_EXPORT static bool ProcessItem (const QModelIndex& theIndex);
+
+ //! Init view by the first selected item in OCAF tree view
+ //! \param theSelected selected items
+ //! \param theDeselected deselected items
+ Standard_EXPORT void UpdateByTreeSelectionChanged (const QItemSelection& theSelected,
+ const QItemSelection& theDeselected);
+
+signals:
+
+ //! Signal about selection of an item in tree view
+ //! \param theIndex a tree view model index of selected item
+ void indexSelected (const QModelIndex& theIndex);
+
+ //! Signal about double click on an item in tree view
+ //! \param theIndex a tree view model index of selected item
+ void indexDoubleClicked (const QModelIndex& theIndex);
+
+private slots:
+
+ //! Listens table view selection model. Gets the first selected tree view model index and emit indexSelected signal.
+ //! \param theSelected a list of selected items
+ //! \param theDeselected a list of deselected items
+ void onTableSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
+
+ //! Listens table view double click. Gets clicked index and emit indexDoubleClicked signal.
+ //! \param theIndex a tree view model index of selected item
+ void onTableDoubleClicked (const QModelIndex& theIndex);
+
+private:
+
+ QWidget* myMainWindow; //!< parent control
+ QTableView* myTableView; //!< current view
+};
+#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 <DFBrowser_TreeLevelViewModel.hxx>
+
+#include <DFBrowser_Item.hxx>
+#include <DFBrowser_ItemRole.hxx>
+#include <DFBrowser_Module.hxx>
+#include <DFBrowser_Tools.hxx>
+#include <DFBrowser_TreeLevelView.hxx>
+
+#include <TDF_AttributeIterator.hxx>
+#include <TDF_ChildIterator.hxx>
+#include <TDF_Label.hxx>
+#include <TreeModel_ModelBase.hxx>
+
+#include <QIcon>
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void DFBrowser_TreeLevelViewModel::Init (const QModelIndex& theTreeIndex)
+{
+ myIndex = theTreeIndex;
+ TreeModel_ItemBasePtr anItem = TreeModel_ModelBase::GetItemByIndex (theTreeIndex);
+ myRowCount = anItem ? anItem->rowCount() : 0;
+ if (!anItem)
+ return;
+ EmitLayoutChanged();
+}
+
+// =======================================================================
+// function : GetTreeViewIndex
+// purpose :
+// =======================================================================
+QModelIndex DFBrowser_TreeLevelViewModel::GetTreeViewIndex (const QModelIndex& theIndex) const
+{
+ return myIndex.model()->index (theIndex.row(), 0, myIndex);
+}
+
+// =======================================================================
+// function : headerData
+// purpose :
+// =======================================================================
+QVariant DFBrowser_TreeLevelViewModel::headerData (int theSection, Qt::Orientation theOrientation, int theRole) const
+{
+ return (theOrientation == Qt::Horizontal && theRole == Qt::DisplayRole && theSection == 1) ? QVariant (tr ("Name")) : QVariant();
+}
+
+// =======================================================================
+// function : index
+// purpose :
+// =======================================================================
+QModelIndex DFBrowser_TreeLevelViewModel::index (int theRow, int theColumn, const QModelIndex& theParent) const
+{
+ if (!hasIndex(theRow, theColumn, theParent))
+ return QModelIndex();
+ return createIndex(theRow, theColumn);
+}
+
+// =======================================================================
+// function : data
+// purpose :
+// =======================================================================
+QVariant DFBrowser_TreeLevelViewModel::data (const QModelIndex& theIndex, int theRole) const
+{
+ QModelIndex anIndex = myIndex.model()->index (theIndex.row(), 0, myIndex);
+
+ if ( !anIndex.isValid() )
+ return QVariant ("undefined");
+
+ QVariant aValue;
+ TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex);
+ if (anIndex.column() == 0)
+ {
+ DFBrowser_ItemBasePtr aDBrowserItem = itemDynamicCast<DFBrowser_ItemBase> (anItemBase);
+ bool aPrevValue = aDBrowserItem->SetUseAdditionalInfo (false);
+ aValue = anItemBase->data (anIndex, theRole);
+ aDBrowserItem->SetUseAdditionalInfo (aPrevValue);
+ }
+ else { // column = 1
+ if (theRole == Qt::DisplayRole || theRole == Qt::ToolTipRole)
+ {
+ DFBrowser_ItemPtr anItem = itemDynamicCast<DFBrowser_Item> (anItemBase);
+ if (anItem)
+ aValue = anItem->GetAttributeInfo (DFBrowser_ItemRole_AdditionalInfo);
+ }
+ }
+ return aValue;
+}
+
+// =======================================================================
+// function : flags
+// purpose :
+// =======================================================================
+Qt::ItemFlags DFBrowser_TreeLevelViewModel::flags (const QModelIndex& theIndex) const
+{
+ if (!theIndex.isValid())
+ return 0;
+ Qt::ItemFlags aFlags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
+
+ return aFlags;
+}
--- /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 DFBrowser_TreeLevelViewModel_H
+#define DFBrowser_TreeLevelViewModel_H
+
+#include <Standard.hxx>
+#include <Standard_Macro.hxx>
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4127) // conditional expression is constant
+#endif
+#include <QAbstractTableModel>
+#include <QVariant>
+
+class QObject;
+
+//! \class DFBrowser_TreeLevelViewModel
+//! Tree Model of one level of OCAF tree view model. It is initialized by tree view index and
+//! contains children and attributes of this label.
+class DFBrowser_TreeLevelViewModel : public QAbstractTableModel
+{
+public:
+
+ //! Constructor
+ DFBrowser_TreeLevelViewModel (QObject* theParent) : QAbstractTableModel (theParent), myRowCount (0) {}
+
+ //! Destructor
+ virtual ~DFBrowser_TreeLevelViewModel() Standard_OVERRIDE {}
+
+ //! Reset OCAF tree model index
+ void Reset() { myIndex = QModelIndex(); }
+
+ //! Fills OCAF tree model index
+ //! \param theTreeIndex an index
+ Standard_EXPORT void Init (const QModelIndex& theTreeIndex);
+
+ //! Returns true if the index is filled
+ bool IsInitialized() const { return myIndex.isValid(); }
+
+ //! Return OCAF tree view model index on level defined by column of the parameter index
+ //! \param theIndex a tree level view model index
+ //! \return model index
+ Standard_EXPORT QModelIndex GetTreeViewIndex (const QModelIndex& theIndex) const;
+
+ //! Emits the layoutChanged signal from outside of this class
+ void EmitLayoutChanged() { emit layoutChanged(); }
+
+ //! It returns value only for DisplayRole for column = 1
+ //! \param theSection an index of value in the container
+ //! \param theIndex a model index
+ //! \param theRole a view role
+ //! \return value intepreted depending on the given role
+ Standard_EXPORT virtual QVariant headerData (int theSection, Qt::Orientation theOrientation,
+ int theRole = Qt::DisplayRole) const Standard_OVERRIDE;
+
+ //! Creates new model index
+ //! \param theRow the index row position
+ //! \param theColummn the index column position
+ //! \param theParent the parent index
+ //! \return the model index
+ Standard_EXPORT virtual QModelIndex index (int theRow, int theColumn,
+ const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE;
+
+ //! Returns item information(short) for display role.
+ //! \param theIndex a model index
+ //! \param theRole a view role
+ //! \return value intepreted depending on the given role
+ Standard_EXPORT virtual QVariant data (const QModelIndex& theIndex,
+ int theRole = Qt::DisplayRole) const Standard_OVERRIDE;
+
+ //! Returns Enabled and Selectable item for any index
+ //! \param theIndex a model index
+ //! \return flags
+ Standard_EXPORT virtual Qt::ItemFlags flags (const QModelIndex& theIndex) const Standard_OVERRIDE;
+
+ //! Returns number of rows
+ virtual int rowCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
+ { (void)theParent; return myRowCount; }
+
+ //! Returns 2 columns
+ virtual int columnCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
+ { (void)theParent; return 2; }
+
+private:
+
+ QModelIndex myIndex; //!< OCAF tree view model index
+ int myRowCount; //!< number of rows of item of treeview model index
+};
+#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 <DFBrowser_TreeModel.hxx>
+
+#include <DFBrowser_Item.hxx>
+#include <DFBrowser_ItemApplication.hxx>
+#include <DFBrowser_ItemDocument.hxx>
+#include <DFBrowser_Module.hxx>
+#include <DFBrowser_Window.hxx>
+#include <DFBrowserPane_Tools.hxx>
+#include <NCollection_List.hxx>
+
+#include <TDocStd_Application.hxx>
+#include <TDocStd_Document.hxx>
+#include <TNaming_Builder.hxx>
+#include <TNaming_NamedShape.hxx>
+
+#include <QAbstractItemModel>
+
+//#define REQUIRE_OCAF_REVIEW:19
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowser_TreeModel::DFBrowser_TreeModel (QObject* theParent, DFBrowser_Module* theModule)
+: TreeModel_ModelBase (theParent)
+{
+ m_pRootItem = DFBrowser_ItemApplication::CreateItem (TreeModel_ItemBasePtr());
+ DFBrowser_ItemApplicationPtr aRootItem = itemDynamicCast<DFBrowser_ItemApplication> (m_pRootItem);
+ aRootItem->SetModule (theModule);
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void DFBrowser_TreeModel::Init (const Handle(TDocStd_Application)& theApplication)
+{
+ DFBrowser_ItemApplicationPtr aRootItem = itemDynamicCast<DFBrowser_ItemApplication> (m_pRootItem);
+ Reset();
+ aRootItem->SetApplication (theApplication);
+ EmitLayoutChanged();
+}
+
+// =======================================================================
+// function : GetTDocStdApplication
+// purpose :
+// =======================================================================
+Handle(TDocStd_Application) DFBrowser_TreeModel::GetTDocStdApplication() const
+{
+ DFBrowser_ItemApplicationPtr aRootItem = itemDynamicCast<DFBrowser_ItemApplication> (m_pRootItem);
+ return aRootItem->GetApplication();
+}
+
+// =======================================================================
+// function : FindIndex
+// purpose :
+// =======================================================================
+QModelIndex DFBrowser_TreeModel::FindIndex (const TDF_Label& theLabel) const
+{
+//#define REQUIRE_OCAF_REVIEW:10 : start (GetReferences)
+ TDF_Label aRoot = theLabel.Root();
+
+ NCollection_List<TDF_Label> aLabels;
+ aLabels.Prepend (theLabel);
+ TDF_Label aFather = theLabel.Father();
+ if (!aFather.IsNull())
+ {
+ while (aFather != aRoot)
+ {
+ aLabels.Prepend (aFather);
+ aFather = aFather.Father();
+ }
+ }
+ bool aDocumentItemFound = false;
+ QModelIndex aParentIndex = index (0, 0);
+ TreeModel_ItemBasePtr aParentItem = TreeModel_ModelBase::GetItemByIndex (aParentIndex); // application item
+ // find document, where label of document item is equal to Root label
+ for (int aChildId = 0, aCount = aParentItem->rowCount(); aChildId < aCount; aChildId++)
+ {
+ QModelIndex anIndex = index (aChildId, 0, aParentIndex);
+ TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex);
+ DFBrowser_ItemDocumentPtr anItem = itemDynamicCast<DFBrowser_ItemDocument> (anItemBase);
+ if (anItem->GetLabel() == aRoot)
+ {
+ aParentItem = anItem;
+ aParentIndex = anIndex;
+ aDocumentItemFound = true;
+ break;
+ }
+ }
+ if (!aDocumentItemFound) // document is not found
+ return QModelIndex();
+
+ for (NCollection_List<TDF_Label>::const_iterator aLabelIt = aLabels.begin(); aLabelIt != aLabels.end()
+ && aParentIndex.isValid(); aLabelIt++)
+ {
+ const TDF_Label aLabel = *aLabelIt;
+ for (int aParentChildId = 0, aCount = aParentItem->rowCount(); aParentChildId < aCount; aParentChildId++)
+ {
+ QModelIndex anIndex = index (aParentChildId, 0, aParentIndex);
+ DFBrowser_ItemPtr anItem = itemDynamicCast<DFBrowser_Item> (TreeModel_ModelBase::GetItemByIndex (anIndex));
+ if (anItem->HasAttribute())
+ continue;
+
+ if (anItem->HasLabel() && anItem->GetLabel().IsEqual (aLabel))
+ {
+ aParentItem = anItem;
+ aParentIndex = anIndex;
+ break;
+ }
+ }
+ }
+ //#define REQUIRE_OCAF_REVIEW:10 : end
+ return aParentIndex;
+}
+
+// =======================================================================
+// function : FindIndexByPath
+// purpose :
+// =======================================================================
+QModelIndex DFBrowser_TreeModel::FindIndexByPath (const QStringList& theLabelEntries, const QString& theValue) const
+{
+ QModelIndex aFoundIndex;
+
+ QModelIndex aRootIndex = index (0, 0);
+ TreeModel_ItemBasePtr aRootItem = TreeModel_ModelBase::GetItemByIndex (aRootIndex); // application item
+ // find document, where label of document item is equal to Root label
+ for (int aDocItemId = 0, aNbDocItems = aRootItem->rowCount(); aDocItemId < aNbDocItems && !aFoundIndex.isValid(); aDocItemId++)
+ {
+ QModelIndex aParentIndex = index (aDocItemId, 0, aRootIndex);
+ if (!aParentIndex.isValid()) // OCAF document for this document item is not found
+ continue;
+ if (theLabelEntries.size() == 0)
+ {
+ aFoundIndex = aParentIndex;
+ break;
+ }
+ TreeModel_ItemBasePtr aParentItem = TreeModel_ModelBase::GetItemByIndex (aParentIndex);
+ for (int aPathId = 1, aPathCount = theLabelEntries.size(); aPathId < aPathCount + 1; aPathId++)
+ {
+ QString anEntry;
+ if (aPathId < aPathCount)
+ anEntry = theLabelEntries[aPathId];
+ else
+ anEntry = theValue;
+
+ bool aFoundEntry = false;
+ for (int aChildId = 0, aNbChildren = aParentItem->rowCount(); aChildId < aNbChildren; aChildId++)
+ {
+ QModelIndex anIndex = index (aChildId, 0, aParentIndex);
+ TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex);
+ DFBrowser_ItemPtr anItem = itemDynamicCast<DFBrowser_Item> (anItemBase);
+
+ if (aPathId == aPathCount && anItem->HasAttribute())
+ {
+ // processing attribute in theValue
+ DFBrowser_ItemApplicationPtr aRootAppItem = itemDynamicCast<DFBrowser_ItemApplication>(m_pRootItem);
+ QString anAttributeInfo = DFBrowser_Module::GetAttributeInfo (anItem->GetAttribute(), aRootAppItem->GetModule(),
+ Qt::DisplayRole, 0).toString();
+ if (anAttributeInfo == anEntry)
+ {
+ aParentItem = anItem;
+ aParentIndex = anIndex;
+ aFoundEntry = true;
+ break;
+ }
+ }
+ else if (anItem->HasLabel() &&
+ anEntry == QString (DFBrowserPane_Tools::GetEntry (anItem->GetLabel()).ToCString()))
+ {
+ aParentItem = anItem;
+ aParentIndex = anIndex;
+ aFoundEntry = true;
+ break;
+ }
+
+ }
+ if (!aFoundEntry) // an entry is not found on some level tree, find it in other documents
+ break;
+ else
+ aFoundIndex = aParentIndex;
+ }
+ }
+ return aFoundIndex;
+}
+
+// =======================================================================
+// function : FindIndexByAttribute
+// purpose :
+// =======================================================================
+QModelIndex DFBrowser_TreeModel::FindIndexByAttribute (Handle(TDF_Attribute) theAttribute) const
+{
+ QModelIndex aFoundIndex;
+ const TDF_Label aLabel = theAttribute->Label();
+
+ QModelIndex aParentIndex = FindIndex (aLabel);
+ if (!aParentIndex.isValid())
+ return aFoundIndex;
+
+ TreeModel_ItemBasePtr aParentItem = TreeModel_ModelBase::GetItemByIndex (aParentIndex);
+ for (int aChildId = 0, aCount = aParentItem->rowCount(); aChildId < aCount; aChildId++)
+ {
+ QModelIndex anIndex = index (aChildId, 0, aParentIndex);
+ TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex);
+ DFBrowser_ItemPtr anItem = itemDynamicCast<DFBrowser_Item> (anItemBase);
+ if (anItem->GetAttribute() == theAttribute)
+ {
+ aFoundIndex = anIndex;
+ break;
+ }
+ }
+ return aFoundIndex;
+}
+
+// =======================================================================
+// function : ConvertToIndices
+// purpose :
+// =======================================================================
+void DFBrowser_TreeModel::ConvertToIndices (const NCollection_List<TDF_Label>& theReferences,
+ QModelIndexList& theIndices)
+{
+//#define REQUIRE_OCAF_REVIEW:10 : start (GetReferences)
+ for (NCollection_List<TDF_Label>::Iterator aLabelItr (theReferences); aLabelItr.More(); aLabelItr.Next())
+ theIndices.append (FindIndex (aLabelItr.Value()));
+//#define REQUIRE_OCAF_REVIEW:10 : end
+}
+
+// =======================================================================
+// function : ConvertToIndices
+// purpose :
+// =======================================================================
+void DFBrowser_TreeModel::ConvertToIndices (const NCollection_List<Handle(TDF_Attribute)>& theReferences,
+ QModelIndexList& theIndices)
+{
+ for (NCollection_List<Handle(TDF_Attribute)>::Iterator anAttrItr (theReferences); anAttrItr.More(); anAttrItr.Next())
+ theIndices.append(FindIndexByAttribute (anAttrItr.Value()));
+}
+
+// =======================================================================
+// function : data
+// purpose :
+// =======================================================================
+QVariant DFBrowser_TreeModel::data (const QModelIndex& theIndex, int theRole) const
+{
+ if (theRole == Qt::BackgroundRole && myHighlightedIndices.contains (theIndex))
+ return DFBrowser_Window::LightHighlightColor();
+ return TreeModel_ModelBase::data (theIndex, theRole);
+}
--- /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 DFBrowser_TreeModel_H
+#define DFBrowser_TreeModel_H
+
+#include <DFBrowser_ItemBase.hxx>
+#include <NCollection_List.hxx>
+#include <Standard.hxx>
+#include <TDF_Label.hxx>
+#include <TDocStd_Application.hxx>
+#include <TreeModel_ModelBase.hxx>
+
+#include <QByteArray>
+#include <QHash>
+#include <QObject>
+
+class DFBrowser_Module;
+class DFBrowser_TreeModel;
+
+//! \class DFBrowser_TreeModel
+//! Tree model that has items described TDocStd_Application. The structure of items is the following:
+//! - <DFBrowser_ItemApplication>: for TDocStd_Application
+//! - <DFBrowser_ItemDocument>: for TDocStd_Document
+//!- <DFBrowser_Item>: for either TDF_Label or TDF_Attribute
+//! It is possible to visualize some items as highlighted.
+class DFBrowser_TreeModel : public TreeModel_ModelBase
+{
+ Q_OBJECT
+public:
+
+ //! Constructor
+ Standard_EXPORT DFBrowser_TreeModel (QObject* theParent, DFBrowser_Module* theModule);
+
+ //! Destructor
+ virtual ~DFBrowser_TreeModel() Standard_OVERRIDE {};
+
+ //! Fills the root item by the application
+ Standard_EXPORT void Init (const Handle(TDocStd_Application)& theApplication);
+
+ //! Returns an OCAF application or NULL
+ //! \return an application instance
+ Standard_EXPORT Handle(TDocStd_Application) GetTDocStdApplication() const;
+
+ //! Returns true if the tree view model contains highlighted items. This highlight is set manually.
+ bool HasHighlighted() { return !myHighlightedIndices.isEmpty(); }
+
+ //! Sets items of the indices highlighted in the model.
+ //! \param theIndices a list of tree model indices
+ void SetHighlighted (const QModelIndexList& theIndices = QModelIndexList()) { myHighlightedIndices = theIndices; }
+
+ //! Returns tree model index of the label item. It creates container of the label fathers and
+ //! starting from the rools label it descends by the found labels till the parameter label.
+ //! \param theLabel an OCAF label
+ //! \return model index if the value is found or Null model index
+ Standard_EXPORT QModelIndex FindIndex (const TDF_Label& theLabel) const;
+
+ //! Returns tree model index by list of label entries and (possible) attribute name.
+ //! \param theLabelEntries a container of label entries starting from root till searched label
+ //! \param theValue a label entry or attribute name
+ //! \return model index if the value is found or Null model index
+ Standard_EXPORT QModelIndex FindIndexByPath (const QStringList& theLabelEntries, const QString& theValue) const;
+
+ //! Returns tree model index of the attribute item. It gets the attributes label, find index of the label
+ //! and after find under this item attribute child item.
+ //! \param theAttribute an OCAF attribute
+ //! \return model index if the value is found or Null model index
+ Standard_EXPORT QModelIndex FindIndexByAttribute (Handle(TDF_Attribute) theAttribute) const;
+
+ //! Returns tree model indices for the labels.
+ Standard_EXPORT void ConvertToIndices (const NCollection_List<TDF_Label>& theReferences, QModelIndexList& theIndices);
+
+ //! Returns tree model indices of references
+ Standard_EXPORT void ConvertToIndices (const NCollection_List<Handle(TDF_Attribute)>& theReferences,
+ QModelIndexList& theIndices);
+
+ //! Returns the data stored under the given role for the current item
+ //! \param theIndex the item model index
+ //! \param theRole the item model role
+ Standard_EXPORT virtual QVariant data (const QModelIndex& theIndex,
+ int theRole = Qt::DisplayRole) const Standard_OVERRIDE;
+
+ //! Returns count of columns in the model
+ //! \param theParent an index of the parent item
+ //! \return integer value
+ virtual int columnCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
+ { (void)theParent; return 1; }
+
+private:
+
+ QModelIndexList myHighlightedIndices; //!< tree model indices that should be visualized as highlighted
+};
+
+#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 <DFBrowser_TreeView.hxx>
+
+// =======================================================================
+// function : SetPredefinedSize
+// purpose :
+// =======================================================================
+void DFBrowser_TreeView::SetPredefinedSize (int theDefaultWidth, int theDefaultHeight)
+{
+ myDefaultWidth = theDefaultWidth;
+ myDefaultHeight = theDefaultHeight;
+}
+
+// =======================================================================
+// function : sizeHint
+// purpose :
+// =======================================================================
+QSize DFBrowser_TreeView::sizeHint() const
+{
+ if (myDefaultWidth > 0 && myDefaultHeight > 0)
+ return QSize (myDefaultWidth, myDefaultHeight);
+ return QTreeView::sizeHint();
+}
--- /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 DFBrowser_TreeView_H
+#define DFBrowser_TreeView_H
+
+#include <Standard.hxx>
+#include <Standard_Macro.hxx>
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4127) // conditional expression is constant
+#endif
+#include <QTreeView>
+
+//! \class DFBrowser_TreeView
+//! Extended tree view control with possibility to set predefined size.
+class DFBrowser_TreeView : public QTreeView
+{
+public:
+
+ //! Constructor
+ Standard_EXPORT DFBrowser_TreeView (QWidget* theParent)
+ : QTreeView (theParent), myDefaultWidth (-1), myDefaultHeight (-1) {}
+
+ //! Destructor
+ virtual ~DFBrowser_TreeView() {}
+
+ //! Sets default size of control, that is used by the first control show
+ //! \param theDefaultWidth the width value
+ //! \param theDefaultHeight the height value
+ Standard_EXPORT void SetPredefinedSize(int theDefaultWidth, int theDefaultHeight);
+
+ //! Returns predefined size if both values are positive, otherwise parent size hint
+ Standard_EXPORT virtual QSize sizeHint() const Standard_OVERRIDE;
+
+private:
+
+ int myDefaultWidth; //!< default width, -1 if it should not be used
+ int myDefaultHeight; //!< default height, -1 if it should not be used
+};
+
+#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 <DFBrowser_Window.hxx>
+
+#include <AIS_InteractiveContext.hxx>
+#include <AIS_InteractiveObject.hxx>
+#include <AIS_ListOfInteractive.hxx>
+
+#include <CDF_Session.hxx>
+
+#include <DFBrowserPane_AttributePaneAPI.hxx>
+
+#include <DFBrowser_AttributePaneStack.hxx>
+#include <DFBrowser_AttributePaneType.hxx>
+#include <DFBrowser_DumpView.hxx>
+#include <DFBrowser_Item.hxx>
+#include <DFBrowser_Module.hxx>
+#include <DFBrowser_OpenApplication.hxx>
+#include <DFBrowser_PropertyPanel.hxx>
+#include <DFBrowser_SearchLine.hxx>
+#include <DFBrowser_SearchView.hxx>
+#include <DFBrowser_Shortcut.hxx>
+#include <DFBrowser_Thread.hxx>
+#include <DFBrowser_ThreadItemSearch.hxx>
+#include <DFBrowser_ThreadItemUsedShapesMap.hxx>
+#include <DFBrowser_Tools.hxx>
+#include <DFBrowser_TreeLevelLine.hxx>
+#include <DFBrowser_TreeLevelView.hxx>
+#include <DFBrowser_TreeModel.hxx>
+#include <DFBrowser_TreeView.hxx>
+
+#include <DFBrowserPane_AttributePaneSelector.hxx>
+#include <DFBrowserPane_SelectionKind.hxx>
+#include <DFBrowserPane_Tools.hxx>
+
+#include <OSD_Directory.hxx>
+#include <OSD_Environment.hxx>
+#include <OSD_Protection.hxx>
+
+#include <View_Displayer.hxx>
+#include <View_ToolBar.hxx>
+#include <View_Viewer.hxx>
+#include <View_Widget.hxx>
+#include <View_Window.hxx>
+
+#include <QAction>
+#include <QApplication>
+#include <QComboBox>
+#include <QDir>
+#include <QDockWidget>
+#include <QGridLayout>
+#include <QList>
+#include <QMainWindow>
+#if QT_VERSION < 0x050000
+#include <QMotifStyle>
+#endif
+#include <QItemSelectionModel>
+#include <QTabWidget>
+#include <QToolBar>
+#include <QTreeView>
+#include <QMenu>
+#include <QMessageBox>
+#include <QStatusBar>
+#include <QWidget>
+#if QT_VERSION < 0x050000
+#include <QWindowsStyle>
+#else
+#include <QStyleFactory>
+#endif
+
+const int DFBROWSER_DEFAULT_WIDTH = 1200;
+const int DFBROWSER_DEFAULT_HEIGHT = 850;
+const int DFBROWSER_DEFAULT_TREE_VIEW_WIDTH = 300;
+const int DFBROWSER_DEFAULT_TREE_VIEW_HEIGHT = 500;
+const int DFBROWSER_DEFAULT_VIEW_WIDTH = 400;
+const int DFBROWSER_DEFAULT_VIEW_HEIGHT = 300;
+
+const int DFBROWSER_DEFAULT_POSITION_X = 200;
+const int DFBROWSER_DEFAULT_POSITION_Y = 60;
+
+const int OCAF_BROWSER_COLUMN_WIDTH_0 = 300;
+const int DEFAULT_PROPERTY_PANEL_HEIGHT = 100;
+const int DEFAULT_BROWSER_HEIGHT = 800;
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowser_Window::DFBrowser_Window()
+: myModule (0), myParent (0), myPropertyPanel (0)
+{
+ myMainWindow = new QMainWindow (0);
+
+ // tree view
+ myTreeView = new DFBrowser_TreeView (myMainWindow);
+ myTreeView->setContextMenuPolicy (Qt::CustomContextMenu);
+ connect (myTreeView, SIGNAL (customContextMenuRequested (const QPoint&)),
+ this, SLOT (onTreeViewContextMenuRequested (const QPoint&)));
+ ((DFBrowser_TreeView*)myTreeView)->SetPredefinedSize (DFBROWSER_DEFAULT_TREE_VIEW_WIDTH,
+ DFBROWSER_DEFAULT_TREE_VIEW_HEIGHT);
+ myTreeView->setHeaderHidden (true);
+ myTreeView->setSortingEnabled (Standard_False);
+
+ QDockWidget* aTreeViewWidget = new QDockWidget (tr ("TreeView"), myMainWindow);
+ aTreeViewWidget->setFeatures (QDockWidget::NoDockWidgetFeatures);
+ aTreeViewWidget->setWidget (myTreeView);
+ myMainWindow->addDockWidget (Qt::LeftDockWidgetArea, aTreeViewWidget);
+ myMainWindow->setCorner (Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
+
+#if QT_VERSION < 0x050000
+ myTreeView->setStyle (new QWindowsStyle);
+#else
+ myTreeView->setStyle (QStyleFactory::create("Windows"));
+#endif
+
+ myTreeLevelLine = new DFBrowser_TreeLevelLine (myMainWindow);
+ connect (myTreeLevelLine->GetSearchLine(), SIGNAL (searchActivated()), this, SLOT (onSearchActivated()));
+ connect (myTreeLevelLine, SIGNAL (indexSelected (const QModelIndex&)),
+ this, SLOT (onTreeLevelLineSelected (const QModelIndex&)));
+ connect (myTreeLevelLine, SIGNAL (updateClicked()), this, SLOT (onUpdateClicked()));
+
+ QDockWidget* aTreeLineDockWidget = new QDockWidget (tr ("Tree Level Line"), myMainWindow);
+ aTreeLineDockWidget->setFeatures (QDockWidget::NoDockWidgetFeatures);
+ aTreeLineDockWidget->setWidget (myTreeLevelLine->GetControl());
+ myMainWindow->addDockWidget (Qt::TopDockWidgetArea, aTreeLineDockWidget);
+
+ // dump view window
+ QWidget* aDumpWidget = new QWidget (myMainWindow);
+ QVBoxLayout* aDumpLay = new QVBoxLayout (aDumpWidget);
+ aDumpLay->setMargin (0);
+ myDumpView = new DFBrowser_DumpView (aDumpWidget);
+ aDumpLay->addWidget (myDumpView->GetControl());
+ QDockWidget* aDumpDockWidget = new QDockWidget (tr ("Dump"), myMainWindow);
+ aDumpDockWidget->setWidget (aDumpWidget);
+ myMainWindow->addDockWidget (Qt::BottomDockWidgetArea, aDumpDockWidget);
+
+ // property panel
+ myPropertyPanel = new DFBrowser_PropertyPanel (myMainWindow);
+ DFBrowser_AttributePaneStack* anAttributePaneStack = myPropertyPanel->GetAttributesStack();
+ anAttributePaneStack->GetSearchView()->SetSearchLine (myTreeLevelLine->GetSearchLine());
+
+ connect (anAttributePaneStack->GetPaneSelector(),
+ SIGNAL (tableSelectionChanged (const QItemSelection&, const QItemSelection&, QItemSelectionModel*)),
+ this, SLOT (onPaneSelectionChanged (const QItemSelection&, const QItemSelection&, QItemSelectionModel*)));
+
+ DFBrowser_SearchView* aSearchView = anAttributePaneStack->GetSearchView();
+ connect (aSearchView, SIGNAL (pathSelected (const QStringList&, const QString&)),
+ this, SLOT (onSearchPathSelected (const QStringList&, const QString&)));
+ connect (aSearchView, SIGNAL (pathDoubleClicked (const QStringList&, const QString&)),
+ this, SLOT (onSearchPathDoubleClicked (const QStringList&, const QString&)));
+
+ DFBrowser_TreeLevelView* aLevelView = anAttributePaneStack->GetTreeLevelView();
+ connect (aLevelView, SIGNAL (indexSelected (const QModelIndex&)), this, SLOT (onLevelSelected (const QModelIndex&)));
+ connect (aLevelView, SIGNAL (indexDoubleClicked (const QModelIndex&)),
+ this, SLOT (onLevelDoubleClicked (const QModelIndex&)));
+
+ myMainWindow->setCentralWidget (myPropertyPanel->GetControl());
+
+ // view
+ myViewWindow = new View_Window (myMainWindow);
+ myViewWindow->GetView()->SetPredefinedSize (DFBROWSER_DEFAULT_VIEW_WIDTH, DFBROWSER_DEFAULT_VIEW_HEIGHT);
+
+ QDockWidget* aViewDockWidget = new QDockWidget (tr ("View"), myMainWindow);
+ aViewDockWidget->setWidget (myViewWindow);
+ myMainWindow->addDockWidget (Qt::BottomDockWidgetArea, aViewDockWidget);
+
+ QColor aHColor = DFBrowser_Window::LightHighlightColor();
+ myViewWindow->GetDisplayer()->SetAttributeColor (Quantity_Color(aHColor.red() / 255., aHColor.green() / 255.,
+ aHColor.blue() / 255., Quantity_TOC_RGB), View_PresentationType_Additional);
+ myMainWindow->tabifyDockWidget (aDumpDockWidget, aViewDockWidget);
+
+ myMainWindow->resize (DFBROWSER_DEFAULT_WIDTH, DFBROWSER_DEFAULT_HEIGHT);
+ myMainWindow->move (DFBROWSER_DEFAULT_POSITION_X, DFBROWSER_DEFAULT_POSITION_Y);
+
+ aTreeViewWidget->resize (DFBROWSER_DEFAULT_TREE_VIEW_WIDTH, DFBROWSER_DEFAULT_HEIGHT);
+
+ myThread = new DFBrowser_Thread (this);
+
+ myShortcut = new DFBrowser_Shortcut (myMainWindow);
+}
+
+// =======================================================================
+// function : Destructor
+// purpose :
+// =======================================================================
+DFBrowser_Window::~DFBrowser_Window()
+{
+ delete myModule;
+}
+
+// =======================================================================
+// function : SetParent
+// purpose :
+// =======================================================================
+void DFBrowser_Window::SetParent (void* theParent)
+{
+ myParent = (QWidget*)theParent;
+ if (myParent)
+ {
+ QLayout* aLayout = myParent->layout();
+ if (aLayout)
+ aLayout->addWidget (GetMainWindow());
+ }
+}
+
+// =======================================================================
+// function : UpdateContent
+// purpose :
+// =======================================================================
+void DFBrowser_Window::UpdateContent()
+{
+ TCollection_AsciiString aName = "TKDFBrowser";
+
+ if (myParameters->FindParameters (aName))
+ Init(myParameters->Parameters (aName));
+ else
+ Init(NCollection_List<Handle(Standard_Transient)>());
+
+ if (myParameters->FindFileNames(aName))
+ {
+ NCollection_List<TCollection_AsciiString> aFileNames = myParameters->FileNames (aName);
+ if (aFileNames.Extent() > 0) // only one document file might be opened
+ OpenFile (aFileNames.First());
+ myParameters->SetFileNames(aName, NCollection_List<TCollection_AsciiString>());
+ }
+ onUpdateClicked();
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void DFBrowser_Window::Init (const NCollection_List<Handle(Standard_Transient)>& theParameters)
+{
+ Handle(TDocStd_Application) anApplication;
+ if (myModule)
+ {
+ DFBrowser_TreeModel* anOCAFViewModel = dynamic_cast<DFBrowser_TreeModel*> (myModule->GetOCAFViewModel());
+ if (anOCAFViewModel)
+ anApplication = anOCAFViewModel->GetTDocStdApplication();
+ }
+ Handle(AIS_InteractiveContext) aContext;
+ if (myModule)
+ aContext = myModule->GetExternalContext();
+
+ bool aSameApplication = !anApplication.IsNull(), aSameContext = !aContext.IsNull();
+ for (NCollection_List<Handle(Standard_Transient)>::Iterator aParametersIt (theParameters);
+ aParametersIt.More(); aParametersIt.Next())
+ {
+ Handle(Standard_Transient) anObject = aParametersIt.Value();
+ // check if the object is an application
+ Handle(TDocStd_Application) anIApplication = Handle(TDocStd_Application)::DownCast (anObject);
+ if (!anIApplication.IsNull())
+ {
+ aSameApplication = anApplication == anIApplication;
+ if (!aSameApplication)
+ anApplication = anIApplication;
+ }
+ // check if the object is an interactive context
+ Handle(AIS_InteractiveContext) anIContext = Handle(AIS_InteractiveContext)::DownCast (anObject);
+ if (!anIContext.IsNull())
+ {
+ aSameContext = aContext == anIContext;
+ if (!aSameContext)
+ aContext = anIContext;
+ }
+ }
+ if (aSameApplication)
+ {
+ if (!aSameContext && !aContext.IsNull())
+ {
+ myModule->SetExternalContext (aContext);
+ myViewWindow->SetContext (View_ContextType_External, aContext);
+ }
+ return;
+ }
+
+ myModule = new DFBrowser_Module();
+ myModule->CreateViewModel (myMainWindow);
+
+ myPropertyPanel->GetAttributesStack()->SetModule (myModule);
+
+ // model should be set after the attribute pane stack is initialized by module
+ QAbstractItemModel* aModel = myModule->GetOCAFViewModel();
+ setOCAFModel (aModel);
+ myModule->SetOCAFViewSelectionModel (myTreeView->selectionModel());
+ myTreeLevelLine->GetSearchLine()->SetModule (myModule);
+ myPropertyPanel->GetAttributesStack()->GetSearchView()->InitModels();
+
+ myShortcut->SetModule (myModule);
+ myThread->SetModule (myModule);
+
+ connect (myModule, SIGNAL (beforeUpdateTreeModel()), this, SLOT (onBeforeUpdateTreeModel()));
+
+ if (!aContext.IsNull())
+ {
+ myModule->SetExternalContext (aContext);
+ myViewWindow->SetContext (View_ContextType_External, aContext);
+ }
+
+ myModule->SetApplication (anApplication);
+ //! expand first three levels: CUSTOM
+ QModelIndex aParentIndex = aModel->index (0, 0);
+ setExpandedLevels (myTreeView, aParentIndex, 3/*levels*/);
+
+ myThread->ProcessApplication();
+ myModule->SetInitialTreeViewSelection();
+}
+
+// =======================================================================
+// function : OpenFile
+// purpose :
+// =======================================================================
+void DFBrowser_Window::OpenFile (const TCollection_AsciiString& theFileName)
+{
+ //#define REQUIRE_OCAF_REVIEW:28 (check that previous application is correctly closed) : start
+
+ QApplication::setOverrideCursor (Qt::WaitCursor);
+ myThread->TerminateThread();
+
+ myTreeLevelLine->ClearHistory();
+ QItemSelectionModel* aSelectionModel = myModule->GetOCAFViewSelectionModel();
+ if (aSelectionModel)
+ {
+ aSelectionModel->clearSelection();
+ QModelIndex anIndex;
+ aSelectionModel->select (anIndex, QItemSelectionModel::ClearAndSelect);
+ }
+ ClearThreadCache();
+
+ myTreeLevelLine->ClearHistory();
+
+ DFBrowser_TreeModel* anOCAFViewModel = dynamic_cast<DFBrowser_TreeModel*> (myModule->GetOCAFViewModel());
+ anOCAFViewModel->Reset();
+
+ //! close previous documents to open new document
+ Handle(TDocStd_Application) anApplication;
+ if (CDF_Session::Exists())
+ {
+ Handle(CDF_Session) aSession = CDF_Session::CurrentSession();
+ if (!aSession.IsNull())
+ {
+ anApplication = Handle(TDocStd_Application)::DownCast (CDF_Session::CurrentSession()->CurrentApplication());
+ if (!anApplication.IsNull())
+ {
+ for (int aDocId = 1, aNbDocuments = anApplication->NbDocuments(); aDocId <= aNbDocuments; aDocId++)
+ {
+ Handle(TDocStd_Document) aDocument;
+ anApplication->GetDocument (aDocId, aDocument);
+ if (!aDocument.IsNull())
+ anApplication->Close (aDocument);
+ }
+ }
+ }
+ }
+ //! open new document
+ bool isSTEPFileName = false;
+ anApplication = DFBrowser_OpenApplication::OpenApplication (theFileName, isSTEPFileName);
+
+ if (myParent)
+ myParent->setObjectName (isSTEPFileName ? QString (TCollection_AsciiString (theFileName).ToCString()) : getWindowTitle());
+
+ if (anApplication.IsNull())
+ {
+ QApplication::restoreOverrideCursor();
+ QMessageBox::information (0, "Error", QString ("File %1 can't be opened by OCAF application")
+ .arg(TCollection_AsciiString (theFileName).ToCString()));
+ }
+ else {
+ myModule->SetApplication (anApplication);
+ //! expand first three levels: CUSTOM
+ QModelIndex aParentIndex = anOCAFViewModel->index (0, 0);
+ setExpandedLevels (myTreeView, aParentIndex, 3/*levels*/);
+
+ myThread->ProcessApplication();
+ myModule->SetInitialTreeViewSelection();
+ QApplication::restoreOverrideCursor();
+ }
+ //#define REQUIRE_OCAF_REVIEW:28 (check that previous application is correctly closed) : end
+}
+
+// =======================================================================
+// function : getWindowTitle
+// purpose :
+// =======================================================================
+QString DFBrowser_Window::getWindowTitle() const
+{
+ DFBrowser_TreeModel* anOCAFViewModel = dynamic_cast<DFBrowser_TreeModel*> (myModule->GetOCAFViewModel());
+ if (!anOCAFViewModel)
+ return "";
+
+ Handle(TDocStd_Application) anApplication = anOCAFViewModel->GetTDocStdApplication();
+ if (anApplication.IsNull() || anApplication->NbDocuments() == 0)
+ return "";
+
+ Handle(TDocStd_Document) aDocument;
+ anApplication->GetDocument (1, aDocument);
+ if (aDocument.IsNull() || !aDocument->IsSaved())
+ return "";
+
+ return DFBrowserPane_Tools::ToString (aDocument->GetPath());
+}
+
+// =======================================================================
+// function : setExpandedLevels
+// purpose :
+// =======================================================================
+void DFBrowser_Window::setExpandedLevels (QTreeView* theTreeView, const QModelIndex& theParentIndex, const int theLevels)
+{
+ if (theLevels <= 0)
+ return;
+
+ QAbstractItemModel* aModel = theTreeView->model();
+ if (!aModel)
+ return;
+
+ theTreeView->setExpanded (theParentIndex, true);
+ for (int aRowId = 0, aRows = aModel->rowCount (theParentIndex); aRowId < aRows; aRowId++)
+ setExpandedLevels (theTreeView, aModel->index (aRowId, 0, theParentIndex), theLevels - 1);
+}
+
+// =======================================================================
+// function : setOCAFModel
+// purpose :
+// =======================================================================
+void DFBrowser_Window::setOCAFModel (QAbstractItemModel* theModel)
+{
+ myTreeView->setModel (theModel);
+ myTreeView->setColumnWidth (0, OCAF_BROWSER_COLUMN_WIDTH_0);
+
+ QItemSelectionModel* aSelectionModel = new QItemSelectionModel (theModel);
+ myTreeView->setSelectionModel (aSelectionModel);
+
+ connect (aSelectionModel, SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
+ myTreeLevelLine, SLOT (OnTreeViewSelectionChanged (const QItemSelection&, const QItemSelection&)));
+ connect(aSelectionModel, SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
+ myDumpView, SLOT (OnTreeViewSelectionChanged (const QItemSelection&, const QItemSelection&)));
+ connect (aSelectionModel, SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
+ this, SLOT (onTreeViewSelectionChanged (const QItemSelection&, const QItemSelection&)));
+}
+
+// =======================================================================
+// function : onBeforeUpdateTreeModel
+// purpose :
+// =======================================================================
+void DFBrowser_Window::onBeforeUpdateTreeModel()
+{
+ myTreeLevelLine->ClearHistory();
+ ClearThreadCache();
+ myThread->ProcessApplication();
+}
+
+// =======================================================================
+// function : ClearThreadCache
+// purpose :
+// =======================================================================
+void DFBrowser_Window::ClearThreadCache()
+{
+ DFBrowser_ThreadItemUsedShapesMap::ClearSortedReferences (myModule);
+ DFBrowser_ThreadItemSearch::ClearValues (GetTreeLevelLine()->GetSearchLine());
+}
+
+// =======================================================================
+// function : SetWhiteBackground
+// purpose :
+// =======================================================================
+void DFBrowser_Window::SetWhiteBackground (QWidget* theControl)
+{
+ QPalette aPalette = theControl->palette();
+ aPalette.setColor (QPalette::All, QPalette::Foreground, Qt::white);
+ theControl->setPalette (aPalette);
+}
+
+// =======================================================================
+// function : TmpDirectory
+// purpose :
+// =======================================================================
+TCollection_AsciiString DFBrowser_Window::TmpDirectory()
+{
+ TCollection_AsciiString aTmpDir;
+#ifdef _WIN32
+ OSD_Environment anEnvironment ("TEMP");
+ aTmpDir = anEnvironment.Value();
+ if (aTmpDir.IsEmpty() )
+ {
+ anEnvironment.SetName("TMP");
+ aTmpDir = anEnvironment.Value();
+ if (aTmpDir.IsEmpty())
+ aTmpDir = "C:\\";
+ }
+ OSD_Path aTmpPath (aTmpDir);
+ OSD_Directory aTmpDirectory (aTmpPath);
+ if (!aTmpDirectory.Exists())
+ aTmpDirectory.Build(OSD_Protection());
+#else
+ OSD_Directory aTmpDirectory = OSD_Directory::BuildTemporary();
+ OSD_Path aTmpPath;
+ aTmpDirectory.Path (aTmpPath);
+ aTmpPath.SystemName(aTmpDir);
+#endif
+
+ return aTmpDir;
+}
+
+// =======================================================================
+// function : SingleSelected
+// purpose :
+// =======================================================================
+QModelIndex DFBrowser_Window::SingleSelected (const QModelIndexList& theIndices, const int theCellId,
+ const Qt::Orientation theOrientation)
+{
+ QModelIndexList aFirstColumnSelectedIndices;
+ for (QModelIndexList::const_iterator anIndicesIt = theIndices.begin(), aLast = theIndices.end();
+ anIndicesIt != aLast; anIndicesIt++)
+ {
+ QModelIndex anIndex = *anIndicesIt;
+ if ((theOrientation == Qt::Horizontal && anIndex.column() == theCellId) ||
+ (theOrientation == Qt::Vertical && anIndex.row() == theCellId))
+ aFirstColumnSelectedIndices.append (anIndex);
+ }
+ return aFirstColumnSelectedIndices.size() == 1 ? aFirstColumnSelectedIndices.first() : QModelIndex();
+}
+
+// =======================================================================
+// function : onTreeViewContextMenuRequested
+// purpose :
+// =======================================================================
+void DFBrowser_Window::onTreeViewContextMenuRequested (const QPoint& thePosition)
+{
+ QMenu* aMenu = new QMenu(GetMainWindow());
+ aMenu->addAction (createAction (tr ("Expand"), SLOT (onExpand())));
+ aMenu->addAction (createAction (tr ("Expand All"), SLOT (onExpandAll())));
+ aMenu->addAction (createAction (tr ("Collapse All"), SLOT (onCollapseAll())));
+
+ QPoint aPoint = myTreeView->mapToGlobal (thePosition);
+ aMenu->exec (aPoint);
+}
+
+// =======================================================================
+// function : createAction
+// purpose :
+// =======================================================================
+QAction* DFBrowser_Window::createAction (const QString& theText, const char* theSlot)
+{
+ QAction* anAction = new QAction (theText, GetMainWindow());
+ connect (anAction, SIGNAL (triggered(bool)), this, theSlot);
+ return anAction;
+}
+
+// =======================================================================
+// function : onExpand
+// purpose :
+// =======================================================================
+void DFBrowser_Window::onExpand()
+{
+ QApplication::setOverrideCursor (Qt::WaitCursor);
+
+ QItemSelectionModel* aSelectionModel = myTreeView->selectionModel();
+ QModelIndexList aSelectedIndices = aSelectionModel->selectedIndexes();
+ for (int aSelectedId = 0, aSize = aSelectedIndices.size(); aSelectedId < aSize; aSelectedId++)
+ {
+ int aLevels = 2;
+ setExpanded (myTreeView, aSelectedIndices[aSelectedId], true, aLevels);
+ }
+ QApplication::restoreOverrideCursor();
+}
+
+// =======================================================================
+// function : onExpandAll
+// purpose :
+// =======================================================================
+void DFBrowser_Window::onExpandAll()
+{
+ QApplication::setOverrideCursor (Qt::WaitCursor);
+
+ QItemSelectionModel* aSelectionModel = myTreeView->selectionModel();
+ QModelIndexList aSelectedIndices = aSelectionModel->selectedIndexes();
+ for (int aSelectedId = 0, aSize = aSelectedIndices.size(); aSelectedId < aSize; aSelectedId++)
+ {
+ int aLevels = -1;
+ setExpanded (myTreeView, aSelectedIndices[aSelectedId], true, aLevels);
+ }
+ QApplication::restoreOverrideCursor();
+}
+
+// =======================================================================
+// function : onCollapseAll
+// purpose :
+// =======================================================================
+void DFBrowser_Window::onCollapseAll()
+{
+ QItemSelectionModel* aSelectionModel = myTreeView->selectionModel();
+ QModelIndexList aSelectedIndices = aSelectionModel->selectedIndexes();
+ for (int aSelectedId = 0, aSize = aSelectedIndices.size(); aSelectedId < aSize; aSelectedId++) {
+ int aLevels = -1;
+ setExpanded (myTreeView, aSelectedIndices[aSelectedId], false, aLevels);
+ }
+}
+
+// =======================================================================
+// function : onTreeViewSelectionChanged
+// purpose :
+// =======================================================================
+void DFBrowser_Window::onTreeViewSelectionChanged (const QItemSelection& theSelected,
+ const QItemSelection& theDeselected)
+{
+ if (!myModule)
+ return;
+ // previuos selection should be cleared in the panel selectors
+ DFBrowser_AttributePaneStack* anAttributePaneStack = myPropertyPanel->GetAttributesStack();
+ anAttributePaneStack->GetPaneSelector()->ClearSelected();
+
+ myPropertyPanel->UpdateBySelectionChanged (theSelected, theDeselected);
+ anAttributePaneStack->GetTreeLevelView()->UpdateByTreeSelectionChanged (theSelected, theDeselected);
+
+ QModelIndexList aSelectedIndices = theSelected.indexes();
+ QModelIndex aSelectedIndex = DFBrowser_Window::SingleSelected (aSelectedIndices, 0);
+
+ myTreeView->scrollTo (aSelectedIndex);
+ View_Displayer* aDisplayer = myViewWindow->GetDisplayer();
+
+ aDisplayer->ErasePresentations (View_PresentationType_Additional, false);
+ aDisplayer->DisplayPresentation (findPresentation (aSelectedIndex), View_PresentationType_Main);
+}
+
+// =======================================================================
+// function : onSearchActivated
+// purpose :
+// =======================================================================
+void DFBrowser_Window::onSearchActivated()
+{
+ myPropertyPanel->GetAttributesStack()->SetPaneMode ((myTreeLevelLine->GetSearchLine()->Text().isEmpty()
+ ? DFBrowser_AttributePaneType_ItemView : DFBrowser_AttributePaneType_SearchView));
+}
+
+// =======================================================================
+// function : onPaneSelectionChanged
+// purpose :
+// =======================================================================
+void DFBrowser_Window::onPaneSelectionChanged (const QItemSelection&,
+ const QItemSelection&,
+ QItemSelectionModel* theModel)
+{
+ DFBrowserPane_AttributePaneAPI* anAttributePane = myPropertyPanel->GetAttributesStack()->GetCurrentPane();
+ switch (anAttributePane->GetSelectionKind (theModel))
+ {
+ case DFBrowserPane_SelectionKind_ExportToShapeViewer:
+ {
+ QItemSelectionModel* aSelectionModel = theModel;
+ QModelIndexList aSelectedIndices = aSelectionModel->selectedIndexes();
+ if (aSelectedIndices.size() != 1)
+ return;
+
+ TCollection_AsciiString aPluginName ("TKShapeView");
+ if (!myParameters->FindParameters (aPluginName))
+ return;
+
+ NCollection_List<Handle(Standard_Transient)> aParameters = myParameters->Parameters (aPluginName);
+ int aParametersCount = aParameters.Extent();
+ anAttributePane->GetSelectionParameters (aSelectionModel, aParameters);
+ if (aParametersCount != aParameters.Extent()) // some TShapes are added
+ {
+ myParameters->SetParameters (aPluginName, aParameters);
+ QMessageBox::information (0, "Information", QString ("TShape %1 is sent to %2 tool.")
+ .arg (DFBrowserPane_Tools::GetPointerInfo (aParameters.Last()).ToCString())
+ .arg (aPluginName.ToCString()));
+ }
+ return;
+ }
+ case DFBrowserPane_SelectionKind_ExportToBREP:
+ case DFBrowserPane_SelectionKind_LabelReferences:
+ case DFBrowserPane_SelectionKind_AttributeReferences:
+ default: break;
+ }
+
+ QItemSelectionModel* aSelectionModel = myTreeView->selectionModel();
+ QModelIndexList aSelectedIndices = aSelectionModel->selectedIndexes();
+ if (aSelectedIndices.size() != 1)
+ return;
+
+ // make the shape visualized
+ QModelIndex aSelectedIndex = aSelectedIndices.first();
+ View_Displayer* aDisplayer = myViewWindow->GetDisplayer();
+ aDisplayer->DisplayPresentation (findPresentation (aSelectedIndex), View_PresentationType_Main);
+
+ // highlight and scroll to the referenced item if it exists
+ Handle(TDF_Attribute) anAttribute = myModule->FindAttribute (aSelectedIndex);
+ NCollection_List<TDF_Label> aReferences;
+ Handle(Standard_Transient) aPresentation;
+//#define REQUIRE_OCAF_REVIEW:10 : start (GetReferences)
+ anAttributePane->GetReferences (anAttribute, aReferences, aPresentation);
+//#define REQUIRE_OCAF_REVIEW:10 : end
+ QModelIndexList anIndices;
+ DFBrowser_TreeModel* aTreeModel = dynamic_cast<DFBrowser_TreeModel*> (myTreeView->model());
+ if (!aReferences.IsEmpty())
+ aTreeModel->ConvertToIndices (aReferences, anIndices);
+ else {
+ NCollection_List<Handle(TDF_Attribute)> anAttributeReferences;
+ anAttributePane->GetAttributeReferences (anAttribute, anAttributeReferences, aPresentation);
+ aTreeModel->ConvertToIndices (anAttributeReferences, anIndices);
+ }
+ highlightIndices (anIndices);
+ // display either the reference presentation of the panel or find a presentation if the reference
+ // is an attribute
+ if (!aPresentation.IsNull())
+ aDisplayer->DisplayPresentation (aPresentation, View_PresentationType_Additional);
+ else {
+ AIS_ListOfInteractive aDisplayed;
+ findPresentations (anIndices, aDisplayed);
+ for (AIS_ListIteratorOfListOfInteractive aDisplayedIt (aDisplayed); aDisplayedIt.More(); aDisplayedIt.Next())
+ aDisplayer->DisplayPresentation (aDisplayedIt.Value(), View_PresentationType_Additional, false);
+
+ aDisplayer->UpdateViewer();
+ }
+}
+
+// =======================================================================
+// function : onTreeLevelLineSelected
+// purpose :
+// =======================================================================
+void DFBrowser_Window::onTreeLevelLineSelected (const QModelIndex& theIndex)
+{
+ QItemSelectionModel* aSelectionModel = myTreeView->selectionModel();
+ if (theIndex.isValid())
+ aSelectionModel->select (theIndex, QItemSelectionModel::ClearAndSelect);
+ else
+ aSelectionModel->clearSelection();
+}
+
+// =======================================================================
+// function : onUpdateClicked
+// purpose :
+// =======================================================================
+void DFBrowser_Window::onUpdateClicked()
+{
+ if (myModule)
+ myModule->UpdateTreeModel();
+}
+
+// =======================================================================
+// function : onSearchPathSelected
+// purpose :
+// =======================================================================
+void DFBrowser_Window::onSearchPathSelected (const QStringList& thePath, const QString& theValue)
+{
+ DFBrowser_TreeModel* aDFBrowserModel = dynamic_cast<DFBrowser_TreeModel*> (myTreeView->model());
+ const QModelIndex& anIndex = aDFBrowserModel->FindIndexByPath (thePath, theValue);
+
+ if (anIndex.isValid())
+ {
+ QModelIndexList anIndices;
+ anIndices.append (anIndex);
+ highlightIndices (anIndices);
+ }
+}
+
+// =======================================================================
+// function : onSearchPathDoubleClicked
+// purpose :
+// =======================================================================
+void DFBrowser_Window::onSearchPathDoubleClicked (const QStringList& thePath, const QString& theValue)
+{
+ DFBrowser_TreeModel* aDFBrowserModel = dynamic_cast<DFBrowser_TreeModel*> (myTreeView->model());
+ const QModelIndex& anIndex = aDFBrowserModel->FindIndexByPath (thePath, theValue);
+
+ QItemSelectionModel* aSelectionModel = myTreeView->selectionModel();
+ if (anIndex.isValid())
+ aSelectionModel->select (anIndex, QItemSelectionModel::ClearAndSelect);
+ else
+ aSelectionModel->clearSelection();
+}
+
+// =======================================================================
+// function : onLevelSelected
+// purpose :
+// =======================================================================
+void DFBrowser_Window::onLevelSelected (const QModelIndex& theIndex)
+{
+ if (!theIndex.isValid())
+ return;
+
+ QModelIndexList anIndices;
+ anIndices.append (theIndex);
+ highlightIndices (anIndices);
+ View_Displayer* aDisplayer = myViewWindow->GetDisplayer();
+ aDisplayer->ErasePresentations (View_PresentationType_Additional, false);
+ aDisplayer->DisplayPresentation (findPresentation (theIndex), View_PresentationType_Main);
+}
+
+// =======================================================================
+// function : onLevelDoubleClicked
+// purpose :
+// =======================================================================
+void DFBrowser_Window::onLevelDoubleClicked (const QModelIndex& theIndex)
+{
+ QItemSelectionModel* aSelectionModel = myTreeView->selectionModel();
+ if (theIndex.isValid())
+ aSelectionModel->select (theIndex, QItemSelectionModel::ClearAndSelect);
+ else
+ aSelectionModel->clearSelection();
+}
+
+// =======================================================================
+// function : highlightIndices
+// purpose :
+// =======================================================================
+void DFBrowser_Window::highlightIndices (const QModelIndexList& theIndices)
+{
+ QAbstractItemModel* aModel = myTreeView->model();
+ if (!aModel)
+ return;
+
+ DFBrowser_TreeModel* aTreeModel = dynamic_cast<DFBrowser_TreeModel*> (aModel);
+ if (!aTreeModel)
+ return;
+
+ aTreeModel->SetHighlighted (theIndices);
+
+ QModelIndex anIndexToScroll;
+ if (theIndices.size() > 0)
+ anIndexToScroll = theIndices.last(); // scroll to last selected index
+ else
+ {
+ // scroll to tree selected item
+ QItemSelectionModel* aSelectionModel = myTreeView->selectionModel();
+ QModelIndexList aSelectedIndices = aSelectionModel->selectedIndexes();
+ if (aSelectedIndices.size() == 1)
+ anIndexToScroll = aSelectedIndices.first();
+ }
+ if (anIndexToScroll.isValid())
+ myTreeView->scrollTo (anIndexToScroll);
+
+ aTreeModel->EmitLayoutChanged();
+}
+
+// =======================================================================
+// function : findPresentation
+// purpose :
+// =======================================================================
+Handle(AIS_InteractiveObject) DFBrowser_Window::findPresentation (const QModelIndex& theIndex)
+{
+ Handle(AIS_InteractiveObject) aPresentation;
+
+ QModelIndexList anIndices;
+ anIndices.append (theIndex);
+ AIS_ListOfInteractive aDisplayed;
+ findPresentations (anIndices, aDisplayed);
+ if (!aDisplayed.IsEmpty())
+ aPresentation = aDisplayed.First();
+
+ return aPresentation;
+}
+
+// =======================================================================
+// function : findPresentations
+// purpose :
+// =======================================================================
+void DFBrowser_Window::findPresentations (const QModelIndexList& theIndices, AIS_ListOfInteractive& thePresentations)
+{
+ for (int anIndexId = 0, aCount = theIndices.size(); anIndexId < aCount; anIndexId++)
+ {
+ Handle(AIS_InteractiveObject) aPresentation;
+ Handle(TDF_Attribute) anAttribute = myModule->FindAttribute (theIndices[anIndexId]);
+ if (anAttribute.IsNull())
+ continue;
+ DFBrowserPane_AttributePaneAPI* anAttributePane = myModule->GetAttributePane (anAttribute);
+ if (!anAttributePane)
+ continue;
+ aPresentation = Handle(AIS_InteractiveObject)::DownCast (anAttributePane->GetPresentation (anAttribute));
+ if (aPresentation.IsNull())
+ continue;
+
+ thePresentations.Append (aPresentation);
+ }
+}
+
+// =======================================================================
+// function : setExpanded
+// purpose :
+// =======================================================================
+void DFBrowser_Window::setExpanded (QTreeView* theTreeView, const QModelIndex& theIndex, const bool isExpanded,
+ int& theLevels)
+{
+ bool isToExpand = theLevels == -1 || theLevels > 0;
+ if (!isToExpand)
+ return;
+
+ theTreeView->setExpanded (theIndex, isExpanded);
+ if (theLevels != -1)
+ theLevels--;
+
+ QAbstractItemModel* aModel = theTreeView->model();
+ for (int aRowId = 0, aRows = aModel->rowCount (theIndex); aRowId < aRows; aRowId++)
+ {
+ int aLevels = theLevels;
+ setExpanded (theTreeView, aModel->index (aRowId, 0, theIndex), isExpanded, aLevels);
+ }
+}
--- /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 DFBrowser_Window_H
+#define DFBrowser_Window_H
+
+#include <AIS_InteractiveObject.hxx>
+#include <AIS_ListOfInteractive.hxx>
+#include <NCollection_List.hxx>
+#include <Standard.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TDF_Label.hxx>
+#include <TInspectorAPI_PluginParameters.hxx>
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4127) // conditional expression is constant
+#endif
+#include <QObject>
+#include <QItemSelection>
+#include <QMainWindow>
+#include <QModelIndexList>
+
+class DFBrowser_DumpView;
+class DFBrowser_Module;
+class DFBrowser_PropertyPanel;
+class DFBrowser_Shortcut;
+class DFBrowser_Thread;
+class DFBrowser_TreeLevelLine;
+
+class View_ToolBar;
+class View_Window;
+
+class QAbstractItemModel;
+class QAction;
+class QTreeView;
+class QWidget;
+
+//! \class DFBrowser_Window
+//! Window that unites all DFBrowser controls.
+//! External functionality : it processes plugin parameters, updates controls content and places itself in parent layout.
+//! It Synchronizes controls content depending on current selection.
+//! It shows context popup menu for OCAF tree view.
+class DFBrowser_Window : public QObject
+{
+ Q_OBJECT
+public:
+
+ //! Constructor
+ Standard_EXPORT DFBrowser_Window();
+
+ //! Destructor
+ Standard_EXPORT virtual ~DFBrowser_Window() Standard_OVERRIDE;
+
+ //! Appends main window into layout of the parent if the parent is child of QWidget
+ //! \param theParent a parent class
+ Standard_EXPORT void SetParent (void* theParent);
+
+ //! Sets parameters container, it should be used when the plugin is initialized or in update content
+ //! \param theParameters a parameters container
+ void SetParameters (const Handle(TInspectorAPI_PluginParameters)& theParameters) { myParameters = theParameters; }
+
+ //! Applyes parameters to Init controls, opens files if there are in parameters, updates OCAF tree view model
+ Standard_EXPORT void UpdateContent();
+
+ //! Fills controls of the plugin by parameters:
+ //! - Find TDocStd_Application and fills OCAF tree model if it differs from the current application
+ //! - Fine AIS_InteractiveObject and fills View if it if it differs from the current context
+ //! - If it is the first call, it creates module, start thread to cache application information, fills selection models
+ //! \param theParameters a parameters container
+ Standard_EXPORT void Init (const NCollection_List<Handle(Standard_Transient)>& theParameters);
+
+ //! Opens application by the name, it may be either OCAF document or STEP file.
+ //! Before opening it cleans tree view history, current selections, stop threads(if it was started),
+ //! reset OCAF tree view model. After opening document, it fills all controls by the created application.
+ //! \param theFileName a file name to be opened
+ Standard_EXPORT void OpenFile (const TCollection_AsciiString& theFileName);
+
+ //! Returns main control
+ QWidget* GetMainWindow() const { return myMainWindow; }
+
+ //! Returns the current module
+ DFBrowser_Module* GetModule() const { return myModule; }
+
+ //! Clears thread cache
+ Standard_EXPORT void ClearThreadCache();
+
+ //! Returns tree level line control
+ DFBrowser_TreeLevelLine* GetTreeLevelLine() const { return myTreeLevelLine; }
+
+ //! Change palette of the widget to have white foreground
+ //! \param theControl a widget to be modified
+ Standard_EXPORT static void SetWhiteBackground (QWidget* theControl);
+
+ //! Returns temporary directory defined by environment variables TEMP or TMP
+ //! \return string value
+ Standard_EXPORT static TCollection_AsciiString TmpDirectory();
+
+ //! Returns light highlight color
+ //! \returns Qt color
+ static QColor LightHighlightColor() { return QColor (229, 243, 255); }
+
+ //! Returns single selected item in the cell of given orientation. If the orientation is Horizontal,
+ //! in the cell id colum, one row should be selected.
+ //! \param theIndices a container of selected indices
+ //! \param theCellId column index if orientation is horizontal, row index otherwise
+ //! \param theOrientation an orientation to apply the cell index
+ //! \return model index from the list
+ Standard_EXPORT static QModelIndex SingleSelected (const QModelIndexList& theIndices, const int theCellId,
+ const Qt::Orientation theOrientation = Qt::Horizontal);
+private slots:
+
+ //! Cleans history in tree level line, clears cache of thread processing, starts threads for application
+ void onBeforeUpdateTreeModel();
+
+ //! Shows context menu for tree view selected item. It contains clear view or BREP operations items
+ //! \param thePosition a clicked point
+ void onTreeViewContextMenuRequested (const QPoint& thePosition);
+
+ //! Expand two next levels for all selected item
+ void onExpand();
+
+ //! Expand all levels for all selected items
+ void onExpandAll();
+
+ //! Collapse all levels for all selected items
+ void onCollapseAll();
+
+ //! Udpates all controls by changed selection in OCAF tree view
+ //! \param theSelected list of selected tree view items
+ //! \param theDeselected list of deselected tree view items
+ void onTreeViewSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
+
+ //! Changes attribute pane stack content depending on search control text
+ void onSearchActivated();
+
+ //! Processes selection change in attribute pane. Depending on selection kind, it will:
+ //! - export to shape viewer
+ //! - display presentation of the pane
+ //! - display references
+ void onPaneSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected,
+ QItemSelectionModel* theModel);
+
+ //! Selects the item in OCAF tree view
+ //! \param theIndex OCAF tree view index
+ void onTreeLevelLineSelected (const QModelIndex& theIndex);
+
+ //! Updates OCAF tree model
+ void onUpdateClicked();
+
+ //! Higlights OCAF tree model item
+ //! \param thePath a container of entries to the item
+ //! \param theValue a label entry or attribute name
+ void onSearchPathSelected (const QStringList& thePath, const QString& theValue);
+
+ //! Selects OCAF tree model item
+ //! \param thePath a container of entries to the item
+ //! \param theValue a label entry or attribute name
+ void onSearchPathDoubleClicked (const QStringList& thePath, const QString& theValue);
+
+ //! Higlights OCAF tree model item
+ //! \param theIndex an OCAF tree model index
+ void onLevelSelected (const QModelIndex& theIndex);
+
+ //! Selects OCAF tree model item
+ //! \param theIndex an OCAF tree model index
+ void onLevelDoubleClicked (const QModelIndex& theIndex);
+
+private:
+
+ //! Inits OCAF tree view with the given model
+ //! \param theModel a model
+ void setOCAFModel (QAbstractItemModel* theModel);
+
+ //! Sets expanded levels in OCAF tree view. Do recursive expand of items.
+ //! \param theTreeView an OCAF tree view
+ //! \param theParentIndex an index which children should be expanded
+ //! \param theLevels a number of levels to be expanded, or -1 for all levels
+ static void setExpandedLevels (QTreeView* theTreeView, const QModelIndex& theParentIndex, const int theLevels);
+
+ //! Marks items highlighted in OCAF tree view model and move view scroll to the first item
+ //! \param theIndices a container of OCAF tree view model indices
+ void highlightIndices (const QModelIndexList& theIndices);
+
+ //! Creates an action with the given text connected to the slot
+ //! \param theText an action text value
+ //! \param theSlot a listener of triggered signal of the new action
+ //! \return a new action
+ QAction* createAction (const QString& theText, const char* theSlot);
+
+ //! Returns candidate to be the window title. It is either name of opened STEP file or the application path
+ //! \return string value
+ QString getWindowTitle() const;
+
+protected:
+
+ //! Returns presentation for the OCAF tree model index. To do this, it uses attribute pane for this item
+ //! \param theIndex a model index
+ //! \return presentation or NULL
+ Handle(AIS_InteractiveObject) findPresentation (const QModelIndex& theIndex);
+
+ //! Returns presentations for the OCAF tree model indices. To do this, it uses attribute pane for this items
+ //! \param theIndex a model index
+ //! \return container of presentations or NULL
+ void findPresentations (const QModelIndexList& theIndices, AIS_ListOfInteractive& thePresentations);
+
+ //! Recursive items expanding in tree view staring from the index
+ //! \param theTreeView an OCAF tree view
+ //! \param theParentIndex an index which children should be expanded
+ //! \param isExpanded a boolean state if the item should be expanded or collapsed
+ //! \param theLevels a number of levels to be expanded, or -1 for all levels
+ static void setExpanded (QTreeView* theTreeView, const QModelIndex& theParentIndex, const bool isExpanded, int& theLevels);
+
+private:
+
+ DFBrowser_Module* myModule; //!< current module
+ QWidget* myParent; //!< widget, comes when Init window, the window control lays in the layout, updates window title
+ QMainWindow* myMainWindow; //!< main control for all components
+ DFBrowser_TreeLevelLine* myTreeLevelLine; //!< navigate line of tree levels to the selected item
+ QTreeView* myTreeView; //!< OCAF tree view
+ DFBrowser_PropertyPanel* myPropertyPanel; //!< property panel shows full information about attribute or search view
+ View_Window* myViewWindow; //!< V3d view to visualize presentations/references if it can be build for a selected item
+ DFBrowser_DumpView* myDumpView; //!< Text editor where "Dump" method output is shown
+ DFBrowser_Thread* myThread; //!< Threads manipulator, starting thread items, listens finalizing
+ DFBrowser_Shortcut* myShortcut; //!< Short cut processor, F5 - updates OCAF view model content
+ Handle(TInspectorAPI_PluginParameters) myParameters; //!< contains application, context, files that should be opened
+};
+
+#endif
--- /dev/null
+DFBrowser.qrc
+DFBrowser_AttributePaneStack.cxx
+DFBrowser_AttributePaneStack.hxx
+DFBrowser_AttributePaneType.hxx
+DFBrowser_Communicator.cxx
+DFBrowser_Communicator.hxx
+DFBrowser_DumpView.cxx
+DFBrowser_DumpView.hxx
+DFBrowser_HighlightDelegate.cxx
+DFBrowser_HighlightDelegate.hxx
+DFBrowser_Item.cxx
+DFBrowser_Item.hxx
+DFBrowser_ItemApplication.cxx
+DFBrowser_ItemApplication.hxx
+DFBrowser_ItemBase.cxx
+DFBrowser_ItemBase.hxx
+DFBrowser_ItemDocument.cxx
+DFBrowser_ItemDocument.hxx
+DFBrowser_ItemRole.hxx
+DFBrowser_Module.cxx
+DFBrowser_Module.hxx
+DFBrowser_OpenApplication.cxx
+DFBrowser_OpenApplication.hxx
+DFBrowser_PropertyPanel.cxx
+DFBrowser_PropertyPanel.hxx
+DFBrowser_SearchItemInfo.hxx
+DFBrowser_SearchLine.cxx
+DFBrowser_SearchLine.hxx
+DFBrowser_SearchLineModel.cxx
+DFBrowser_SearchLineModel.hxx
+DFBrowser_SearchView.cxx
+DFBrowser_SearchView.hxx
+DFBrowser_Shortcut.cxx
+DFBrowser_Shortcut.hxx
+DFBrowser_Thread.cxx
+DFBrowser_Thread.hxx
+DFBrowser_ThreadItem.hxx
+DFBrowser_ThreadItemSearch.cxx
+DFBrowser_ThreadItemSearch.hxx
+DFBrowser_ThreadItemUsedShapesMap.cxx
+DFBrowser_ThreadItemUsedShapesMap.hxx
+DFBrowser_Tools.cxx
+DFBrowser_Tools.hxx
+DFBrowser_TreeLevelLine.cxx
+DFBrowser_TreeLevelLine.hxx
+DFBrowser_TreeLevelLineDelegate.cxx
+DFBrowser_TreeLevelLineDelegate.hxx
+DFBrowser_TreeLevelLineModel.cxx
+DFBrowser_TreeLevelLineModel.hxx
+DFBrowser_TreeLevelView.cxx
+DFBrowser_TreeLevelView.hxx
+DFBrowser_TreeLevelViewModel.cxx
+DFBrowser_TreeLevelViewModel.hxx
+DFBrowser_TreeModel.cxx
+DFBrowser_TreeModel.hxx
+DFBrowser_TreeView.cxx
+DFBrowser_TreeView.hxx
+DFBrowser_Window.cxx
+DFBrowser_Window.hxx
--- /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 DFBROWSERPANE_H
+#define DFBROWSERPANE_H
+
+#ifdef DFBrowserPane_EXPORTS
+ #ifdef _WIN32
+ #define DFBROWSERPANE_EXPORT __declspec(dllexport)
+ #else
+ #define DFBROWSERPANE_EXPORT
+ #endif
+#else
+ #ifdef _WIN32
+ #define DFBROWSERPANE_EXPORT __declspec(dllimport)
+ #else
+ #define DFBROWSERPANE_EXPORT
+ #endif
+#endif
+
+#endif
--- /dev/null
+<!DOCTYPE RCC><RCC version="1.0">
+ <qresource>
+ <file>icons/attribute.png</file>
+ <file>icons/attribute_40x40.png</file>
+ <file>icons/export_shape.png</file>
+ <file>icons/folder_export.png</file>
+ <file>icons/label.png</file>
+ <file>icons/label_folder_16x16.png</file>
+ <file>icons/label_folder_40x40.png</file>
+ <file>icons/named_shape.png</file>
+ <file>icons/named_shape_40x40.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 <DFBrowserPane_AttributePane.hxx>
+#include <DFBrowserPane_ItemRole.hxx>
+#include <DFBrowserPane_TableView.hxx>
+#include <DFBrowserPane_Tools.hxx>
+#include <DFBrowserPane_AttributePaneModel.hxx>
+
+#include <AIS_InteractiveObject.hxx>
+
+#include <QGridLayout>
+#include <QHeaderView>
+#include <QItemSelectionModel>
+#include <QTableView>
+#include <QWidget>
+
+//#define REQUIRE_OCAF_REVIEW:3 : start
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowserPane_AttributePane::DFBrowserPane_AttributePane()
+: DFBrowserPane_AttributePaneAPI(), myMainWidget (0), myTableView (0), myPaneModel (0)
+{
+ myPaneModel = new DFBrowserPane_AttributePaneModel();
+
+ QList<QVariant> aHeaderValues;
+ aHeaderValues << "Values";
+ getPaneModel()->SetHeaderValues (aHeaderValues, Qt::Horizontal);
+
+ mySelectionModels.push_back (new QItemSelectionModel (myPaneModel));
+}
+
+// =======================================================================
+// function : GetWidget
+// purpose :
+// =======================================================================
+QWidget* DFBrowserPane_AttributePane::GetWidget (QWidget* theParent, const bool isToCreate)
+{
+ if (!myMainWidget && isToCreate)
+ myMainWidget = CreateWidget (theParent);
+ return myMainWidget;
+}
+
+// =======================================================================
+// function : CreateWidget
+// purpose :
+// =======================================================================
+QWidget* DFBrowserPane_AttributePane::CreateWidget (QWidget* theParent)
+{
+ QWidget* aMainWidget = new QWidget (theParent);
+ aMainWidget->setVisible (false);
+
+ myTableView = new DFBrowserPane_TableView (aMainWidget, getTableColumnWidths());
+ myTableView->SetModel (myPaneModel);
+ QTableView* aTableView = myTableView->GetTableView();
+ aTableView->setSelectionModel (mySelectionModels.front());
+ aTableView->setSelectionBehavior (QAbstractItemView::SelectRows);
+
+ QGridLayout* aLay = new QGridLayout (aMainWidget);
+ aLay->setContentsMargins (0, 0, 0, 0);
+ aLay->addWidget (myTableView);
+
+ return aMainWidget;
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void DFBrowserPane_AttributePane::Init (const Handle(TDF_Attribute)& theAttribute)
+{
+ QList<QVariant> aValues;
+ GetValues (theAttribute, aValues);
+ getPaneModel()->Init (aValues);
+}
+
+// =======================================================================
+// function : GetAttributeInfo
+// purpose :
+// =======================================================================
+QVariant DFBrowserPane_AttributePane::GetAttributeInfo (const Handle(TDF_Attribute)& theAttribute,
+ int theRole, int theColumnId)
+{
+ switch (theRole)
+ {
+ case DFBrowserPane_ItemRole_ShortInfo:
+ {
+ QList<QVariant> aValues;
+ GetShortAttributeInfo (theAttribute, aValues);
+ QStringList anInfoList;
+ for (QList<QVariant>::const_iterator aValuesIt = aValues.begin(); aValuesIt != aValues.end(); aValuesIt++)
+ anInfoList.append (aValuesIt->toString());
+ return QVariant (anInfoList.join (", "));
+ }
+ default:
+ return DFBrowserPane_AttributePane::GetAttributeInfoByType (theAttribute.IsNull() ? ""
+ : theAttribute->DynamicType()->Name(), theRole, theColumnId);
+ }
+}
+
+// =======================================================================
+// function : GetAttributeInfoByType
+// purpose :
+// =======================================================================
+QVariant DFBrowserPane_AttributePane::GetAttributeInfoByType (const Standard_CString& theAttributeName,
+ int theRole, int theColumnId)
+{
+ if (theColumnId != 0)
+ return QVariant();
+
+ switch (theRole)
+ {
+ case Qt::DisplayRole:
+ case Qt::ToolTipRole: return QVariant (theAttributeName);
+ case Qt::DecorationRole: return QIcon (":/icons/attribute.png");
+ case DFBrowserPane_ItemRole_Decoration_40x40: return QIcon (":/icons/attribute_40x40.png");
+ default: break;
+ }
+ return QVariant();
+}
+
+// =======================================================================
+// function : getPaneModel
+// purpose :
+// =======================================================================
+DFBrowserPane_AttributePaneModel* DFBrowserPane_AttributePane::getPaneModel() const
+{
+ return dynamic_cast<DFBrowserPane_AttributePaneModel*> (myPaneModel);
+}
+
+// =======================================================================
+// function : getTableColumnWidths
+// purpose :
+// =======================================================================
+QMap<int, int> DFBrowserPane_AttributePane::getTableColumnWidths() const
+{
+ QMap<int, int> aValues;
+ for (int aColumnId = 0, aCount = getPaneModel()->columnCount(); aColumnId < aCount; aColumnId++)
+ aValues.insert (aColumnId, DFBrowserPane_Tools::DefaultPanelColumnWidth (aColumnId));
+ return aValues;
+}
+//#define REQUIRE_OCAF_REVIEW:2 : end
--- /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 DFBrowserPane_AttributePane_H
+#define DFBrowserPane_AttributePane_H
+
+#include <DFBrowserPane_AttributePaneAPI.hxx>
+
+#include <TDF_Attribute.hxx>
+#include <TDF_Label.hxx>
+#include <Standard.hxx>
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4127) // conditional expression is constant
+#endif
+#include <QList>
+#include <QVariant>
+
+class DFBrowserPane_AttributePaneModel;
+class DFBrowserPane_TableView;
+
+class QAbstractTableModel;
+class QItemSelectionModel;
+
+//! \class DFBrowserPane_AttributePane
+//! \brief This is an extension of base attribute pane:
+//! - GetWidget() creates table view, view model and selection model. Table is vertical with one column.
+//! - Init() obtains GetValues and give it to the table view model
+//! If standard pane with such a table is used, only GetValues() should be redefined in children
+class DFBrowserPane_AttributePane : public DFBrowserPane_AttributePaneAPI
+{
+public:
+
+ //! Constructor
+ Standard_EXPORT DFBrowserPane_AttributePane();
+
+ //! Destructor
+ virtual ~DFBrowserPane_AttributePane() {}
+
+ //! Creates a new widget
+ //! \param theParent a parent widget
+ //! \return pane widget
+ Standard_EXPORT virtual QWidget* CreateWidget(QWidget* theParent);
+
+ //! Creates widget if it was not created and isToCreate is true
+ //! \param theParent a parent widget
+ //! \param isToCreate flag if the widget should be created if it is NULL
+ //! \return pane widget
+ Standard_EXPORT virtual QWidget* GetWidget(QWidget* theParent, const bool isToCreate) Standard_OVERRIDE;
+
+ //! Gets values of attribute using GetValues() and Init the view model
+ //! \param theAttribute a current attribute
+ Standard_EXPORT virtual void Init(const Handle(TDF_Attribute)& theAttribute) Standard_OVERRIDE;
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ virtual void GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
+ { (void)theAttribute; (void)theValues; };
+
+ //! Returns common information for the given attribute kind
+ //! \param theAttributeName a kind of attribute
+ //! \param theRole a role of information, used by tree model (e.g. DisplayRole, icon, background and so on)
+ //! \param theColumnId a tree model column
+ //! \return value, interpreted by tree model depending on the role
+ Standard_EXPORT static QVariant GetAttributeInfoByType(const Standard_CString& theAttributeName, int theRole, int theColumnId);
+
+ //! Returns information for the given attribute
+ //! \param theAttribute a current attribute
+ //! \param theRole a role of information, used by tree model (e.g. DisplayRole, icon, background and so on)
+ //! \param theColumnId a tree model column
+ //! \return value, interpreted by tree model depending on the role
+ Standard_EXPORT virtual QVariant GetAttributeInfo(const Handle(TDF_Attribute)& theAttribute, int theRole, int theColumnId);
+
+ //! Returns brief attribute information. In general case, it returns GetValues() result.
+ //! \param theAttribute a current attribute
+ //! \param theValues a result list of values
+ virtual void GetShortAttributeInfo (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
+ { GetValues(theAttribute, theValues); }
+
+ //! Returns list of selection models. In default implementation it contains a selection model for the table view
+ //! \returns container of models
+ virtual std::list<QItemSelectionModel*> GetSelectionModels() Standard_OVERRIDE { return mySelectionModels; }
+
+protected:
+
+ //! Returns converted table view model
+ Standard_EXPORT DFBrowserPane_AttributePaneModel* getPaneModel() const;
+
+ //! Returns converted table view
+ DFBrowserPane_TableView* getTableView() const { return myTableView; }
+
+ //! Defines widths of table columns
+ //! \return container of widths
+ Standard_EXPORT virtual QMap<int, int> getTableColumnWidths() const;
+
+protected:
+
+ QWidget* myMainWidget; //!< widget created in this pane
+ DFBrowserPane_TableView* myTableView; //!< table for visualization of attribute parameters
+ QAbstractTableModel* myPaneModel; //!< table view model. It is created before the table view, so we need to cache it
+ std::list<QItemSelectionModel*> mySelectionModels; //! selection models
+};
+
+#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.
+
+#ifndef DFBrowserPane_AttributePaneAPI_H
+#define DFBrowserPane_AttributePaneAPI_H
+
+#include <TDF_Attribute.hxx>
+#include <NCollection_List.hxx>
+#include <TDF_Label.hxx>
+#include <TDF_LabelList.hxx>
+#include <Standard.hxx>
+#include <Standard_Transient.hxx>
+
+#include <list>
+
+class QWidget;
+class QItemSelectionModel;
+
+//! \class DFBrowserPane_AttributePane
+//! \brief This is a base class for attribute pane. It defines methods that should be redefined in chindren.
+//! The kinds of information provided by the methods:
+//! - widget, a control that should be shown for this kind of attribute
+//! - Init method to fill control by the attribute context
+//! - selection models that are active, the application can connect to the models to react to selection change
+//! - presentation/references/attribute references of attribute custom information about this attribute
+class DFBrowserPane_AttributePaneAPI
+{
+public:
+
+ //! Constructor
+ DFBrowserPane_AttributePaneAPI() {}
+
+ //! Destructor
+ virtual ~DFBrowserPane_AttributePaneAPI() {}
+
+ //! Creates widget to visualize values of this kind of attribute
+ //! \param theParent a parent for the widget
+ //! \param isToCreate flag whether the widget should be created
+ virtual QWidget* GetWidget (QWidget* theParent, const bool isToCreate)
+ { (void)theParent; (void)isToCreate; return 0; }
+
+ //! Initializes the content of the pane by the parameter attribute
+ //! \param theAttribute an OCAF attribute
+ virtual void Init (const Handle(TDF_Attribute)& theAttribute) { (void)theAttribute; };
+
+ //! Returns selections models of the pane, if the selection is possible in the pane controls
+ virtual std::list<QItemSelectionModel*> GetSelectionModels() { return std::list<QItemSelectionModel*>(); }
+
+ //! Returns selection kind for the model, it may be General selection or Additional selection for example
+ //! \param theModel one of selection models provided by this pane
+ //! \return selection kind
+ virtual int GetSelectionKind (QItemSelectionModel* theModel) { (void)theModel; return -1; }
+
+ //! Returns selection parameters, that may be useful for communicate between tools
+ //! \param theModel one of selection models provided by this pane
+ //! \theParameters a container of parameters, might be extended depending on the pane state(e.g. selection)
+ virtual void GetSelectionParameters (QItemSelectionModel* theModel,
+ NCollection_List<Handle(Standard_Transient)>& theParameters)
+ { (void)theModel; (void)theParameters; }
+
+ //! Returns presentation of the attribute to be visualized in the view
+ //! \param theAttribute a current attribute
+ //! \return handle of presentation if the attribute has, to be visualized
+ virtual Handle(Standard_Transient) GetPresentation (const Handle(TDF_Attribute)& theAttribute)
+ { (void)theAttribute; return Handle(Standard_Transient)(); }
+
+ //! Returns container of Label references to the attribute
+ //! \param theAttribute a current attribute
+ //! \param theRefLabels a container of label references, to be selected in tree view
+ //! \param theRefPresentation handle of presentation for the references, to be visualized
+ virtual void GetReferences (const Handle(TDF_Attribute)& theAttribute,
+ NCollection_List<TDF_Label>& theRefLabels,
+ Handle(Standard_Transient)& theRefPresentation)
+ { (void)theAttribute; (void)theRefLabels; (void)theRefPresentation; }
+
+ //! Returns container of Attribute references to the attribute
+ //! \param theAttribute a current attribute
+ //! \param theRefAttributes a container of attribute references, to be selected in tree view
+ //! \param theRefPresentation handle of presentation for the references, to be visualized
+ virtual void GetAttributeReferences (const Handle(TDF_Attribute)& theAttribute,
+ NCollection_List<Handle(TDF_Attribute)>& theRefAttributes,
+ Handle(Standard_Transient)& theRefPresentation)
+ { (void)theAttribute; (void)theRefAttributes; (void)theRefPresentation; }
+};
+
+#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 <DFBrowserPane_AttributePaneCreator.hxx>
+
+#include <TDF_Attribute.hxx>
+
+#include <TDF_Reference.hxx>
+
+// the types are defined in TDF library
+#include <DFBrowserPane_TDFReference.hxx>
+#include <DFBrowserPane_TDFTagSource.hxx>
+
+#include <TDataStd_Current.hxx>
+#include <TDataStd_Name.hxx>
+#include <TDataStd_Comment.hxx>
+#include <TDataStd_Integer.hxx>
+#include <TDataStd_IntegerArray.hxx>
+#include <TDataStd_Real.hxx>
+#include <TDataStd_RealArray.hxx>
+#include <TDataStd_ExtStringArray.hxx>
+#include <TDataStd_UAttribute.hxx>
+#include <TDataStd_TreeNode.hxx>
+#include <TDataStd_Directory.hxx>
+#include <TDataStd_NoteBook.hxx>
+#include <TDataStd_Expression.hxx>
+#include <TDataStd_Relation.hxx>
+#include <TDataStd_Variable.hxx>
+#include <TDataStd_Tick.hxx>
+#include <TDataStd_AsciiString.hxx>
+#include <TDataStd_IntPackedMap.hxx>
+#include <TDataStd_IntegerList.hxx>
+#include <TDataStd_RealList.hxx>
+#include <TDataStd_ExtStringList.hxx>
+#include <TDataStd_BooleanList.hxx>
+#include <TDataStd_ReferenceList.hxx>
+#include <TDataStd_BooleanArray.hxx>
+#include <TDataStd_ReferenceArray.hxx>
+#include <TDataStd_ByteArray.hxx>
+#include <TDataStd_NamedData.hxx>
+
+#include <TDocStd_Modified.hxx>
+#include <TDocStd_Owner.hxx>
+#include <TDocStd_XLink.hxx>
+#include <TDocStd_XLinkRoot.hxx>
+#include <TPrsStd_AISViewer.hxx>
+#include <TPrsStd_AISPresentation.hxx>
+
+#include <TNaming_NamedShape.hxx>
+#include <TNaming_Naming.hxx>
+#include <TNaming_UsedShapes.hxx>
+
+#include <TFunction_Function.hxx>
+#include <TFunction_GraphNode.hxx>
+#include <TFunction_Scope.hxx>
+
+// the types are defined in TDataStd.cdl
+// Basic attributes
+#include <DFBrowserPane_TDataStdCurrent.hxx>
+#include <DFBrowserPane_TDataStdName.hxx>
+#include <DFBrowserPane_TDataStdComment.hxx>
+#include <DFBrowserPane_TDataStdInteger.hxx>
+#include <DFBrowserPane_TDataStdIntegerArray.hxx>
+#include <DFBrowserPane_TDataStdReal.hxx>
+#include <DFBrowserPane_TDataStdRealArray.hxx>
+#include <DFBrowserPane_TDataStdExtStringArray.hxx>
+#include <DFBrowserPane_TDataStdUAttribute.hxx>
+
+#include <DFBrowserPane_TDataStdTreeNode.hxx>
+#include <DFBrowserPane_TDataStdDirectory.hxx>
+#include <DFBrowserPane_TDataStdNoteBook.hxx>
+#include <DFBrowserPane_TDataStdExpression.hxx>
+#include <DFBrowserPane_TDataStdRelation.hxx>
+#include <DFBrowserPane_TDataStdVariable.hxx>
+
+//Extension
+#include <DFBrowserPane_TDataStdTick.hxx>
+#include <DFBrowserPane_TDataStdAsciiString.hxx>
+#include <DFBrowserPane_TDataStdIntPackedMap.hxx>
+// Lists:
+#include <DFBrowserPane_TDataStdIntegerList.hxx>
+#include <DFBrowserPane_TDataStdRealList.hxx>
+#include <DFBrowserPane_TDataStdExtStringList.hxx>
+#include <DFBrowserPane_TDataStdBooleanList.hxx>
+#include <DFBrowserPane_TDataStdReferenceList.hxx>
+
+// Arrays:
+#include <DFBrowserPane_TDataStdBooleanArray.hxx>
+#include <DFBrowserPane_TDataStdReferenceArray.hxx>
+#include <DFBrowserPane_TDataStdByteArray.hxx>
+#include <DFBrowserPane_TDataStdNamedData.hxx>
+
+// TDocStd attributes
+#include <DFBrowserPane_TDocStdModified.hxx>
+#include <DFBrowserPane_TDocStdOwner.hxx>
+#include <DFBrowserPane_TDocStdXLink.hxx>
+#include <DFBrowserPane_TDocStdXLinkRoot.hxx>
+
+// TPrsStd attributes
+#include <DFBrowserPane_TPrsStdAISViewer.hxx>
+#include <DFBrowserPane_TPrsStdAISPresentation.hxx>
+
+// TNaming attributes
+#include <DFBrowserPane_TNamingNamedShape.hxx>
+#include <DFBrowserPane_TNamingNaming.hxx>
+#include <DFBrowserPane_TNamingUsedShapes.hxx>
+
+// TFunction attributes
+#include <DFBrowserPane_TFunctionFunction.hxx>
+#include <DFBrowserPane_TFunctionGraphNode.hxx>
+#include <DFBrowserPane_TFunctionScope.hxx>
+
+//#define REQUIRE_OCAF_REVIEW:1 : start
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowserPane_AttributePaneAPI* DFBrowserPane_AttributePaneCreator::CreateAttributePane (
+ const Standard_CString& theAttributeName)
+{
+ DFBrowserPane_AttributePaneAPI* aPane = 0;
+ if (theAttributeName == STANDARD_TYPE (TDF_Reference)->Name())
+ aPane = new DFBrowserPane_TDFReference();
+ else if (theAttributeName == STANDARD_TYPE (TDF_TagSource)->Name())
+ aPane = new DFBrowserPane_TDFTagSource();
+ else if (theAttributeName == STANDARD_TYPE (TDataStd_Current)->Name()) // Basic attributes
+ aPane = new DFBrowserPane_TDataStdCurrent();
+ else if (theAttributeName == STANDARD_TYPE (TDataStd_Name)->Name())
+ aPane = new DFBrowserPane_TDataStdName();
+ else if (theAttributeName == STANDARD_TYPE (TDataStd_Comment)->Name())
+ aPane = new DFBrowserPane_TDataStdComment();
+ else if (theAttributeName == STANDARD_TYPE (TDataStd_Integer)->Name())
+ aPane = new DFBrowserPane_TDataStdInteger();
+ else if (theAttributeName == STANDARD_TYPE (TDataStd_IntegerArray)->Name())
+ aPane = new DFBrowserPane_TDataStdIntegerArray();
+ else if (theAttributeName == STANDARD_TYPE (TDataStd_Real)->Name())
+ aPane = new DFBrowserPane_TDataStdReal();
+ else if (theAttributeName == STANDARD_TYPE (TDataStd_RealArray)->Name())
+ aPane = new DFBrowserPane_TDataStdRealArray();
+ else if (theAttributeName == STANDARD_TYPE (TDataStd_ExtStringArray)->Name())
+ aPane = new DFBrowserPane_TDataStdExtStringArray();
+ else if (theAttributeName == STANDARD_TYPE (TDataStd_UAttribute)->Name())
+ aPane = new DFBrowserPane_TDataStdUAttribute();
+ else if (theAttributeName == STANDARD_TYPE (TDataStd_TreeNode)->Name()) // Attributes for organization
+ aPane = new DFBrowserPane_TDataStdTreeNode();
+ else if (theAttributeName == STANDARD_TYPE (TDataStd_Directory)->Name())
+ aPane = new DFBrowserPane_TDataStdDirectory();
+ else if (theAttributeName == STANDARD_TYPE (TDataStd_NoteBook)->Name()) // Other attributes
+ aPane = new DFBrowserPane_TDataStdNoteBook();
+ else if (theAttributeName == STANDARD_TYPE (TDataStd_Expression)->Name())
+ aPane = new DFBrowserPane_TDataStdExpression();
+ else if (theAttributeName == STANDARD_TYPE (TDataStd_Relation)->Name())
+ aPane = new DFBrowserPane_TDataStdRelation();
+ else if (theAttributeName == STANDARD_TYPE (TDataStd_Variable)->Name())
+ aPane = new DFBrowserPane_TDataStdVariable();
+ else if (theAttributeName == STANDARD_TYPE (TDataStd_Tick)->Name()) //Extension
+ aPane = new DFBrowserPane_TDataStdTick();
+ else if (theAttributeName == STANDARD_TYPE (TDataStd_AsciiString)->Name())
+ aPane = new DFBrowserPane_TDataStdAsciiString();
+ else if (theAttributeName == STANDARD_TYPE (TDataStd_IntPackedMap)->Name())
+ aPane = new DFBrowserPane_TDataStdIntPackedMap();
+ else if (theAttributeName == STANDARD_TYPE (TDataStd_IntegerList)->Name()) // Lists
+ aPane = new DFBrowserPane_TDataStdIntegerList();
+ else if (theAttributeName == STANDARD_TYPE (TDataStd_RealList)->Name())
+ aPane = new DFBrowserPane_TDataStdRealList();
+ else if (theAttributeName == STANDARD_TYPE (TDataStd_ExtStringList)->Name())
+ aPane = new DFBrowserPane_TDataStdExtStringList();
+ else if (theAttributeName == STANDARD_TYPE (TDataStd_BooleanList)->Name())
+ aPane = new DFBrowserPane_TDataStdBooleanList();
+ else if (theAttributeName == STANDARD_TYPE (TDataStd_ReferenceList)->Name())
+ aPane = new DFBrowserPane_TDataStdReferenceList();
+ else if (theAttributeName == STANDARD_TYPE (TDataStd_BooleanArray)->Name()) // Arrays:
+ aPane = new DFBrowserPane_TDataStdBooleanArray();
+ else if (theAttributeName == STANDARD_TYPE (TDataStd_ReferenceArray)->Name())
+ aPane = new DFBrowserPane_TDataStdReferenceArray();
+ else if (theAttributeName == STANDARD_TYPE (TDataStd_ByteArray)->Name())
+ aPane = new DFBrowserPane_TDataStdByteArray();
+ else if (theAttributeName == STANDARD_TYPE (TDataStd_NamedData)->Name())
+ aPane = new DFBrowserPane_TDataStdNamedData();
+ else if (theAttributeName == STANDARD_TYPE (TDocStd_Modified)->Name()) // TDocStd attributes
+ aPane = new DFBrowserPane_TDocStdModified();
+ else if (theAttributeName == STANDARD_TYPE (TDocStd_Owner)->Name())
+ aPane = new DFBrowserPane_TDocStdOwner();
+ else if (theAttributeName == STANDARD_TYPE (TDocStd_XLink)->Name())
+ aPane = new DFBrowserPane_TDocStdXLink();
+ else if (theAttributeName == STANDARD_TYPE (TDocStd_XLinkRoot)->Name())
+ aPane = new DFBrowserPane_TDocStdXLinkRoot();
+ else if (theAttributeName == STANDARD_TYPE (TPrsStd_AISViewer)->Name()) // TPrsStd attributes
+ aPane = new DFBrowserPane_TPrsStdAISViewer();
+ else if (theAttributeName == STANDARD_TYPE (TPrsStd_AISPresentation)->Name())
+ aPane = new DFBrowserPane_TPrsStdAISPresentation();
+ else if (theAttributeName == STANDARD_TYPE (TNaming_NamedShape)->Name()) // TNaming attributes
+ aPane = new DFBrowserPane_TNamingNamedShape();
+ else if (theAttributeName == STANDARD_TYPE (TNaming_Naming)->Name())
+ aPane = new DFBrowserPane_TNamingNaming();
+ else if (theAttributeName == STANDARD_TYPE (TNaming_UsedShapes)->Name())
+ aPane = new DFBrowserPane_TNamingUsedShapes();
+ else if (theAttributeName == STANDARD_TYPE (TFunction_Function)->Name()) // TFunction attributes
+ aPane = new DFBrowserPane_TFunctionFunction();
+ else if (theAttributeName == STANDARD_TYPE (TFunction_GraphNode)->Name())
+ aPane = new DFBrowserPane_TFunctionGraphNode();
+ else if (theAttributeName == STANDARD_TYPE (TFunction_Scope)->Name())
+ aPane = new DFBrowserPane_TFunctionScope();
+
+ return aPane;
+}
+
+//#define REQUIRE_OCAF_REVIEW : end
--- /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 DFBrowserPane_AttributePaneCreator_H
+#define DFBrowserPane_AttributePaneCreator_H
+
+#include <DFBrowserPane_AttributePaneAPI.hxx>
+#include <DFBrowserPane_AttributePaneCreatorAPI.hxx>
+#include <Standard.hxx>
+
+//! \class DFBrowserPane_AttributePaneCreator
+//! \brief This class can creates attribute pane for attribute name.
+class DFBrowserPane_AttributePaneCreator : public DFBrowserPane_AttributePaneCreatorAPI
+{
+public:
+
+ //! Constructor
+ DFBrowserPane_AttributePaneCreator() : DFBrowserPane_AttributePaneCreatorAPI() {}
+
+ //! Destructor
+ virtual ~DFBrowserPane_AttributePaneCreator() Standard_OVERRIDE {}
+
+public:
+
+ //! Creates attribute pane for TDF, TDataStd, TDocStd, TPrsStd, TNaming and TFunction attribute types
+ //! \param theAttributeName a standard type of attribute
+ //! \return an attribute pane if it can be created for this type
+ Standard_EXPORT virtual DFBrowserPane_AttributePaneAPI* CreateAttributePane(const Standard_CString& theAttributeName) Standard_OVERRIDE;
+};
+
+#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.
+
+#ifndef DFBrowserPane_AttributePaneCreatorAPI_H
+#define DFBrowserPane_AttributePaneCreatorAPI_H
+
+#include <Standard.hxx>
+#include <Standard_Macro.hxx>
+
+class DFBrowserPane_AttributePaneAPI;
+
+//! \class DFBrowserPane_AttributePaneCreatorAPI
+//! \brief An interface to create attribute panes by attribute name.
+class DFBrowserPane_AttributePaneCreatorAPI
+{
+public:
+
+ //! Constructor
+ DFBrowserPane_AttributePaneCreatorAPI() {}
+
+ //! Destructor
+ virtual ~DFBrowserPane_AttributePaneCreatorAPI() {}
+
+ //! Creates attribute pane for attribute types
+ //! \param theAttributeName a standard type of attribute
+ //! \return an attribute pane if it can be created for this type
+ virtual DFBrowserPane_AttributePaneAPI* CreateAttributePane (const Standard_CString& theAttributeName) = 0;
+};
+
+#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 <DFBrowserPane_AttributePaneModel.hxx>
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowserPane_AttributePaneModel::DFBrowserPane_AttributePaneModel (QObject* theParent)
+: QAbstractTableModel (theParent), myOrientation (Qt::Vertical), myColumnCount (1)
+{
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void DFBrowserPane_AttributePaneModel::Init (const QList<QVariant>& theValues)
+{
+ myValuesMap.clear();
+
+ if (myOrientation == Qt::Vertical)
+ {
+ int aRows = theValues.size() / myColumnCount;
+ QList<QVariant> aRowValues;
+ int aValuesIndex = 0;
+ for (int aRowId = 0; aRowId < aRows; aRowId++)
+ {
+ aRowValues.clear();
+ for (int aColumnId = 0; aColumnId < myColumnCount; aColumnId++)
+ {
+ aRowValues.append (theValues[aValuesIndex]);
+ aValuesIndex++;
+ }
+ myValuesMap[aRowId] = aRowValues;
+ }
+ }
+ else {
+ int aCols = theValues.size() / myColumnCount;
+ QList<QVariant> aColValues;
+ int aValuesIndex = 0;
+ for (int aColumnId = 0; aColumnId < aCols; aColumnId++)
+ {
+ aColValues.clear();
+ for (int aRowId = 0; aRowId < myColumnCount; aRowId++)
+ {
+ aColValues.append (theValues[aValuesIndex]);
+ aValuesIndex++;
+ }
+ myValuesMap[aColumnId] = aColValues;
+ }
+ }
+ emit layoutChanged();
+}
+
+// =======================================================================
+// function : SetHeaderValues
+// purpose :
+// =======================================================================
+void DFBrowserPane_AttributePaneModel::SetHeaderValues (const QList<QVariant>& theValues,
+ Qt::Orientation theOrientation)
+{
+ if (theOrientation == Qt::Horizontal)
+ myHorizontalHeaderValues = theValues;
+ else
+ myVerticalHeaderValues = theValues;
+}
+
+// =======================================================================
+// function : columnCount
+// purpose :
+// =======================================================================
+int DFBrowserPane_AttributePaneModel::columnCount (const QModelIndex&/* theParent*/) const
+{
+ return myOrientation == Qt::Vertical ? myColumnCount : myValuesMap.size();
+}
+
+// =======================================================================
+// function : rowCount
+// purpose :
+// =======================================================================
+int DFBrowserPane_AttributePaneModel::rowCount (const QModelIndex&/* theParent*/) const
+{
+ return myOrientation == Qt::Vertical ? myValuesMap.size() : myColumnCount;
+}
+
+// =======================================================================
+// function : data
+// purpose :
+// =======================================================================
+QVariant DFBrowserPane_AttributePaneModel::data (const QModelIndex& theIndex, int theRole) const
+{
+ QVariant aValue;
+
+ if (theRole == Qt::DisplayRole)
+ {
+ if (myOrientation == Qt::Vertical)
+ {
+ int aRowId = theIndex.row();
+ QList<QVariant> aRowValues = myValuesMap[aRowId];
+ aValue = aRowValues.at (theIndex.column());
+ }
+ else
+ {
+ int aColId = theIndex.column();
+ QList<QVariant> aColValues = myValuesMap[aColId];
+ aValue = aColValues.at (theIndex.row());
+ }
+ }
+ return aValue;
+}
+
+// =======================================================================
+// function : headerData
+// purpose :
+// =======================================================================
+QVariant DFBrowserPane_AttributePaneModel::headerData (int theSection, Qt::Orientation theOrientation,
+ int theRole) const
+{
+ QVariant aValue = QAbstractTableModel::headerData (theSection, theOrientation, theRole);
+ if (theRole == Qt::DisplayRole)
+ {
+ if (theOrientation == Qt::Horizontal)
+ {
+ if (!myHorizontalHeaderValues.empty() && theSection < myHorizontalHeaderValues.size())
+ aValue = myHorizontalHeaderValues[theSection];
+ }
+ else
+ { // vertical
+ if (!myVerticalHeaderValues.empty() && theSection < myVerticalHeaderValues.size())
+ aValue = myVerticalHeaderValues[theSection];
+ }
+ }
+ return aValue;
+}
--- /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 DFBrowserPane_AttributePaneModel_H
+#define DFBrowserPane_AttributePaneModel_H
+
+#include <Standard.hxx>
+#include <TDocStd_Document.hxx>
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4127) // conditional expression is constant
+#endif
+#include <QAbstractTableModel>
+#include <QList>
+#include <QVariant>
+
+//! \class DFBrowserPane_AttributePaneModel
+//! \brief This is an extension of table model to visualize a container of values
+//! It is possible to:
+//! - set orientation to interpretate the values.
+//! - set table view header values.
+//! Items of the view are enabled and selectable.
+class DFBrowserPane_AttributePaneModel : public QAbstractTableModel
+{
+public:
+
+ //! Constructor
+ Standard_EXPORT DFBrowserPane_AttributePaneModel(QObject* theParent = 0);
+
+ //! Destructor
+ virtual ~DFBrowserPane_AttributePaneModel() {}
+
+ //! Sets direction of the values applying, whether it should be placed by rows or by columns
+ //! \param theOrientation if horizontal, the values are applyed by rows, otherwise by columns
+ void SetOrientation (const Qt::Orientation& theOrientation) { myOrientation = theOrientation; }
+
+ //! Sets number of columns
+ //! \param theColumnCount a column count
+ void SetColumnCount (const int theColumnCount) { myColumnCount = theColumnCount; }
+
+ //! Fills the model with the values. Store the values in a cache.
+ //! \param theValues a container of values
+ Standard_EXPORT void Init(const QList<QVariant>& theValues);
+
+ //! Fills the model header values for orientation.
+ //! \param theValues a container of header text values
+ //! \param theOrientation an orientation of header
+ Standard_EXPORT void SetHeaderValues(const QList<QVariant>& theValues, Qt::Orientation theOrientation);
+
+ //! Returns number of columns, depending on orientation: myColumnCount or size of values container
+ //! \param theParent an index of the parent item
+ //! \return an integer value
+ Standard_EXPORT virtual int columnCount(const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE;
+
+ //! Returns number of rows, depending on orientation: myColumnCount or size of values container
+ //! \param theParent an index of the parent item
+ //! \return an integer value
+ Standard_EXPORT virtual int rowCount(const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE;
+
+ //! 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
+ Standard_EXPORT virtual QVariant data(const QModelIndex& theIndex, int theRole = Qt::DisplayRole) const Standard_OVERRIDE;
+
+ //! Returns content of the model index for the given role, it is obtainer from internal container of header values
+ //! It returns value only for DisplayRole.
+ //! \param theSection an index of value in the container
+ //! \param theIndex a model index
+ //! \param theRole a view role
+ //! \return value intepreted depending on the given role
+ Standard_EXPORT virtual QVariant headerData(int theSection, Qt::Orientation theOrientation, int theRole = Qt::DisplayRole) const Standard_OVERRIDE;
+
+ //! Returns flags for the item: ItemIsEnabled | Qt::ItemIsSelectable
+ //! \param theIndex a model index
+ //! \return flags
+ Qt::ItemFlags flags (const QModelIndex& theIndex) const
+ { return theIndex.isValid() ? Qt::ItemIsEnabled | Qt::ItemIsSelectable : Qt::NoItemFlags; }
+
+private:
+
+ Qt::Orientation myOrientation; //!< orientation how the values should fill the current table view
+ int myColumnCount; //!< number of table columns
+ QMap< int, QList<QVariant> > myValuesMap; //!< container of values, filled in Init(), used in data()
+ QList<QVariant> myHorizontalHeaderValues; //!< table horizontal header values
+ QList<QVariant> myVerticalHeaderValues; //!< table vertical header values
+};
+
+#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 <DFBrowserPane_AttributePaneSelector.hxx>
+
+#include <QItemSelectionModel>
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowserPane_AttributePaneSelector::DFBrowserPane_AttributePaneSelector (QObject* theParent)
+: QObject (theParent), mySendSelectionChangeBlocked (false)
+{
+}
+
+// =======================================================================
+// function : Destructor
+// purpose :
+// =======================================================================
+DFBrowserPane_AttributePaneSelector::~DFBrowserPane_AttributePaneSelector()
+{
+ SetCurrentSelectionModels (std::list<QItemSelectionModel*>());
+}
+
+// =======================================================================
+// function : SetCurrentSelectionModels
+// purpose :
+// =======================================================================
+void DFBrowserPane_AttributePaneSelector::SetCurrentSelectionModels (const std::list<QItemSelectionModel*>& theModels)
+{
+ for (std::list<QItemSelectionModel*>::const_iterator anModelsIt = mySelectionModels.begin(),
+ aLast = mySelectionModels.end(); anModelsIt != aLast; anModelsIt++)
+ disconnect (*anModelsIt, SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
+ this, SLOT (onTableSelectionChanged (const QItemSelection&, const QItemSelection&)));
+
+ mySelectionModels = theModels;
+ for (std::list<QItemSelectionModel*>::const_iterator anModelsIt = mySelectionModels.begin(),
+ aLast = mySelectionModels.end(); anModelsIt != aLast; anModelsIt++)
+ connect (*anModelsIt, SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
+ this, SLOT (onTableSelectionChanged (const QItemSelection&, const QItemSelection&)));
+}
+
+// =======================================================================
+// function : ClearSelected
+// purpose :
+// =======================================================================
+void DFBrowserPane_AttributePaneSelector::ClearSelected()
+{
+ mySendSelectionChangeBlocked = true;
+ for (std::list<QItemSelectionModel*>::const_iterator anModelsIt = mySelectionModels.begin(),
+ aLast = mySelectionModels.end(); anModelsIt != aLast; anModelsIt++)
+ (*anModelsIt)->clearSelection();
+ mySendSelectionChangeBlocked = false;
+}
+
+// =======================================================================
+// function :
+// purpose :
+// =======================================================================
+void DFBrowserPane_AttributePaneSelector::onTableSelectionChanged (const QItemSelection& theSelected,
+ const QItemSelection& theDeselected)
+{
+ if (mySendSelectionChangeBlocked)
+ return;
+
+ QItemSelectionModel* aModel = (QItemSelectionModel*)sender();
+ emit tableSelectionChanged (theSelected, theDeselected, aModel);
+}
--- /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 DFBrowserPane_AttributePaneSelector_H
+#define DFBrowserPane_AttributePaneSelector_H
+
+#include <Standard.hxx>
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4127) // conditional expression is constant
+#endif
+
+#include <QObject>
+#include <QItemSelection>
+#include <list>
+
+class QItemSelectionModel;
+
+//! \class DFBrowserPane_AttributePaneSelector
+//! \brief Container of active selection models. It connects to selection changed signal of the models and
+//! emits one signal for any selection.
+class DFBrowserPane_AttributePaneSelector : public QObject
+{
+ Q_OBJECT
+public:
+
+ //! Constructor
+ Standard_EXPORT DFBrowserPane_AttributePaneSelector(QObject* theParent);
+
+ //! Destructor
+ Standard_EXPORT virtual ~DFBrowserPane_AttributePaneSelector();
+
+ //! Fills the pane selection by the given models. Disconnect it from the previous model and connect to new models
+ //! \param theModels a list of selection models
+ Standard_EXPORT void SetCurrentSelectionModels(const std::list<QItemSelectionModel*>& theModels);
+
+ //! Clears selection in all selection models using block for selection changed flag
+ Standard_EXPORT void ClearSelected();
+
+signals:
+
+ //! Signal about selection changed in the model
+ //! \param theSelected selected items
+ //! \param theDeselected deselected items
+ //! \param theModel a selection model where the selection happens
+ void tableSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected,
+ QItemSelectionModel* theModel);
+protected slots:
+
+ //! Listens selectionChanged() of the model and emits signal tableSelectionChanged filled with the selection model
+ //! \param theSelected selected items
+ //! \param theDeselected deselected items
+ void onTableSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
+
+private:
+
+ std::list<QItemSelectionModel*> mySelectionModels; //!< container of selection models
+ bool mySendSelectionChangeBlocked; //!< flag is selection processing should not performed, avoid cyclic dependency
+};
+
+#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 <DFBrowserPane_HelperArray.hxx>
+#include <DFBrowserPane_TableView.hxx>
+
+#include <DFBrowserPane_AttributePaneModel.hxx>
+
+#include <QList>
+#include <QVariant>
+#include <QGridLayout>
+#include <QWidget>
+
+//#define REQUIRE_OCAF_REVIEW:6 : start
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowserPane_HelperArray::DFBrowserPane_HelperArray (DFBrowserPane_AttributePaneModel* theValuesModel)
+ : myValuesModel (theValuesModel)
+{
+ myBoundsModel = new DFBrowserPane_AttributePaneModel();
+
+ QList<QVariant> aHeaderValues;
+ aHeaderValues << "Bounds";
+ myBoundsModel->SetHeaderValues (aHeaderValues, Qt::Horizontal);
+}
+
+// =======================================================================
+// function : CreateWidget
+// purpose :
+// =======================================================================
+void DFBrowserPane_HelperArray::CreateWidget (QWidget* theParent, QWidget* theValuesView)
+{
+ myArrayBounds = new DFBrowserPane_TableView (theParent);
+ myArrayBounds->SetModel (myBoundsModel);
+ DFBrowserPane_TableView::SetFixedRowCount (2, myArrayBounds->GetTableView());
+
+ QGridLayout* aLay = new QGridLayout (theParent);
+ aLay->addWidget (myArrayBounds);
+ aLay->addWidget (theValuesView);
+ aLay->setRowStretch (1, 1);
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void DFBrowserPane_HelperArray::Init (const QList<QVariant>& theValues)
+{
+ QList<QVariant> aTmpValues;
+ aTmpValues << theValues[0] << theValues[1];
+ myBoundsModel->Init (aTmpValues);
+
+ aTmpValues.clear();
+ QList<QVariant> aHeaderValues;
+ int aLower = theValues[0].toInt();
+ for (int aValuesIt = 2, aSize = theValues.size(); aValuesIt < aSize; aValuesIt++)
+ {
+ aTmpValues << theValues[aValuesIt];
+ aHeaderValues << aLower + (aValuesIt - 2);
+ }
+ myValuesModel->SetHeaderValues (aHeaderValues, Qt::Vertical);
+ myValuesModel->Init (aTmpValues);
+}
+
+// =======================================================================
+// function : GetShortAttributeInfo
+// purpose :
+// =======================================================================
+void DFBrowserPane_HelperArray::GetShortAttributeInfo (const Handle(TDF_Attribute)& /*theAttribute*/,
+ QList<QVariant>& theValues)
+{
+ for (int aRowId = 0, aRows = myValuesModel->rowCount(); aRowId < aRows; aRowId++)
+ theValues.append (myValuesModel->data (myValuesModel->index (aRowId, 0)));
+}
+//#define REQUIRE_OCAF_REVIEW:6 : end
--- /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 DFBrowserPane_HelperArray_H
+#define DFBrowserPane_HelperArray_H
+
+#include <Standard.hxx>
+#include <TDF_Attribute.hxx>
+
+class DFBrowserPane_AttributePaneModel;
+class DFBrowserPane_TableView;
+
+class QWidget;
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4127) // conditional expression is constant
+#endif
+#include <QList>
+#include <QVariant>
+
+//! \class DFBrowserPane_HelperArray
+//! \brief Class that is used for list and array attributes. Two tables, the first for bounds, the second for values.
+//! Bound table contains two values: Lower and Upper values of the container.
+//! So, the first and the second values in GetValue() are these bounds, other values are used to fill usual table view.
+class DFBrowserPane_HelperArray
+{
+public:
+
+ //! Constructor
+ Standard_EXPORT DFBrowserPane_HelperArray(DFBrowserPane_AttributePaneModel* theValuesModel);
+
+ //! Destructor
+ virtual ~DFBrowserPane_HelperArray() {}
+
+ //! Creates bounds table view and grid layout, where the bounds view and the values view are shown
+ //! \param theParent a parent widget
+ //! \param theValuesView a view of values(table view filled by myValuesModel)
+ Standard_EXPORT void CreateWidget(QWidget* theParent, QWidget* theValuesView);
+
+ //! Fills bounds model by firsth and second values, fills values model by left values
+ //! \param theValues values to fill views
+ Standard_EXPORT void Init(const QList<QVariant>& theValues);
+
+ //! Returns only values of values view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of result values
+ Standard_EXPORT virtual void GetShortAttributeInfo(const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues);
+
+private:
+
+ DFBrowserPane_AttributePaneModel* myValuesModel; //!< model of table view
+ DFBrowserPane_AttributePaneModel* myBoundsModel; //!< model of bounds view
+ DFBrowserPane_TableView* myArrayBounds; //!< bounds view
+};
+#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 <DFBrowserPane_HelperExport.hxx>
+
+#include <BRepTools.hxx>
+#include <TCollection_AsciiString.hxx>
+
+#include <QApplication>
+#include <QFileDialog>
+
+// =======================================================================
+// function : AddShape
+// purpose :
+// =======================================================================
+void DFBrowserPane_HelperExport::AddShape (const TopoDS_Shape& theShape, const QModelIndexList& theIndices)
+{
+ for (int anIndicesIt = 0, aCount = theIndices.size(); anIndicesIt < aCount; anIndicesIt++)
+ myShapes[theIndices[anIndicesIt]] = theShape;
+}
+
+// =======================================================================
+// function : OnButtonPressed
+// purpose :
+// =======================================================================
+void DFBrowserPane_HelperExport::OnButtonPressed (const QModelIndex& theIndex)
+{
+ if (!myShapes.contains (theIndex))
+ return;
+
+ const TopoDS_Shape& aShape = myShapes[theIndex];
+
+ if (aShape.IsNull())
+ return;
+
+ QString aFileExtension = ".brep";
+
+ QString aFilter (tr ("BREP file (*%1*)").arg (aFileExtension));
+ QString aSelectedFilter;
+ QString aFileName = QFileDialog::getSaveFileName (0, tr ("Export shape to BREP file"), QString(),
+ aFilter, &aSelectedFilter);
+ if (!aFileName.isEmpty()) {
+ QApplication::setOverrideCursor (Qt::WaitCursor);
+ if (aFileName.indexOf (aFileExtension) < 0)
+ aFileName += QString (aFileExtension);
+
+ const TCollection_AsciiString anAsciiName(aFileName.toUtf8().data());
+ BRepTools::Write(aShape, anAsciiName.ToCString());
+ QApplication::restoreOverrideCursor();
+ }
+}
--- /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 DFBrowserPane_HelperExport_H
+#define DFBrowserPane_HelperExport_H
+
+#include <DFBrowserPane.hxx>
+#include <TopoDS_Shape.hxx>
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4127) // conditional expression is constant
+#endif
+#include <QObject>
+#include <QModelIndex>
+
+//! \class DFBrowserPane_HelperExport
+//! \brief It performs export to BREP of a shape by button is pressed
+//! It contains a conainer of shapes for model indices. If button is pressed for index where the
+//! shape exists, this shape is exported to BREP file.
+//! It contains a container of shapes, it is important to clear this helper after using.
+class DFBROWSERPANE_EXPORT DFBrowserPane_HelperExport : public QObject
+{
+ Q_OBJECT
+public:
+ //! Constructor
+ DFBrowserPane_HelperExport (QObject* theParent) { (void)theParent; }
+
+ //! Destructor
+ virtual ~DFBrowserPane_HelperExport() Standard_OVERRIDE {}
+
+ //! Clears current shapes
+ void Clear() { myShapes.clear(); }
+
+ //! Append a shape to be exported if pressed button on item from the given list
+ //! \param theShape a shape
+ //! \param theIndicies a list of indices for this shape
+ void AddShape (const TopoDS_Shape& theShape, const QModelIndexList& theIndices);
+
+ //! Returns whether the map of shapes contains a shape for the index
+ //! \param theIndex a model index
+ //! \return true if the map contains shape
+ bool HasShape (const QModelIndex& theIndex) const { return myShapes.contains (theIndex); }
+
+ //! Returns shape for the index
+ //! \param theIndex a model view index
+ //! \return a cached shape
+ const TopoDS_Shape& GetShape (const QModelIndex& theIndex) { return myShapes[theIndex]; }
+
+public slots:
+
+ //! Slot that processing button press for the model index
+ //! \param theIndex a model index
+ void OnButtonPressed (const QModelIndex& theIndex);
+
+private:
+ QMap<QModelIndex, TopoDS_Shape> myShapes; //!< a container of shapes
+};
+
+#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 <DFBrowserPane_HelperGroupContent.hxx>
+
+#include <QHBoxLayout>
+#include <QWidget>
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowserPane_HelperGroupContent::DFBrowserPane_HelperGroupContent (const QString& theTitle, QWidget* theParent,
+ QWidget* theControl)
+: QGroupBox (theTitle, theParent), myControl (0)
+{
+ setCheckable (true);
+
+ myControl = theControl;
+ QHBoxLayout* aLayout = new QHBoxLayout (this);
+ aLayout->addWidget (myControl);
+
+ connect (this, SIGNAL (clicked (bool)), this, SLOT (onChecked(bool)));
+
+ setChecked (false);
+ onChecked (isChecked());
+}
+
+// =======================================================================
+// function : onChecked
+// purpose :
+// =======================================================================
+void DFBrowserPane_HelperGroupContent::onChecked (bool theState)
+{
+ if (myControl)
+ myControl->setVisible (theState);
+}
--- /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 DFBrowserPane_HelperGroupContent_H
+#define DFBrowserPane_HelperGroupContent_H
+
+#include <Standard.hxx>
+#include <Standard_Macro.hxx>
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4127) // conditional expression is constant
+#endif
+#include <QGroupBox>
+
+class QWidget;
+
+//! \class DFBrowserPane_HelperGroupContent
+//! \brief Creates a check group box for the given control. If checked, the control is enabled,
+//! otherwise it sets it as disabled
+class DFBrowserPane_HelperGroupContent : public QGroupBox
+{
+Q_OBJECT
+public:
+
+ //! Constructor
+ Standard_EXPORT DFBrowserPane_HelperGroupContent (const QString& theTitle, QWidget* theParent, QWidget* theControl);
+
+ //! Destructor
+ virtual ~DFBrowserPane_HelperGroupContent() Standard_OVERRIDE {}
+
+protected slots:
+ //! Set enable/disable current control depending on check box state
+ //! \param theState state of the check box
+ void onChecked (bool theState);
+
+private:
+
+ QWidget* myControl; //!< the source control, that will be enabled/disabled
+};
+
+#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 <DFBrowserPane_ItemDelegateButton.hxx>
+
+#include <QAbstractItemModel>
+#include <QEvent>
+#include <QPainter>
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowserPane_ItemDelegateButton::DFBrowserPane_ItemDelegateButton (QObject* theParent, const QString& theIcon)
+: QStyledItemDelegate (theParent)
+{
+ myIcon = QIcon (theIcon);
+}
+
+// =======================================================================
+// function : paint
+// purpose :
+// =======================================================================
+void DFBrowserPane_ItemDelegateButton::paint (QPainter* thePainter, const QStyleOptionViewItem& theOption,
+ const QModelIndex& theIndex) const
+{
+ if (!myFreeRows.contains (theIndex.row()))
+ thePainter->drawPixmap (theOption.rect, myIcon.pixmap (20,20));
+}
+
+// =======================================================================
+// function : editorEvent
+// purpose :
+// =======================================================================
+bool DFBrowserPane_ItemDelegateButton::editorEvent (QEvent* theEvent, QAbstractItemModel* theModel,
+ const QStyleOptionViewItem& theOption, const QModelIndex& theIndex)
+{
+ if (theEvent->type() == QEvent::MouseButtonPress && !myFreeRows.contains (theIndex.row()))
+ emit buttonPressed (theIndex);
+
+ return QStyledItemDelegate::editorEvent (theEvent, theModel, theOption, theIndex);
+}
--- /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 DFBrowserPane_ItemDelegateButton_H
+#define DFBrowserPane_ItemDelegateButton_H
+
+#include <Standard.hxx>
+#include <Standard_Macro.hxx>
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4127) // conditional expression is constant
+#endif
+#include <QStyledItemDelegate>
+#include <QStyleOptionViewItem>
+#include <QModelIndex>
+#include <QString>
+#include <QIcon>
+
+class QObject;
+class QPainter;
+class QEvent;
+class QAbstractItemModel;
+
+//! \class DFBrowserPane_ItemDelegateButton
+//! \brief It paints an icon in all rows of the view in a separate column.
+//! It is possible to set rows where this icon is not shown.
+//! Click on the cell where the icon exists emits buttonPressed signal
+class DFBrowserPane_ItemDelegateButton : public QStyledItemDelegate
+{
+ Q_OBJECT
+public:
+
+ //! Constructor
+ Standard_EXPORT DFBrowserPane_ItemDelegateButton (QObject* theParent, const QString& theIcon);
+
+ //! Destructor
+ virtual ~DFBrowserPane_ItemDelegateButton() {}
+
+public:
+
+ //! Stores indices of rows where the icon should not be shown
+ //! \param theRows an indices of rows
+ void SetFreeRows (const QList<int>& theRows) { myFreeRows = theRows; }
+
+ //! Draw an icon in the cell
+ //! \param thePainter a painter
+ //! \param theOption a paint options
+ //! \param theIndex a view index
+ Standard_EXPORT virtual void paint (QPainter* thePainter, const QStyleOptionViewItem& theOption,
+ const QModelIndex& theIndex) const Standard_OVERRIDE;
+
+ //! Emits pressed signal if event type is mouse button pressed and there is icon for this index
+ //! After signal it calls the parent method
+ //! \param theEvent a processed event
+ //! \param theModel a current view model
+ //! \param theOption display options
+ //! \param theIndex an edited item
+ Standard_EXPORT virtual bool editorEvent (QEvent* theEvent, QAbstractItemModel* theModel,
+ const QStyleOptionViewItem& theOption, const QModelIndex& theIndex) Standard_OVERRIDE;
+signals:
+
+ //! Signal about button pressing
+ //! \param theIndex an index of clicked item
+ void buttonPressed (const QModelIndex& theIndex);
+
+private:
+
+ QIcon myIcon; //!< an item icon
+ QList<int> myFreeRows; //!< container of row indices where icon is not used
+};
+
+#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.
+
+#ifndef DFBrowserPane_ItemRole_H
+#define DFBrowserPane_ItemRole_H
+
+//! Custom item role for attribute pane
+enum DFBrowserPane_ItemRole
+{
+ DFBrowserPane_ItemRole_ShortInfo = Qt::UserRole + 1, //!< not full information of an attribute
+ DFBrowserPane_ItemRole_Decoration_40x40, //!< icon with greater size
+ DFBrowserPane_ItemRole_DisplayExtended, // extended item information (with additional information) for Qt::DisplayRole
+ DFBrowserPane_ItemRole_ToolTipExtended // exteneded tool tip information for Qt::ToolTipRole
+};
+
+#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.
+
+#ifndef DFBrowserPane_OcctEnumType_H
+#define DFBrowserPane_OcctEnumType_H
+
+//! Information for OCCT enumeration type
+enum DFBrowserPane_OcctEnumType
+{
+ DB_CONSTRAINT_TYPE = 0, //!< TDataXtd_ConstraintEnum values
+ DB_NAMING_TYPE = 1, //!< TNaming_NameType values
+ DB_SHAPE_TYPE = 2, //!< TopAbs_ShapeEnum values
+ DB_NS_TYPE = 3, //!< TNaming_Evolution values
+ DB_GEOM_TYPE = 4, //!< TDataXtd_GeometryEnum values
+ DB_DIMENSION_TYPE = 5, //!< TDataStd_RealEnum values
+ DB_MATERIAL_TYPE = 6, //!< Graphic3d_NameOfMaterial values
+ DB_DISPLAY_MODE = 7, //!< AIS_DisplayMode values
+ DB_ORIENTATION_TYPE = 8 //!< TopAbs_Orientation values
+};
+
+#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.
+
+#ifndef DFBrowserPane_SelectionKind_H
+#define DFBrowserPane_SelectionKind_H
+
+//! Selection kinds returned by attribute pane
+enum DFBrowserPane_SelectionKind
+{
+ DFBrowserPane_SelectionKind_ExportToBREP, //!< Click on "Export to BREP" button
+ DFBrowserPane_SelectionKind_ExportToShapeViewer, //!< Click on "Export to ShapeViewer" button
+ DFBrowserPane_SelectionKind_LabelReferences, //!< Select label's reference (reserved)
+ DFBrowserPane_SelectionKind_AttributeReferences //!< Select Attribute reference (reserved)
+};
+
+#endif // _DFBrowserPane_SelectionKind_H
--- /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 <DFBrowserPane_TDFReference.hxx>
+
+#include <DFBrowserPane_TableView.hxx>
+#include <DFBrowserPane_Tools.hxx>
+
+#include <TDF_Reference.hxx>
+
+#include <QVariant>
+#include <QTableView>
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDFReference::GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
+{
+ Handle(TDF_Reference) anAttribute = Handle(TDF_Reference)::DownCast (theAttribute);
+ if (!anAttribute.IsNull())
+ {
+ TDF_Label aLabel = anAttribute->Get();
+ theValues.append (DFBrowserPane_Tools::GetEntry (aLabel).ToCString());
+ }
+}
+
+// =======================================================================
+// function : GetReferences
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDFReference::GetReferences (const Handle(TDF_Attribute)& theAttribute,
+ NCollection_List<TDF_Label>& theRefLabels,
+ Handle(Standard_Transient)& /*theRefPresentation*/)
+{
+ Handle(TDF_Reference) anAttribute = Handle(TDF_Reference)::DownCast (theAttribute);
+ if (anAttribute.IsNull())
+ return;
+
+ QTableView* aTableView = getTableView()->GetTableView();
+ QItemSelectionModel* aSelectionModel = aTableView->selectionModel();
+ QModelIndexList aSelectedIndices = aSelectionModel->selectedIndexes();
+ if (aSelectedIndices.size() > 0)
+ theRefLabels.Append (anAttribute->Get());
+}
--- /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 DFBrowserPane_TDFReference_H
+#define DFBrowserPane_TDFReference_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+
+//! \class DFBrowserPane_TDFReference
+//! \brief The class to manipulate of TDF_Reference attribute
+class DFBrowserPane_TDFReference : public DFBrowserPane_AttributePane
+{
+public:
+ //! Constructor
+ DFBrowserPane_TDFReference() {}
+
+ //! Destructor
+ virtual ~DFBrowserPane_TDFReference() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+
+ //! Returns container of Label references to the attribute
+ //! \param theAttribute a current attribute
+ //! \param theRefLabels a container of label references, to be selected in tree view
+ //! \param theRefPresentation handle of presentation for the references, to be visualized
+ Standard_EXPORT virtual void GetReferences (const Handle(TDF_Attribute)& theAttribute,
+ NCollection_List<TDF_Label>& theRefLabels,
+ Handle(Standard_Transient)& theRefPresentation) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPane_TDFTagSource.hxx>
+
+#include <TDF_TagSource.hxx>
+
+#include <QVariant>
+#include <QWidget>
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDFTagSource::GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
+{
+ Handle(TDF_TagSource) anAttribute = Handle(TDF_TagSource)::DownCast (theAttribute);
+ if (anAttribute.IsNull())
+ return;
+ theValues.append (anAttribute->Get());
+}
+
--- /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 DFBrowserPane_TDFTagSource_H
+#define DFBrowserPane_TDFTagSource_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+
+//! \class DFBrowserPane_TDFTagSource
+//! \brief The class to manipulate of TDF_TagSource attribute
+class DFBrowserPane_TDFTagSource : public DFBrowserPane_AttributePane
+{
+public:
+ //! Constructor
+ DFBrowserPane_TDFTagSource() {}
+
+ //! Destructor
+ virtual ~DFBrowserPane_TDFTagSource() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPane_TDataStdAsciiString.hxx>
+
+#include <TDataStd_AsciiString.hxx>
+
+#include <QVariant>
+#include <QIcon>
+
+//#define REQUIRE_OCAF_REVIEW:4 : start
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdAsciiString::GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues)
+{
+ Handle(TDataStd_AsciiString) anAttribute = Handle(TDataStd_AsciiString)::DownCast (theAttribute);
+ if (!anAttribute.IsNull())
+ theValues.append (anAttribute->Get().ToCString());
+}
+//#define REQUIRE_OCAF_REVIEW:4 : end
--- /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 DFBrowserPane_TDataStdAsciiString_H
+#define DFBrowserPane_TDataStdAsciiString_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+
+//! \class DFBrowserPane_TDataStdAsciiString
+//! \brief The class to manipulate of TDataStd_AsciiString attribute
+class DFBrowserPane_TDataStdAsciiString : public DFBrowserPane_AttributePane
+{
+public:
+
+ //! Constructor
+ DFBrowserPane_TDataStdAsciiString() {}
+
+ //! Destructor
+ virtual ~DFBrowserPane_TDataStdAsciiString() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPane_TDataStdBooleanArray.hxx>
+#include <DFBrowserPane_TableView.hxx>
+#include <DFBrowserPane_AttributePaneModel.hxx>
+#include <DFBrowserPane_HelperArray.hxx>
+
+#include <TDataStd_BooleanArray.hxx>
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4127) // conditional expression is constant
+#endif
+
+#include <QVariant>
+#include <QWidget>
+#include <QGridLayout>
+
+//#define REQUIRE_OCAF_REVIEW:5 : start
+// =======================================================================
+// function : CreateWidget
+// purpose :
+// =======================================================================
+QWidget* DFBrowserPane_TDataStdBooleanArray::CreateWidget (QWidget* theParent)
+{
+ QWidget* aMainWidget = new QWidget (theParent);
+ myTableView = new DFBrowserPane_TableView (aMainWidget);
+ myTableView->SetModel (getPaneModel());
+
+ myArrayTableHelper.CreateWidget (aMainWidget, myTableView);
+
+ return aMainWidget;
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdBooleanArray::Init (const Handle(TDF_Attribute)& theAttribute)
+{
+ QList<QVariant> aValues;
+ GetValues (theAttribute, aValues);
+ myArrayTableHelper.Init (aValues);
+}
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdBooleanArray::GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues)
+{
+ Handle(TDataStd_BooleanArray) anAttribute = Handle(TDataStd_BooleanArray)::DownCast (theAttribute);
+ if (!anAttribute.IsNull())
+ {
+ theValues.append (anAttribute->Lower());
+ theValues.append (anAttribute->Upper());
+ for (int aValuesId = anAttribute->Lower(); aValuesId <= anAttribute->Upper(); aValuesId++)
+ theValues.append (anAttribute->Value (aValuesId));
+ }
+}
+
+// =======================================================================
+// function : GetShortAttributeInfo
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdBooleanArray::GetShortAttributeInfo (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues)
+{
+ QList<QVariant> aValues;
+ GetValues (theAttribute, aValues);
+ myArrayTableHelper.Init (aValues);
+ return myArrayTableHelper.GetShortAttributeInfo (theAttribute, theValues);
+}
+//#define REQUIRE_OCAF_REVIEW:5 : end
--- /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 DFBrowserPane_TDataStdBooleanArray_H
+#define DFBrowserPane_TDataStdBooleanArray_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+
+#include <DFBrowserPane_HelperArray.hxx>
+
+//! \class DFBrowserPane_TDataStdBooleanArray
+//! \brief The class to manipulate of TDataStd_BooleanArray attribute
+class DFBrowserPane_TDataStdBooleanArray : public DFBrowserPane_AttributePane
+{
+public:
+
+ //! Constructor
+ Standard_EXPORT DFBrowserPane_TDataStdBooleanArray() : DFBrowserPane_AttributePane(), myArrayTableHelper(getPaneModel()) {}
+
+ //! Destructor
+ Standard_EXPORT virtual ~DFBrowserPane_TDataStdBooleanArray() {}
+
+ //! Creates table view and call create widget of array table helper
+ //! \param theParent a parent widget
+ //! \return a new widget
+ Standard_EXPORT virtual QWidget* CreateWidget (QWidget* theParent) Standard_OVERRIDE;
+
+ //! Calls Init of array table helper
+ //! \param theAttribute a current attribute
+ Standard_EXPORT virtual void Init (const Handle(TDF_Attribute)& theAttribute) Standard_OVERRIDE;
+
+ //! Returns short attribute information using array table helper
+ //! \param theAttribute a current attribute
+ //! \param theValues container of output values
+ Standard_EXPORT virtual void GetShortAttributeInfo (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+
+private:
+
+ DFBrowserPane_HelperArray myArrayTableHelper; //!< common interface to fill array pane
+};
+
+#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 <DFBrowserPane_TDataStdBooleanList.hxx>
+
+#include <TDataStd_BooleanList.hxx>
+#include <TDataStd_ListIteratorOfListOfByte.hxx>
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4127) // conditional expression is constant
+#endif
+#include <QVariant>
+#include <QWidget>
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdBooleanList::GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
+{
+ Handle(TDataStd_BooleanList) anAttribute = Handle(TDataStd_BooleanList)::DownCast (theAttribute);
+ if (anAttribute.IsNull())
+ return;
+
+ for (TDataStd_ListIteratorOfListOfByte aBoolListIt (anAttribute->List()); aBoolListIt.More(); aBoolListIt.Next())
+ theValues.append (aBoolListIt.Value());
+}
--- /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 DFBrowserPane_TDataStdBooleanList_H
+#define DFBrowserPane_TDataStdBooleanList_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+
+//! \class DFBrowserPane_TDataStdBooleanList
+//! \brief The class to manipulate of TDataStd_BooleanList attribute
+class DFBrowserPane_TDataStdBooleanList : public DFBrowserPane_AttributePane
+{
+public:
+
+ //! Constructor
+ DFBrowserPane_TDataStdBooleanList() {}
+
+ //! Destructor
+ virtual ~DFBrowserPane_TDataStdBooleanList() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPane_TDataStdByteArray.hxx>
+#include <DFBrowserPane_TableView.hxx>
+#include <DFBrowserPane_AttributePaneModel.hxx>
+#include <DFBrowserPane_HelperArray.hxx>
+
+#include <TDataStd_ByteArray.hxx>
+
+#include <QVariant>
+#include <QWidget>
+
+// =======================================================================
+// function : CreateWidget
+// purpose :
+// =======================================================================
+QWidget* DFBrowserPane_TDataStdByteArray::CreateWidget (QWidget* theParent)
+{
+ QWidget* aMainWidget = new QWidget (theParent);
+ myTableView = new DFBrowserPane_TableView (aMainWidget);
+ myTableView->SetModel (getPaneModel());
+
+ myArrayTableHelper.CreateWidget (aMainWidget, myTableView);
+
+ return aMainWidget;
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdByteArray::Init (const Handle(TDF_Attribute)& theAttribute)
+{
+ QList<QVariant> aValues;
+ GetValues (theAttribute, aValues);
+ myArrayTableHelper.Init (aValues);
+}
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdByteArray::GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
+{
+ Handle(TDataStd_ByteArray) anAttribute = Handle(TDataStd_ByteArray)::DownCast (theAttribute);
+ if (anAttribute.IsNull())
+ return;
+
+ theValues.append (anAttribute->Lower());
+ theValues.append (anAttribute->Upper());
+ for (int aValueId = anAttribute->Lower(); aValueId <= anAttribute->Upper(); aValueId++)
+ theValues.append (anAttribute->Value (aValueId));
+}
+
+// =======================================================================
+// function : GetShortAttributeInfo
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdByteArray::GetShortAttributeInfo (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues)
+{
+ QList<QVariant> aValues;
+ GetValues (theAttribute, aValues);
+ myArrayTableHelper.Init (aValues);
+ return myArrayTableHelper.GetShortAttributeInfo (theAttribute, theValues);
+}
--- /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 DFBrowserPane_TDataStdByteArray_H
+#define DFBrowserPane_TDataStdByteArray_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+
+#include <DFBrowserPane_HelperArray.hxx>
+
+//! \class DFBrowserPane_TDataStdByteArray
+//! \brief The class to manipulate of TDataStd_ByteArra attribute
+class DFBrowserPane_TDataStdByteArray : public DFBrowserPane_AttributePane
+{
+public:
+
+ //! Constructor
+ Standard_EXPORT DFBrowserPane_TDataStdByteArray() : DFBrowserPane_AttributePane(), myArrayTableHelper(getPaneModel()) {}
+
+ //! Destructor
+ Standard_EXPORT virtual ~DFBrowserPane_TDataStdByteArray() {}
+
+ //! Creates table view and call create widget of array table helper
+ //! \param theParent a parent widget
+ //! \return a new widget
+ Standard_EXPORT virtual QWidget* CreateWidget (QWidget* theParent) Standard_OVERRIDE;
+
+ //! Calls Init of array table helper
+ //! \param theAttribute a current attribute
+ Standard_EXPORT virtual void Init (const Handle(TDF_Attribute)& theAttribute) Standard_OVERRIDE;
+
+ //! Returns short attribute information using array table helper
+ //! \param theAttribute a current attribute
+ //! \param theValues container of output values
+ Standard_EXPORT virtual void GetShortAttributeInfo (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+
+private:
+
+ DFBrowserPane_HelperArray myArrayTableHelper; //!< common interface to fill array pane
+};
+
+#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 <DFBrowserPane_TDataStdComment.hxx>
+#include <DFBrowserPane_Tools.hxx>
+
+#include <TDataStd_Comment.hxx>
+
+#include <QVariant>
+#include <QWidget>
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdComment::GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
+{
+ Handle(TDataStd_Comment) anAttribute = Handle(TDataStd_Comment)::DownCast (theAttribute);
+ if (anAttribute.IsNull())
+ return;
+ theValues.append (DFBrowserPane_Tools::ToString (anAttribute->Get()));
+}
--- /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 DFBrowserPane_TDataStdComment_H
+#define DFBrowserPane_TDataStdComment_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+
+//! \class DFBrowserPane_TDataStdComment
+//! \brief The class to manipulate of TDataStd_Comment attribute
+class DFBrowserPane_TDataStdComment : public DFBrowserPane_AttributePane
+{
+public:
+ //! Constructor
+ DFBrowserPane_TDataStdComment() {}
+
+ //! Destructor
+ virtual ~DFBrowserPane_TDataStdComment() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPane_TDataStdCurrent.hxx>
+#include <DFBrowserPane_Tools.hxx>
+
+#include <TDataStd_Current.hxx>
+
+#include <QVariant>
+#include <QWidget>
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdCurrent::GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
+{
+ Handle(TDataStd_Current) anAttribute = Handle(TDataStd_Current)::DownCast (theAttribute);
+ if (anAttribute.IsNull())
+ return;
+ theValues.append (DFBrowserPane_Tools::GetEntry (anAttribute->GetLabel()).ToCString());
+}
--- /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 DFBrowserPane_TDataStdCurrent_H
+#define DFBrowserPane_TDataStdCurrent_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+
+//! \class DFBrowserPane_TDataStdCurrent
+//! \brief The class to manipulate of TDataStd_Current attribute
+class DFBrowserPane_TDataStdCurrent : public DFBrowserPane_AttributePane
+{
+public:
+ //! Constructor
+ DFBrowserPane_TDataStdCurrent() {}
+
+ //! Destructor
+ virtual ~DFBrowserPane_TDataStdCurrent() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPane_TDataStdDirectory.hxx>
+
+#include <TDataStd_Directory.hxx>
+
+#include <QVariant>
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdDirectory::GetValues (const Handle(TDF_Attribute)&, QList<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 DFBrowserPane_TDataStdDirectory_H
+#define DFBrowserPane_TDataStdDirectory_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+
+//! \class DFBrowserPane_TDataStdDirectory
+//! \brief The class to manipulate of TDataStd_Directory attribute
+class DFBrowserPane_TDataStdDirectory : public DFBrowserPane_AttributePane
+{
+public:
+
+ //! Constructor
+ DFBrowserPane_TDataStdDirectory() {}
+
+ //! Destructor
+ virtual ~DFBrowserPane_TDataStdDirectory() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPane_TDataStdExpression.hxx>
+#include <DFBrowserPane_Tools.hxx>
+
+#include <TDataStd_Expression.hxx>
+#include <QVariant>
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdExpression::GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
+{
+ Handle(TDataStd_Expression) anAttribute = Handle(TDataStd_Expression)::DownCast (theAttribute);
+ if (anAttribute.IsNull())
+ return;
+
+ theValues.append (DFBrowserPane_Tools::ToString (anAttribute->GetExpression()));
+}
+
--- /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 DFBrowserPane_TDataStdExpression_H
+#define DFBrowserPane_TDataStdExpression_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+
+//! \class DFBrowserPane_TDataStdExpression
+//! \brief The class to manipulate of TDataStd_Expression attribute
+class DFBrowserPane_TDataStdExpression : public DFBrowserPane_AttributePane
+{
+public:
+ //! Constructor
+ DFBrowserPane_TDataStdExpression() {}
+
+ //! Destructor
+ virtual ~DFBrowserPane_TDataStdExpression() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPane_TDataStdExtStringArray.hxx>
+#include <DFBrowserPane_Tools.hxx>
+#include <DFBrowserPane_TableView.hxx>
+#include <DFBrowserPane_AttributePaneModel.hxx>
+#include <DFBrowserPane_HelperArray.hxx>
+
+#include <TDataStd_ExtStringArray.hxx>
+
+#include <QVariant>
+#include <QWidget>
+
+// =======================================================================
+// function : CreateWidget
+// purpose :
+// =======================================================================
+QWidget* DFBrowserPane_TDataStdExtStringArray::CreateWidget (QWidget* theParent)
+{
+ QWidget* aMainWidget = new QWidget (theParent);
+ myTableView = new DFBrowserPane_TableView (aMainWidget);
+ myTableView->SetModel (getPaneModel());
+
+ myArrayTableHelper.CreateWidget (aMainWidget, myTableView);
+
+ return aMainWidget;
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdExtStringArray::Init (const Handle(TDF_Attribute)& theAttribute)
+{
+ QList<QVariant> aValues;
+ GetValues (theAttribute, aValues);
+ myArrayTableHelper.Init (aValues);
+}
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdExtStringArray::GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
+{
+ Handle(TDataStd_ExtStringArray) anAttribute = Handle(TDataStd_ExtStringArray)::DownCast (theAttribute);
+ if (anAttribute.IsNull())
+ return;
+ theValues.append (anAttribute->Lower());
+ theValues.append (anAttribute->Upper());
+ for (int aValueId = anAttribute->Lower(); aValueId <= anAttribute->Upper(); aValueId++)
+ theValues.append (DFBrowserPane_Tools::ToString (anAttribute->Value(aValueId)));
+}
+
+// =======================================================================
+// function : GetShortAttributeInfo
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdExtStringArray::GetShortAttributeInfo (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues)
+{
+ QList<QVariant> aValues;
+ GetValues (theAttribute, aValues);
+ myArrayTableHelper.Init (aValues);
+ return myArrayTableHelper.GetShortAttributeInfo (theAttribute, theValues);
+}
--- /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 DFBrowserPane_TDataStdExtStringArray_H
+#define DFBrowserPane_TDataStdExtStringArray_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+
+#include <DFBrowserPane_HelperArray.hxx>
+
+//! \class DFBrowserPane_TDataStdExtStringArray
+//! \brief The class to manipulate of TDataStd_ExtStringArray attribute
+class DFBrowserPane_TDataStdExtStringArray : public DFBrowserPane_AttributePane
+{
+public:
+ //! Constructor
+ Standard_EXPORT DFBrowserPane_TDataStdExtStringArray() : DFBrowserPane_AttributePane(), myArrayTableHelper(getPaneModel()) {}
+
+ //! Destructor
+ Standard_EXPORT virtual ~DFBrowserPane_TDataStdExtStringArray() {}
+
+ //! Creates table view and call create widget of array table helper
+ //! \param theParent a parent widget
+ //! \return a new widget
+ Standard_EXPORT virtual QWidget* CreateWidget (QWidget* theParent) Standard_OVERRIDE;
+
+ //! Calls Init of array table helper
+ //! \param theAttribute a current attribute
+ Standard_EXPORT virtual void Init (const Handle(TDF_Attribute)& theAttribute) Standard_OVERRIDE;
+
+ //! Returns short attribute information using array table helper
+ //! \param theAttribute a current attribute
+ //! \param theValues container of output values
+ Standard_EXPORT virtual void GetShortAttributeInfo (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+
+private:
+
+ DFBrowserPane_HelperArray myArrayTableHelper; //!< common interface to fill array pane
+};
+
+#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 <DFBrowserPane_TDataStdExtStringList.hxx>
+#include <DFBrowserPane_Tools.hxx>
+
+#include <TDataStd_ExtStringList.hxx>
+#include <TDataStd_ListIteratorOfListOfExtendedString.hxx>
+
+#include <QVariant>
+#include <QWidget>
+
+//#define REQUIRE_OCAF_REVIEW:7 : start (DFBrowserPane_Tools)
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdExtStringList::GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
+{
+ Handle(TDataStd_ExtStringList) anAttribute = Handle(TDataStd_ExtStringList)::DownCast (theAttribute);
+ if (anAttribute.IsNull())
+ return;
+
+ for (TDataStd_ListIteratorOfListOfExtendedString aValuesIt(anAttribute->List()); aValuesIt.More(); aValuesIt.Next())
+ theValues.append (DFBrowserPane_Tools::ToString (aValuesIt.Value()));
+}
+//#define REQUIRE_OCAF_REVIEW:7 : end
--- /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 DFBrowserPane_TDataStdExtStringList_H
+#define DFBrowserPane_TDataStdExtStringList_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+
+//! \class DFBrowserPane_TDataStdExtStringList
+//! \brief The class to manipulate of TDataStd_ExtStringList attribute
+class DFBrowserPane_TDataStdExtStringList : public DFBrowserPane_AttributePane
+{
+public:
+
+ //! Constructor
+ DFBrowserPane_TDataStdExtStringList() {}
+
+ //! Destructor
+ virtual ~DFBrowserPane_TDataStdExtStringList() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPane_TDataStdIntPackedMap.hxx>
+
+#include <TDataStd_IntPackedMap.hxx>
+#include <TColStd_MapIteratorOfPackedMapOfInteger.hxx>
+
+#include <QVariant>
+#include <QWidget>
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdIntPackedMap::GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
+{
+ Handle(TDataStd_IntPackedMap) anAttribute = Handle(TDataStd_IntPackedMap)::DownCast (theAttribute);
+ if (anAttribute.IsNull())
+ return;
+
+ for (TColStd_MapIteratorOfPackedMapOfInteger aValueIt(anAttribute->GetMap()); aValueIt.More(); aValueIt.Next())
+ theValues.append (aValueIt.Key());
+}
--- /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 DFBrowserPane_TDataStdIntPackedMap_H
+#define DFBrowserPane_TDataStdIntPackedMap_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+
+//! \class DFBrowserPane_TDataStdIntPackedMap
+//! \brief The class to manipulate of TDataStd_IntPackedMap attribute
+class DFBrowserPane_TDataStdIntPackedMap : public DFBrowserPane_AttributePane
+{
+public:
+
+ //! Constructor
+ DFBrowserPane_TDataStdIntPackedMap() {}
+
+ //! Destructor
+ virtual ~DFBrowserPane_TDataStdIntPackedMap() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPane_TDataStdInteger.hxx>
+
+#include <TDataStd_Integer.hxx>
+
+#include <QVariant>
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdInteger::GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
+{
+ Handle(TDataStd_Integer) anAttribute = Handle(TDataStd_Integer)::DownCast (theAttribute);
+ if (anAttribute.IsNull())
+ return;
+
+ theValues.append (anAttribute->Get());
+}
--- /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 DFBrowserPane_TDataStdInteger_H
+#define DFBrowserPane_TDataStdInteger_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+
+//! \class DFBrowserPane_TDataStdInteger
+//! \brief The class to manipulate of TDataStd_Integer attribute
+class DFBrowserPane_TDataStdInteger : public DFBrowserPane_AttributePane
+{
+public:
+ //! Constructor
+ DFBrowserPane_TDataStdInteger() {}
+
+ //! Destructor
+ virtual ~DFBrowserPane_TDataStdInteger() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPane_TDataStdIntegerArray.hxx>
+#include <DFBrowserPane_TableView.hxx>
+#include <DFBrowserPane_AttributePaneModel.hxx>
+#include <DFBrowserPane_HelperArray.hxx>
+
+#include <TDataStd_IntegerArray.hxx>
+
+#include <QVariant>
+#include <QWidget>
+
+// =======================================================================
+// function : CreateWidget
+// purpose :
+// =======================================================================
+QWidget* DFBrowserPane_TDataStdIntegerArray::CreateWidget (QWidget* theParent)
+{
+ QWidget* aMainWidget = new QWidget (theParent);
+ myTableView = new DFBrowserPane_TableView (aMainWidget);
+ myTableView->SetModel (getPaneModel());
+
+ myArrayTableHelper.CreateWidget (aMainWidget, myTableView);
+
+ return aMainWidget;
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdIntegerArray::Init (const Handle(TDF_Attribute)& theAttribute)
+{
+ QList<QVariant> aValues;
+ GetValues (theAttribute, aValues);
+ myArrayTableHelper.Init (aValues);
+}
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdIntegerArray::GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
+{
+ Handle(TDataStd_IntegerArray) anAttribute = Handle(TDataStd_IntegerArray)::DownCast (theAttribute);
+ if (anAttribute.IsNull())
+ return;
+
+ theValues.append (anAttribute->Lower());
+ theValues.append (anAttribute->Upper());
+ for (int aValueId = anAttribute->Lower(); aValueId <= anAttribute->Upper(); aValueId++)
+ theValues.append (anAttribute->Value(aValueId));
+}
+
+// =======================================================================
+// function : GetShortAttributeInfo
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdIntegerArray::GetShortAttributeInfo (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues)
+{
+ QList<QVariant> aValues;
+ GetValues (theAttribute, aValues);
+ myArrayTableHelper.Init (aValues);
+ return myArrayTableHelper.GetShortAttributeInfo (theAttribute, theValues);
+}
--- /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 DFBrowserPane_TDataStdIntegerArray_H
+#define DFBrowserPane_TDataStdIntegerArray_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+
+#include <DFBrowserPane_HelperArray.hxx>
+
+//! \class DFBrowserPane_TDataStdIntegerArray
+//! \brief The class to manipulate of TDataStd_IntegerArray attribute
+class DFBrowserPane_TDataStdIntegerArray : public DFBrowserPane_AttributePane
+{
+public:
+ //! Constructor
+ Standard_EXPORT DFBrowserPane_TDataStdIntegerArray() : DFBrowserPane_AttributePane(), myArrayTableHelper(getPaneModel()) {}
+
+ //! Destructor
+ Standard_EXPORT virtual ~DFBrowserPane_TDataStdIntegerArray() {}
+
+ //! Creates table view and call create widget of array table helper
+ //! \param theParent a parent widget
+ //! \return a new widget
+ Standard_EXPORT virtual QWidget* CreateWidget (QWidget* theParent) Standard_OVERRIDE;
+
+ //! Calls Init of array table helper
+ //! \param theAttribute a current attribute
+ Standard_EXPORT virtual void Init (const Handle(TDF_Attribute)& theAttribute) Standard_OVERRIDE;
+
+ //! Returns short attribute information using array table helper
+ //! \param theAttribute a current attribute
+ //! \param theValues container of output values
+ Standard_EXPORT virtual void GetShortAttributeInfo (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+
+private:
+
+ DFBrowserPane_HelperArray myArrayTableHelper; //!< common interface to fill array pane
+};
+
+#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 <DFBrowserPane_TDataStdIntegerList.hxx>
+
+#include <TDataStd_IntegerList.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+
+#include <QVariant>
+#include <QWidget>
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdIntegerList::GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
+{
+ Handle(TDataStd_IntegerList) anAttribute = Handle(TDataStd_IntegerList)::DownCast (theAttribute);
+ if (anAttribute.IsNull())
+ return;
+
+ for (TColStd_ListIteratorOfListOfInteger aValuesIt (anAttribute->List()); aValuesIt.More(); aValuesIt.Next())
+ theValues.append (aValuesIt.Value());
+}
--- /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 DFBrowserPane_TDataStdIntegerList_H
+#define DFBrowserPane_TDataStdIntegerList_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+
+//! \class DFBrowserPane_TDataStdIntegerList
+//! \brief The class to manipulate of TDataStd_IntegerList attribute
+class DFBrowserPane_TDataStdIntegerList : public DFBrowserPane_AttributePane
+{
+public:
+
+ //! Constructor
+ DFBrowserPane_TDataStdIntegerList() {}
+
+ //! Destructor
+ virtual ~DFBrowserPane_TDataStdIntegerList() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPane_TDataStdName.hxx>
+#include <DFBrowserPane_Tools.hxx>
+
+#include <TDataStd_Name.hxx>
+
+#include <QVariant>
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdName::GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
+{
+ Handle(TDataStd_Name) anAttribute = Handle(TDataStd_Name)::DownCast (theAttribute);
+ if (anAttribute.IsNull())
+ return;
+
+ theValues.append (DFBrowserPane_Tools::ToString (anAttribute->Get()));
+}
+
--- /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 DFBrowserPane_TDataStdName_H
+#define DFBrowserPane_TDataStdName_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+
+//! \class DFBrowserPane_TDataStdName
+//! \brief The class to manipulate of TDataStd_Name attribute
+class DFBrowserPane_TDataStdName : public DFBrowserPane_AttributePane
+{
+public:
+
+ //! Constructor
+ DFBrowserPane_TDataStdName() {}
+
+ //! Destructor
+ virtual ~DFBrowserPane_TDataStdName() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPane_TDataStdNamedData.hxx>
+
+#include <DFBrowserPane_AttributePaneModel.hxx>
+#include <DFBrowserPane_HelperGroupContent.hxx>
+#include <DFBrowserPane_TableView.hxx>
+#include <DFBrowserPane_Tools.hxx>
+
+#include <TColStd_DataMapOfStringInteger.hxx>
+#include <TColStd_DataMapIteratorOfDataMapOfStringInteger.hxx>
+#include <TColStd_HArray1OfInteger.hxx>
+#include <TColStd_HArray1OfReal.hxx>
+
+#include <TDataStd_DataMapIteratorOfDataMapOfStringByte.hxx>
+#include <TDataStd_DataMapIteratorOfDataMapOfStringHArray1OfInteger.hxx>
+#include <TDataStd_DataMapIteratorOfDataMapOfStringHArray1OfReal.hxx>
+#include <TDataStd_DataMapIteratorOfDataMapOfStringReal.hxx>
+#include <TDataStd_DataMapIteratorOfDataMapOfStringString.hxx>
+#include <TDataStd_DataMapOfStringByte.hxx>
+#include <TDataStd_DataMapOfStringHArray1OfInteger.hxx>
+#include <TDataStd_DataMapOfStringReal.hxx>
+#include <TDataStd_DataMapOfStringString.hxx>
+#include <TDataStd_HDataMapOfStringHArray1OfInteger.hxx>
+#include <TDataStd_NamedData.hxx>
+
+#include <QVariant>
+#include <QVBoxLayout>
+#include <QWidget>
+
+static const QString VALUES_INTEGER = "values_integer";
+static const QString VALUES_REAL = "values_real";
+static const QString VALUES_STRING = "values_string";
+static const QString VALUES_BYTE = "values_byte";
+static const QString VALUES_INT_ARRAY = "values_int_array";
+static const QString VALUES_REAL_ARRAY = "values_real_array";
+
+//#define REQUIRE_OCAF_REVIEW:9 : start
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowserPane_TDataStdNamedData::DFBrowserPane_TDataStdNamedData()
+ : DFBrowserPane_AttributePane()
+{
+ myPaneModel = createPaneModel();
+ myRealValuesModel = createPaneModel();
+ myStringValuesModel = createPaneModel();
+ myByteValuesModel = createPaneModel();
+ myIntArrayValuesModel = createPaneModel();
+ myRealArrayModel = createPaneModel();
+}
+
+// =======================================================================
+// function : createPaneModel
+// purpose :
+// =======================================================================
+DFBrowserPane_AttributePaneModel* DFBrowserPane_TDataStdNamedData::createPaneModel()
+{
+ DFBrowserPane_AttributePaneModel* aTableModel = new DFBrowserPane_AttributePaneModel();
+
+ aTableModel->SetOrientation (Qt::Horizontal);
+
+ QList<QVariant> aHeaderValues;
+ aHeaderValues << "Name" << "Value";
+ aTableModel->SetHeaderValues (aHeaderValues, Qt::Vertical);
+ aTableModel->SetColumnCount (2); // indeed these are rows as table orientation is Horizontal
+
+ return aTableModel;
+}
+
+// =======================================================================
+// function : CreateWidget
+// purpose :
+// =======================================================================
+QWidget* DFBrowserPane_TDataStdNamedData::CreateWidget (QWidget* theParent)
+{
+ QWidget* aMainWidget = new QWidget (theParent);
+ QVBoxLayout* aLay = new QVBoxLayout (aMainWidget);
+
+ myTableView = new DFBrowserPane_TableView (aMainWidget);
+ myTableView->SetModel (getPaneModel());
+ myIntValuesContent = new DFBrowserPane_HelperGroupContent ("Named integers", aMainWidget, myTableView);
+ aLay->addWidget (myIntValuesContent);
+
+ myRealValues = new DFBrowserPane_TableView (aMainWidget);
+ myRealValues->SetModel (myRealValuesModel);
+ myRealValuesContent = new DFBrowserPane_HelperGroupContent ("Named reals", aMainWidget, myRealValues);
+ aLay->addWidget (myRealValuesContent);
+
+ myStringValues = new DFBrowserPane_TableView (aMainWidget);
+ myStringValues->SetModel (myStringValuesModel);
+ myStringValuesContent = new DFBrowserPane_HelperGroupContent ("Named strings", aMainWidget, myStringValues);
+ aLay->addWidget (myStringValuesContent);
+
+ myByteValues = new DFBrowserPane_TableView (aMainWidget);
+ myByteValues->SetModel (myByteValuesModel);
+ myByteValuesContent = new DFBrowserPane_HelperGroupContent ("Named bytes", aMainWidget, myByteValues);
+ aLay->addWidget (myByteValuesContent);
+
+ myIntArrayValues = new DFBrowserPane_TableView (aMainWidget);
+ myIntArrayValues->SetModel (myIntArrayValuesModel);
+ myIntArrayValuesContent = new DFBrowserPane_HelperGroupContent ("Named integer arrays", aMainWidget, myIntArrayValues);
+ aLay->addWidget (myIntArrayValuesContent);
+
+ myRealArrayValues = new DFBrowserPane_TableView (aMainWidget);
+ myRealArrayValues->SetModel (myRealArrayModel);
+ myRealArrayValuesContent = new DFBrowserPane_HelperGroupContent ("Named real arrays", aMainWidget, myRealArrayValues);
+ aLay->addWidget (myRealArrayValuesContent);
+
+ aLay->addStretch (1);
+
+ return aMainWidget;
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdNamedData::Init (const Handle(TDF_Attribute)& theAttribute)
+{
+ QList<QVariant> aValues;
+ GetValues (theAttribute, aValues);
+
+ getPaneModel()->Init (getPartOfValues (VALUES_INTEGER, VALUES_REAL, aValues));
+ myRealValuesModel->Init (getPartOfValues (VALUES_REAL, VALUES_STRING, aValues));
+ myStringValuesModel->Init (getPartOfValues (VALUES_STRING, VALUES_BYTE, aValues));
+ myByteValuesModel->Init (getPartOfValues (VALUES_BYTE, VALUES_INT_ARRAY, aValues));
+ myIntArrayValuesModel->Init (getPartOfValues (VALUES_INT_ARRAY, VALUES_REAL_ARRAY, aValues));
+ myRealArrayModel->Init (getPartOfValues (VALUES_REAL_ARRAY, "", aValues));
+}
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdNamedData::GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
+{
+ Handle(TDataStd_NamedData) anAttribute = Handle(TDataStd_NamedData)::DownCast (theAttribute);
+ if (anAttribute.IsNull())
+ return;
+
+ theValues.append (VALUES_INTEGER);
+ for (TColStd_DataMapIteratorOfDataMapOfStringInteger anIntIter(anAttribute->GetIntegersContainer());
+ anIntIter.More(); anIntIter.Next())
+ {
+ theValues.append (DFBrowserPane_Tools::ToString (anIntIter.Key()));
+ theValues.append (anIntIter.Value());
+ }
+ theValues.append (VALUES_REAL);
+ for (TDataStd_DataMapIteratorOfDataMapOfStringReal aRealIter(anAttribute->GetRealsContainer());
+ aRealIter.More(); aRealIter.Next())
+ {
+ theValues.append (DFBrowserPane_Tools::ToString (aRealIter.Key()));
+ theValues.append (aRealIter.Value());
+ }
+ theValues.append (VALUES_STRING);
+ for (TDataStd_DataMapIteratorOfDataMapOfStringString aStrIter(anAttribute->GetStringsContainer());
+ aStrIter.More(); aStrIter.Next())
+ {
+ theValues.append (DFBrowserPane_Tools::ToString (aStrIter.Key()));
+ theValues.append (DFBrowserPane_Tools::ToString (aStrIter.Value()));
+ }
+ theValues.append (VALUES_BYTE);
+ for (TDataStd_DataMapIteratorOfDataMapOfStringByte aByteIter(anAttribute->GetBytesContainer());
+ aByteIter.More(); aByteIter.Next())
+ {
+ theValues.append (DFBrowserPane_Tools::ToString (aByteIter.Key()));
+ theValues.append (aByteIter.Value());
+ }
+ theValues.append (VALUES_INT_ARRAY);
+ QStringList anArrayValues;
+ for (TDataStd_DataMapIteratorOfDataMapOfStringHArray1OfInteger anIntArrayIter(anAttribute->GetArraysOfIntegersContainer());
+ anIntArrayIter.More(); anIntArrayIter.Next())
+ {
+ theValues.append (DFBrowserPane_Tools::ToString (anIntArrayIter.Key()));
+ anArrayValues.clear();
+ const Handle(TColStd_HArray1OfInteger)& aSubIt = anIntArrayIter.Value();
+ if (!aSubIt.IsNull())
+ {
+ for (Standard_Integer aLowerId = aSubIt->Lower(), i = aLowerId, anUpperId = aSubIt->Upper(); i <= anUpperId; i++)
+ anArrayValues.append (QString::number (aSubIt->Value (i)));
+ }
+ theValues.append (anArrayValues.join (QString (',')));
+ }
+ theValues.append (VALUES_REAL_ARRAY);
+ for (TDataStd_DataMapIteratorOfDataMapOfStringHArray1OfReal aRealArrayIter (anAttribute->GetArraysOfRealsContainer());
+ aRealArrayIter.More(); aRealArrayIter.Next())
+ {
+ theValues.append (DFBrowserPane_Tools::ToString (aRealArrayIter.Key()));
+ anArrayValues.clear();
+ const Handle(TColStd_HArray1OfReal)& aSubIt = aRealArrayIter.Value();
+ if (!aSubIt.IsNull())
+ {
+ for (Standard_Integer aLowerId = aSubIt->Lower(), i = aLowerId, anUpperId = aSubIt->Upper(); i <= anUpperId; i++)
+ anArrayValues.append (QString::number (aSubIt->Value (i)));
+ }
+ theValues.append (anArrayValues.join (QString (',')));
+ }
+}
+
+// =======================================================================
+// function : getPartOfValues
+// purpose :
+// =======================================================================
+QList<QVariant> DFBrowserPane_TDataStdNamedData::getPartOfValues (const QString& theKey1, const QString& theKey2,
+ const QList<QVariant>& theValues) const
+{
+ QList<QVariant> aValues;
+
+ bool aFoundKey1 = false, aFoundKey2 = false;
+ for (int aValueId = 0; aValueId < theValues.size() && !aFoundKey2; aValueId++)
+ {
+ QString aValue = theValues[aValueId].toString();
+ if (!aFoundKey1)
+ aFoundKey1 = aValue == theKey1;
+ else
+ {
+ aFoundKey2 = aValue == theKey2;
+ if (!aFoundKey2)
+ aValues.append (aValue);
+ }
+ }
+ return aValues;
+}
+//#define REQUIRE_OCAF_REVIEW:9 : end
--- /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 DFBrowserPane_TDataStdNamedData_H
+#define DFBrowserPane_TDataStdNamedData_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+
+class DFBrowserPane_AttributePaneModel;
+class DFBrowserPane_HelperGroupContent;
+class DFBrowserPane_TableView;
+
+//! \class DFBrowserPane_TDataStdNamedData
+//! \brief The class to manipulate of TDataStd_NamedData attribute
+//! This pane contains six pair of table views, where values of this data container presented
+//! The first table in pair presents size of a separate data container, the second presents values
+//! Each control for data container is grouped in a checkable group box to switch off/on using of a container.
+class DFBrowserPane_TDataStdNamedData : public DFBrowserPane_AttributePane
+{
+public:
+
+ //! Constructor
+ Standard_EXPORT DFBrowserPane_TDataStdNamedData();
+
+ //! Destructor
+ virtual ~DFBrowserPane_TDataStdNamedData() {}
+
+ //! Creates a new widget that contains containers for attribute values
+ //! \param theParent a parent widget
+ //! \return pane widget
+ Standard_EXPORT virtual QWidget* CreateWidget (QWidget* theParent) Standard_OVERRIDE;
+
+ //! Gets values of attribute using GetValues(), after fill tables if the pane with the values and Init the view model
+ //! \param theAttribute a current attribute
+ Standard_EXPORT virtual void Init (const Handle(TDF_Attribute)& theAttribute) Standard_OVERRIDE;
+
+ //! Returns values to fill the table view model. The values are separated by an auxiliary key for getPartOfValues
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+
+private:
+
+ //! Obtains sub container of a general values container for given keys to fill tables for this kind
+ //! \param theKey1 a key where values are started
+ //! \param theKey2 a key before that the values are got
+ //! \param theValues a full container of values for the current attribute
+ //! \returns sub container
+ QList<QVariant> getPartOfValues (const QString& theKey1, const QString& theKey2,
+ const QList<QVariant>& theValues) const;
+
+ //! Creates a model with two columns: "Name" to "Value". The orientation is horizontal
+ DFBrowserPane_AttributePaneModel* createPaneModel();
+
+private:
+
+ //! myPaneMode and myTableView are used for int values
+ DFBrowserPane_HelperGroupContent* myIntValuesContent; //!< check box of values using
+
+ DFBrowserPane_AttributePaneModel* myRealValuesModel; //!< real values model
+ DFBrowserPane_TableView* myRealValues; //!< values table view
+ DFBrowserPane_HelperGroupContent* myRealValuesContent; //!< check box of values using
+
+ DFBrowserPane_AttributePaneModel* myStringValuesModel; //!< string values model
+ DFBrowserPane_TableView* myStringValues; //!< values table view
+ DFBrowserPane_HelperGroupContent* myStringValuesContent; //!< check box of values using
+
+ DFBrowserPane_AttributePaneModel* myByteValuesModel; //!< byte values model
+ DFBrowserPane_TableView* myByteValues; //!< values table view
+ DFBrowserPane_HelperGroupContent* myByteValuesContent; //!< check box of values using
+
+ DFBrowserPane_AttributePaneModel* myIntArrayValuesModel; //!< int array values model
+ DFBrowserPane_TableView* myIntArrayValues; //!< values table view
+ DFBrowserPane_HelperGroupContent* myIntArrayValuesContent; //!< check box of values using
+
+ DFBrowserPane_AttributePaneModel* myRealArrayModel; //!< real array values model
+ DFBrowserPane_TableView* myRealArrayValues; //!< values table view
+ DFBrowserPane_HelperGroupContent* myRealArrayValuesContent; //!< check box of values using
+};
+
+#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 <DFBrowserPane_TDataStdNoteBook.hxx>
+
+#include <TDataStd_NoteBook.hxx>
+
+#include <QVariant>
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdNoteBook::GetValues (const Handle(TDF_Attribute)&, QList<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 DFBrowserPane_TDataStdNoteBook_H
+#define DFBrowserPane_TDataStdNoteBook_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+
+//! \class DFBrowserPane_TDataStdNoteBook
+//! \brief The class to manipulate of TDataStd_NoteBook attribute
+class DFBrowserPane_TDataStdNoteBook : public DFBrowserPane_AttributePane
+{
+public:
+
+ //! Constructor
+ DFBrowserPane_TDataStdNoteBook() {}
+
+ //! Destructor
+ virtual ~DFBrowserPane_TDataStdNoteBook() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPane_TDataStdReal.hxx>
+
+#include <TDataStd_Real.hxx>
+
+#include <QVariant>
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdReal::GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
+{
+ Handle(TDataStd_Real) anAttribute = Handle(TDataStd_Real)::DownCast (theAttribute);
+ if (anAttribute.IsNull())
+ return;
+
+ theValues.append (anAttribute->Get());
+}
+
--- /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 DFBrowserPane_TDataStdReal_H
+#define DFBrowserPane_TDataStdReal_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+
+//! \class DFBrowserPane_TDataStdReal
+//! \brief The class to manipulate of TDataStd_Real attribute
+class DFBrowserPane_TDataStdReal : public DFBrowserPane_AttributePane
+{
+public:
+
+ //! Constructor
+ DFBrowserPane_TDataStdReal() {}
+
+ //! Destructor
+ virtual ~DFBrowserPane_TDataStdReal() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPane_TDataStdRealArray.hxx>
+
+#include <DFBrowserPane_AttributePaneModel.hxx>
+#include <DFBrowserPane_HelperArray.hxx>
+#include <DFBrowserPane_TableView.hxx>
+
+#include <TDataStd_RealArray.hxx>
+
+#include <QVariant>
+#include <QWidget>
+
+// =======================================================================
+// function : CreateWidget
+// purpose :
+// =======================================================================
+QWidget* DFBrowserPane_TDataStdRealArray::CreateWidget (QWidget* theParent)
+{
+ QWidget* aMainWidget = new QWidget (theParent);
+ myTableView = new DFBrowserPane_TableView (aMainWidget);
+ myTableView->SetModel (getPaneModel());
+
+ myArrayTableHelper.CreateWidget (aMainWidget, myTableView);
+
+ return aMainWidget;
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdRealArray::Init (const Handle(TDF_Attribute)& theAttribute)
+{
+ QList<QVariant> aValues;
+ GetValues (theAttribute, aValues);
+ myArrayTableHelper.Init (aValues);
+}
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdRealArray::GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
+{
+ Handle(TDataStd_RealArray) anAttribute = Handle(TDataStd_RealArray)::DownCast (theAttribute);
+ if (anAttribute.IsNull())
+ return;
+ theValues.append (anAttribute->Lower());
+ theValues.append (anAttribute->Upper());
+ for (int aValueId = anAttribute->Lower(); aValueId <= anAttribute->Upper(); aValueId++)
+ theValues.append (anAttribute->Value(aValueId));
+}
+
+// =======================================================================
+// function : GetShortAttributeInfo
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdRealArray::GetShortAttributeInfo (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues)
+{
+ QList<QVariant> aValues;
+ GetValues (theAttribute, aValues);
+ myArrayTableHelper.Init (aValues);
+ return myArrayTableHelper.GetShortAttributeInfo (theAttribute, theValues);
+}
--- /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 DFBrowserPane_TDataStdRealArray_H
+#define DFBrowserPane_TDataStdRealArray_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+
+#include <DFBrowserPane_HelperArray.hxx>
+
+//! \class DFBrowserPane_TDataStdRealArray
+//! \brief The class to manipulate of TDataStd_RealArray attribute
+class DFBrowserPane_TDataStdRealArray : public DFBrowserPane_AttributePane
+{
+public:
+
+ //! Constructor
+ Standard_EXPORT DFBrowserPane_TDataStdRealArray() : DFBrowserPane_AttributePane(), myArrayTableHelper(getPaneModel()) {}
+
+ //! Destructor
+ Standard_EXPORT virtual ~DFBrowserPane_TDataStdRealArray() {}
+
+ //! Creates table view and call create widget of array table helper
+ //! \param theParent a parent widget
+ //! \return a new widget
+ Standard_EXPORT virtual QWidget* CreateWidget (QWidget* theParent) Standard_OVERRIDE;
+
+ //! Calls Init of array table helper
+ //! \param theAttribute a current attribute
+ Standard_EXPORT virtual void Init (const Handle(TDF_Attribute)& theAttribute) Standard_OVERRIDE;
+
+ //! Returns short attribute information using array table helper
+ //! \param theAttribute a current attribute
+ //! \param theValues container of output values
+ Standard_EXPORT virtual void GetShortAttributeInfo (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+
+private:
+
+ DFBrowserPane_HelperArray myArrayTableHelper; //!< common interface to fill array pane
+};
+
+#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 <DFBrowserPane_TDataStdRealList.hxx>
+
+#include <TColStd_ListIteratorOfListOfReal.hxx>
+#include <TDataStd_RealList.hxx>
+
+#include <QVariant>
+#include <QWidget>
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdRealList::GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
+{
+ Handle(TDataStd_RealList) anAttribute = Handle(TDataStd_RealList)::DownCast (theAttribute);
+ if (anAttribute.IsNull())
+ return;
+
+ for (TColStd_ListIteratorOfListOfReal aRealListIt(anAttribute->List()); aRealListIt.More(); aRealListIt.Next())
+ theValues.append (aRealListIt.Value());
+}
--- /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 DFBrowserPane_TDataStdRealList_H
+#define DFBrowserPane_TDataStdRealList_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+
+//! \class DFBrowserPane_TDataStdRealList
+//! \brief The class to manipulate of TDataStd_RealList attribute
+class DFBrowserPane_TDataStdRealList : public DFBrowserPane_AttributePane
+{
+public:
+ //! Constructor
+ DFBrowserPane_TDataStdRealList() {}
+
+ //! Destructor
+ virtual ~DFBrowserPane_TDataStdRealList() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPane_TDataStdReferenceArray.hxx>
+
+#include <DFBrowserPane_AttributePaneModel.hxx>
+#include <DFBrowserPane_HelperArray.hxx>
+#include <DFBrowserPane_TableView.hxx>
+#include <DFBrowserPane_Tools.hxx>
+
+#include <TDataStd_ReferenceArray.hxx>
+
+#include <QGridLayout>
+#include <QItemSelectionModel>
+#include <QTableView>
+#include <QVariant>
+#include <QWidget>
+
+//#define REQUIRE_OCAF_REVIEW:10 : start (GetReferences)
+// =======================================================================
+// function : CreateWidget
+// purpose :
+// =======================================================================
+QWidget* DFBrowserPane_TDataStdReferenceArray::CreateWidget (QWidget* theParent)
+{
+ QWidget* aMainWidget = new QWidget (theParent);
+ myTableView = new DFBrowserPane_TableView (aMainWidget);
+ myTableView->SetModel (getPaneModel());
+ myTableView->GetTableView()->setSelectionModel (mySelectionModels.front());
+
+ myArrayTableHelper.CreateWidget (aMainWidget, myTableView);
+
+ return aMainWidget;
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdReferenceArray::Init (const Handle(TDF_Attribute)& theAttribute)
+{
+ QList<QVariant> aValues;
+ GetValues (theAttribute, aValues);
+ myArrayTableHelper.Init (aValues);
+}
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdReferenceArray::GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
+{
+ Handle(TDataStd_ReferenceArray) anAttribute = Handle(TDataStd_ReferenceArray)::DownCast (theAttribute);
+ if (anAttribute.IsNull())
+ return;
+
+ theValues.append (anAttribute->Lower());
+ theValues.append (anAttribute->Upper());
+ for (int aValueId = anAttribute->Lower(); aValueId <= anAttribute->Upper(); aValueId++)
+ theValues.append (DFBrowserPane_Tools::GetEntry (anAttribute->Value(aValueId)).ToCString());
+}
+
+// =======================================================================
+// function : GetShortAttributeInfo
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdReferenceArray::GetShortAttributeInfo (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues)
+{
+ QList<QVariant> aValues;
+ GetValues (theAttribute, aValues);
+ myArrayTableHelper.Init (aValues);
+ return myArrayTableHelper.GetShortAttributeInfo (theAttribute, theValues);
+}
+
+// =======================================================================
+// function : GetReferences
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdReferenceArray::GetReferences (const Handle(TDF_Attribute)& theAttribute,
+ NCollection_List<TDF_Label>& theRefLabels,
+ Handle(Standard_Transient)& /*theRefPresentation*/)
+{
+ if (!getTableView())
+ return;
+ QStringList aSelectedEntries = DFBrowserPane_TableView::GetSelectedColumnValues (getTableView()->GetTableView(), 0);
+
+ Handle(TDataStd_ReferenceArray) anAttribute = Handle(TDataStd_ReferenceArray)::DownCast (theAttribute);
+ if (anAttribute.IsNull())
+ return;
+
+ for (int aValueId = anAttribute->Lower(); aValueId <= anAttribute->Upper(); aValueId++)
+ {
+ TDF_Label aLabel = anAttribute->Value (aValueId);
+ if (aSelectedEntries.contains (DFBrowserPane_Tools::GetEntry (aLabel).ToCString()))
+ theRefLabels.Append (aLabel);
+ }
+}
+//#define REQUIRE_OCAF_REVIEW:10 : end
--- /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 DFBrowserPane_TDataStdReferenceArray_H
+#define DFBrowserPane_TDataStdReferenceArray_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+
+#include <DFBrowserPane_HelperArray.hxx>
+
+//! \class DFBrowserPane_TDataStdReferenceArray
+//! \brief The class to manipulate of TDataStd_ReferenceArray attribute
+class DFBrowserPane_TDataStdReferenceArray : public DFBrowserPane_AttributePane
+{
+public:
+
+ //! Constructor
+ Standard_EXPORT DFBrowserPane_TDataStdReferenceArray() : DFBrowserPane_AttributePane(), myArrayTableHelper(getPaneModel()) {}
+
+ //! Destructor
+ Standard_EXPORT virtual ~DFBrowserPane_TDataStdReferenceArray() {}
+
+ //! Creates table view and call create widget of array table helper
+ //! \param theParent a parent widget
+ //! \return a new widget
+ Standard_EXPORT virtual QWidget* CreateWidget (QWidget* theParent) Standard_OVERRIDE;
+
+ //! Calls Init of array table helper
+ //! \param theAttribute a current attribute
+ Standard_EXPORT virtual void Init (const Handle(TDF_Attribute)& theAttribute) Standard_OVERRIDE;
+
+ //! Returns short attribute information using array table helper
+ //! \param theAttribute a current attribute
+ //! \param theValues container of output values
+ Standard_EXPORT virtual void GetShortAttributeInfo (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+
+ //! Returns container of Label references to the attribute
+ //! \param theAttribute a current attribute
+ //! \param theRefLabels a container of label references, to be selected in tree view
+ //! \param theRefPresentation handle of presentation for the references, to be visualized
+ Standard_EXPORT virtual void GetReferences (const Handle(TDF_Attribute)& theAttribute,
+ NCollection_List<TDF_Label>& theRefLabels,
+ Handle(Standard_Transient)& theRefPresentation) Standard_OVERRIDE;
+private:
+
+ DFBrowserPane_HelperArray myArrayTableHelper; //!< common interface to fill array pane
+};
+
+#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 <DFBrowserPane_TDataStdReferenceList.hxx>
+
+#include <DFBrowserPane_TableView.hxx>
+#include <DFBrowserPane_Tools.hxx>
+
+#include <TDataStd_ReferenceList.hxx>
+#include <TDF_ListIteratorOfLabelList.hxx>
+
+#include <QVariant>
+#include <QWidget>
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdReferenceList::GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
+{
+ Handle(TDataStd_ReferenceList) anAttribute = Handle(TDataStd_ReferenceList)::DownCast (theAttribute);
+ if (anAttribute.IsNull())
+ return;
+
+ for (TDF_ListIteratorOfLabelList aLabelIt(anAttribute->List()); aLabelIt.More(); aLabelIt.Next())
+ theValues.append (DFBrowserPane_Tools::GetEntry (aLabelIt.Value()).ToCString());
+}
+
+// =======================================================================
+// function : GetReferences
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdReferenceList::GetReferences (const Handle(TDF_Attribute)& theAttribute,
+ NCollection_List<TDF_Label>& theRefLabels,
+ Handle(Standard_Transient)& /*theRefPresentation*/)
+{
+ QStringList aSelectedEntries = DFBrowserPane_TableView::GetSelectedColumnValues (getTableView()->GetTableView(), 0);
+ Handle(TDataStd_ReferenceList) anAttribute = Handle(TDataStd_ReferenceList)::DownCast (theAttribute);
+ if (anAttribute.IsNull())
+ return;
+ for (TDF_ListIteratorOfLabelList aLabelIt(anAttribute->List()); aLabelIt.More(); aLabelIt.Next())
+ {
+ const TDF_Label& aLabel = aLabelIt.Value();
+ if (aSelectedEntries.contains (DFBrowserPane_Tools::GetEntry (aLabel).ToCString()))
+ theRefLabels.Append (aLabel);
+ }
+}
--- /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 DFBrowserPane_TDataStdReferenceList_H
+#define DFBrowserPane_TDataStdReferenceList_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+
+//! \class DFBrowserPane_TDataStdReferenceList
+//! \brief The class to manipulate of TDataStd_ReferenceList attribute
+class DFBrowserPane_TDataStdReferenceList : public DFBrowserPane_AttributePane
+{
+public:
+
+ //! Constructor
+ DFBrowserPane_TDataStdReferenceList() {}
+
+ //! Destructor
+ virtual ~DFBrowserPane_TDataStdReferenceList() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+
+ //! Returns container of Label references to the attribute
+ //! \param theAttribute a current attribute
+ //! \param theRefLabels a container of label references, to be selected in tree view
+ //! \param theRefPresentation handle of presentation for the references, to be visualized
+ Standard_EXPORT virtual void GetReferences (const Handle(TDF_Attribute)& theAttribute,
+ NCollection_List<TDF_Label>& theRefLabels,
+ Handle(Standard_Transient)& theRefPresentation) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPane_TDataStdRelation.hxx>
+
+#include <TDataStd_Relation.hxx>
+
+#include <QVariant>
+#include <QWidget>
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdRelation::GetValues (const Handle(TDF_Attribute)&, QList<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 DFBrowserPane_TDataStdRelation_H
+#define DFBrowserPane_TDataStdRelation_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+
+//! \class DFBrowserPane_TDataStdRelation
+//! \brief The class to manipulate of TDataStd_Relation attribute
+class DFBrowserPane_TDataStdRelation : public DFBrowserPane_AttributePane
+{
+public:
+
+ //! Constructor
+ DFBrowserPane_TDataStdRelation() {}
+
+ //! Destructor
+ virtual ~DFBrowserPane_TDataStdRelation() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPane_TDataStdTick.hxx>
+
+#include <TDataStd_Tick.hxx>
+
+#include <QVariant>
+#include <QWidget>
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdTick::GetValues (const Handle(TDF_Attribute)&, QList<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 DFBrowserPane_TDataStdTick_H
+#define DFBrowserPane_TDataStdTick_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+
+//! \class DFBrowserPane_TDataStdTick
+//! \brief The class to manipulate of TDataStd_Tick attribute
+class DFBrowserPane_TDataStdTick : public DFBrowserPane_AttributePane
+{
+public:
+
+ //! Constructor
+ DFBrowserPane_TDataStdTick() {}
+
+ //! Destructor
+ virtual ~DFBrowserPane_TDataStdTick() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPane_TDataStdTreeNode.hxx>
+
+#include <DFBrowserPane_AttributePaneModel.hxx>
+#include <DFBrowserPane_TableView.hxx>
+#include <DFBrowserPane_TDataStdTreeNodeItem.hxx>
+#include <DFBrowserPane_TDataStdTreeNodeModel.hxx>
+#include <DFBrowserPane_Tools.hxx>
+
+#include <TDataStd_TreeNode.hxx>
+
+#include <QVariant>
+#include <QTableView>
+#include <QTreeView>
+#include <QVBoxLayout>
+#include <QWidget>
+#include <QItemSelectionModel>
+
+//#define REQUIRE_OCAF_REVIEW:11
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowserPane_TDataStdTreeNode::DFBrowserPane_TDataStdTreeNode()
+: DFBrowserPane_AttributePane()
+{
+ myModel = new DFBrowserPane_TDataStdTreeNodeModel (0);
+ mySelectionModels.clear(); // do not use selection model of parent pane
+ mySelectionModels.push_back (new QItemSelectionModel (myModel));
+}
+
+// =======================================================================
+// function : CreateWidget
+// purpose :
+// =======================================================================
+QWidget* DFBrowserPane_TDataStdTreeNode::CreateWidget (QWidget* theParent)
+{
+ QWidget* aMainWidget = new QWidget (theParent);
+ aMainWidget->setVisible (false);
+
+ myTableView = new DFBrowserPane_TableView (aMainWidget, getTableColumnWidths());
+ DFBrowserPane_TableView::SetFixedRowCount (1, myTableView->GetTableView());
+ myTableView->SetModel (myPaneModel);
+ QTableView* aTableView = myTableView->GetTableView();
+ aTableView->setSelectionModel (mySelectionModels.front());
+ aTableView->setSelectionBehavior (QAbstractItemView::SelectRows);
+
+ QVBoxLayout* aLay = new QVBoxLayout (aMainWidget);
+ aLay->setContentsMargins (0, 0, 0, 0);
+ aLay->addWidget (myTableView);
+
+ myTreeNodeView = new QTreeView (theParent);
+ myTreeNodeView->setModel (myModel);
+ myTreeNodeView->setSelectionModel (mySelectionModels.front());
+ myTreeNodeView->setSelectionBehavior (QAbstractItemView::SelectRows);
+
+ aLay->addWidget (myTreeNodeView);
+ return aMainWidget;
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdTreeNode::Init (const Handle(TDF_Attribute)& theAttribute)
+{
+ Handle(TDataStd_TreeNode) aTreeNode = Handle(TDataStd_TreeNode)::DownCast (theAttribute);
+
+ bool aDefaultGUID = aTreeNode->ID() != aTreeNode->GetDefaultTreeID();
+ myTableView->setVisible (!aDefaultGUID);
+ if (!aDefaultGUID) {
+ QList<QVariant> aValues;
+ char aStr[256];
+ aTreeNode->ID().ToCString (aStr);
+ TCollection_AsciiString aString(aStr);
+ aValues.append (DFBrowserPane_Tools::ToString(aString));
+ getPaneModel()->Init (aValues);
+ }
+
+
+ DFBrowserPane_TDataStdTreeNodeModel* aModel = dynamic_cast<DFBrowserPane_TDataStdTreeNodeModel*> (myModel);
+ aModel->Reset();
+
+ if (!aTreeNode.IsNull())
+ {
+ Handle(TDataStd_TreeNode) aRootItem = aTreeNode->Root();
+ aModel->SetAttribute (aRootItem);
+
+ QModelIndex anIndex = aModel->FindIndex (theAttribute);
+ if (anIndex.isValid())
+ {
+ myTreeNodeView->setExpanded (anIndex.parent(), true);
+ myTreeNodeView->scrollTo (anIndex);
+
+ TreeModel_ItemBasePtr anAttributeItem = TreeModel_ModelBase::GetItemByIndex (anIndex);
+ DFBrowserPane_TDataStdTreeNodeItemPtr anAttributeNodeItem =
+ itemDynamicCast<DFBrowserPane_TDataStdTreeNodeItem>(anAttributeItem);
+ anAttributeNodeItem->setCurrentAttribute (true);
+ }
+ }
+ aModel->EmitLayoutChanged();
+}
+
+// =======================================================================
+// function : GetShortAttributeInfo
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdTreeNode::GetShortAttributeInfo (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues)
+{
+ Handle(TDataStd_TreeNode) aTNAttribute = Handle(TDataStd_TreeNode)::DownCast (theAttribute);
+ bool aDefaultGUID = aTNAttribute->ID() != aTNAttribute->GetDefaultTreeID();
+ QString aGUIDPrefix;
+ if (!aDefaultGUID) {
+ QList<QVariant> aValues;
+ char aStr[256];
+ aTNAttribute->ID().ToCString (aStr);
+ TCollection_AsciiString aString(aStr);
+ aGUIDPrefix = DFBrowserPane_Tools::ToString(aString);
+ }
+
+ if (aTNAttribute->HasFather())
+ {
+ TDF_Label aLabel = aTNAttribute->Father()->Label();
+ theValues.append (QString ("%1 ==> %2").arg(aGUIDPrefix).arg (DFBrowserPane_Tools::GetEntry (aLabel).ToCString()));
+ }
+ else
+ {
+ Handle(TDataStd_TreeNode) aFirstChild = aTNAttribute->First();
+ QStringList aRefs;
+ while (! aFirstChild.IsNull() )
+ {
+ TDF_Label aLabel = aFirstChild->Label();
+ aRefs.append (DFBrowserPane_Tools::GetEntry (aLabel).ToCString());
+ aFirstChild = aFirstChild->Next();
+ }
+ theValues.append (QString ("%1 <== (%2)").arg(aGUIDPrefix).arg (aRefs.join (", ")));
+ }
+}
+
+// =======================================================================
+// function : GetReferences
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdTreeNode::GetReferences (const Handle(TDF_Attribute)& theAttribute,
+ NCollection_List<TDF_Label>& theRefLabels,
+ Handle(Standard_Transient)&)
+{
+ Handle(TDataStd_TreeNode) anAttribute = Handle(TDataStd_TreeNode)::DownCast (theAttribute);
+ if (anAttribute.IsNull())
+ return;
+
+ theRefLabels.Append (anAttribute->Label());
+}
--- /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 DFBrowserPane_TDataStdTreeNode_H
+#define DFBrowserPane_TDataStdTreeNode_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+
+class QAbstractItemModel;
+class QTreeView;
+
+//! \class DFBrowserPane_TDataStdTreeNode
+//! \brief The class to manipulate of TDataStd_TreeNode attribute
+class DFBrowserPane_TDataStdTreeNode : public DFBrowserPane_AttributePane
+{
+public:
+
+ //! Constructor
+ Standard_EXPORT DFBrowserPane_TDataStdTreeNode();
+
+ //! Destructor
+ virtual ~DFBrowserPane_TDataStdTreeNode() {}
+
+ //! Creates table view and call create widget of array table helper
+ //! \param theParent a parent widget
+ //! \return a new widget
+ Standard_EXPORT virtual QWidget* CreateWidget (QWidget* theParent) Standard_OVERRIDE;
+
+ //! Initializes the content of the pane by the parameter attribute
+ //! \param theAttribute an OCAF attribute
+ Standard_EXPORT virtual void Init (const Handle(TDF_Attribute)& theAttribute) Standard_OVERRIDE;
+
+ //! Returns brief attribute information. In general case, it returns GetValues() result.
+ //! \param theAttribute a current attribute
+ //! \param theValues a result list of values
+ Standard_EXPORT virtual void GetShortAttributeInfo (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ virtual void GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues) Standard_OVERRIDE
+ { (void)theAttribute; (void)theValues; }
+
+ //! Returns container of Label references to the attribute
+ //! \param theAttribute a current attribute
+ //! \param theRefLabels a container of label references, to be selected in tree view
+ //! \param theRefPresentation handle of presentation for the references, to be visualized
+ Standard_EXPORT virtual void GetReferences (const Handle(TDF_Attribute)& theAttribute,
+ NCollection_List<TDF_Label>& theRefLabels,
+ Handle(Standard_Transient)& theRefPresentation) Standard_OVERRIDE;
+
+private:
+
+ QAbstractItemModel* myModel;
+ QTreeView* myTreeNodeView;
+};
+
+#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 <DFBrowserPane_TDataStdTreeNodeItem.hxx>
+
+#include <DFBrowser_Module.hxx>
+#include <DFBrowser_Tools.hxx>
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <DFBrowserPane_Tools.hxx>
+
+#include <TDataStd_TreeNode.hxx>
+#include <TDataStd_ChildNodeIterator.hxx>
+#include <TDF_AttributeIterator.hxx>
+#include <TDF_ChildIterator.hxx>
+
+#include <QIcon>
+#include <QObject>
+
+//#define REQUIRE_OCAF_REVIEW:11
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdTreeNodeItem::Init()
+{
+ DFBrowserPane_TDataStdTreeNodeItemPtr aParentItem = itemDynamicCast<DFBrowserPane_TDataStdTreeNodeItem> (Parent());
+ // if aParentItem is empty, it is the root item, an attribute field is already filled by SetAttribute method
+ if (aParentItem)
+ myAttribute = aParentItem->getChildAttribute (Row());
+
+ Handle(TDataStd_TreeNode) aTreeNode = Handle(TDataStd_TreeNode)::DownCast (myAttribute);
+ if (aTreeNode.IsNull())
+ return;
+
+ TreeModel_ItemBase::Init();
+
+ myRowCount = aTreeNode->NbChildren (false);
+ myLabelName = QString (DFBrowserPane_Tools::GetEntry (aTreeNode->Label()).ToCString());
+}
+
+// =======================================================================
+// function : Reset
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdTreeNodeItem::Reset()
+{
+ DFBrowserPane_TDataStdTreeNodeItemPtr aParentItem = itemDynamicCast<DFBrowserPane_TDataStdTreeNodeItem> (Parent());
+ if (aParentItem)
+ {
+ Handle(TDF_Attribute) anAttribute;
+ SetAttribute (anAttribute);
+ myRowCount = 0;
+ myLabelName = QString();
+ }
+ myIsCurrentItem = false;
+ TreeModel_ItemBase::Reset();
+}
+
+// =======================================================================
+// function : data
+// purpose :
+// =======================================================================
+QVariant DFBrowserPane_TDataStdTreeNodeItem::initValue (const int theRole) const
+{
+ if (Column() != 0)
+ return QVariant();
+
+ switch (theRole)
+ {
+ case Qt::DisplayRole:
+ case Qt::ToolTipRole: return getName();
+ case Qt::ForegroundRole: return myIsCurrentItem ? QColor (Qt::darkBlue) : QColor (Qt::black);
+ default: break;
+ }
+ return QVariant();
+}
+
+// =======================================================================
+// function : createChild
+// purpose :
+// =======================================================================
+TreeModel_ItemBasePtr DFBrowserPane_TDataStdTreeNodeItem::createChild(int theRow, int theColumn)
+{
+ return DFBrowserPane_TDataStdTreeNodeItem::CreateItem(currentItem(), theRow, theColumn);
+}
+
+// =======================================================================
+// function : initItem
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdTreeNodeItem::initItem() const
+{
+ if (IsInitialized())
+ return;
+ const_cast<DFBrowserPane_TDataStdTreeNodeItem*>(this)->Init();
+}
+
+// =======================================================================
+// function : getChildAttribute
+// purpose :
+// =======================================================================
+Handle(TDF_Attribute) DFBrowserPane_TDataStdTreeNodeItem::getChildAttribute (const int theChildRow) const
+{
+ Handle(TDF_Attribute) aResult;
+
+ Handle(TDataStd_TreeNode) aTreeNode = Handle(TDataStd_TreeNode)::DownCast (myAttribute);
+ int aChildNodeId = 0;
+ for (TDataStd_ChildNodeIterator aChildIt (aTreeNode); aChildIt.More(); aChildIt.Next(), aChildNodeId++)
+ {
+ if (aChildNodeId != theChildRow)
+ continue;
+ aResult = aChildIt.Value();
+ break;
+ }
+ return aResult;
+}
+
+// =======================================================================
+// function : getRowCount
+// purpose :
+// =======================================================================
+int DFBrowserPane_TDataStdTreeNodeItem::getRowCount() const
+{
+ initItem();
+ return myRowCount;
+}
--- /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 DFBrowserPane_TDataStdTreeNodeItem_H
+#define DFBrowserPane_TDataStdTreeNodeItem_H
+
+#include <Standard.hxx>
+#include <TDF_Attribute.hxx>
+#include <TreeModel_ItemBase.hxx>
+
+#include <QList>
+#include <QMap>
+#include <QVariant>
+
+class DFBrowserPane_TDataStdTreeNodeItem;
+typedef QExplicitlySharedDataPointer<DFBrowserPane_TDataStdTreeNodeItem> DFBrowserPane_TDataStdTreeNodeItemPtr;
+
+//! \class DFBrowserPane_TDataStdTreeNodeItem
+//! An item connected to TDataStd_TreeNode attribute. Parent is NULL or tree node item.
+//! Childrens are items for children of tree node attribute.
+class DFBrowserPane_TDataStdTreeNodeItem : public TreeModel_ItemBase
+{
+
+public:
+
+ //! Creates an item wrapped by a shared pointer
+ //! \param theRow the item row positition in the parent item
+ //! \param theColumn the item column positition in the parent item
+ //! \return the pointer to the created item
+ static DFBrowserPane_TDataStdTreeNodeItemPtr CreateItem (TreeModel_ItemBasePtr theParent,
+ const int theRow, const int theColumn)
+ { return DFBrowserPane_TDataStdTreeNodeItemPtr (new DFBrowserPane_TDataStdTreeNodeItem (theParent, theRow, theColumn)); }
+
+ //!Destructor
+ virtual ~DFBrowserPane_TDataStdTreeNodeItem() Standard_OVERRIDE {};
+
+ //! Store a current attribute
+ //! \param theAttribute an attribute
+ void SetAttribute (const Handle(TDF_Attribute)& theAttribute) { myAttribute = theAttribute; }
+
+ //! Set state if the attribute is current(corresponds to the selected attribute in tree)
+ //! \param theCurrent boolean state
+ void setCurrentAttribute (const bool theCurrent) { myIsCurrentItem = theCurrent; }
+
+ //! Returns child attribute of the current attribute
+ //! \param theChildRow an index of a child attribute
+ //! \returns an attribute
+ Standard_EXPORT Handle(TDF_Attribute) getChildAttribute (const int theChildRow) const;
+
+ //! Inits the item, fills internal containers
+ Standard_EXPORT virtual void Init() Standard_OVERRIDE;
+
+ //! Resets the cached item values. Throws down the initialized state of the item.
+ Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
+
+protected:
+
+ //! Returns the data stored under the given role for the current item.
+ //! \param theRole an enumeration value of role for data obtaining
+ virtual QVariant initValue (const int theRole = Qt::DisplayRole) const Standard_OVERRIDE;
+
+ //! \return number of children.
+ virtual int initRowCount() const Standard_OVERRIDE { return getRowCount(); }
+
+ //! Creates a child item in the given position.
+ //! \param theRow the child row position
+ //! \param theColumn the child column position
+ //! \return the created item
+ virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
+
+protected:
+
+ //! Constructor
+ //! param theParent a parent item
+ //! \param theRow the item row positition in the parent item
+ //! \param theColumn the item column positition in the parent item
+ DFBrowserPane_TDataStdTreeNodeItem(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ : TreeModel_ItemBase (theParent, theRow, theColumn), myIsCurrentItem (false) {}
+
+ //! Initialize the current item. It creates a backup of the specific item information
+ void initItem() const;
+
+ //! Returns number of children attributes, initializes item is necessary
+ int getRowCount() const;
+
+ //! Returns entry of the label of the current attribute tree node
+ QString getName() const { return myLabelName; }
+
+private:
+
+ Handle(TDF_Attribute) myAttribute; //! current attribute in tree node hierarchy
+ bool myIsCurrentItem; //! state whether this attribute is active in DFBrowser selected attribute in tree
+
+ int myRowCount; //! cached value of rows count
+ QString myLabelName; //! cached value of label name of the label of the current tree node attribute
+};
+
+#endif
\ 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 <DFBrowserPane_TDataStdTreeNodeModel.hxx>
+#include <DFBrowserPane_TDataStdTreeNodeItem.hxx>
+
+#include <TDataStd_TreeNode.hxx>
+
+#include <QAbstractItemModel>
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowserPane_TDataStdTreeNodeModel::DFBrowserPane_TDataStdTreeNodeModel (QObject* theParent)
+: TreeModel_ModelBase (theParent)
+{
+ m_pRootItem = DFBrowserPane_TDataStdTreeNodeItem::CreateItem (TreeModel_ItemBasePtr(), 0, 0);
+}
+
+// =======================================================================
+// function : SetAttribute
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdTreeNodeModel::SetAttribute (const Handle(TDF_Attribute)& theAttribute)
+{
+ DFBrowserPane_TDataStdTreeNodeItemPtr aRootItem = itemDynamicCast<DFBrowserPane_TDataStdTreeNodeItem>(m_pRootItem);
+ Reset();
+ aRootItem->SetAttribute (theAttribute);
+ EmitLayoutChanged();
+}
--- /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 DFBrowserPane_TDataStdTreeNodeMode_H
+#define DFBrowserPane_TDataStdTreeNodeMode_H
+
+#include <Standard.hxx>
+#include <TDF_Attribute.hxx>
+#include <TreeModel_ModelBase.hxx>
+
+#include <QObject>
+#include <QHash>
+#include <QByteArray>
+
+//! \class DFBrowserPane_TDataStdTreeNodeModel
+//! \brief It builds a tree of items for the given tree node attribute.
+class DFBrowserPane_TDataStdTreeNodeModel : public TreeModel_ModelBase
+{
+ Q_OBJECT
+public:
+
+ //! Constructor
+ Standard_EXPORT DFBrowserPane_TDataStdTreeNodeModel (QObject* theParent);
+
+ //! Destructor
+ virtual ~DFBrowserPane_TDataStdTreeNodeModel() Standard_OVERRIDE {};
+
+ //! Initializes the tree model by the attribute
+ //! \param theAttribute a current attribute
+ Standard_EXPORT void SetAttribute (const Handle(TDF_Attribute)& theAttribute);
+
+ //! Returns model index by the attribute.
+ QModelIndex FindIndex (const Handle(TDF_Attribute)& theAttribute) { (void)theAttribute; return QModelIndex(); }
+
+ //! Returns count of columns in the model.
+ //! \param theParent an index of the parent item
+ //! \return integer value
+ virtual int columnCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
+ { (void)theParent; return 1; }
+
+private:
+
+ Handle(TDF_Attribute) myAttribute; //! the parent attribute
+};
+
+#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 <DFBrowserPane_TDataStdUAttribute.hxx>
+#include <DFBrowserPane_Tools.hxx>
+
+#include <TDataStd_UAttribute.hxx>
+
+#include <QVariant>
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdUAttribute::GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
+{
+ Handle(TDataStd_UAttribute) anAttribute = Handle(TDataStd_UAttribute)::DownCast (theAttribute);
+ if (anAttribute.IsNull())
+ return;
+ char aStr[256];
+ theAttribute->ID().ToCString(aStr);
+ TCollection_AsciiString aString(aStr);
+
+ theValues.append (DFBrowserPane_Tools::ToString (aString));
+}
+
--- /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 DFBrowserPane_TDataStdUAttribute_H
+#define DFBrowserPane_TDataStdUAttribute_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+
+//! \class DFBrowserPane_TDataStdUAttribute
+//! \brief The class to manipulate of TDataStd_UAttribute attribute
+class DFBrowserPane_TDataStdUAttribute : public DFBrowserPane_AttributePane
+{
+public:
+
+ //! Constructor
+ DFBrowserPane_TDataStdUAttribute() {}
+
+ //! Destructor
+ virtual ~DFBrowserPane_TDataStdUAttribute() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPane_TDataStdVariable.hxx>
+
+#include <TDataStd_Variable.hxx>
+
+#include <QVariant>
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDataStdVariable::GetValues (const Handle(TDF_Attribute)&, QList<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 DFBrowserPane_TDataStdVariable_H
+#define DFBrowserPane_TDataStdVariable_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+
+//! \class DFBrowserPane_TDataStdVariable
+//! \brief The class to manipulate of TDataStd_Variable attribute
+class DFBrowserPane_TDataStdVariable : public DFBrowserPane_AttributePane
+{
+public:
+ //! Constructor
+ DFBrowserPane_TDataStdVariable() {}
+
+ //! Destructor
+ virtual ~DFBrowserPane_TDataStdVariable() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPane_TDocStdModified.hxx>
+
+#include <TDocStd_Modified.hxx>
+
+#include <QVariant>
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDocStdModified::GetValues (const Handle(TDF_Attribute)&, QList<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 DFBrowserPane_TDocStdModified_H
+#define DFBrowserPane_TDocStdModified_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+
+//! \class DFBrowserPane_TDocStdModified
+//! \brief The class to manipulate of TDocStd_Modified attribute
+class DFBrowserPane_TDocStdModified : public DFBrowserPane_AttributePane
+{
+public:
+
+ //! Constructor
+ DFBrowserPane_TDocStdModified() {}
+
+ //! Destructor
+ virtual ~DFBrowserPane_TDocStdModified() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPane_TDocStdOwner.hxx>
+
+#include <DFBrowserPane_AttributePaneModel.hxx>
+#include <DFBrowserPane_TableView.hxx>
+#include <DFBrowserPane_Tools.hxx>
+
+#include <TDocStd_Document.hxx>
+#include <TDocStd_Owner.hxx>
+#include <TDF_Delta.hxx>
+#include <TDF_ListIteratorOfDeltaList.hxx>
+
+#include <QVariant>
+#include <QWidget>
+
+#include <QGridLayout>
+#include <QGroupBox>
+#include <QTableView>
+
+//#define REQUIRE_OCAF_REVIEW:12
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowserPane_TDocStdOwner::DFBrowserPane_TDocStdOwner()
+ : DFBrowserPane_AttributePane()
+{
+ getPaneModel()->SetColumnCount (2);
+
+ QList<QVariant> theValues;
+ theValues << "Method" << "Value";
+ getPaneModel()->SetHeaderValues (theValues, Qt::Horizontal);
+}
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDocStdOwner::GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
+{
+ Handle(TDocStd_Owner) anAttribute = Handle(TDocStd_Owner)::DownCast (theAttribute);
+ if (anAttribute.IsNull())
+ return;
+
+ Handle(TDocStd_Document) aDocument = anAttribute->GetDocument();
+ if (aDocument.IsNull())
+ return;
+
+ theValues << STANDARD_TYPE (TDocStd_Document)->Name() << ""
+ << "IsSaved" << DFBrowserPane_Tools::BoolToStr (aDocument->IsSaved())
+ << "IsChanged" << DFBrowserPane_Tools::BoolToStr (aDocument->IsChanged())
+ << "GetSavedTime" << DFBrowserPane_Tools::BoolToStr (aDocument->GetSavedTime())
+ << "GetName" << (aDocument->IsSaved() ? DFBrowserPane_Tools::ToString (aDocument->GetName()) : "")
+ << "GetPath" << (aDocument->IsSaved() ? DFBrowserPane_Tools::ToString (aDocument->GetPath()) : "")
+ << "Main" << DFBrowserPane_Tools::GetEntry (aDocument->Main()).ToCString()
+ << "IsEmpty" << DFBrowserPane_Tools::BoolToStr (aDocument->IsEmpty())
+ << "IsValid" << DFBrowserPane_Tools::BoolToStr (aDocument->IsValid())
+ << "HasOpenCommand" << DFBrowserPane_Tools::BoolToStr (aDocument->HasOpenCommand())
+ << "GetUndoLimit" << QString::number (aDocument->GetUndoLimit())
+ << "GetAvailableUndos" << QString::number (aDocument->GetAvailableUndos())
+ << "GetUndos" << convertToString (aDocument->GetUndos())
+ << "GetAvailableRedos" << QString::number (aDocument->GetAvailableRedos())
+ << "GetRedos" << convertToString (aDocument->GetRedos())
+ << "StorageFormat" << DFBrowserPane_Tools::ToString (aDocument->StorageFormat())
+ << "IsNestedTransactionMode" << DFBrowserPane_Tools::BoolToStr (aDocument->IsNestedTransactionMode())
+ << "ModificationMode" << DFBrowserPane_Tools::BoolToStr (aDocument->ModificationMode())
+ << STANDARD_TYPE (CDM_Document)->Name() << "";
+
+ TColStd_SequenceOfExtendedString anExtensions;
+ aDocument->Extensions(anExtensions);
+ theValues << "Extensions" << convertToString (anExtensions)
+ << "FromReferencesNumber" << QString::number (aDocument->FromReferencesNumber())
+ << "ToReferencesNumber" << QString::number (aDocument->ToReferencesNumber())
+ << "IsReadOnly" << DFBrowserPane_Tools::BoolToStr (aDocument->IsReadOnly())
+ << "Modifications" << QString::number (aDocument->Modifications());
+ TColStd_SequenceOfExtendedString aComments;
+ aDocument->Extensions(aComments);
+
+ if (!aDocument->IsOpened())
+ return; // application is empty, an exception is sent in Application(),
+ // an exception is sent in FindDescription if the application is not defined
+
+ theValues << "Comments" << convertToString (aComments)
+ << "Presentation" << ""
+ << "IsStored" << DFBrowserPane_Tools::BoolToStr (aDocument->IsStored())
+ << "StorageVersion" << QString::number (aDocument->StorageVersion())
+ << "Folder" << (aDocument->IsStored() ? DFBrowserPane_Tools::ToString (aDocument->Folder()) : "")
+ << "HasRequestedFolder" << DFBrowserPane_Tools::BoolToStr (aDocument->HasRequestedFolder())
+ << "RequestedFolder" << (aDocument->HasRequestedFolder() ? DFBrowserPane_Tools::ToString (aDocument->RequestedFolder()) : "")
+ << "RequestedName" << DFBrowserPane_Tools::ToString (aDocument->RequestedName())
+ << "HasRequestedPreviousVersion" << DFBrowserPane_Tools::BoolToStr (aDocument->HasRequestedPreviousVersion())
+ << "RequestedPreviousVersion" << (aDocument->HasRequestedPreviousVersion() ?
+ DFBrowserPane_Tools::ToString (aDocument->RequestedPreviousVersion()) : "")
+ << "RequestedComment" << DFBrowserPane_Tools::ToString (aDocument->RequestedComment())
+ << "FindFileExtension" << DFBrowserPane_Tools::BoolToStr (aDocument->FindFileExtension())
+ << "FileExtension" << DFBrowserPane_Tools::ToString (aDocument->FileExtension())
+ << "FindDataType" << "" // DFBrowserPane_Tools::BoolToStr (aDocument->FindDataType())
+ << "DataType" << ""// DFBrowserPane_Tools::ToString (aDocument->DataType())
+ << "FindVersionDataType" << ""// DFBrowserPane_Tools::BoolToStr (aDocument->FindVersionDataType())
+
+ << "VersionDataType" << ""// DFBrowserPane_Tools::ToString (aDocument->VersionDataType())
+ << "FindDescription" << DFBrowserPane_Tools::BoolToStr (aDocument->FindDescription())
+ << "Description" << DFBrowserPane_Tools::ToString (aDocument->Description())
+ << "FindDomain" << ""// DFBrowserPane_Tools::BoolToStr (aDocument->FindDomain())
+ << "Domain" << ""// DFBrowserPane_Tools::ToString (aDocument->Domain())
+ << "FindStoragePlugin" << ""// DFBrowserPane_Tools::BoolToStr (aDocument->FindStoragePlugin())
+ << "StoragePlugin" << ""// DFBrowserPane_Tools::ToString (aDocument->StoragePlugin())
+ << "IsModified" << DFBrowserPane_Tools::BoolToStr (aDocument->IsModified())
+ << "IsOpened" << DFBrowserPane_Tools::BoolToStr (aDocument->IsOpened())
+ << "CanClose" << DFBrowserPane_Tools::BoolToStr (aDocument->CanClose())
+ << "ReferenceCounter" << QString::number (aDocument->ReferenceCounter());
+
+ // TODO IsInSession, IsStored, Name, IsReadOnly, IsUpToDate, CanCloseReference, IsOpened
+}
+
+// =======================================================================
+// function : GetShortAttributeInfo
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDocStdOwner::GetShortAttributeInfo (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues)
+{
+ Handle(TDocStd_Owner) anAttribute = Handle(TDocStd_Owner)::DownCast (theAttribute);
+ if (anAttribute.IsNull())
+ return;
+
+ Handle(TDocStd_Document) aDocument = anAttribute->GetDocument();
+ if (aDocument.IsNull())
+ return;
+
+ theValues.append (DFBrowserPane_Tools::ToString (aDocument->StorageFormat()));
+}
+
+// =======================================================================
+// function : convertToString
+// purpose :
+// =======================================================================
+QString DFBrowserPane_TDocStdOwner::convertToString (const TDF_DeltaList& theDeltaList)
+{
+ QStringList aNames;
+
+ for (TDF_ListIteratorOfDeltaList aDeltaIt (theDeltaList); aDeltaIt.More(); aDeltaIt.Next())
+ {
+ QString aName = DFBrowserPane_Tools::ToString (aDeltaIt.Value()->Name());
+ aNames.append (aName.isEmpty() ? "-" : aName);
+ }
+ return QString ("[%1]").arg (aNames.join (";"));
+}
+
+// =======================================================================
+// function : convertToString
+// purpose :
+// =======================================================================
+QString DFBrowserPane_TDocStdOwner::convertToString (const TColStd_SequenceOfExtendedString& theExtensions)
+{
+ QStringList aNames;
+ for (Standard_Integer anExtensionId = 1, aNumber = theExtensions.Length(); anExtensionId <= aNumber; anExtensionId++)
+ aNames.append (DFBrowserPane_Tools::ToString (theExtensions(anExtensionId)));
+
+ return QString ("[%1]").arg (aNames.join (";"));
+}
--- /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 DFBrowserPane_TDocStdOwner_H
+#define DFBrowserPane_TDocStdOwner_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+#include <TColStd_SequenceOfExtendedString.hxx>
+#include <TDF_DeltaList.hxx>
+
+//! \class DFBrowserPane_TDocStdOwner
+//! \brief The class to manipulate of TDocStd_Owner attribute
+class DFBrowserPane_TDocStdOwner : public DFBrowserPane_AttributePane
+{
+public:
+
+ //! Constructor
+ Standard_EXPORT DFBrowserPane_TDocStdOwner();
+
+ //! Destructor
+ virtual ~DFBrowserPane_TDocStdOwner() {}
+
+ //! Returns brief attribute information. In general case, it returns GetValues() result.
+ //! \param theAttribute a current attribute
+ //! \param theValues a result list of values
+ Standard_EXPORT virtual void GetShortAttributeInfo (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+
+private:
+
+ //! Generate string container by the parameter list
+ //! \param a list of TDF delta
+ //! \param string result
+ static QString convertToString (const TDF_DeltaList& theList);
+
+ //! Generate string container by the parameter list
+ //! \param a list of extensions
+ //! \param string result
+ static QString convertToString (const TColStd_SequenceOfExtendedString& theExtensions);
+
+ //! Generate string container by the ext string value
+ //! \param an ext string [short*]
+ //! \param string result
+ static QString convertToString (const Standard_ExtString& theValue) { (void)theValue; return ""; }
+};
+
+#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 <DFBrowserPane_TDocStdXLink.hxx>
+
+#include <TDocStd_XLink.hxx>
+
+#include <QVariant>
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDocStdXLink::GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
+{
+ Handle(TDocStd_XLink) anAttribute = Handle(TDocStd_XLink)::DownCast (theAttribute);
+ if (anAttribute.IsNull())
+ return;
+ theValues.append (anAttribute->LabelEntry().ToCString());
+ theValues.append (anAttribute->DocumentEntry().ToCString());
+}
+
--- /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 DFBrowserPane_TDocStdXLink_H
+#define DFBrowserPane_TDocStdXLink_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+
+//! \class DFBrowserPane_TDocStdXLink
+//! \brief The class to manipulate of TDocStd_XLink attribute
+class DFBrowserPane_TDocStdXLink : public DFBrowserPane_AttributePane
+{
+public:
+
+ //! Constructor
+ DFBrowserPane_TDocStdXLink() {}
+
+ //! Destructor
+ virtual ~DFBrowserPane_TDocStdXLink() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPane_TDocStdXLinkRoot.hxx>
+
+#include <TDocStd_XLinkRoot.hxx>
+
+#include <QVariant>
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPane_TDocStdXLinkRoot::GetValues (const Handle(TDF_Attribute)&, QList<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 DFBrowserPane_TDocStdXLinkRoot_H
+#define DFBrowserPane_TDocStdXLinkRoot_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+
+//! \class DFBrowserPane_TDocStdXLinkRoot
+//! \brief The class to manipulate of TDocStd_XLinkRoot attribute
+class DFBrowserPane_TDocStdXLinkRoot : public DFBrowserPane_AttributePane
+{
+public:
+
+ //! Constructor
+ DFBrowserPane_TDocStdXLinkRoot() {}
+
+ //! Destructor
+ virtual ~DFBrowserPane_TDocStdXLinkRoot() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPane_TFunctionFunction.hxx>
+#include <DFBrowserPane_Tools.hxx>
+
+#include <TFunction_Function.hxx>
+
+#include <QVariant>
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPane_TFunctionFunction::GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
+{
+ Handle(TFunction_Function) anAttribute = Handle(TFunction_Function)::DownCast (theAttribute);
+ if (anAttribute.IsNull())
+ return;
+ char aStr[256];
+ anAttribute->GetDriverGUID().ToCString (aStr);
+ TCollection_AsciiString aString(aStr);
+
+ theValues.append (DFBrowserPane_Tools::ToString(aString));
+}
+
--- /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 DFBrowserPane_TFunctionFunction_H
+#define DFBrowserPane_TFunctionFunction_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+
+//! \class DFBrowserPane_TFunctionFunction
+//! \brief The class to manipulate of TFunction_Function attribute
+class DFBrowserPane_TFunctionFunction : public DFBrowserPane_AttributePane
+{
+public:
+
+ //! Constructor
+ DFBrowserPane_TFunctionFunction() {}
+
+ //! Destructor
+ virtual ~DFBrowserPane_TFunctionFunction() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPane_TFunctionGraphNode.hxx>
+
+#include <TFunction_GraphNode.hxx>
+
+#include <QVariant>
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPane_TFunctionGraphNode::GetValues (const Handle(TDF_Attribute)&, QList<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 DFBrowserPane_TFunctionGraphNode_H
+#define DFBrowserPane_TFunctionGraphNode_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+
+//! \class DFBrowserPane_TFunctionGraphNode
+//! \brief The class to manipulate of TFunction_GraphNode attribute
+class DFBrowserPane_TFunctionGraphNode : public DFBrowserPane_AttributePane
+{
+public:
+
+ //! Constructor
+ DFBrowserPane_TFunctionGraphNode() {}
+
+ //! Destructor
+ virtual ~DFBrowserPane_TFunctionGraphNode() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPane_TFunctionScope.hxx>
+
+#include <TFunction_Scope.hxx>
+
+#include <QVariant>
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPane_TFunctionScope::GetValues (const Handle(TDF_Attribute)&, QList<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 DFBrowserPane_TFunctionScope_H
+#define DFBrowserPane_TFunctionScope_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+
+//! \class DFBrowserPane_TFunctionScope
+//! \brief The class to manipulate of TFunction_Scope attribute
+class DFBrowserPane_TFunctionScope : public DFBrowserPane_AttributePane
+{
+public:
+
+ //! Constructor
+ DFBrowserPane_TFunctionScope() {}
+
+ //! Destructor
+ virtual ~DFBrowserPane_TFunctionScope() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPane_TNamingNamedShape.hxx>
+
+#include <DFBrowserPane_AttributePaneModel.hxx>
+#include <DFBrowserPane_ItemDelegateButton.hxx>
+#include <DFBrowserPane_ItemRole.hxx>
+#include <DFBrowserPane_HelperExport.hxx>
+#include <DFBrowserPane_SelectionKind.hxx>
+#include <DFBrowserPane_TableView.hxx>
+#include <DFBrowserPane_Tools.hxx>
+
+#include <AIS_InteractiveObject.hxx>
+#include <AIS_Shape.hxx>
+#include <BRep_Builder.hxx>
+#include <BRepTools.hxx>
+#include <TNaming_Builder.hxx>
+#include <TNaming_Iterator.hxx>
+#include <TNaming_NamedShape.hxx>
+#include <TNaming_Tool.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Compound.hxx>
+
+#include <QFileDialog>
+#include <QGridLayout>
+#include <QEvent>
+#include <QHeaderView>
+#include <QIcon>
+#include <QMap>
+#include <QPainter>
+#include <QStyledItemDelegate>
+#include <QTableView>
+#include <QVariant>
+#include <QWidget>
+
+const int COLUMN_EXPORT_WIDTH = 20;
+const int COLUMN_TYPE_WIDTH = 70;
+const int COLUMN_POINTER_WIDTH = 110;
+const int COLUMN_REFERENCE_WIDTH = 90;
+const int COLUMN_EVOLUTION_WIDTH = 90;
+
+//#define REQUIRE_OCAF_REVIEW:13
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowserPane_TNamingNamedShape::DFBrowserPane_TNamingNamedShape()
+: DFBrowserPane_AttributePane(), myEvolutionTableView (0), myHelperExport (0)
+{
+ QList<QVariant> aHeaderValues;
+ aHeaderValues << "Value" << "Type" << "BREP" << "SV";
+ getPaneModel()->SetHeaderValues (aHeaderValues, Qt::Horizontal);
+ getPaneModel()->SetColumnCount (aHeaderValues.count());
+
+ aHeaderValues.clear();
+ aHeaderValues << "Version" << "Evolution" << "Shape" << "Current Shape" << "Original Shape";
+ getPaneModel()->SetHeaderValues (aHeaderValues, Qt::Vertical);
+
+ aHeaderValues.clear();
+ aHeaderValues << "New Shape" << "Type" << "" << "Old Shape" << "Type" << "Label" << "" << "Evolution" << "isModified";
+ myEvolutionPaneModel = new DFBrowserPane_AttributePaneModel();
+ myEvolutionPaneModel->SetHeaderValues (aHeaderValues, Qt::Horizontal);
+ myEvolutionPaneModel->SetColumnCount (aHeaderValues.count());
+ QItemSelectionModel* aSelectionModel = new QItemSelectionModel (myEvolutionPaneModel);
+ mySelectionModels.push_back (aSelectionModel);
+}
+
+// =======================================================================
+// function : CreateWidget
+// purpose :
+// =======================================================================
+QWidget* DFBrowserPane_TNamingNamedShape::CreateWidget (QWidget* theParent)
+{
+ QWidget* aMainWidget = new QWidget (theParent);
+ aMainWidget->setVisible (false);
+
+ myTableView = new DFBrowserPane_TableView (aMainWidget);
+ myTableView->SetModel (myPaneModel);
+ QTableView* aTableView = myTableView->GetTableView();
+ aTableView->setSelectionBehavior (QAbstractItemView::SelectItems);
+ std::list<QItemSelectionModel*>::const_iterator aSelectionModelsIt = mySelectionModels.begin();
+ aTableView->setSelectionModel (*aSelectionModelsIt);
+ aSelectionModelsIt++;
+
+ aTableView->horizontalHeader()->setStretchLastSection (false);
+ aTableView->setColumnWidth (0, COLUMN_POINTER_WIDTH);
+ aTableView->setColumnWidth (1, COLUMN_TYPE_WIDTH);
+ aTableView->setColumnWidth (2, COLUMN_EXPORT_WIDTH);
+ aTableView->setColumnWidth (3, COLUMN_EXPORT_WIDTH);
+ aTableView->verticalHeader()->setVisible (true);
+ DFBrowserPane_ItemDelegateButton* anItemDelegate = new DFBrowserPane_ItemDelegateButton (aTableView,
+ ":/icons/export_shape.png");
+ QList<int> aRows;
+ aRows << 0 << 1;
+ anItemDelegate->SetFreeRows (aRows);
+ QObject::connect (anItemDelegate, SIGNAL (buttonPressed (const QModelIndex&)),
+ &myHelperExport, SLOT (OnButtonPressed (const QModelIndex&)));
+ aTableView->setItemDelegateForColumn (2, anItemDelegate);
+
+ DFBrowserPane_ItemDelegateButton* anItemDelegate2 = new DFBrowserPane_ItemDelegateButton (aTableView,
+ ":/icons/folder_export.png");
+ anItemDelegate2->SetFreeRows (aRows);
+ aTableView->setItemDelegateForColumn (3, anItemDelegate2);
+
+ myEvolutionTableView = new DFBrowserPane_TableView (aMainWidget);
+ myEvolutionTableView->SetModel (myEvolutionPaneModel);
+ aTableView = myEvolutionTableView->GetTableView();
+
+ aTableView->setSelectionModel (*aSelectionModelsIt);
+
+ QList<int> aColumnWidths;
+ aColumnWidths << COLUMN_POINTER_WIDTH << COLUMN_TYPE_WIDTH << COLUMN_EXPORT_WIDTH << COLUMN_POINTER_WIDTH
+ << COLUMN_TYPE_WIDTH << COLUMN_REFERENCE_WIDTH << COLUMN_EXPORT_WIDTH << COLUMN_EVOLUTION_WIDTH;
+ for (int aColumnId = 0, aCount = aColumnWidths.size(); aColumnId < aCount; aColumnId++)
+ aTableView->setColumnWidth (aColumnId, aColumnWidths[aColumnId]);
+
+ anItemDelegate = new DFBrowserPane_ItemDelegateButton (myEvolutionTableView->GetTableView(), ":/icons/export_shape.png");
+ QObject::connect (anItemDelegate, SIGNAL (buttonPressed (const QModelIndex&)),
+ &myHelperExport, SLOT (OnButtonPressed (const QModelIndex&)));
+ myEvolutionTableView->GetTableView()->setItemDelegateForColumn (2, anItemDelegate);
+
+ anItemDelegate = new DFBrowserPane_ItemDelegateButton (myEvolutionTableView->GetTableView(), ":/icons/export_shape.png");
+ QObject::connect (anItemDelegate, SIGNAL (buttonPressed (const QModelIndex&)),
+ &myHelperExport, SLOT (OnButtonPressed (const QModelIndex&)));
+ myEvolutionTableView->GetTableView()->setItemDelegateForColumn (6, anItemDelegate);
+
+ QGridLayout* aLay = new QGridLayout (aMainWidget);
+ aLay->setContentsMargins (0, 0, 0, 0);
+ aLay->addWidget (myTableView, 0, 0);
+ aLay->addWidget (myEvolutionTableView, 1, 0);
+
+ return aMainWidget;
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void DFBrowserPane_TNamingNamedShape::Init (const Handle(TDF_Attribute)& theAttribute)
+{
+ Handle(TNaming_NamedShape) aShapeAttr = Handle(TNaming_NamedShape)::DownCast (theAttribute);
+ myHelperExport.Clear();
+
+ // table view filling
+ QList<QVariant> aValues;
+ aValues << QString::number (aShapeAttr->Version()) << "" << "" << "";
+ aValues << DFBrowserPane_Tools::ToName (DB_NS_TYPE, aShapeAttr->Evolution()).ToCString() << "" << "" << "";
+
+ NCollection_List<TopoDS_Shape> aShapes;
+ {
+ TopoDS_Shape aShape = aShapeAttr->Get();
+ TCollection_AsciiString aShapeInfo = !aShape.IsNull() ? DFBrowserPane_Tools::GetPointerInfo (aShape.TShape()) : "";
+ aValues << aShapeInfo.ToCString() << DFBrowserPane_Tools::ShapeTypeInfo (aShape) << "" << "";
+ aShapes.Append (aShape);
+
+ TopoDS_Shape aCurrentShape = TNaming_Tool::CurrentShape (aShapeAttr);
+ TCollection_AsciiString aCurrentShapeInfo = !aCurrentShape.IsNull() ?
+ DFBrowserPane_Tools::GetPointerInfo (aCurrentShape.TShape()) : "";
+ aValues << aCurrentShapeInfo.ToCString() << DFBrowserPane_Tools::ShapeTypeInfo (aCurrentShape) << "" << "";
+ aShapes.Append (aCurrentShape);
+
+ TopoDS_Shape anOriginalShape = TNaming_Tool::OriginalShape (aShapeAttr);
+ TCollection_AsciiString anOriginalShapeInfo = !anOriginalShape.IsNull() ?
+ DFBrowserPane_Tools::GetPointerInfo (aShape.TShape()) : "";
+ aValues << anOriginalShapeInfo.ToCString() << DFBrowserPane_Tools::ShapeTypeInfo (anOriginalShape) << "" << "";
+ aShapes.Append (anOriginalShape);
+ }
+
+ DFBrowserPane_AttributePaneModel* aModel = getPaneModel();
+ aModel->Init (aValues);
+
+ QModelIndexList anIndices;
+ int aRowId = 2;
+ for (NCollection_List<TopoDS_Shape>::Iterator aShapeIt (aShapes); aShapeIt.More(); aShapeIt.Next(), aRowId++)
+ {
+ const TopoDS_Shape& aShape = aShapeIt.Value();
+ if (aShape.IsNull())
+ continue;
+
+ anIndices.clear();
+ anIndices << aModel->index (aRowId, 2) << aModel->index (aRowId, 3);
+ myHelperExport.AddShape (aShape, anIndices);
+ }
+
+ // evolution table view filling
+ aValues.clear();
+ aRowId = 0;
+ for (TNaming_Iterator aShapeAttrIt (aShapeAttr); aShapeAttrIt.More(); aShapeAttrIt.Next(), aRowId++)
+ {
+ const TopoDS_Shape& anOldShape = aShapeAttrIt.OldShape();
+ const TopoDS_Shape& aNewShape = aShapeAttrIt.NewShape();
+
+ Handle(TNaming_NamedShape) anOldAttr = TNaming_Tool::NamedShape (anOldShape, aShapeAttr->Label());
+ QString aLabelInfo;
+ if (!anOldAttr.IsNull())
+ {
+ TDF_Label anOldLabel = anOldAttr->Label();
+ if (!anOldLabel.IsNull())
+ aLabelInfo = QString (DFBrowserPane_Tools::GetEntry (anOldLabel).ToCString());
+ }
+ if (!aNewShape.IsNull())
+ aValues << DFBrowserPane_Tools::GetPointerInfo (aNewShape.TShape()->This()).ToCString()
+ << DFBrowserPane_Tools::ShapeTypeInfo (aNewShape)
+ << "";
+ else
+ aValues << "" << "" << "";
+ if (!anOldShape.IsNull())
+ aValues << DFBrowserPane_Tools::GetPointerInfo (anOldShape.TShape()->This()).ToCString()
+ << DFBrowserPane_Tools::ShapeTypeInfo (anOldShape)
+ << aLabelInfo
+ << "";
+ else
+ aValues << "" << "" << "" << "";
+ aValues << DFBrowserPane_Tools::ToName (DB_NS_TYPE, aShapeAttrIt.Evolution()).ToCString()
+ << (aShapeAttrIt.IsModification() ? "true" : "false");
+ }
+
+ if (myEvolutionTableView)
+ {
+ myEvolutionTableView->setVisible (aValues.size() > 0);
+ myEvolutionPaneModel->Init (aValues);
+
+ aRowId = 0;
+ for (TNaming_Iterator aShapeAttrIt (aShapeAttr); aShapeAttrIt.More(); aShapeAttrIt.Next(), aRowId++)
+ {
+ const TopoDS_Shape& anOldShape = aShapeAttrIt.OldShape();
+ const TopoDS_Shape& aNewShape = aShapeAttrIt.NewShape();
+
+ if (!aNewShape.IsNull())
+ {
+ anIndices.clear();
+ anIndices << myEvolutionPaneModel->index (aRowId, 0) << myEvolutionPaneModel->index (aRowId, 1)
+ << myEvolutionPaneModel->index (aRowId, 2);
+ myHelperExport.AddShape (aNewShape, anIndices);
+ }
+ if (!anOldShape.IsNull())
+ {
+ anIndices.clear();
+ anIndices << myEvolutionPaneModel->index (aRowId, 3) << myEvolutionPaneModel->index (aRowId, 4)
+ << myEvolutionPaneModel->index (aRowId, 5) << myEvolutionPaneModel->index (aRowId, 6);
+ myHelperExport.AddShape (anOldShape, anIndices);
+ }
+ }
+ }
+}
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPane_TNamingNamedShape::GetValues (const Handle(TDF_Attribute)&, QList<QVariant>&)
+{
+}
+
+// =======================================================================
+// function : GetAttributeInfo
+// purpose :
+// =======================================================================
+QVariant DFBrowserPane_TNamingNamedShape::GetAttributeInfo (const Handle(TDF_Attribute)& theAttribute, int theRole,
+ int theColumnId)
+{
+ if (theColumnId != 0)
+ return DFBrowserPane_AttributePane::GetAttributeInfo (theAttribute, theRole, theColumnId);
+
+ switch (theRole)
+ {
+ case Qt::DecorationRole: return QIcon (":/icons/named_shape.png");
+ case DFBrowserPane_ItemRole_Decoration_40x40: return QIcon (":/icons/named_shape_40x40.png");
+ case Qt::ForegroundRole:
+ {
+ TopoDS_Shape aShape;
+ Handle(TNaming_NamedShape) anAttribute = Handle(TNaming_NamedShape)::DownCast (theAttribute);
+ if (!anAttribute.IsNull())
+ aShape = anAttribute->Get();
+ if (aShape.IsNull())
+ return QColor (Qt::black);
+
+ return QColor (aShape.Orientation() == TopAbs_FORWARD ? Qt::darkGray :
+ aShape.Orientation() == TopAbs_REVERSED ? QColor (Qt::gray) : Qt::black);
+ }
+ default:
+ break;
+ }
+ return DFBrowserPane_AttributePane::GetAttributeInfo (theAttribute, theRole, theColumnId);
+}
+
+// =======================================================================
+// function : GetShortAttributeInfo
+// purpose :
+// =======================================================================
+void DFBrowserPane_TNamingNamedShape::GetShortAttributeInfo (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues)
+{
+ Handle(TNaming_NamedShape) aShapeAttribute = Handle(TNaming_NamedShape)::DownCast (theAttribute);
+
+ if (aShapeAttribute->Get().IsNull())
+ theValues.append ("EMPTY SHAPE");
+ else
+ {
+ theValues.append (QString ("%1 : %2").arg (DFBrowserPane_Tools::ToName (DB_SHAPE_TYPE, aShapeAttribute->Get().ShapeType()).ToCString())
+ .arg (DFBrowserPane_Tools::ToName (DB_NS_TYPE, aShapeAttribute->Evolution()).ToCString()));
+ }
+}
+
+// =======================================================================
+// function : GetSelectionKind
+// purpose :
+// =======================================================================
+int DFBrowserPane_TNamingNamedShape::GetSelectionKind (QItemSelectionModel* theModel)
+{
+ int aKind = DFBrowserPane_AttributePaneAPI::GetSelectionKind (theModel);
+
+ QTableView* aTableView = myTableView->GetTableView();
+ if (aTableView->selectionModel() != theModel)
+ return aKind;
+
+ QModelIndexList aSelectedIndices = theModel->selectedIndexes();
+ if (aSelectedIndices.size() != 1)
+ return aKind;
+
+ QModelIndex aSelectedIndex = aSelectedIndices.first();
+ int aRow = aSelectedIndex.row();
+ if (aRow == 0 || aRow == 1)
+ return aKind;
+
+ if (aSelectedIndex.column() == 3)
+ aKind = DFBrowserPane_SelectionKind_ExportToShapeViewer;
+
+ return aKind;
+}
+
+// =======================================================================
+// function : GetSelectionParameters
+// purpose :
+// =======================================================================
+void DFBrowserPane_TNamingNamedShape::GetSelectionParameters (QItemSelectionModel* theModel,
+ NCollection_List<Handle(Standard_Transient)>& theParameters)
+{
+ QTableView* aTableView = myTableView->GetTableView();
+ if (aTableView->selectionModel() != theModel)
+ return;
+
+ QModelIndexList aSelectedIndices = theModel->selectedIndexes();
+ if (aSelectedIndices.size() != 1)
+ return;
+
+ QModelIndex aSelectedIndex = aSelectedIndices.first();
+ if (aSelectedIndex.column() != 3)
+ return;
+
+ const TopoDS_Shape& aShape = myHelperExport.GetShape (aSelectedIndex);
+ if (aShape.IsNull())
+ return;
+ theParameters.Append (aShape.TShape());
+}
+
+// =======================================================================
+// function : GetReferences
+// purpose :
+// =======================================================================
+void DFBrowserPane_TNamingNamedShape::GetReferences (const Handle(TDF_Attribute)& theAttribute,
+ NCollection_List<TDF_Label>& theRefLabels,
+ Handle(Standard_Transient)& theRefPresentation)
+{
+ if (!myEvolutionTableView)
+ return;
+ QStringList aSelectedEntries = DFBrowserPane_TableView::GetSelectedColumnValues (
+ myEvolutionTableView->GetTableView(), 5);
+
+ Handle(TNaming_NamedShape) aShapeAttr = Handle(TNaming_NamedShape)::DownCast (theAttribute);
+ for (TNaming_Iterator aShapeAttrIt (aShapeAttr); aShapeAttrIt.More(); aShapeAttrIt.Next())
+ {
+ const TopoDS_Shape& anOldShape = aShapeAttrIt.OldShape();
+
+ Handle(TNaming_NamedShape) anOldAttr = TNaming_Tool::NamedShape (anOldShape, aShapeAttr->Label());
+ QString aLabelInfo;
+ if (!anOldAttr.IsNull())
+ {
+ TDF_Label anOldLabel = anOldAttr->Label();
+ if (!anOldLabel.IsNull())
+ {
+ if (aSelectedEntries.contains (DFBrowserPane_Tools::GetEntry (anOldLabel).ToCString()))
+ theRefLabels.Append (anOldLabel);
+ }
+ }
+ }
+ TopoDS_Shape aShape = getSelectedShapes();
+ if (!aShape.IsNull())
+ theRefPresentation = new AIS_Shape (aShape);
+}
+
+// =======================================================================
+// function : GetPresentation
+// purpose :
+// =======================================================================
+Handle(Standard_Transient) DFBrowserPane_TNamingNamedShape::GetPresentation (const Handle(TDF_Attribute)& theAttribute)
+{
+ Handle(Standard_Transient) aPresentation;
+ Handle(TNaming_NamedShape) aShapeAttr = Handle(TNaming_NamedShape)::DownCast (theAttribute);
+ if (aShapeAttr.IsNull())
+ return aPresentation;
+
+ TopoDS_Shape aShape = aShapeAttr->Get();
+ if (aShape.IsNull())
+ return aPresentation;
+
+ aPresentation = new AIS_Shape (aShape);
+ return aPresentation;
+}
+
+// =======================================================================
+// function : getSelectedShapes
+// purpose :
+// =======================================================================
+TopoDS_Shape DFBrowserPane_TNamingNamedShape::getSelectedShapes()
+{
+ TopoDS_Shape aShape;
+
+ if (!myTableView && !myEvolutionTableView)
+ return aShape;
+
+ // table view selected shapes
+ QItemSelectionModel* aTableViewSelModel = myTableView->GetTableView()->selectionModel();
+ QModelIndexList anIndices = aTableViewSelModel->selectedIndexes();
+
+ BRep_Builder aBuilder;
+ TopoDS_Compound aComp;
+ aBuilder.MakeCompound (aComp);
+ bool aHasShapes = false;
+ for (QModelIndexList::const_iterator anIt = anIndices.begin(), aLast = anIndices.end(); anIt != aLast; anIt++)
+ {
+ QModelIndex anIndex = *anIt;
+ if (!myHelperExport.HasShape (anIndex))
+ continue;
+ aBuilder.Add (aComp, myHelperExport.GetShape (anIndex));
+ aHasShapes = true;
+ }
+
+ // evolution table selected shapes
+ aTableViewSelModel = myEvolutionTableView->GetTableView()->selectionModel();
+ anIndices.clear();
+ anIndices = aTableViewSelModel->selectedIndexes();
+ for (QModelIndexList::const_iterator anIt = anIndices.begin(), aLast = anIndices.end(); anIt != aLast; anIt++)
+ {
+ QModelIndex anIndex = *anIt;
+ if (!myHelperExport.HasShape (anIndex))
+ continue;
+ aBuilder.Add (aComp, myHelperExport.GetShape (anIndex));
+ aHasShapes = true;
+ }
+ if (aHasShapes)
+ aShape = aComp;
+ return aShape;
+}
--- /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 DFBrowserPane_TNamingNamedShape_H
+#define DFBrowserPane_TNamingNamedShape_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <DFBrowserPane_HelperExport.hxx>
+#include <Standard.hxx>
+#include <TDF_Attribute.hxx>
+#include <TNaming_NamedShape.hxx>
+#include <TopoDS_Shape.hxx>
+
+#include <QMap>
+#include <QModelIndex>
+
+class DFBrowserPane_TableView;
+class DFBrowserPane_AttributePaneModel;
+
+//! \class DFBrowserPane_TNamingNamedShape
+//! \brief The class to manipulate of TNaming_NamedShape attribute
+class DFBrowserPane_TNamingNamedShape : public DFBrowserPane_AttributePane
+{
+public:
+
+ //! Constructor
+ Standard_EXPORT DFBrowserPane_TNamingNamedShape();
+
+ //! Destructor
+ Standard_EXPORT virtual ~DFBrowserPane_TNamingNamedShape() {}
+
+ //! Creates table view and call create widget of array table helper
+ //! \param theParent a parent widget
+ //! \return a new widget
+ Standard_EXPORT virtual QWidget* CreateWidget (QWidget* theParent) Standard_OVERRIDE;
+
+ //! Initializes the content of the pane by the parameter attribute
+ //! \param theAttribute an OCAF attribute
+ Standard_EXPORT void Init (const Handle(TDF_Attribute)& theAttribute);
+
+ //! Returns information for the given attribute
+ //! \param theAttribute a current attribute
+ //! \param theRole a role of information, used by tree model (e.g. DisplayRole, icon, background and so on)
+ //! \param theColumnId a tree model column
+ //! \return value, interpreted by tree model depending on the role
+ Standard_EXPORT virtual QVariant GetAttributeInfo (const Handle(TDF_Attribute)& theAttribute,
+ int theRole, int theColumnId) Standard_OVERRIDE;
+
+ //! Returns brief attribute information. In general case, it returns GetValues() result.
+ //! \param theAttribute a current attribute
+ //! \param theValues a result list of values
+ Standard_EXPORT virtual void GetShortAttributeInfo (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+
+ //! Returns selection kind for the model, it may be General selection or Additional selection for example
+ //! \param theModel one of selection models provided by this pane
+ //! \return selection kind
+ Standard_EXPORT virtual int GetSelectionKind (QItemSelectionModel* theModel) Standard_OVERRIDE;
+
+ //! Returns selection parameters, that may be useful for communicate between tools
+ //! \param theModel one of selection models provided by this pane
+ //! \theParameters a container of parameters, might be extended depending on the pane state(e.g. selection)
+ Standard_EXPORT virtual void GetSelectionParameters (QItemSelectionModel* theModel,
+ NCollection_List<Handle(Standard_Transient)>& theParameters) Standard_OVERRIDE;
+
+ //! Returns container of Label references to the attribute
+ //! \param theAttribute a current attribute
+ //! \param theRefLabels a container of label references, to be selected in tree view
+ //! \param theRefPresentation handle of presentation for the references, to be visualized
+ Standard_EXPORT virtual void GetReferences (const Handle(TDF_Attribute)& theAttribute,
+ NCollection_List<TDF_Label>& theRefLabels,
+ Handle(Standard_Transient)& theRefPresentation) Standard_OVERRIDE;
+
+ //! Returns presentation of the attribute to be visualized in the view
+ //! \param theAttribute a current attribute
+ //! \return handle of presentation if the attribute has, to be visualized
+ Standard_EXPORT virtual Handle(Standard_Transient) GetPresentation
+ (const Handle (TDF_Attribute)& theAttribute) Standard_OVERRIDE;
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+
+protected:
+
+ //! Returns a compound of selected shapes in both, values and evolution tables
+ //! \return shape or NULL
+ TopoDS_Shape getSelectedShapes();
+
+private:
+
+ DFBrowserPane_TableView* myEvolutionTableView; //!< table view for evolution shapes
+ DFBrowserPane_AttributePaneModel* myEvolutionPaneModel;//!< view model for evolution shapes
+
+ DFBrowserPane_HelperExport myHelperExport; //!<! helper to perform export to BREP
+};
+
+#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 <DFBrowserPane_TNamingNaming.hxx>
+
+#include <AIS_Shape.hxx>
+#include <BRep_Builder.hxx>
+
+#include <DFBrowserPane_AttributePaneModel.hxx>
+#include <DFBrowserPane_TableView.hxx>
+#include <DFBrowserPane_Tools.hxx>
+
+#include <TDF_Label.hxx>
+#include <TNaming_ListIteratorOfListOfNamedShape.hxx>
+#include <TNaming_Name.hxx>
+#include <TNaming_Naming.hxx>
+#include <TNaming_NamedShape.hxx>
+
+#include <TopoDS_Compound.hxx>
+
+#include <QGridLayout>
+#include <QHeaderView>
+#include <QTableView>
+#include <QVariant>
+#include <QWidget>
+
+//#define REQUIRE_OCAF_REVIEW:14
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowserPane_TNamingNaming::DFBrowserPane_TNamingNaming()
+: DFBrowserPane_AttributePane(), myNamingView (0)
+{
+ myNamingModel = new DFBrowserPane_AttributePaneModel();
+
+ QList<QVariant> aHeaderValues;
+ aHeaderValues << "Type" << "Shape Type" << "Stop Named Shape" << "Index";
+ aHeaderValues << "Key_TShape" << "Context Label" << "Orientation";
+ myNamingModel->SetHeaderValues (aHeaderValues, Qt::Vertical);
+
+ aHeaderValues.clear();
+ aHeaderValues << "Arguments";
+ getPaneModel()->SetHeaderValues (aHeaderValues, Qt::Horizontal);
+}
+
+// =======================================================================
+// function : CreateWidget
+// purpose :
+// =======================================================================
+QWidget* DFBrowserPane_TNamingNaming::CreateWidget (QWidget* theParent)
+{
+ QWidget* aMainWidget = new QWidget (theParent);
+
+ myNamingView = new DFBrowserPane_TableView (aMainWidget);
+ myNamingView->GetTableView()->verticalHeader()->setVisible (true);
+ myNamingView->GetTableView()->horizontalHeader()->setVisible (false);
+ myNamingView->SetModel (myNamingModel);
+
+ myTableView = new DFBrowserPane_TableView (aMainWidget);
+ myTableView->SetModel (getPaneModel());
+ myTableView->GetTableView()->setSelectionModel (mySelectionModels.front());
+
+ QGridLayout* aLay = new QGridLayout (aMainWidget);
+ aLay->addWidget (myNamingView);
+ aLay->addWidget (myTableView);
+ aLay->setRowStretch (1, 1);
+
+ return aMainWidget;
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void DFBrowserPane_TNamingNaming::Init (const Handle(TDF_Attribute)& theAttribute)
+{
+ QList<QVariant> aValues;
+ GetValues (theAttribute, aValues);
+
+ QList<QVariant> aNamingValues;
+ for (int anValueId = 0; anValueId < 7; anValueId++)
+ aNamingValues.append (aValues[anValueId]);
+ myNamingModel->Init (aNamingValues);
+
+ QList<QVariant> aNamedShapesValues;
+ for (int anValueId = 7, aCount = aValues.size(); anValueId < aCount; anValueId++)
+ aNamedShapesValues.append (aValues[anValueId]);
+
+ getPaneModel()->Init (aNamedShapesValues);
+}
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPane_TNamingNaming::GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
+{
+ Handle(TNaming_Naming) anAttribute = Handle(TNaming_Naming)::DownCast (theAttribute);
+ if (anAttribute.IsNull())
+ return;
+
+ TNaming_Name aNamingName = anAttribute->GetName();
+
+ // values from 0-6
+ theValues.append (DFBrowserPane_Tools::ToName (DB_NAMING_TYPE, aNamingName.Type()).ToCString());
+ theValues.append (DFBrowserPane_Tools::ToName (DB_SHAPE_TYPE, aNamingName.ShapeType()).ToCString());
+ Handle(TNaming_NamedShape) aStopShape = aNamingName.StopNamedShape();
+ theValues.append (!aStopShape.IsNull() ? DFBrowserPane_Tools::GetEntry (aStopShape->Label()).ToCString() : "");
+ theValues.append (QString::number (aNamingName.Index()));
+ TopoDS_Shape aShape = aNamingName.Shape();
+ theValues.append (!aShape.IsNull() ? DFBrowserPane_Tools::GetPointerInfo (aShape.TShape()->This()).ToCString() : "");
+ TDF_Label aContextLabel = aNamingName.ContextLabel();
+ theValues.append (!aContextLabel.IsNull() ? DFBrowserPane_Tools::GetEntry (aContextLabel).ToCString() : "");
+ theValues.append (DFBrowserPane_Tools::ToName (DB_ORIENTATION_TYPE, aNamingName.Orientation()).ToCString());
+
+ // values from 7 till count of arguments
+ for (TNaming_ListIteratorOfListOfNamedShape anArgIt(aNamingName.Arguments()); anArgIt.More(); anArgIt.Next())
+ theValues.append (DFBrowserPane_Tools::GetEntry (anArgIt.Value()->Label()).ToCString());
+}
+
+// =======================================================================
+// function : GetPresentation
+// purpose :
+// =======================================================================
+Handle(Standard_Transient) DFBrowserPane_TNamingNaming::GetPresentation (const Handle (TDF_Attribute)& theAttribute)
+{
+ Handle(Standard_Transient) aPresentation;
+ Handle(TNaming_Naming) anAttribute = Handle(TNaming_Naming)::DownCast (theAttribute);
+ if (anAttribute.IsNull())
+ return aPresentation;
+
+ DFBrowserPane_TableView* aTableView = getTableView();
+ if (!aTableView) // the pane is not visualized yet
+ return aPresentation;
+
+ QStringList aSelectedEntries = DFBrowserPane_TableView::GetSelectedColumnValues (aTableView->GetTableView(), 0);
+ TNaming_Name aNamingName = anAttribute->GetName();
+
+ BRep_Builder aBuilder;
+ TopoDS_Compound aComp;
+ aBuilder.MakeCompound (aComp);
+ bool aHasShapes = false;
+ for (TNaming_ListIteratorOfListOfNamedShape aNamingIt(aNamingName.Arguments()); aNamingIt.More(); aNamingIt.Next())
+ {
+ Handle(TNaming_NamedShape) aShapeAttr = aNamingIt.Value();
+ if (aShapeAttr.IsNull())
+ continue;
+ TDF_Label aLabel = aShapeAttr->Label();
+ if (!aSelectedEntries.contains (DFBrowserPane_Tools::GetEntry (aLabel).ToCString()))
+ continue;
+ aBuilder.Add (aComp, aShapeAttr->Get());
+ aHasShapes = true;
+ }
+ TopoDS_Shape aShape = aComp;
+ if (!aShape.IsNull() && aHasShapes)
+ aPresentation = new AIS_Shape (aShape);
+
+ return aPresentation;
+}
+
+// =======================================================================
+// function : GetReferences
+// purpose :
+// =======================================================================
+void DFBrowserPane_TNamingNaming::GetReferences (const Handle(TDF_Attribute)& theAttribute,
+ NCollection_List<TDF_Label>& theRefLabels,
+ Handle(Standard_Transient)&)
+{
+ Handle(TNaming_Naming) anAttribute = Handle(TNaming_Naming)::DownCast (theAttribute);
+ if (anAttribute.IsNull())
+ return;
+
+ QStringList aSelectedEntries = DFBrowserPane_TableView::GetSelectedColumnValues (getTableView()->GetTableView(), 0);
+ for (TNaming_ListIteratorOfListOfNamedShape aNamingIt(anAttribute->GetName().Arguments()); aNamingIt.More(); aNamingIt.Next())
+ {
+ Handle(TNaming_NamedShape) aShapeAttr = aNamingIt.Value();
+ if (aShapeAttr.IsNull())
+ continue;
+ TDF_Label aLabel = aShapeAttr->Label();
+ if (aSelectedEntries.contains (DFBrowserPane_Tools::GetEntry (aLabel).ToCString()))
+ theRefLabels.Append (aLabel);
+ }
+}
--- /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 DFBrowserPane_TNamingNaming_H
+#define DFBrowserPane_TNamingNaming_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+
+class DFBrowserPane_AttributePaneModel;
+class DFBrowserPane_TableView;
+
+class QWidget;
+
+//! \class DFBrowserPane_TNamingNaming
+//! \brief The class to manipulate of TNaming_Naming attribute
+class DFBrowserPane_TNamingNaming : public DFBrowserPane_AttributePane
+{
+public:
+
+ //! Constructor
+ Standard_EXPORT DFBrowserPane_TNamingNaming();
+
+ //! Destructor
+ virtual ~DFBrowserPane_TNamingNaming() {}
+
+ //! Creates table view and call create widget of array table helper
+ //! \param theParent a parent widget
+ //! \return a new widget
+ Standard_EXPORT virtual QWidget* CreateWidget (QWidget* theParent) Standard_OVERRIDE;
+
+ //! Initializes the content of the pane by the parameter attribute
+ //! \param theAttribute an OCAF attribute
+ Standard_EXPORT virtual void Init (const Handle(TDF_Attribute)& theAttribute) Standard_OVERRIDE;
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+
+ //! Returns presentation of the attribute to be visualized in the view
+ //! \param theAttribute a current attribute
+ //! \return handle of presentation if the attribute has, to be visualized
+ Standard_EXPORT virtual Handle(Standard_Transient) GetPresentation
+ (const Handle (TDF_Attribute)& theAttribute) Standard_OVERRIDE;
+
+ //! Returns container of Label references to the attribute
+ //! \param theAttribute a current attribute
+ //! \param theRefLabels a container of label references, to be selected in tree view
+ //! \param theRefPresentation handle of presentation for the references, to be visualized
+ Standard_EXPORT virtual void GetReferences (const Handle(TDF_Attribute)& theAttribute,
+ NCollection_List<TDF_Label>& theRefLabels,
+ Handle(Standard_Transient)& theRefPresentation) Standard_OVERRIDE;
+private:
+
+ DFBrowserPane_TableView* myNamingView; //!< naming table view
+ DFBrowserPane_AttributePaneModel* myNamingModel; //!< naming parameters model
+};
+
+#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 <DFBrowserPane_TNamingUsedShapes.hxx>
+
+#include <AIS_Shape.hxx>
+#include <BRep_Builder.hxx>
+
+#include <DFBrowserPane_AttributePaneModel.hxx>
+#include <DFBrowserPane_AttributePaneSelector.hxx>
+#include <DFBrowserPane_TableView.hxx>
+#include <DFBrowserPane_Tools.hxx>
+
+#include <TDF_Label.hxx>
+
+#include <TNaming_DataMapIteratorOfDataMapOfShapePtrRefShape.hxx>
+#include <TNaming_NamedShape.hxx>
+#include <TNaming_PtrRefShape.hxx>
+#include <TNaming_RefShape.hxx>
+#include <TNaming_UsedShapes.hxx>
+
+#include <TopoDS_Compound.hxx>
+#include <TopoDS_Shape.hxx>
+
+#include <QItemSelectionModel>
+#include <QTableView>
+#include <QVariant>
+#include <QWidget>
+
+//#define REQUIRE_OCAF_REVIEW:15
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowserPane_TNamingUsedShapes::DFBrowserPane_TNamingUsedShapes()
+: DFBrowserPane_AttributePane()
+{
+ getPaneModel()->SetColumnCount (4);
+
+ QList<QVariant> theValues;
+ theValues << "ShapeType" << "Label Entry" << "Key_TShape" << "Value_TShape";
+ getPaneModel()->SetHeaderValues (theValues, Qt::Horizontal);
+}
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPane_TNamingUsedShapes::GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
+{
+ Handle(TNaming_UsedShapes) anAttribute = Handle(TNaming_UsedShapes)::DownCast (theAttribute);
+ if (anAttribute.IsNull())
+ return;
+
+ std::list<TCollection_AsciiString> aReferences;
+ if (myAttributeRefs.Find (anAttribute, aReferences))
+ {
+ QMap<TCollection_AsciiString, QList<QVariant> > anEntryValues;
+ QList<QVariant> aValues;
+ TNaming_DataMapOfShapePtrRefShape& aMap = anAttribute->Map();
+ for (TNaming_DataMapIteratorOfDataMapOfShapePtrRefShape aRefIt (aMap); aRefIt.More(); aRefIt.Next())
+ {
+ TCollection_AsciiString anEntry = DFBrowserPane_Tools::GetEntry (aRefIt.Value()->Label());
+ aValues.clear();
+ TopoDS_Shape aShape = aRefIt.Key();
+ aValues.append (!aShape.IsNull() ? DFBrowserPane_Tools::ToName (DB_SHAPE_TYPE, aShape.ShapeType()).ToCString()
+ : "EMPTY SHAPE");
+ aValues.append (!aShape.IsNull() ? DFBrowserPane_Tools::GetPointerInfo (aShape.TShape()->This()).ToCString() : "");
+ const TopoDS_Shape aValueShape = aRefIt.Value()->Shape();
+ aValues.append (!aValueShape.IsNull() ?
+ DFBrowserPane_Tools::GetPointerInfo (aValueShape.TShape()->This()).ToCString() : "");
+ anEntryValues[anEntry] = aValues;
+ }
+
+ for (std::list<TCollection_AsciiString>::const_iterator aRefIt = aReferences.begin(); aRefIt != aReferences.end(); aRefIt++)
+ {
+ aValues = anEntryValues[*aRefIt];
+ theValues << aValues[0] << QString ((*aRefIt).ToCString()) << aValues[1] << aValues[2];
+ }
+ }
+ else
+ {
+ TNaming_DataMapOfShapePtrRefShape& aMap = anAttribute->Map();
+ for (TNaming_DataMapIteratorOfDataMapOfShapePtrRefShape aRefIt (aMap); aRefIt.More(); aRefIt.Next())
+ {
+ TopoDS_Shape aShape = aRefIt.Key();
+ theValues.append (!aShape.IsNull() ? DFBrowserPane_Tools::ToName (DB_SHAPE_TYPE, aShape.ShapeType()).ToCString()
+ : "EMPTY SHAPE");
+ theValues.append (DFBrowserPane_Tools::GetEntry (aRefIt.Value()->Label()).ToCString());
+ theValues.append (!aShape.IsNull() ? DFBrowserPane_Tools::GetPointerInfo (aShape.TShape()->This()).ToCString() : "");
+ const TopoDS_Shape aValueShape = aRefIt.Value()->Shape();
+ theValues.append (!aValueShape.IsNull() ? DFBrowserPane_Tools::GetPointerInfo (aValueShape.TShape()->This()).ToCString() : "");
+ }
+ }
+}
+
+// =======================================================================
+// function : GetAttributeInfo
+// purpose :
+// =======================================================================
+QVariant DFBrowserPane_TNamingUsedShapes::GetAttributeInfo (const Handle(TDF_Attribute)& theAttribute, int theRole,
+ int theColumnId)
+{
+ if (theColumnId != 0)
+ return DFBrowserPane_AttributePane::GetAttributeInfo (theAttribute, theRole, theColumnId);
+
+ switch (theRole)
+ {
+ case Qt::ForegroundRole: return QColor (myAttributeRefs.IsEmpty() ? Qt::gray : Qt::black);
+ case Qt::ToolTipRole:
+ return QVariant (myAttributeRefs.IsEmpty() ? QString (QObject::tr ("Content is not sorted yet")) : "");
+ default:
+ break;
+ }
+ return DFBrowserPane_AttributePane::GetAttributeInfo (theAttribute, theRole, theColumnId);
+}
+
+// =======================================================================
+// function : GetShortAttributeInfo
+// purpose :
+// =======================================================================
+void DFBrowserPane_TNamingUsedShapes::GetShortAttributeInfo (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues)
+{
+ Handle(TNaming_UsedShapes) anAttribute = Handle(TNaming_UsedShapes)::DownCast (theAttribute);
+ if (anAttribute.IsNull())
+ return;
+
+ theValues.append (QString ("[%1]").arg (anAttribute->Map().Extent()));
+}
+
+// =======================================================================
+// function : GetAttributeReferences
+// purpose :
+// =======================================================================
+void DFBrowserPane_TNamingUsedShapes::GetAttributeReferences (const Handle(TDF_Attribute)& theAttribute,
+ NCollection_List<Handle(TDF_Attribute)>& theRefAttributes,
+ Handle(Standard_Transient)& /*theRefPresentation*/)
+{
+ Handle(TNaming_UsedShapes) anAttribute = Handle(TNaming_UsedShapes)::DownCast (theAttribute);
+ if (anAttribute.IsNull())
+ return;
+
+ QStringList aSelectedEntries = DFBrowserPane_TableView::GetSelectedColumnValues (getTableView()->GetTableView(), 1);
+ for (TNaming_DataMapIteratorOfDataMapOfShapePtrRefShape aRefIt (anAttribute->Map()); aRefIt.More(); aRefIt.Next())
+ {
+ if (aSelectedEntries.contains (DFBrowserPane_Tools::GetEntry (aRefIt.Value()->Label()).ToCString()))
+ theRefAttributes.Append (aRefIt.Value()->NamedShape());
+ }
+}
--- /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 DFBrowserPane_TNamingUsedShapes_H
+#define DFBrowserPane_TNamingUsedShapes_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <NCollection_DataMap.hxx>
+#include <Standard.hxx>
+#include <TCollection_AsciiString.hxx>
+
+class QWidget;
+
+//! \class DFBrowserPane_TNamingUsedShapes
+//! \brief The class to manipulate of TNaming_UsedShapes attribute
+class DFBrowserPane_TNamingUsedShapes : public DFBrowserPane_AttributePane
+{
+public:
+
+ //! Constructor
+ Standard_EXPORT DFBrowserPane_TNamingUsedShapes();
+
+ //! Destructor
+ virtual ~DFBrowserPane_TNamingUsedShapes() {}
+
+ //! Sets cache of sorted references. If it exists, table view values are obtained not from the attibute
+ //! \param theAttributeRefs container of references
+ void SetSortedReferences (NCollection_DataMap<Handle(TDF_Attribute), std::list<TCollection_AsciiString> >& theAttributeRefs)
+ { myAttributeRefs = theAttributeRefs; }
+
+ //! Clears cache container of sorted references
+ void ClearSortedReferences() { myAttributeRefs.Clear(); }
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+
+ //! Returns brief attribute information. In general case, it returns GetValues() result.
+ //! \param theAttribute a current attribute
+ //! \param theValues a result list of values
+ Standard_EXPORT virtual void GetShortAttributeInfo (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+
+ //! Returns information for the given attribute
+ //! \param theAttribute a current attribute
+ //! \param theRole a role of information, used by tree model (e.g. DisplayRole, icon, background and so on)
+ //! \param theColumnId a tree model column
+ //! \return value, interpreted by tree model depending on the role
+ Standard_EXPORT virtual QVariant GetAttributeInfo (const Handle(TDF_Attribute)& theAttribute,
+ int theRole, int theColumnId) Standard_OVERRIDE;
+
+ //! Returns container of Attribute references to the attribute
+ //! \param theAttribute a current attribute
+ //! \param theRefAttributes a container of attribute references, to be selected in tree view
+ //! \param theRefPresentation handle of presentation for the references, to be visualized
+ Standard_EXPORT virtual void GetAttributeReferences (const Handle(TDF_Attribute)& theAttribute,
+ NCollection_List<Handle(TDF_Attribute)>& theRefAttributes,
+ Handle(Standard_Transient)& theRefPresentation) Standard_OVERRIDE;
+
+private:
+
+ NCollection_DataMap<Handle(TDF_Attribute), std::list<TCollection_AsciiString> > myAttributeRefs;
+};
+
+#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 <DFBrowserPane_TPrsStdAISPresentation.hxx>
+
+#include <DFBrowserPane_AttributePaneModel.hxx>
+#include <DFBrowserPane_Tools.hxx>
+
+#include <TPrsStd_AISPresentation.hxx>
+
+#include <QVariant>
+#include <QWidget>
+
+//#define REQUIRE_OCAF_REVIEW:16
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowserPane_TPrsStdAISPresentation::DFBrowserPane_TPrsStdAISPresentation()
+ : DFBrowserPane_AttributePane()
+{
+ getPaneModel()->SetColumnCount (2);
+
+ QList<QVariant> theValues;
+ theValues << "Method" << "Value";
+ getPaneModel()->SetHeaderValues (theValues, Qt::Horizontal);
+}
+
+// =======================================================================
+// function : toString
+// purpose :
+// =======================================================================
+QString toString (const Quantity_NameOfColor& theNameOfColor)
+{
+ Quantity_Color aColor(theNameOfColor);
+ return QString ("(%1, %2, %3)").arg (aColor.Red()).arg (aColor.Green()).arg (aColor.Blue());
+}
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPane_TPrsStdAISPresentation::GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
+{
+ Handle(TPrsStd_AISPresentation) anAttribute = Handle(TPrsStd_AISPresentation)::DownCast (theAttribute);
+ if (anAttribute.IsNull())
+ return;
+ Handle(AIS_InteractiveObject) anIO = anAttribute->GetAIS();
+ theValues << "GetDriverGUID" << ""//DFBrowserPane_Tools::ToString (anAttribute->GetDriverGUID())
+ << "GetAIS" << (anIO.IsNull() ? "Null" : anAttribute->DynamicType()->Name())
+ << "IsDisplayed" << DFBrowserPane_Tools::BoolToStr (anAttribute->IsDisplayed())
+ << "GetContext()" << (!anIO->GetContext().IsNull() ?
+ DFBrowserPane_Tools::GetPointerInfo (anIO->GetContext()).ToCString() : "")
+ << "HasOwnMaterial" << DFBrowserPane_Tools::BoolToStr (anAttribute->HasOwnMaterial())
+ << "Material" << (anAttribute->HasOwnMaterial() ?
+ DFBrowserPane_Tools::ToName (DB_MATERIAL_TYPE, anAttribute->Material()) : "").ToCString()
+ << "Transparency" << TCollection_AsciiString (anAttribute->Transparency()).ToCString()
+ << "HasOwnColor" << DFBrowserPane_Tools::BoolToStr (anAttribute->HasOwnColor())
+ << "Color" << (anAttribute->HasOwnColor() ? toString (anAttribute->Color()) : "")
+ << "HasOwnWidth"<< DFBrowserPane_Tools::BoolToStr (anAttribute->HasOwnWidth())
+ << "Width"<< (anAttribute->HasOwnWidth() ? QString::number (anAttribute->Width()) : "")
+ << "HasOwnMode"<< DFBrowserPane_Tools::BoolToStr (anAttribute->HasOwnMode())
+ << "Width"<< (anAttribute->HasOwnMode() ? DFBrowserPane_Tools::ToName (
+ DB_DISPLAY_MODE, anAttribute->Mode()) : "").ToCString()
+ << "HasOwnSelectionMode" << DFBrowserPane_Tools::BoolToStr (anAttribute->HasOwnSelectionMode())
+ << "SelectionMode" << (anAttribute->HasOwnSelectionMode() ?
+ QString::number (anAttribute->SelectionMode()) : "");
+}
+
+// =======================================================================
+// function : GetPresentation
+// purpose :
+// =======================================================================
+Handle(Standard_Transient) DFBrowserPane_TPrsStdAISPresentation::GetPresentation (
+ const Handle(TDF_Attribute)& theAttribute)
+{
+ Handle(Standard_Transient) aPresentation;
+
+ Handle(TPrsStd_AISPresentation) anAttribute = Handle(TPrsStd_AISPresentation)::DownCast (theAttribute);
+ if (!anAttribute.IsNull())
+ aPresentation = anAttribute->GetAIS();
+
+ return aPresentation;
+}
--- /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 DFBrowserPane_TPrsStdAISPresentation_H
+#define DFBrowserPane_TPrsStdAISPresentation_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+
+//! \class DFBrowserPane_TPrsStdAISPresentation
+//! \brief The class to manipulate of TPrsStdAIS_Presentation attribute
+class DFBrowserPane_TPrsStdAISPresentation : public DFBrowserPane_AttributePane
+{
+public:
+ //! Constructor
+ Standard_EXPORT DFBrowserPane_TPrsStdAISPresentation();
+
+ //! Destructor
+ virtual ~DFBrowserPane_TPrsStdAISPresentation() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+
+ //! Returns presentation of the attribute to be visualized in the view
+ //! \param theAttribute a current attribute
+ //! \return handle of presentation if the attribute has, to be visualized
+ Standard_EXPORT virtual Handle(Standard_Transient) GetPresentation
+ (const Handle (TDF_Attribute)& theAttribute) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPane_TPrsStdAISViewer.hxx>
+
+#include <TPrsStd_AISViewer.hxx>
+
+#include <QVariant>
+
+// =======================================================================
+// function :
+// purpose :
+// =======================================================================
+void DFBrowserPane_TPrsStdAISViewer::GetValues (const Handle(TDF_Attribute)&, QList<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 DFBrowserPane_TPrsStdAISViewer_H
+#define DFBrowserPane_TPrsStdAISViewer_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+
+//! \class DFBrowserPane_TPrsStdAISViewer
+//! \brief The class to manipulate of TPrsStd_AISViewer attribute
+class DFBrowserPane_TPrsStdAISViewer : public DFBrowserPane_AttributePane
+{
+public:
+ //! Constructor
+ DFBrowserPane_TPrsStdAISViewer() {}
+
+ //! Destructor
+ virtual ~DFBrowserPane_TPrsStdAISViewer() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ virtual void GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPane_TableView.hxx>
+#include <DFBrowserPane_Tools.hxx>
+
+#include <QWidget>
+#include <QTableView>
+#include <QAbstractTableModel>
+#include <QHeaderView>
+#include <QHBoxLayout>
+
+static const int DEFAULT_ROW_HEIGHT = 30;
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowserPane_TableView::DFBrowserPane_TableView (QWidget* theParent,
+ const QMap<int, int>& theDefaultColumnWidths)
+: QWidget (theParent)
+{
+ QHBoxLayout* aLay = new QHBoxLayout (this);
+ aLay->setContentsMargins (0, 0, 0, 0);
+
+ myTableView = new QTableView (theParent);
+ myTableView->setShowGrid (false);
+
+ QHeaderView* aVHeader = myTableView->verticalHeader();
+ aVHeader->setVisible (false);
+ aVHeader->setDefaultSectionSize (aVHeader->minimumSectionSize() + DFBrowserPane_Tools::HeaderSectionMargin());
+
+ myTableView->horizontalHeader()->setStretchLastSection (true);
+ aLay->addWidget (myTableView);
+ myDefaultColumnWidths = theDefaultColumnWidths;
+}
+
+// =======================================================================
+// function : SetModel
+// purpose :
+// =======================================================================
+void DFBrowserPane_TableView::SetModel (QAbstractTableModel* theModel)
+{
+ myTableView->setModel (theModel);
+
+ for (int aColumnId = 0, aCount = theModel->columnCount(); aColumnId < aCount; aColumnId++)
+ myTableView->setColumnWidth (aColumnId, myDefaultColumnWidths.contains (aColumnId) ?
+ myDefaultColumnWidths[aColumnId] : DFBrowserPane_Tools::DefaultPanelColumnWidth (aColumnId));
+}
+
+// =======================================================================
+// function : SetFixedRowCount
+// purpose :
+// =======================================================================
+void DFBrowserPane_TableView::SetFixedRowCount (const int theCount, QTableView* theView)
+{
+ theView->setMaximumHeight (DEFAULT_ROW_HEIGHT*(theCount + 1/*header row*/));
+}
+
+// =======================================================================
+// function : GetSelectedColumnValues
+// purpose :
+// =======================================================================
+QStringList DFBrowserPane_TableView::GetSelectedColumnValues (QTableView* theTableView, const int theColumnId)
+{
+ QAbstractItemModel* aModel = theTableView->model();
+ QModelIndexList aSelectedIndices = theTableView->selectionModel()->selectedIndexes();
+
+ QStringList aSelectedEntries;
+ for (QModelIndexList::const_iterator aSelectedIt = aSelectedIndices.begin();
+ aSelectedIt != aSelectedIndices.end(); aSelectedIt++)
+ {
+ QModelIndex anIndex = *aSelectedIt;
+ aSelectedEntries.append (aModel->data (aModel->index (anIndex.row(), theColumnId, anIndex.parent()), Qt::DisplayRole).toString());
+ }
+ return aSelectedEntries;
+}
--- /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 DFBrowserPane_TableView_H
+#define DFBrowserPane_TableView_H
+
+#include <Standard.hxx>
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4127) // conditional expression is constant
+#endif
+#include <QWidget>
+#include <QMap>
+
+class QTableView;
+class QAbstractTableModel;
+
+//! \class DFBrowserPane_TableView
+//! \brief The widget that contains table view with some settings:
+//! - table grid is hidden
+//! - vertical header is hidden
+//! - stretch last column by horizonal
+//! - default width of columns.
+class DFBrowserPane_TableView : public QWidget
+{
+public:
+
+ //! Constructor
+ Standard_EXPORT DFBrowserPane_TableView (QWidget* theParent,
+ const QMap<int, int>& theDefaultColumnWidths = QMap<int, int>());
+ //! Destructor
+ virtual ~DFBrowserPane_TableView() {}
+
+ //! Sets model into table view. After, set column widths for view
+ Standard_EXPORT void SetModel (QAbstractTableModel* theModel);
+
+ //! Returns the current table view
+ QTableView* GetTableView() const { return myTableView; }
+
+ //! Updates table view height to contain the given number of rows only
+ //! \param theCount a row count
+ //! \param theView a table view, which size will be changed
+ Standard_EXPORT static void SetFixedRowCount (const int theCount, QTableView* theView);
+
+ //! Returns names of selected items in the view
+ //! \param theView a table view
+ //! \param theColumnId a column index
+ //! \return container of strings
+ Standard_EXPORT static QStringList GetSelectedColumnValues (QTableView* theTable, const int theColumnId);
+
+private:
+
+ QTableView* myTableView; //!< the current table view
+ QMap<int, int> myDefaultColumnWidths; //!< container of default widths of columns
+};
+
+#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 <DFBrowserPane_Tools.hxx>
+
+#include <AIS_DisplayMode.hxx>
+#include <Graphic3d_MaterialAspect.hxx>
+#include <Graphic3d_NameOfMaterial.hxx>
+#include <Standard_Version.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TDataStd.hxx>
+#include <TDataStd_RealEnum.hxx>
+#include <TDataXtd.hxx>
+#include <TDataXtd_ConstraintEnum.hxx>
+#include <TDataXtd_GeometryEnum.hxx>
+#include <TDF_Tool.hxx>
+#include <TNaming.hxx>
+#include <TNaming_NameType.hxx>
+#include <TNaming_Evolution.hxx>
+#include <TopAbs.hxx>
+#include <TopAbs_ShapeEnum.hxx>
+#include <TopAbs_Orientation.hxx>
+
+#include <QApplication>
+#include <QStringList>
+#include <QStyle>
+
+#include <sstream>
+
+//#define REQUIRE_OCAF_REVIEW:8 : start
+const int TABLE_COLUMN_0_WIDTH = 200;
+const int TABLE_COLUMN_OTHER_WIDTH = 120;
+
+// =======================================================================
+// function : DefaultPanelColumnWidth
+// purpose :
+// =======================================================================
+int DFBrowserPane_Tools::DefaultPanelColumnWidth (const int theColumnId)
+{
+ return theColumnId == 0 ? TABLE_COLUMN_0_WIDTH : TABLE_COLUMN_OTHER_WIDTH;
+}
+
+// =======================================================================
+// function : GetEntry
+// purpose :
+// =======================================================================
+TCollection_AsciiString DFBrowserPane_Tools::GetEntry (const TDF_Label& theLabel)
+{
+ if (theLabel.IsNull())
+ return "Null";
+
+ TCollection_AsciiString anAsciiEntry;
+ TDF_Tool::Entry(theLabel, anAsciiEntry);
+ return anAsciiEntry;
+}
+
+// =======================================================================
+// function : GetPointerInfo
+// purpose :
+// =======================================================================
+TCollection_AsciiString DFBrowserPane_Tools::GetPointerInfo (const Handle(Standard_Transient)& thePointer, const bool isShortInfo)
+{
+ std::ostringstream aPtrStr;
+ aPtrStr << thePointer.operator->();
+ if (!isShortInfo)
+ return aPtrStr.str().c_str();
+
+ TCollection_AsciiString anInfoPtr (aPtrStr.str().c_str());
+ for (int aSymbolId = 1; aSymbolId < anInfoPtr.Length(); aSymbolId++)
+ {
+ if (anInfoPtr.Value(aSymbolId) != '0')
+ {
+ anInfoPtr = anInfoPtr.SubString(aSymbolId, anInfoPtr.Length());
+ anInfoPtr.Prepend("0x");
+ return anInfoPtr;
+ }
+ }
+ return aPtrStr.str().c_str();
+}
+
+// =======================================================================
+// function : ShapeTypeInfo
+// purpose :
+// =======================================================================
+QVariant DFBrowserPane_Tools::ShapeTypeInfo (const TopoDS_Shape& theShape)
+{
+ return theShape.IsNull() ? QString ("Empty")
+ : QString (DFBrowserPane_Tools::ToName (DB_SHAPE_TYPE, theShape.ShapeType()).ToCString());
+}
+
+// =======================================================================
+// function : ToName
+// purpose :
+// =======================================================================
+TCollection_AsciiString DFBrowserPane_Tools::ToName (const DFBrowserPane_OcctEnumType& theType,
+ const Standard_Integer& theEnumId)
+{
+ Standard_SStream aSStream;
+ switch (theType)
+ {
+ case DB_CONSTRAINT_TYPE: { TDataXtd::Print ((TDataXtd_ConstraintEnum)theEnumId, aSStream); break; }
+ case DB_NAMING_TYPE: { TNaming::Print ((TNaming_NameType)theEnumId, aSStream); break; }
+ case DB_SHAPE_TYPE: { TopAbs::Print ((TopAbs_ShapeEnum)theEnumId, aSStream); break; }
+ case DB_NS_TYPE: { TNaming::Print ((TNaming_Evolution)theEnumId, aSStream); break; }
+ case DB_GEOM_TYPE: { TDataXtd::Print ((TDataXtd_GeometryEnum)theEnumId, aSStream); break; }
+ case DB_DIMENSION_TYPE: { TDataStd::Print ((TDataStd_RealEnum)theEnumId, aSStream); break; }
+ case DB_MATERIAL_TYPE: return Graphic3d_MaterialAspect::MaterialName (theEnumId+1);
+ case DB_DISPLAY_MODE:
+ {
+ switch (theEnumId)
+ {
+ case AIS_WireFrame: return "WireFrame";
+ case AIS_Shaded: return "Shaded";
+ default: return "UNKNOWN DISPLAY MODE";
+ }
+ break;
+ }
+ case DB_ORIENTATION_TYPE: { TopAbs::Print((TopAbs_Orientation)theEnumId, aSStream); break; }
+ default: return "UNKNOWN PARAMETER";
+ }
+ return aSStream.str().c_str();
+}
+//#define REQUIRE_OCAF_REVIEW:8 : end
--- /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 DFBrowserPane_Tools_H
+#define DFBrowserPane_Tools_H
+
+#include <DFBrowserPane_OcctEnumType.hxx>
+#include <Standard.hxx>
+#include <TCollection_ExtendedString.hxx>
+#include <TDF_Label.hxx>
+#include <TopLoc_Location.hxx>
+#include <TopoDS_Shape.hxx>
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4127) // conditional expression is constant
+#endif
+#include <QApplication>
+#include <QString>
+#include <QStyle>
+#include <QString>
+#include <QVariant>
+
+#define PROPERTY_TABLE_ROW_COUNT 200
+
+//! \class DFBrowserPane_Tools
+//! \brief The tool that gives auxiliary methods for TDocStd elements manipulation
+class DFBrowserPane_Tools
+{
+public:
+
+ //! Returns default value for table view model: width[0] = 200, width[others] = 120
+ //! \param theColumnId a column index
+ //! \returns value
+ Standard_EXPORT static int DefaultPanelColumnWidth (const int theColumnId);
+
+ //! Returns header margin, defined in style settings of application
+ //! \return integer value
+ Standard_EXPORT static int HeaderSectionMargin() { return qApp->style()->pixelMetric (QStyle::PM_HeaderMargin); }
+
+ //! Returns a string presentation of the label
+ //! \param theLabel a label object
+ //! \return the string value
+ Standard_EXPORT static TCollection_AsciiString GetEntry (const TDF_Label& theLabel);
+
+ //! Convert pointer to string value
+ //! \param thePointer a pointer
+ //! \param isShortInfo if true, all '0' symbols in the beginning of the pointer are skipped
+ //! \return the string value
+ Standard_EXPORT static TCollection_AsciiString GetPointerInfo (const Handle(Standard_Transient)& thePointer,
+ const bool isShortInfo = true);
+
+ //! Returns string value corresponded to the shape type if it is not null.
+ //! \param theShape a checked shape
+ //! \return string value or empty string value
+ Standard_EXPORT static QVariant ShapeTypeInfo (const TopoDS_Shape& theShape);
+
+ //! Returns "true" or "false" text for the given boolean state
+ //! \param theValue a boolean value
+ //! \return string value
+ Standard_EXPORT static QString BoolToStr (const bool theValue) { return theValue ? "true" : "false"; }
+
+ //! Converts a Qt string to OCCT extended string
+ //! \param theValue a converted string
+ //! \return the extended string value
+ Standard_EXPORT static QString ToString(const TCollection_ExtendedString& theValue)
+ {
+ return QString::fromUtf16((uint16_t*)theValue.ToExtString());
+ }
+
+ //! Converts enumeration value into string text
+ //! \param theType an enumeration kind
+ //! \param theEnumId an enumeration value
+ //! \return string presentation
+ Standard_EXPORT static TCollection_AsciiString ToName (const DFBrowserPane_OcctEnumType& theType,
+ const Standard_Integer& theEnumId);
+};
+
+#endif
--- /dev/null
+DFBrowserPane.hxx
+DFBrowserPane.qrc
+DFBrowserPane_AttributePane.cxx
+DFBrowserPane_AttributePane.hxx
+DFBrowserPane_AttributePaneAPI.hxx
+DFBrowserPane_AttributePaneCreator.cxx
+DFBrowserPane_AttributePaneCreator.hxx
+DFBrowserPane_AttributePaneCreatorAPI.hxx
+DFBrowserPane_AttributePaneModel.cxx
+DFBrowserPane_AttributePaneModel.hxx
+DFBrowserPane_AttributePaneSelector.cxx
+DFBrowserPane_AttributePaneSelector.hxx
+DFBrowserPane_HelperArray.cxx
+DFBrowserPane_HelperArray.hxx
+DFBrowserPane_HelperExport.cxx
+DFBrowserPane_HelperExport.hxx
+DFBrowserPane_HelperGroupContent.cxx
+DFBrowserPane_HelperGroupContent.hxx
+DFBrowserPane_ItemDelegateButton.cxx
+DFBrowserPane_ItemDelegateButton.hxx
+DFBrowserPane_ItemRole.hxx
+DFBrowserPane_OcctEnumType.hxx
+DFBrowserPane_SelectionKind.hxx
+DFBrowserPane_TableView.cxx
+DFBrowserPane_TableView.hxx
+DFBrowserPane_TDataStdAsciiString.cxx
+DFBrowserPane_TDataStdAsciiString.hxx
+DFBrowserPane_TDataStdBooleanArray.cxx
+DFBrowserPane_TDataStdBooleanArray.hxx
+DFBrowserPane_TDataStdBooleanList.cxx
+DFBrowserPane_TDataStdBooleanList.hxx
+DFBrowserPane_TDataStdByteArray.cxx
+DFBrowserPane_TDataStdByteArray.hxx
+DFBrowserPane_TDataStdComment.cxx
+DFBrowserPane_TDataStdComment.hxx
+DFBrowserPane_TDataStdCurrent.cxx
+DFBrowserPane_TDataStdCurrent.hxx
+DFBrowserPane_TDataStdDirectory.cxx
+DFBrowserPane_TDataStdDirectory.hxx
+DFBrowserPane_TDataStdExpression.cxx
+DFBrowserPane_TDataStdExpression.hxx
+DFBrowserPane_TDataStdExtStringArray.cxx
+DFBrowserPane_TDataStdExtStringArray.hxx
+DFBrowserPane_TDataStdExtStringList.cxx
+DFBrowserPane_TDataStdExtStringList.hxx
+DFBrowserPane_TDataStdInteger.cxx
+DFBrowserPane_TDataStdInteger.hxx
+DFBrowserPane_TDataStdIntegerArray.cxx
+DFBrowserPane_TDataStdIntegerArray.hxx
+DFBrowserPane_TDataStdIntegerList.cxx
+DFBrowserPane_TDataStdIntegerList.hxx
+DFBrowserPane_TDataStdIntPackedMap.cxx
+DFBrowserPane_TDataStdIntPackedMap.hxx
+DFBrowserPane_TDataStdName.cxx
+DFBrowserPane_TDataStdName.hxx
+DFBrowserPane_TDataStdNamedData.cxx
+DFBrowserPane_TDataStdNamedData.hxx
+DFBrowserPane_TDataStdNoteBook.cxx
+DFBrowserPane_TDataStdNoteBook.hxx
+DFBrowserPane_TDataStdReal.cxx
+DFBrowserPane_TDataStdReal.hxx
+DFBrowserPane_TDataStdRealArray.cxx
+DFBrowserPane_TDataStdRealArray.hxx
+DFBrowserPane_TDataStdRealList.cxx
+DFBrowserPane_TDataStdRealList.hxx
+DFBrowserPane_TDataStdReferenceArray.cxx
+DFBrowserPane_TDataStdReferenceArray.hxx
+DFBrowserPane_TDataStdReferenceList.cxx
+DFBrowserPane_TDataStdReferenceList.hxx
+DFBrowserPane_TDataStdRelation.cxx
+DFBrowserPane_TDataStdRelation.hxx
+DFBrowserPane_TDataStdTick.cxx
+DFBrowserPane_TDataStdTick.hxx
+DFBrowserPane_TDataStdTreeNode.cxx
+DFBrowserPane_TDataStdTreeNode.hxx
+DFBrowserPane_TDataStdTreeNodeItem.cxx
+DFBrowserPane_TDataStdTreeNodeItem.hxx
+DFBrowserPane_TDataStdTreeNodeModel.cxx
+DFBrowserPane_TDataStdTreeNodeModel.hxx
+DFBrowserPane_TDataStdUAttribute.cxx
+DFBrowserPane_TDataStdUAttribute.hxx
+DFBrowserPane_TDataStdVariable.cxx
+DFBrowserPane_TDataStdVariable.hxx
+DFBrowserPane_TDFReference.cxx
+DFBrowserPane_TDFReference.hxx
+DFBrowserPane_TDFTagSource.cxx
+DFBrowserPane_TDFTagSource.hxx
+DFBrowserPane_TDocStdModified.cxx
+DFBrowserPane_TDocStdModified.hxx
+DFBrowserPane_TDocStdOwner.cxx
+DFBrowserPane_TDocStdOwner.hxx
+DFBrowserPane_TDocStdXLink.cxx
+DFBrowserPane_TDocStdXLink.hxx
+DFBrowserPane_TDocStdXLinkRoot.cxx
+DFBrowserPane_TDocStdXLinkRoot.hxx
+DFBrowserPane_TFunctionFunction.cxx
+DFBrowserPane_TFunctionFunction.hxx
+DFBrowserPane_TFunctionGraphNode.cxx
+DFBrowserPane_TFunctionGraphNode.hxx
+DFBrowserPane_TFunctionScope.cxx
+DFBrowserPane_TFunctionScope.hxx
+DFBrowserPane_TNamingNamedShape.cxx
+DFBrowserPane_TNamingNamedShape.hxx
+DFBrowserPane_TNamingNaming.cxx
+DFBrowserPane_TNamingNaming.hxx
+DFBrowserPane_TNamingUsedShapes.cxx
+DFBrowserPane_TNamingUsedShapes.hxx
+DFBrowserPane_Tools.cxx
+DFBrowserPane_Tools.hxx
+DFBrowserPane_TPrsStdAISPresentation.cxx
+DFBrowserPane_TPrsStdAISPresentation.hxx
+DFBrowserPane_TPrsStdAISViewer.cxx
+DFBrowserPane_TPrsStdAISViewer.hxx
\ 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 <DFBrowserPaneXDE_AttributeCommonPane.hxx>
+
+#include <DFBrowserPane_ItemRole.hxx>
+#include <DFBrowserPaneXDE_XDEDRAW.hxx>
+
+#include <TDataStd_TreeNode.hxx>
+#include <TDF_Reference.hxx>
+#include <TNaming_NamedShape.hxx>
+#include <XCAFDoc_Volume.hxx>
+#include <XCAFDoc_Area.hxx>
+#include <XCAFDoc_Centroid.hxx>
+#include <TDataStd_UAttribute.hxx>
+#include <XCAFDoc_Color.hxx>
+#include <XCAFDoc_DimTol.hxx>
+#include <XCAFDoc_Material.hxx>
+#include <XCAFDoc_GraphNode.hxx>
+
+#include <set>
+
+#include <QStringList>
+
+static std::set<Standard_CString> AttributeTypes;
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowserPaneXDE_AttributeCommonPane::DFBrowserPaneXDE_AttributeCommonPane (DFBrowserPane_AttributePaneAPI* theStandardPane)
+: DFBrowserPane_AttributePane()
+{
+ myStandardPane = dynamic_cast<DFBrowserPane_AttributePane*> (theStandardPane);
+}
+
+// =======================================================================
+// function : ProcessAttribute
+// purpose :
+// =======================================================================
+bool DFBrowserPaneXDE_AttributeCommonPane::ProcessAttribute (const Standard_CString& theAttributeType)
+{
+ if (AttributeTypes.empty())
+ {
+ AttributeTypes.insert (STANDARD_TYPE (TDataStd_TreeNode)->Name());
+ AttributeTypes.insert (STANDARD_TYPE (TDF_Reference)->Name());
+ AttributeTypes.insert (STANDARD_TYPE (TNaming_NamedShape)->Name());
+ AttributeTypes.insert (STANDARD_TYPE (XCAFDoc_Volume)->Name());
+ AttributeTypes.insert (STANDARD_TYPE (XCAFDoc_Area)->Name());
+ AttributeTypes.insert (STANDARD_TYPE (XCAFDoc_Centroid)->Name());
+ AttributeTypes.insert (STANDARD_TYPE (TDataStd_UAttribute)->Name());
+ AttributeTypes.insert (STANDARD_TYPE (XCAFDoc_Color)->Name());
+ AttributeTypes.insert (STANDARD_TYPE (XCAFDoc_DimTol)->Name());
+ AttributeTypes.insert (STANDARD_TYPE (XCAFDoc_Material)->Name());
+ AttributeTypes.insert (STANDARD_TYPE (XCAFDoc_GraphNode)->Name());
+ }
+ return AttributeTypes.find (theAttributeType) != AttributeTypes.end();
+}
+
+// =======================================================================
+// function : CreateWidget
+// purpose :
+// =======================================================================
+QWidget* DFBrowserPaneXDE_AttributeCommonPane::CreateWidget (QWidget* theParent)
+{
+ return myStandardPane ? myStandardPane->CreateWidget (theParent) : 0;
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void DFBrowserPaneXDE_AttributeCommonPane::Init (const Handle(TDF_Attribute)& theAttribute)
+{
+ if (myStandardPane)
+ myStandardPane->Init (theAttribute);
+}
+
+// =======================================================================
+// function : GetSelectionModels
+// purpose :
+// =======================================================================
+std::list<QItemSelectionModel*> DFBrowserPaneXDE_AttributeCommonPane::GetSelectionModels()
+{
+ return myStandardPane ? myStandardPane->GetSelectionModels() : std::list<QItemSelectionModel*>();
+}
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPaneXDE_AttributeCommonPane::GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
+{
+ if (myStandardPane)
+ myStandardPane->GetValues (theAttribute, theValues);
+}
+
+// =======================================================================
+// function : GetAttributeInfo
+// purpose :
+// =======================================================================
+QVariant DFBrowserPaneXDE_AttributeCommonPane::GetAttributeInfo (const Handle(TDF_Attribute)& theAttribute,
+ int theRole, int theColumnId)
+{
+ QVariant aValue;
+ if (myStandardPane)
+ {
+ if (theRole == DFBrowserPane_ItemRole_ShortInfo)
+ {
+ QList<QVariant> aValues;
+ GetShortAttributeInfo (theAttribute, aValues);
+ QStringList anInfoList;
+ for (QList<QVariant>::const_iterator aValuesIt = aValues.begin(); aValuesIt != aValues.end(); aValuesIt++)
+ anInfoList.append (aValuesIt->toString());
+ aValue = anInfoList.join (", ");
+ }
+ else
+ aValue = myStandardPane->GetAttributeInfo (theAttribute, theRole, theColumnId);
+ }
+ else
+ aValue = DFBrowserPane_AttributePane::GetAttributeInfoByType (theAttribute->DynamicType()->Name(),
+ theRole, theColumnId);
+ return aValue;
+}
+
+// =======================================================================
+// function : GetShortAttributeInfo
+// purpose :
+// =======================================================================
+void DFBrowserPaneXDE_AttributeCommonPane::GetShortAttributeInfo (
+ const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
+{
+ theValues.append (DFBrowserPaneXDE_XDEDRAW::GetAttributeInfo (theAttribute).ToCString());
+}
+
+// =======================================================================
+// function : GetSelectionKind
+// purpose :
+// =======================================================================
+int DFBrowserPaneXDE_AttributeCommonPane::GetSelectionKind (QItemSelectionModel* theModel)
+{
+ if (myStandardPane)
+ return myStandardPane->GetSelectionKind (theModel);
+
+ return DFBrowserPane_AttributePane::GetSelectionKind (theModel);
+}
+
+// =======================================================================
+// function : GetSelectionParameters
+// purpose :
+// =======================================================================
+void DFBrowserPaneXDE_AttributeCommonPane::GetSelectionParameters (QItemSelectionModel* theModel,
+ NCollection_List<Handle(Standard_Transient)>& theParameters)
+{
+ if (myStandardPane)
+ myStandardPane->GetSelectionParameters (theModel, theParameters);
+
+ DFBrowserPane_AttributePane::GetSelectionParameters (theModel, theParameters);
+}
+
+// =======================================================================
+// function : GetPresentation
+// purpose :
+// =======================================================================
+Handle(Standard_Transient) DFBrowserPaneXDE_AttributeCommonPane::GetPresentation (
+ const Handle(TDF_Attribute)& theAttribute)
+{
+ Handle(Standard_Transient) anIO;
+ if (myStandardPane)
+ anIO = myStandardPane->GetPresentation (theAttribute);
+ return anIO;
+}
+
+// =======================================================================
+// function : GetReferences
+// purpose :
+// =======================================================================
+void DFBrowserPaneXDE_AttributeCommonPane::GetReferences (
+ const Handle(TDF_Attribute)& theAttribute,
+ NCollection_List<TDF_Label>& theRefLabels,
+ Handle(Standard_Transient)& theRefPresentation)
+{
+ Handle(Standard_Transient) anIO;
+ if (myStandardPane)
+ myStandardPane->GetReferences (theAttribute, theRefLabels, theRefPresentation);
+}
+
+// =======================================================================
+// function : GetAttributeReferences
+// purpose :
+// =======================================================================
+void DFBrowserPaneXDE_AttributeCommonPane::GetAttributeReferences (
+ const Handle(TDF_Attribute)& theAttribute,
+ NCollection_List<Handle(TDF_Attribute)>& theRefAttributes,
+ Handle(Standard_Transient)& theRefPresentation)
+{
+ Handle(Standard_Transient) anIO;
+ if (myStandardPane)
+ myStandardPane->GetAttributeReferences (theAttribute, theRefAttributes, theRefPresentation);
+}
--- /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 DFBrowserPaneXDE_AttributeCommonPane_H
+#define DFBrowserPaneXDE_AttributeCommonPane_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+#include <TopoDS_Shape.hxx>
+
+#include <QVariant>
+
+class QWidget;
+class QItemSelectionModel;
+
+//! \class DFBrowserPaneXDE_AttributeCommonPane
+//! \brief It covers standard attribute panes. The purpose is to return XDE specific short information for
+//! several kinds of attributes. The other functionality is the same as for standard panes, it just sends
+//! it to the panes.
+class DFBrowserPaneXDE_AttributeCommonPane : public DFBrowserPane_AttributePane
+{
+public:
+
+ //! Constructor
+ Standard_EXPORT DFBrowserPaneXDE_AttributeCommonPane (DFBrowserPane_AttributePaneAPI* theStandardPane);
+
+ //! Destructor
+ virtual ~DFBrowserPaneXDE_AttributeCommonPane() {}
+
+ //! Returns true if this type can be processed by this pane. It contains standard attributes that
+ //! have difference in presentation (TDataStd_TreeNode, TDF_Reference, TNaming_NamedShape and TDataStd_UAttribute).
+ //! Also it contains XCAFDoc attributes (should be implemented in this package or pane will be empty)
+ //! \param theAttributeType an attribute type
+ Standard_EXPORT static bool ProcessAttribute (const Standard_CString& theAttributeType);
+
+ //! Creates table view and call create widget of array table helper
+ //! \param theParent a parent widget
+ //! \return a new widget
+ Standard_EXPORT virtual QWidget* CreateWidget (QWidget* theParent) Standard_OVERRIDE;
+
+ //! Initializes the content of the pane by the parameter attribute
+ //! \param theAttribute an OCAF attribute
+ Standard_EXPORT void Init (const Handle(TDF_Attribute)& theAttribute);
+
+ //! Returns list of selection models. In default implementation it contains a selection model for the table view
+ //! \returns container of models
+ Standard_EXPORT virtual std::list<QItemSelectionModel*> GetSelectionModels() Standard_OVERRIDE;
+
+ //! Returns information for the given attribute
+ //! \param theAttribute a current attribute
+ //! \param theRole a role of information, used by tree model (e.g. DisplayRole, icon, background and so on)
+ //! \param theColumnId a tree model column
+ //! \return value, interpreted by tree model depending on the role
+ Standard_EXPORT virtual QVariant GetAttributeInfo (const Handle(TDF_Attribute)& theAttribute,
+ int theRole, int theColumnId) Standard_OVERRIDE;
+
+ //! Returns brief attribute information. In general case, it returns GetValues() result.
+ //! \param theAttribute a current attribute
+ //! \param theValues a result list of values
+ Standard_EXPORT virtual void GetShortAttributeInfo (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+
+ //! Returns selection kind for the model, it may be General selection or Additional selection for example
+ //! \param theModel one of selection models provided by this pane
+ //! \return selection kind
+ Standard_EXPORT virtual int GetSelectionKind (QItemSelectionModel* theModel) Standard_OVERRIDE;
+
+ //! Returns selection parameters, that may be useful for communicate between tools
+ //! \param theModel one of selection models provided by this pane
+ //! \theParameters a container of parameters, might be extended depending on the pane state(e.g. selection)
+ Standard_EXPORT virtual void GetSelectionParameters (QItemSelectionModel* theModel,
+ NCollection_List<Handle(Standard_Transient)>& theParameters) Standard_OVERRIDE;
+
+ //! Returns presentation of the attribute to be visualized in the view
+ //! \param theAttribute a current attribute
+ //! \return handle of presentation if the attribute has, to be visualized
+ Standard_EXPORT virtual Handle(Standard_Transient) GetPresentation
+ (const Handle (TDF_Attribute)& theAttribute) Standard_OVERRIDE;
+
+ //! Returns container of Label references to the attribute
+ //! \param theAttribute a current attribute
+ //! \param theRefLabels a container of label references, to be selected in tree view
+ //! \param theRefPresentation handle of presentation for the references, to be visualized
+ Standard_EXPORT virtual void GetReferences (const Handle(TDF_Attribute)& theAttribute,
+ NCollection_List<TDF_Label>& theRefLabels,
+ Handle(Standard_Transient)& theRefPresentation) Standard_OVERRIDE;
+
+ //! Returns container of Attribute references to the attribute
+ //! \param theAttribute a current attribute
+ //! \param theRefAttributes a container of attribute references, to be selected in tree view
+ //! \param theRefPresentation handle of presentation for the references, to be visualized
+ Standard_EXPORT virtual void GetAttributeReferences (const Handle(TDF_Attribute)& theAttribute,
+ NCollection_List<Handle(TDF_Attribute)>& theRefAttributes,
+ Handle(Standard_Transient)& theRefPresentation) Standard_OVERRIDE;
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+
+private:
+
+ DFBrowserPane_AttributePane* myStandardPane; //!< pane, that corresponds to the current type of attribute
+};
+
+#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 <DFBrowserPaneXDE_AttributePaneCreator.hxx>
+
+#include <DFBrowserPaneXDE_AttributeCommonPane.hxx>
+#include <DFBrowserPaneXDE_XCAFDocArea.hxx>
+#include <DFBrowserPaneXDE_XCAFDocCentroid.hxx>
+#include <DFBrowserPaneXDE_XCAFDocColor.hxx>
+#include <DFBrowserPaneXDE_XCAFDocColorTool.hxx>
+#include <DFBrowserPaneXDE_XCAFDocDatum.hxx>
+#include <DFBrowserPaneXDE_XCAFDocDimension.hxx>
+#include <DFBrowserPaneXDE_XCAFDocDimTol.hxx>
+#include <DFBrowserPaneXDE_XCAFDocDimTolTool.hxx>
+#include <DFBrowserPaneXDE_XCAFDocDocumentTool.hxx>
+#include <DFBrowserPaneXDE_XCAFDocGeomTolerance.hxx>
+#include <DFBrowserPaneXDE_XCAFDocGraphNode.hxx>
+#include <DFBrowserPaneXDE_XCAFDocLayerTool.hxx>
+#include <DFBrowserPaneXDE_XCAFDocLocation.hxx>
+#include <DFBrowserPaneXDE_XCAFDocMaterial.hxx>
+#include <DFBrowserPaneXDE_XCAFDocMaterialTool.hxx>
+#include <DFBrowserPaneXDE_XCAFDocShapeMapTool.hxx>
+#include <DFBrowserPaneXDE_XCAFDocShapeTool.hxx>
+
+#include <Standard_Version.hxx>
+
+#include <XCAFDoc_Area.hxx>
+#include <XCAFDoc_Centroid.hxx>
+#include <XCAFDoc_Color.hxx>
+#include <XCAFDoc_ColorTool.hxx>
+#include <XCAFDoc_Datum.hxx>
+#if OCC_VERSION_HEX > 0x060901
+#include <XCAFDoc_Dimension.hxx>
+#include <XCAFDoc_GeomTolerance.hxx>
+#endif
+#include <XCAFDoc_DimTol.hxx>
+#include <XCAFDoc_DimTolTool.hxx>
+#include <XCAFDoc_DocumentTool.hxx>
+#include <XCAFDoc_GraphNode.hxx>
+#include <XCAFDoc_LayerTool.hxx>
+#include <XCAFDoc_Location.hxx>
+#include <XCAFDoc_Material.hxx>
+#include <XCAFDoc_MaterialTool.hxx>
+#include <XCAFDoc_ShapeMapTool.hxx>
+#include <XCAFDoc_ShapeTool.hxx>
+#include <XCAFDoc_ShapeMapTool.hxx>
+
+//#define REQUIRE_OCAF_REVIEW:2 : start
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowserPaneXDE_AttributePaneCreator::DFBrowserPaneXDE_AttributePaneCreator(
+ DFBrowserPane_AttributePaneCreatorAPI* theStandardPaneCreator)
+: myStandardPaneCreator (theStandardPaneCreator)
+{
+}
+
+// =======================================================================
+// function : CreateAttributePane
+// purpose :
+// =======================================================================
+DFBrowserPane_AttributePaneAPI* DFBrowserPaneXDE_AttributePaneCreator::CreateAttributePane (const Standard_CString& theAttributeName)
+{
+ DFBrowserPane_AttributePaneAPI* aPane = 0;
+ if (DFBrowserPaneXDE_AttributeCommonPane::ProcessAttribute (theAttributeName))
+ {
+ DFBrowserPane_AttributePaneAPI* aStandardPane = myStandardPaneCreator->CreateAttributePane (theAttributeName);
+ if (!aStandardPane)
+ aStandardPane = createXDEPane (theAttributeName);
+ aPane = new DFBrowserPaneXDE_AttributeCommonPane (aStandardPane);
+ }
+ else
+ aPane = createXDEPane (theAttributeName);
+
+ return aPane;
+}
+
+// =======================================================================
+// function : createXDEPane
+// purpose :
+// =======================================================================
+DFBrowserPane_AttributePaneAPI* DFBrowserPaneXDE_AttributePaneCreator::createXDEPane (const Standard_CString& theAttributeName)
+{
+ DFBrowserPane_AttributePaneAPI* aPane = 0;
+ if (theAttributeName == STANDARD_TYPE (XCAFDoc_ShapeMapTool)->Name())
+ aPane = new DFBrowserPaneXDE_XCAFDocShapeMapTool();
+ else if (theAttributeName == STANDARD_TYPE (XCAFDoc_Area)->Name())
+ aPane = new DFBrowserPaneXDE_XCAFDocArea();
+ else if (theAttributeName == STANDARD_TYPE (XCAFDoc_Centroid)->Name())
+ aPane = new DFBrowserPaneXDE_XCAFDocCentroid();
+ else if (theAttributeName == STANDARD_TYPE (XCAFDoc_Color)->Name())
+ aPane = new DFBrowserPaneXDE_XCAFDocColor();
+ else if (theAttributeName == STANDARD_TYPE (XCAFDoc_ColorTool)->Name())
+ aPane = new DFBrowserPaneXDE_XCAFDocColorTool();
+ else if (theAttributeName == STANDARD_TYPE (XCAFDoc_Datum)->Name())
+ aPane = new DFBrowserPaneXDE_XCAFDocDatum();
+#if OCC_VERSION_HEX > 0x060901
+ else if (theAttributeName == STANDARD_TYPE (XCAFDoc_Dimension)->Name())
+ aPane = new DFBrowserPaneXDE_XCAFDocDimension();
+#endif
+ else if (theAttributeName == STANDARD_TYPE (XCAFDoc_DimTol)->Name())
+ aPane = new DFBrowserPaneXDE_XCAFDocDimTol();
+ else if (theAttributeName == STANDARD_TYPE (XCAFDoc_DimTolTool)->Name())
+ aPane = new DFBrowserPaneXDE_XCAFDocDimTolTool();
+ else if (theAttributeName == STANDARD_TYPE (XCAFDoc_DocumentTool)->Name())
+ aPane = new DFBrowserPaneXDE_XCAFDocDocumentTool();
+#if OCC_VERSION_HEX > 0x060901
+ else if (theAttributeName == STANDARD_TYPE (XCAFDoc_GeomTolerance)->Name())
+ aPane = new DFBrowserPaneXDE_XCAFDocGeomTolerance();
+#endif
+ else if (theAttributeName == STANDARD_TYPE (XCAFDoc_GraphNode)->Name())
+ aPane = new DFBrowserPaneXDE_XCAFDocGraphNode();
+ else if (theAttributeName == STANDARD_TYPE (XCAFDoc_LayerTool)->Name())
+ aPane = new DFBrowserPaneXDE_XCAFDocLayerTool();
+ else if (theAttributeName == STANDARD_TYPE (XCAFDoc_Location)->Name())
+ aPane = new DFBrowserPaneXDE_XCAFDocLocation();
+ else if (theAttributeName == STANDARD_TYPE (XCAFDoc_Material)->Name())
+ aPane = new DFBrowserPaneXDE_XCAFDocMaterial();
+ else if (theAttributeName == STANDARD_TYPE (XCAFDoc_MaterialTool)->Name())
+ aPane = new DFBrowserPaneXDE_XCAFDocMaterialTool();
+ else if (theAttributeName == STANDARD_TYPE (XCAFDoc_ShapeMapTool)->Name())
+ aPane = new DFBrowserPaneXDE_XCAFDocShapeMapTool();
+ else if (theAttributeName == STANDARD_TYPE (XCAFDoc_ShapeTool)->Name())
+ aPane = new DFBrowserPaneXDE_XCAFDocShapeTool();
+ return aPane;
+}
+//#define REQUIRE_OCAF_REVIEW:2 : end
--- /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 DFBrowserPaneXDE_ATTRIBUTEPANECREATOR_H
+#define DFBrowserPaneXDE_ATTRIBUTEPANECREATOR_H
+
+#include <DFBrowserPane_AttributePaneCreatorAPI.hxx>
+#include <Standard.hxx>
+#include <Standard_Macro.hxx>
+
+class DFBrowserPane_AttributePaneAPI;
+
+//! \class DFBrowserPaneXDE_AttributePaneCreator
+//! \brief This class can creates attribute pane for XDE attribute name.
+//! It creates the following panes:
+//! - custom panes for XCAFDoc attributes own panes
+//! - extended panes (modified short information) for several types of attribute (use AttributeCommonPane)
+//! - common panes described in DFBrowserPane library
+class DFBrowserPaneXDE_AttributePaneCreator : public DFBrowserPane_AttributePaneCreatorAPI
+{
+public:
+
+ //! Constructor
+ Standard_EXPORT DFBrowserPaneXDE_AttributePaneCreator (DFBrowserPane_AttributePaneCreatorAPI* theStandardPaneCreator);
+
+ //! Destructor
+ virtual ~DFBrowserPaneXDE_AttributePaneCreator() Standard_OVERRIDE {}
+
+ //! Creates attribute panes for XCAFDoc attributes, extended and common panes from DFBrowserPane library
+ //! \param theAttributeName a type of attribute
+ //! \return an attribute pane if it can be created for this type
+ Standard_EXPORT virtual DFBrowserPane_AttributePaneAPI* CreateAttributePane
+ (const Standard_CString& theAttributeName) Standard_OVERRIDE;
+
+protected:
+
+ //! Cretates pane for XCAFDoc attribute name
+ //! \param theAttributeName a type of attribute
+ //! \return an attribute pane if it can be created for this type
+ DFBrowserPane_AttributePaneAPI* createXDEPane (const Standard_CString& theAttributeName);
+
+private:
+
+ DFBrowserPane_AttributePaneCreatorAPI* myStandardPaneCreator; //! pane creator for panes from DFBrowserPane library
+};
+
+#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 <DFBrowserPaneXDE_Tools.hxx>
+
+#include <DFBrowserPane_AttributePaneAPI.hxx>
+
+#include <TCollection_AsciiString.hxx>
+#include <TDataStd_Name.hxx>
+#include <TDF_ChildIterator.hxx>
+#include <TDF_Tool.hxx>
+#include <TDocStd_Document.hxx>
+
+#include <Standard_GUID.hxx>
+
+#include <XCAFDoc_Area.hxx>
+#include <XCAFDoc_Centroid.hxx>
+#include <XCAFDoc_Color.hxx>
+#include <XCAFDoc_Datum.hxx>
+#include <XCAFDoc_DocumentTool.hxx>
+#include <XCAFDoc_GraphNode.hxx>
+#include <XCAFDoc_Location.hxx>
+#include <XCAFDoc_Material.hxx>
+#include <XCAFDoc_Volume.hxx>
+
+namespace DFBrowserPaneXDE_Tools
+{
+
+ // =======================================================================
+ // function : IsXDEApplication
+ // purpose :
+ // =======================================================================
+ bool IsXDEApplication (const Handle(TDocStd_Application)& theApplication)
+ {
+ bool isXDEApp = false;
+
+ Handle(TDocStd_Document) aDocument;
+ Standard_Integer aNbDoc = theApplication->NbDocuments();
+ if (aNbDoc == 0)
+ return isXDEApp;
+
+ theApplication->GetDocument (1, aDocument);
+ if (aDocument.IsNull())
+ return isXDEApp;
+
+ for (TDF_ChildIterator aLabelsIt (aDocument->Main().Root()); aLabelsIt.More() && !isXDEApp; aLabelsIt.Next())
+ {
+ const TDF_Label aLabel = aLabelsIt.Value();
+ if (aLabel.IsNull())
+ break;
+ Handle(TDF_Attribute) anAttribute;
+ aLabel.FindAttribute (XCAFDoc_DocumentTool::GetID(), anAttribute);
+ isXDEApp = !anAttribute.IsNull();
+ }
+ return isXDEApp;
+ }
+}
--- /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 DFBrowserPaneXDE_Tools_H
+#define DFBrowserPaneXDE_Tools_H
+
+#include <Standard.hxx>
+#include <TDF_Attribute.hxx>
+#include <TDF_Label.hxx>
+#include <TDocStd_Application.hxx>
+
+#ifdef _MSC_VER
+#pragma warning(disable:4127) // conditional expression is constant
+#endif
+#include <QMap>
+#include <QWidget>
+#include <QString>
+
+class DFBrowserPane_AttributePaneAPI;
+
+//! \namespace DFBrowserPaneXDE_Tools
+//! The namespace that gives auxiliary methods for XCAFDoc elements manipulation
+namespace DFBrowserPaneXDE_Tools
+{
+ //! Returns true if the application is XDE: application has document where there is XCAFDoc_DocumentTool attribute in
+ //! a child label of the root
+ //! \param theApplication checked application
+ //! \return boolean value
+ Standard_EXPORT bool IsXDEApplication (const Handle(TDocStd_Application)& theApplication);
+}
+
+#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 <DFBrowserPaneXDE_XCAFDocArea.hxx>
+
+#include <XCAFDoc_Area.hxx>
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPaneXDE_XCAFDocArea::GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
+{
+ Handle(XCAFDoc_Area) anAttr = Handle(XCAFDoc_Area)::DownCast (theAttribute);
+ theValues.append (anAttr->Get());
+}
+
--- /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 DFBrowserPaneXDE_XCAFDocArea_H
+#define DFBrowserPaneXDE_XCAFDocArea_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+#include <TDF_Attribute.hxx>
+
+//! \class DFBrowserPaneXDE_XCAFDocArea
+//! \brief The class to manipulate of XCAF_DocArea attribute
+class DFBrowserPaneXDE_XCAFDocArea : public DFBrowserPane_AttributePane
+{
+public:
+
+ //! Constructor
+ DFBrowserPaneXDE_XCAFDocArea() {}
+
+ //! Destructor
+ virtual ~DFBrowserPaneXDE_XCAFDocArea() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPaneXDE_XCAFDocCentroid.hxx>
+#include <DFBrowserPane_AttributePaneModel.hxx>
+
+#include <XCAFDoc_Centroid.hxx>
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowserPaneXDE_XCAFDocCentroid::DFBrowserPaneXDE_XCAFDocCentroid()
+: DFBrowserPane_AttributePane()
+{
+ getPaneModel()->SetColumnCount (2);
+}
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPaneXDE_XCAFDocCentroid::GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
+{
+ Handle(XCAFDoc_Centroid) anAttr = Handle(XCAFDoc_Centroid)::DownCast (theAttribute);
+ gp_Pnt aPoint = anAttr->Get();
+ theValues << "X" << aPoint.X()
+ << "Y" << aPoint.Y()
+ << "Z" << aPoint.Z();
+}
+
+// =======================================================================
+// function : GetShortAttributeInfo
+// purpose :
+// =======================================================================
+void DFBrowserPaneXDE_XCAFDocCentroid::GetShortAttributeInfo (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues)
+{
+ Handle(XCAFDoc_Centroid) anAttr = Handle(XCAFDoc_Centroid)::DownCast (theAttribute);
+ gp_Pnt aPoint = anAttr->Get();
+ theValues.append (QString ("(%1, %2, %3)").arg (aPoint.X()).arg (aPoint.Y()).arg (aPoint.Z()));
+}
--- /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 DFBrowserPaneXDE_XCAFDocCentroid_H
+#define DFBrowserPaneXDE_XCAFDocCentroid_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+#include <TDF_Attribute.hxx>
+
+//! \class DFBrowserPaneXDE_XCAFDocCentroid
+//! \brief The class to manipulate of XCAFDoc_Centroid attribute
+class DFBrowserPaneXDE_XCAFDocCentroid : public DFBrowserPane_AttributePane
+{
+public:
+ //! Constructor
+ Standard_EXPORT DFBrowserPaneXDE_XCAFDocCentroid();
+
+ //! Destructor
+ Standard_EXPORT virtual ~DFBrowserPaneXDE_XCAFDocCentroid() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+
+ //! Returns brief attribute information. In general case, it returns GetValues() result.
+ //! \param theAttribute a current attribute
+ //! \param theValues a result list of values
+ Standard_EXPORT virtual void GetShortAttributeInfo (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPaneXDE_XCAFDocColor.hxx>
+#include <DFBrowserPane_AttributePaneModel.hxx>
+
+#include <XCAFDoc_Color.hxx>
+
+#include <Quantity_Color.hxx>
+
+#include <QColor>
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowserPaneXDE_XCAFDocColor::DFBrowserPaneXDE_XCAFDocColor()
+: DFBrowserPane_AttributePane()
+{
+ getPaneModel()->SetColumnCount (2);
+}
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPaneXDE_XCAFDocColor::GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
+{
+ Handle(XCAFDoc_Color) anAttr = Handle(XCAFDoc_Color)::DownCast (theAttribute);
+ const Quantity_Color& aColor = anAttr->GetColor();
+
+ theValues << "Red" << aColor.Red();
+ theValues << "Green" << aColor.Green();
+ theValues << "Blue" << aColor.Blue();
+
+ theValues << "Quantity_NameOfColor (nearest)" << aColor.Name();
+}
+
+// =======================================================================
+// function : GetShortAttributeInfo
+// purpose :
+// =======================================================================
+void DFBrowserPaneXDE_XCAFDocColor::GetShortAttributeInfo (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues)
+{
+ Handle(XCAFDoc_Color) anAttr = Handle(XCAFDoc_Color)::DownCast (theAttribute);
+ const Quantity_Color& aColor = anAttr->GetColor();
+ theValues.append (QString ("(%1, %2, %3)").arg (aColor.Red()).arg (aColor.Green()).arg (aColor.Blue()));
+}
+
+// =======================================================================
+// function : GetAttributeInfo
+// purpose :
+// =======================================================================
+QVariant DFBrowserPaneXDE_XCAFDocColor::GetAttributeInfo (const Handle(TDF_Attribute)& theAttribute, int theRole, int theColumnId)
+{
+ if (theColumnId != 0)
+ return DFBrowserPane_AttributePane::GetAttributeInfo (theAttribute, theRole, theColumnId);
+
+ switch (theRole)
+ {
+ case Qt::BackgroundRole:
+ {
+ const Quantity_Color& aColor = Handle(XCAFDoc_Color)::DownCast (theAttribute)->GetColor();
+ return QColor ((int)(aColor.Red()*255.), (int)(aColor.Green()*255.), (int)(aColor.Blue()*255.));
+ }
+ default:
+ break;
+ }
+ return DFBrowserPane_AttributePane::GetAttributeInfo (theAttribute, theRole, theColumnId);
+}
--- /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 DFBrowserPaneXDE_XCAFDocColor_H
+#define DFBrowserPaneXDE_XCAFDocColor_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+#include <TDF_Attribute.hxx>
+
+//! \class DFBrowserPaneXDE_XCAFDocColor
+//! \brief The class to manipulate of XCAFDoc_Color attribute
+class DFBrowserPaneXDE_XCAFDocColor : public DFBrowserPane_AttributePane
+{
+public:
+ //! Constructor
+ Standard_EXPORT DFBrowserPaneXDE_XCAFDocColor();
+
+ //! Destructor
+ virtual ~DFBrowserPaneXDE_XCAFDocColor() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+
+ //! Returns brief attribute information. In general case, it returns GetValues() result.
+ //! \param theAttribute a current attribute
+ //! \param theValues a result list of values
+ Standard_EXPORT virtual void GetShortAttributeInfo (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+
+ //! Returns information for the given attribute
+ //! \param theAttribute a current attribute
+ //! \param theRole a role of information, used by tree model (e.g. DisplayRole, icon, background and so on)
+ //! \param theColumnId a tree model column
+ //! \return value, interpreted by tree model depending on the role
+ Standard_EXPORT virtual QVariant GetAttributeInfo (const Handle(TDF_Attribute)& theAttribute,
+ int theRole, int theColumnId) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPaneXDE_XCAFDocColorTool.hxx>
+
+#include <XCAFDoc_Area.hxx>
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPaneXDE_XCAFDocColorTool::GetValues (const Handle(TDF_Attribute)&, QList<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 DFBrowserPaneXDE_XCAFDocColorTool_H
+#define DFBrowserPaneXDE_XCAFDocColorTool_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+#include <TDF_Attribute.hxx>
+
+//! \class DFBrowserPaneXDE_
+//! \brief The class to manipulate of XCAFDoc_ColorTool attribute
+class DFBrowserPaneXDE_XCAFDocColorTool : public DFBrowserPane_AttributePane
+{
+public:
+ //! Constructor
+ DFBrowserPaneXDE_XCAFDocColorTool() {}
+
+ //! Destructor
+ virtual ~DFBrowserPaneXDE_XCAFDocColorTool() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPaneXDE_XCAFDocDatum.hxx>
+
+#include <DFBrowserPane_AttributePaneModel.hxx>
+
+#include <Standard_Version.hxx>
+#include <TCollection_HAsciiString.hxx>
+
+#include <XCAFDoc_Datum.hxx>
+#if OCC_VERSION_HEX > 0x060901
+#include <XCAFDimTolObjects_DatumObject.hxx>
+#endif
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowserPaneXDE_XCAFDocDatum::DFBrowserPaneXDE_XCAFDocDatum()
+: DFBrowserPane_AttributePane()
+{
+ getPaneModel()->SetColumnCount (2);
+}
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPaneXDE_XCAFDocDatum::GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
+{
+ Handle(XCAFDoc_Datum) anAttr = Handle(XCAFDoc_Datum)::DownCast (theAttribute);
+
+ Handle(TCollection_HAsciiString) aName = anAttr->GetName();
+ Handle(TCollection_HAsciiString) aDescription = anAttr->GetDescription();
+ Handle(TCollection_HAsciiString) anIndentification = anAttr->GetIdentification();
+
+ theValues << "Name" << (!aName.IsNull() ? aName->ToCString() : QString (""))
+ << "Description" << (!aDescription.IsNull() ? aDescription->ToCString() : QString (""))
+ << "Indentification" << (!anIndentification.IsNull() ? anIndentification->ToCString() : QString (""));
+
+#if OCC_VERSION_HEX > 0x060901
+ Handle(XCAFDimTolObjects_DatumObject) anObject = anAttr->GetObject();
+ Handle(TCollection_HAsciiString) anObjectName;
+ if (!anObject.IsNull())
+ anObjectName = anObject->GetName();
+ theValues << "Object" << (!anObjectName.IsNull() ? anObjectName->ToCString() : "Empty Name");
+#endif
+}
+
+// =======================================================================
+// function : GetShortAttributeInfo
+// purpose :
+// =======================================================================
+void DFBrowserPaneXDE_XCAFDocDatum::GetShortAttributeInfo (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
+{
+ Handle(XCAFDoc_Datum) anAttr = Handle(XCAFDoc_Datum)::DownCast (theAttribute);
+
+ Handle(TCollection_HAsciiString) aName = anAttr->GetName();
+ theValues << (!aName.IsNull() ? aName->ToCString() : QString (""));
+}
--- /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 DFBrowserPaneXDE_XCAFDocDatum_H
+#define DFBrowserPaneXDE_XCAFDocDatum_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+#include <TDF_Attribute.hxx>
+
+//! \class DFBrowserPaneXDE_XCAFDocDatum
+//! \brief The class to manipulate of XCAFDoc_Datum attribute
+class DFBrowserPaneXDE_XCAFDocDatum : public DFBrowserPane_AttributePane
+{
+public:
+ //! Constructor
+ Standard_EXPORT DFBrowserPaneXDE_XCAFDocDatum();
+
+ //! Destructor
+ virtual ~DFBrowserPaneXDE_XCAFDocDatum() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+
+ //! Returns brief attribute information. In general case, it returns GetValues() result.
+ //! \param theAttribute a current attribute
+ //! \param theValues a result list of values
+ Standard_EXPORT virtual void GetShortAttributeInfo (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPaneXDE_XCAFDocDimTol.hxx>
+
+#include <XCAFDoc_DimTol.hxx>
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPaneXDE_XCAFDocDimTol::GetValues (const Handle(TDF_Attribute)&, QList<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 DFBrowserPaneXDE_XCAFDocDimTol_H
+#define DFBrowserPaneXDE_XCAFDocDimTol_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+#include <TDF_Attribute.hxx>
+
+//! \class DFBrowserPaneXDE_XCAFDocDimTol
+//! \brief The class to manipulate of XCAFDoc_DimTol attribute
+class DFBrowserPaneXDE_XCAFDocDimTol : public DFBrowserPane_AttributePane
+{
+public:
+ //! Constructor
+ DFBrowserPaneXDE_XCAFDocDimTol() {}
+
+ //! Destructor
+ virtual ~DFBrowserPaneXDE_XCAFDocDimTol() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPaneXDE_XCAFDocDimTolTool.hxx>
+
+#include <XCAFDoc_DimTolTool.hxx>
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPaneXDE_XCAFDocDimTolTool::GetValues (const Handle(TDF_Attribute)&, QList<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 DFBrowserPaneXDE_XCAFDocDimTolTool_H
+#define DFBrowserPaneXDE_XCAFDocDimTolTool_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+#include <TDF_Attribute.hxx>
+
+//! \class DFBrowserPaneXDE_XCAFDocDimTolTool
+//! \brief The class to manipulate of XCAFDoc_DimTolTool attribute
+class DFBrowserPaneXDE_XCAFDocDimTolTool : public DFBrowserPane_AttributePane
+{
+public:
+
+ //! Constructor
+ DFBrowserPaneXDE_XCAFDocDimTolTool() {}
+
+ //! Destructor
+ virtual ~DFBrowserPaneXDE_XCAFDocDimTolTool() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPaneXDE_XCAFDocDimension.hxx>
+
+#include <XCAFDoc_Dimension.hxx>
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPaneXDE_XCAFDocDimension::GetValues (const Handle(TDF_Attribute)&, QList<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 DFBrowserPaneXDE_XCAFDocDimension_H
+#define DFBrowserPaneXDE_XCAFDocDimension_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+#include <TDF_Attribute.hxx>
+
+//! \class DFBrowserPaneXDE_XCAFDocDimension
+//! \brief The class to manipulate of XCAFDoc_Dimension attribute
+class DFBrowserPaneXDE_XCAFDocDimension : public DFBrowserPane_AttributePane
+{
+public:
+ //! Constructor
+ DFBrowserPaneXDE_XCAFDocDimension() {}
+
+ //! Destructor
+ virtual ~DFBrowserPaneXDE_XCAFDocDimension() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPaneXDE_XCAFDocDocumentTool.hxx>
+
+#include <XCAFDoc_DocumentTool.hxx>
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPaneXDE_XCAFDocDocumentTool::GetValues (const Handle(TDF_Attribute)&, QList<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 DFBrowserPaneXDE_XCAFDocDocumentTool_H
+#define DFBrowserPaneXDE_XCAFDocDocumentTool_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+#include <TDF_Attribute.hxx>
+
+//! \class DFBrowserPaneXDE_
+//! \brief The class to manipulate of XCAFDoc_DocumentTool attribute
+class DFBrowserPaneXDE_XCAFDocDocumentTool : public DFBrowserPane_AttributePane
+{
+public:
+ //! Constructor
+ DFBrowserPaneXDE_XCAFDocDocumentTool() {}
+
+ //! Destructor
+ virtual ~DFBrowserPaneXDE_XCAFDocDocumentTool() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPaneXDE_XCAFDocGeomTolerance.hxx>
+
+#include <XCAFDoc_GeomTolerance.hxx>
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPaneXDE_XCAFDocGeomTolerance::GetValues (const Handle(TDF_Attribute)&, QList<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 DFBrowserPaneXDE_XCAFDocGeomTolerance_H
+#define DFBrowserPaneXDE_XCAFDocGeomTolerance_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+#include <TDF_Attribute.hxx>
+
+//! \class DFBrowserPaneXDE_XCAFDocGeomTolerance
+//! \brief The class to manipulate of XCAFDoc_GeomTolerance attribute
+class DFBrowserPaneXDE_XCAFDocGeomTolerance : public DFBrowserPane_AttributePane
+{
+public:
+ //! Constructor
+ DFBrowserPaneXDE_XCAFDocGeomTolerance() {}
+
+ //! Destructor
+ virtual ~DFBrowserPaneXDE_XCAFDocGeomTolerance() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPaneXDE_XCAFDocGraphNode.hxx>
+
+#include <XCAFDoc_GraphNode.hxx>
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPaneXDE_XCAFDocGraphNode::GetValues (const Handle(TDF_Attribute)&, QList<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 DFBrowserPaneXDE_XCAFDocGraphNode_H
+#define DFBrowserPaneXDE_XCAFDocGraphNode_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+#include <TDF_Attribute.hxx>
+
+//! \class DFBrowserPaneXDE_XCAFDocGraphNode
+//! \brief The class to manipulate of XCAFDoc_GraphNode attribute
+class DFBrowserPaneXDE_XCAFDocGraphNode : public DFBrowserPane_AttributePane
+{
+public:
+
+ //! Constructor
+ DFBrowserPaneXDE_XCAFDocGraphNode() {}
+
+ //! Destructor
+ virtual ~DFBrowserPaneXDE_XCAFDocGraphNode() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPaneXDE_XCAFDocLayerTool.hxx>
+
+#include <XCAFDoc_Area.hxx>
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPaneXDE_XCAFDocLayerTool::GetValues (const Handle(TDF_Attribute)&, QList<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 DFBrowserPaneXDE_XCAFDocLayerTool_H
+#define DFBrowserPaneXDE_XCAFDocLayerTool_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+#include <TDF_Attribute.hxx>
+
+//! \class DFBrowserPaneXDE_XCAFDocLayerTool
+//! \brief The class to manipulate of XCAFDoc_LayerTool attribute
+class DFBrowserPaneXDE_XCAFDocLayerTool : public DFBrowserPane_AttributePane
+{
+public:
+ //! Constructor
+ DFBrowserPaneXDE_XCAFDocLayerTool() {}
+
+ //! Destructor
+ virtual ~DFBrowserPaneXDE_XCAFDocLayerTool() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPaneXDE_XCAFDocLocation.hxx>
+
+#include <XCAFDoc_Location.hxx>
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPaneXDE_XCAFDocLocation::GetValues (const Handle(TDF_Attribute)&, QList<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 DFBrowserPaneXDE_XCAFDocLocation_H
+#define DFBrowserPaneXDE_XCAFDocLocation_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+#include <TDF_Attribute.hxx>
+
+//! \class DFBrowserPaneXDE_XCAFDocLocation
+//! \brief The class to manipulate of XCAFDoc_Location attribute
+class DFBrowserPaneXDE_XCAFDocLocation : public DFBrowserPane_AttributePane
+{
+public:
+ //! Constructor
+ DFBrowserPaneXDE_XCAFDocLocation() {}
+
+ //! Destructor
+ virtual ~DFBrowserPaneXDE_XCAFDocLocation() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPaneXDE_XCAFDocMaterial.hxx>
+
+#include <XCAFDoc_Material.hxx>
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPaneXDE_XCAFDocMaterial::GetValues (const Handle(TDF_Attribute)&, QList<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 DFBrowserPaneXDE_XCAFDocMaterial_H
+#define DFBrowserPaneXDE_XCAFDocMaterial_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+#include <TDF_Attribute.hxx>
+
+//! \class DFBrowserPaneXDE_XCAFDocMaterial
+//! \brief The class to manipulate of XCAFDoc_Material attribute
+class DFBrowserPaneXDE_XCAFDocMaterial : public DFBrowserPane_AttributePane
+{
+public:
+
+ //! Constructor
+ DFBrowserPaneXDE_XCAFDocMaterial() {}
+
+ //! Destructor
+ virtual ~DFBrowserPaneXDE_XCAFDocMaterial() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPaneXDE_XCAFDocMaterialTool.hxx>
+
+#include <XCAFDoc_MaterialTool.hxx>
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPaneXDE_XCAFDocMaterialTool::GetValues (const Handle(TDF_Attribute)&, QList<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 DFBrowserPaneXDE_XCAFDocMaterialTool_H
+#define DFBrowserPaneXDE_XCAFDocMaterialTool_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+#include <TDF_Attribute.hxx>
+
+//! \class DFBrowserPaneXDE_XCAFDocMaterialTool
+//! \brief The class to manipulate of XCAFDoc_MaterialTool attribute
+class DFBrowserPaneXDE_XCAFDocMaterialTool : public DFBrowserPane_AttributePane
+{
+public:
+ //! Constructor
+ DFBrowserPaneXDE_XCAFDocMaterialTool() {}
+
+ //! Destructor
+ virtual ~DFBrowserPaneXDE_XCAFDocMaterialTool() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPaneXDE_XCAFDocShapeMapTool.hxx>
+
+#include <DFBrowserPane_AttributePaneModel.hxx>
+#include <DFBrowserPane_HelperExport.hxx>
+#include <DFBrowserPane_ItemDelegateButton.hxx>
+#include <DFBrowserPane_TableView.hxx>
+#include <DFBrowserPane_Tools.hxx>
+
+#include <AIS_Shape.hxx>
+#include <BRepTools.hxx>
+#include <BRep_Builder.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Compound.hxx>
+#include <XCAFDoc_ShapeMapTool.hxx>
+
+#include <QEvent>
+#include <QFileDialog>
+#include <QGridLayout>
+#include <QHeaderView>
+#include <QIcon>
+#include <QMap>
+#include <QPainter>
+#include <QStyledItemDelegate>
+#include <QTableView>
+#include <QVariant>
+#include <QWidget>
+
+const int COLUMN_EXPORT_WIDTH = 20;
+const int COLUMN_TYPE_WIDTH = 70;
+const int COLUMN_POINTER_WIDTH = 110;
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+DFBrowserPaneXDE_XCAFDocShapeMapTool::DFBrowserPaneXDE_XCAFDocShapeMapTool()
+: DFBrowserPane_AttributePane(), myHelperExport (0)
+{
+ QList<QVariant> aHeaderValues;
+ aHeaderValues << "TShape"<< "Type" << "";
+
+ getPaneModel()->SetHeaderValues (aHeaderValues, Qt::Horizontal);
+ getPaneModel()->SetColumnCount (aHeaderValues.count());
+}
+
+// =======================================================================
+// function : CreateWidget
+// purpose :
+// =======================================================================
+QWidget* DFBrowserPaneXDE_XCAFDocShapeMapTool::CreateWidget (QWidget* theParent)
+{
+ QWidget* aMainWidget = new QWidget (theParent);
+ aMainWidget->setVisible (false);
+
+ myTableView = new DFBrowserPane_TableView (aMainWidget);
+ myTableView->SetModel (myPaneModel);
+ QTableView* aTableView = myTableView->GetTableView();
+ aTableView->setSelectionModel (mySelectionModels.front());
+ aTableView->horizontalHeader()->setStretchLastSection (false);
+
+ aTableView->setColumnWidth (0, COLUMN_POINTER_WIDTH);
+ aTableView->setColumnWidth (1, COLUMN_TYPE_WIDTH);
+ aTableView->setColumnWidth (2, COLUMN_EXPORT_WIDTH);
+ aTableView->verticalHeader()->setVisible (true);
+ DFBrowserPane_ItemDelegateButton* anItemDelegate = new DFBrowserPane_ItemDelegateButton (aTableView,
+ ":/icons/export_shape.png");
+ QObject::connect (anItemDelegate, SIGNAL (buttonPressed (const QModelIndex&)),
+ &myHelperExport, SLOT (OnButtonPressed (const QModelIndex&)));
+ aTableView->setItemDelegateForColumn (2, anItemDelegate);
+
+ QGridLayout* aLay = new QGridLayout (aMainWidget);
+ aLay->setContentsMargins (0, 0, 0, 0);
+ aLay->addWidget (myTableView, 0, 0);
+
+ return aMainWidget;
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void DFBrowserPaneXDE_XCAFDocShapeMapTool::Init (const Handle(TDF_Attribute)& theAttribute)
+{
+ DFBrowserPane_AttributePaneAPI::Init (theAttribute);
+}
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPaneXDE_XCAFDocShapeMapTool::GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
+{
+ Handle(XCAFDoc_ShapeMapTool) anAttr = Handle(XCAFDoc_ShapeMapTool)::DownCast (theAttribute);
+
+ const TopTools_IndexedMapOfShape& aShapeMap = anAttr->GetMap();
+ for (int aShapeValueId = 1, aNbShapes = aShapeMap.Extent(); aShapeValueId <= aNbShapes; aShapeValueId++)
+ {
+ const TopoDS_Shape& aShape = aShapeMap(aShapeValueId);
+
+ if (!aShape.IsNull())
+ theValues << DFBrowserPane_Tools::GetPointerInfo (aShape.TShape()->This()).ToCString()
+ << DFBrowserPane_Tools::ShapeTypeInfo (aShape)
+ << "";
+ else
+ theValues << "" << "" << "";
+ }
+}
+
+// =======================================================================
+// function : GetShortAttributeInfo
+// purpose :
+// =======================================================================
+void DFBrowserPaneXDE_XCAFDocShapeMapTool::GetShortAttributeInfo (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues)
+{
+ Handle(XCAFDoc_ShapeMapTool) anAttr = Handle(XCAFDoc_ShapeMapTool)::DownCast (theAttribute);
+ theValues.append (QString ("[%1]").arg (anAttr->GetMap().Extent()));
+}
+
+// =======================================================================
+// function : GetPresentation
+// purpose :
+// =======================================================================
+Handle(Standard_Transient) DFBrowserPaneXDE_XCAFDocShapeMapTool::GetPresentation (const Handle(TDF_Attribute)& theAttribute)
+{
+ Handle(AIS_InteractiveObject) aPresentation;
+
+ Handle(XCAFDoc_ShapeMapTool) anAttr = Handle(XCAFDoc_ShapeMapTool)::DownCast (theAttribute);
+ if (anAttr.IsNull())
+ return aPresentation;
+
+ BRep_Builder aBuilder;
+ TopoDS_Compound aComp;
+ aBuilder.MakeCompound (aComp);
+
+ const TopTools_IndexedMapOfShape& aShapeMap = anAttr->GetMap();
+ for (int aShapeValueId = 1, aNbShapes = aShapeMap.Extent(); aShapeValueId <= aNbShapes; aShapeValueId++)
+ {
+ const TopoDS_Shape& aShape = aShapeMap(aShapeValueId);
+ if (!aShape.IsNull())
+ aBuilder.Add (aComp, aShape);
+ }
+ aPresentation = new AIS_Shape (aComp);
+ return aPresentation;
+}
--- /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 DFBrowserPaneXDE_XCAFDocShapeMapTool_H
+#define DFBrowserPaneXDE_XCAFDocShapeMapTool_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <DFBrowserPane_HelperExport.hxx>
+#include <Standard.hxx>
+#include <TDF_Attribute.hxx>
+
+class DFBrowserPane_TableView;
+class QWidget;
+
+//! \class DFBrowserPaneXDE_
+//! \brief The class to manipulate of XCAFDoc_ShapeMapTool attribute
+class DFBrowserPaneXDE_XCAFDocShapeMapTool : public DFBrowserPane_AttributePane
+{
+public:
+ //! Constructor
+ Standard_EXPORT DFBrowserPaneXDE_XCAFDocShapeMapTool();
+
+ //! Destructor
+ virtual ~DFBrowserPaneXDE_XCAFDocShapeMapTool() {}
+
+ //! Creates table view and call create widget of array table helper
+ //! \param theParent a parent widget
+ //! \return a new widget
+ Standard_EXPORT virtual QWidget* CreateWidget (QWidget* theParent) Standard_OVERRIDE;
+
+ //! Initializes the content of the pane by the parameter attribute
+ //! \param theAttribute an OCAF attribute
+ Standard_EXPORT virtual void Init (const Handle(TDF_Attribute)& theAttribute) Standard_OVERRIDE;
+
+ //! Returns brief attribute information. In general case, it returns GetValues() result.
+ //! \param theAttribute a current attribute
+ //! \param theValues a result list of values
+ Standard_EXPORT virtual void GetShortAttributeInfo (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+
+ //! Returns presentation of the attribute to be visualized in the view
+ //! \param theAttribute a current attribute
+ //! \return handle of presentation if the attribute has, to be visualized
+ Standard_EXPORT virtual Handle(Standard_Transient) GetPresentation
+ (const Handle(TDF_Attribute)& theAttribute) Standard_OVERRIDE;
+
+private:
+
+ DFBrowserPane_HelperExport myHelperExport; //!< processing of Export button click
+};
+
+#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 <DFBrowserPaneXDE_XCAFDocShapeTool.hxx>
+
+#include <XCAFDoc_ShapeTool.hxx>
+
+// =======================================================================
+// function : GetValues
+// purpose :
+// =======================================================================
+void DFBrowserPaneXDE_XCAFDocShapeTool::GetValues (const Handle(TDF_Attribute)&, QList<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 DFBrowserPaneXDE_XCAFDocShapeTool_H
+#define DFBrowserPaneXDE_XCAFDocShapeTool_H
+
+#include <DFBrowserPane_AttributePane.hxx>
+#include <Standard.hxx>
+#include <TDF_Attribute.hxx>
+
+//! \class DFBrowserPaneXDE_
+//! \brief The class to manipulate of XCAFDoc_ShapeTool attribute
+class DFBrowserPaneXDE_XCAFDocShapeTool : public DFBrowserPane_AttributePane
+{
+public:
+
+ //! Constructor
+ DFBrowserPaneXDE_XCAFDocShapeTool() {}
+
+ //! Destructor
+ virtual ~DFBrowserPaneXDE_XCAFDocShapeTool() {}
+
+ //! Returns values to fill the table view model
+ //! \param theAttribute a current attribute
+ //! \param theValues a container of values
+ Standard_EXPORT virtual void GetValues (const Handle(TDF_Attribute)& theAttribute,
+ QList<QVariant>& theValues) Standard_OVERRIDE;
+};
+
+#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 <DFBrowserPaneXDE_XDEDRAW.hxx>
+
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_HAsciiString.hxx>
+#include <TColStd_HArray1OfReal.hxx>
+
+#include <TDataStd_AsciiString.hxx>
+#include <TDataStd_ByteArray.hxx>
+#include <TDataStd_Comment.hxx>
+#include <TDataStd_Integer.hxx>
+#include <TDataStd_IntegerArray.hxx>
+#include <TDataStd_Name.hxx>
+#include <TDataStd_Real.hxx>
+#include <TDataStd_RealArray.hxx>
+#include <TDataStd_TreeNode.hxx>
+#include <TDataStd_UAttribute.hxx>
+
+#include <TDF_Reference.hxx>
+#include <TDF_Tool.hxx>
+
+#include <TNaming_NamedShape.hxx>
+#include <TopoDS_Shape.hxx>
+
+#include <XCAFDoc.hxx>
+#include <XCAFDoc_Area.hxx>
+#include <XCAFDoc_Centroid.hxx>
+#include <XCAFDoc_Color.hxx>
+#include <XCAFDoc_ColorTool.hxx>
+#include <XCAFDoc_DimTol.hxx>
+#include <Standard_Version.hxx>
+#if OCC_VERSION_HEX > 0x060901
+#include <XCAFDoc_Dimension.hxx>
+#include <XCAFDoc_GeomTolerance.hxx>
+#endif
+#include <XCAFDoc_Datum.hxx>
+#include <XCAFDoc_DocumentTool.hxx>
+#include <XCAFDoc_GraphNode.hxx>
+#include <XCAFDoc_LayerTool.hxx>
+#include <XCAFDoc_Material.hxx>
+#include <XCAFDoc_ShapeTool.hxx>
+#include <XCAFDoc_Volume.hxx>
+
+// =======================================================================
+// function : GetAttributeInfo
+// purpose :
+// =======================================================================
+TCollection_AsciiString DFBrowserPaneXDE_XDEDRAW::GetAttributeInfo (Handle(TDF_Attribute) att)
+{
+ TCollection_AsciiString anInfo;
+
+ if ( att->IsKind(STANDARD_TYPE (TDataStd_TreeNode)) ) {
+ Standard_CString type = "";
+ if ( att->ID() == XCAFDoc::ShapeRefGUID() ) type = "Shape Instance Link";
+ else if ( att->ID() == XCAFDoc::ColorRefGUID(XCAFDoc_ColorGen) ) type = "Generic Color Link";
+ else if ( att->ID() == XCAFDoc::ColorRefGUID(XCAFDoc_ColorSurf) ) type = "Surface Color Link";
+ else if ( att->ID() == XCAFDoc::ColorRefGUID(XCAFDoc_ColorCurv) ) type = "Curve Color Link";
+ else if ( att->ID() == XCAFDoc::DimTolRefGUID() ) type = "DGT Link";
+ else if ( att->ID() == XCAFDoc::DatumRefGUID() ) type = "Datum Link";
+ else if ( att->ID() == XCAFDoc::MaterialRefGUID() ) type = "Material Link";
+ Handle(TDataStd_TreeNode) TN = Handle(TDataStd_TreeNode)::DownCast (att);
+ TCollection_AsciiString ref;
+ if ( TN->HasFather() ) {
+ TDF_Tool::Entry ( TN->Father()->Label(), ref );
+ anInfo = type;
+ anInfo += TCollection_AsciiString (" ==> ") + ref.ToCString();
+ }
+ else {
+ anInfo = type;
+ anInfo += TCollection_AsciiString (" <== (") + ref.ToCString();
+ Handle(TDataStd_TreeNode) child = TN->First();
+ while ( ! child.IsNull() ) {
+ TDF_Tool::Entry ( child->Label(), ref );
+ if ( child != TN->First() ) anInfo += ", " ;
+ anInfo += ref.ToCString();
+ child = child->Next();
+ }
+ anInfo += ")";
+ }
+ }
+ else if ( att->IsKind(STANDARD_TYPE (TDF_Reference)) ) {
+ Handle(TDF_Reference) val = Handle(TDF_Reference)::DownCast ( att );
+ TCollection_AsciiString ref;
+ TDF_Tool::Entry ( val->Get(), ref );
+ anInfo += TCollection_AsciiString ("==> ") + ref.ToCString();
+ }
+ else if ( att->IsKind(STANDARD_TYPE (TDataStd_Integer)) ) {
+ Handle(TDataStd_Integer) val = Handle(TDataStd_Integer)::DownCast ( att );
+ anInfo = TCollection_AsciiString ( val->Get() );
+ }
+ else if ( att->IsKind(STANDARD_TYPE (TDataStd_Real)) ) {
+ Handle(TDataStd_Real) val = Handle(TDataStd_Real)::DownCast ( att );
+ anInfo = TCollection_AsciiString ( val->Get() );
+ }
+ else if ( att->IsKind(STANDARD_TYPE (TDataStd_Name)) ) {
+ Handle(TDataStd_Name) val = Handle(TDataStd_Name)::DownCast ( att );
+ anInfo = TCollection_AsciiString ( val->Get(), '?' );
+ }
+ else if ( att->IsKind(STANDARD_TYPE (TDataStd_Comment)) ) {
+ Handle(TDataStd_Comment) val = Handle(TDataStd_Comment)::DownCast ( att );
+ anInfo = TCollection_AsciiString ( val->Get(), '?' );
+ }
+ else if ( att->IsKind(STANDARD_TYPE (TDataStd_AsciiString)) ) {
+ Handle(TDataStd_AsciiString) val = Handle(TDataStd_AsciiString)::DownCast ( att );
+ anInfo = TCollection_AsciiString ( val->Get(), '?' );
+ }
+ else if ( att->IsKind(STANDARD_TYPE (TDataStd_IntegerArray)) ) {
+ Handle(TDataStd_IntegerArray) val = Handle(TDataStd_IntegerArray)::DownCast ( att );
+ for ( Standard_Integer j=val->Lower(); j <= val->Upper(); j++ ) {
+ if ( j > val->Lower() ) anInfo += TCollection_AsciiString ( ", " );
+ anInfo += TCollection_AsciiString ( val->Value(j) );
+ }
+ }
+ else if ( att->IsKind(STANDARD_TYPE (TDataStd_RealArray)) ) {
+ Handle(TDataStd_RealArray) val = Handle(TDataStd_RealArray)::DownCast ( att );
+ for ( Standard_Integer j=val->Lower(); j <= val->Upper(); j++ ) {
+ if ( j > val->Lower() ) anInfo += TCollection_AsciiString ( ", " );
+ anInfo += TCollection_AsciiString ( val->Value(j) );
+ }
+ }
+ else if ( att->IsKind(STANDARD_TYPE (TDataStd_ByteArray)) ) {
+ Handle(TDataStd_ByteArray) val = Handle(TDataStd_ByteArray)::DownCast ( att );
+ for ( Standard_Integer j=val->Lower(); j <= val->Upper(); j++ ) {
+ if ( j > val->Lower() ) anInfo += TCollection_AsciiString ( ", " );
+ anInfo += TCollection_AsciiString ( val->Value(j) );
+ }
+ }
+ else if ( att->IsKind(STANDARD_TYPE (TNaming_NamedShape)) ) {
+ Handle(TNaming_NamedShape) val = Handle(TNaming_NamedShape)::DownCast ( att );
+ TopoDS_Shape S = val->Get();
+ if (!S.IsNull())
+ anInfo = S.TShape()->DynamicType()->Name();
+ else
+ anInfo = "Empty Shape";
+ if ( ! S.Location().IsIdentity() ) anInfo += TCollection_AsciiString ( "(located)" );
+ }
+ else if ( att->IsKind(STANDARD_TYPE (XCAFDoc_Volume)) ) {
+ Handle(XCAFDoc_Volume) val = Handle(XCAFDoc_Volume)::DownCast ( att );
+ anInfo += TCollection_AsciiString ( val->Get() );
+ }
+ else if ( att->IsKind(STANDARD_TYPE (XCAFDoc_Area)) ) {
+ Handle(XCAFDoc_Area) val = Handle(XCAFDoc_Area)::DownCast ( att );
+ TCollection_AsciiString str ( val->Get() );
+ anInfo = str.ToCString();
+ }
+ else if ( att->IsKind(STANDARD_TYPE (XCAFDoc_Centroid)) ) {
+ Handle(XCAFDoc_Centroid) val = Handle(XCAFDoc_Centroid)::DownCast ( att );
+ gp_Pnt myCentroid = val->Get();
+ anInfo = "(" ;
+ anInfo += TCollection_AsciiString ( myCentroid.X() ).ToCString();
+ anInfo += TCollection_AsciiString ( " , " );
+ anInfo += TCollection_AsciiString ( TCollection_AsciiString ( myCentroid.Y() ).ToCString() );
+ anInfo += TCollection_AsciiString ( " , " );
+ anInfo += TCollection_AsciiString ( myCentroid.Z() ).ToCString();
+ anInfo += TCollection_AsciiString ( ")" );
+ }
+ else if ( att->IsKind(STANDARD_TYPE (TDataStd_UAttribute)) ) {
+ if ( att->ID() == XCAFDoc::AssemblyGUID() ) anInfo += TCollection_AsciiString ( "is assembly" );
+ if ( att->ID() == XCAFDoc::InvisibleGUID() ) anInfo += TCollection_AsciiString ( "invisible" );
+ }
+ else if ( att->IsKind(STANDARD_TYPE (XCAFDoc_Color)) ) {
+ Handle(XCAFDoc_Color) val = Handle(XCAFDoc_Color)::DownCast ( att );
+ Quantity_Color C = val->GetColor();
+ char string[260];
+ Sprintf ( string, "%s (%g, %g, %g)", C.StringName ( C.Name() ),
+ C.Red(), C.Green(), C.Blue() );
+ anInfo = string;
+ }
+ else if ( att->IsKind(STANDARD_TYPE (XCAFDoc_DimTol)) ) {
+ Handle(XCAFDoc_DimTol) val = Handle(XCAFDoc_DimTol)::DownCast ( att );
+ Standard_Integer kind = val->GetKind();
+ Handle(TColStd_HArray1OfReal) HAR = val->GetVal();
+ if(kind<20) { //dimension
+ anInfo = "Diameter (ValueRange[";
+ anInfo += TCollection_AsciiString ( HAR->Value(1) );
+ anInfo += TCollection_AsciiString ( "," );
+ anInfo += TCollection_AsciiString ( HAR->Value(2) );
+ anInfo += TCollection_AsciiString ( "])" );
+ }
+ else {
+ switch (kind) {
+ case 21: anInfo = "GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol_1"; break;
+ case 22: anInfo = "GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol_2"; break;
+ case 23: anInfo = "GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol_3"; break;
+ case 24: anInfo = "AngularityTolerance"; break;
+ case 25: anInfo = "CircularRunoutTolerance"; break;
+ case 26: anInfo = "CoaxialityTolerance"; break;
+ case 27: anInfo = "ConcentricityTolerance"; break;
+ case 28: anInfo = "ParallelismTolerance"; break;
+ case 29: anInfo = "PerpendicularityTolerance"; break;
+ case 30: anInfo = "SymmetryTolerance"; break;
+ case 31: anInfo = "TotalRunoutTolerance"; break;
+ case 35: anInfo = "ModifiedGeometricTolerance_1"; break;
+ case 36: anInfo = "ModifiedGeometricTolerance_2"; break;
+ case 37: anInfo = "ModifiedGeometricTolerance_3"; break;
+ case 38: anInfo = "CylindricityTolerance"; break;
+ case 39: anInfo = "FlatnessTolerance"; break;
+ case 40: anInfo = "LineProfileTolerance"; break;
+ case 41: anInfo = "PositionTolerance"; break;
+ case 42: anInfo = "RoundnessTolerance"; break;
+ case 43: anInfo = "StraightnessTolerance"; break;
+ case 44: anInfo = "SurfaceProfileTolerance"; break;
+ }
+ if (anInfo.Length() > 0) {
+ anInfo += " (Value=";
+ anInfo += TCollection_AsciiString (HAR->Value (1));
+ anInfo += ")";
+ }
+ }
+ }
+ else if ( att->IsKind(STANDARD_TYPE (XCAFDoc_Material)) ) {
+ Handle(XCAFDoc_Material) val = Handle(XCAFDoc_Material)::DownCast ( att );
+ Standard_Real dens = val->GetDensity();
+ Standard_CString dimdens = "g/cu sm";
+ if(dens==0)
+ anInfo = val->GetName()->ToCString();
+ else {
+ anInfo = val->GetName()->ToCString();
+ anInfo += "(density=";
+ anInfo += TCollection_AsciiString ( dens );
+ anInfo += dimdens;
+ anInfo += ")";
+ }
+ }
+ else if ( att->IsKind(STANDARD_TYPE (XCAFDoc_GraphNode)) ) {
+ Standard_CString type;
+ if ( att->ID() == XCAFDoc::LayerRefGUID() ) {
+ type = "Layer Instance Link";
+ }
+ else if ( att->ID() == XCAFDoc::SHUORefGUID() ) {
+ type = "SHUO Instance Link";
+ }
+ else if ( att->ID() == XCAFDoc::DatumTolRefGUID() ) {
+ type = "DatumToler Link";
+ }
+#if OCC_VERSION_HEX > 0x060901
+ else if ( att->ID() == XCAFDoc::DimensionRefFirstGUID() ) {
+ type = "Dimension Link First";
+ }
+ else if ( att->ID() == XCAFDoc::DimensionRefSecondGUID() ) {
+ type = "Dimension Link Second";
+ }
+ else if ( att->ID() == XCAFDoc::GeomToleranceRefGUID() ){
+ type = "GeomTolerance Link";
+ }
+#endif
+ else
+ return TCollection_AsciiString();
+
+ Handle(XCAFDoc_GraphNode) DETGN = Handle(XCAFDoc_GraphNode)::DownCast (att);
+ TCollection_AsciiString ref;
+ Standard_Integer ii = 1;
+ if (DETGN->NbFathers()!=0) {
+
+ TDF_Tool::Entry ( DETGN->GetFather(ii)->Label(), ref );
+ anInfo = type;
+ anInfo += " ==> (";
+ anInfo += ref;
+ for (ii = 2; ii <= DETGN->NbFathers(); ii++) {
+ TDF_Tool::Entry ( DETGN->GetFather(ii)->Label(), ref );
+ anInfo += ", ";
+ anInfo += ref.ToCString();
+ }
+ anInfo += ") ";
+ }
+ ii = 1;
+ if (DETGN->NbChildren ()!=0) {
+ TDF_Tool::Entry ( DETGN->GetChild(ii)->Label(), ref );
+ anInfo += type;
+ anInfo += " <== (";
+ anInfo += ref;
+ for (ii = 2; ii <= DETGN->NbChildren (); ii++) {
+ TDF_Tool::Entry ( DETGN->GetChild(ii)->Label(), ref );
+ anInfo += ", ";
+ anInfo += ref;
+ }
+ anInfo += ") ";
+ }
+ }
+ return anInfo;
+}
--- /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 _DFBrowserPaneXDE_XDEDRAW__H
+#define _DFBrowserPaneXDE_XDEDRAW__H
+
+#include <Standard.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TDF_Attribute.hxx>
+
+//! \class DFBrowserPaneXDE_XDEDRAW
+//! \brief The tool that gives auxiliary methods for XDE elements manipulation
+class DFBrowserPaneXDE_XDEDRAW
+{
+public:
+ //! Dumps the attribute information into a string. The similar information is provided in Draw for XDE format
+ //! \param theAttribute
+ //! \return the GUID value
+ Standard_EXPORT static TCollection_AsciiString GetAttributeInfo (Handle(TDF_Attribute) theAttribute);
+};
+
+#endif
--- /dev/null
+DFBrowserPaneXDE_AttributeCommonPane.cxx
+DFBrowserPaneXDE_AttributeCommonPane.hxx
+DFBrowserPaneXDE_AttributePaneCreator.cxx
+DFBrowserPaneXDE_AttributePaneCreator.hxx
+DFBrowserPaneXDE_Tools.cxx
+DFBrowserPaneXDE_Tools.hxx
+DFBrowserPaneXDE_XCAFDocArea.cxx
+DFBrowserPaneXDE_XCAFDocArea.hxx
+DFBrowserPaneXDE_XCAFDocCentroid.cxx
+DFBrowserPaneXDE_XCAFDocCentroid.hxx
+DFBrowserPaneXDE_XCAFDocColor.cxx
+DFBrowserPaneXDE_XCAFDocColor.hxx
+DFBrowserPaneXDE_XCAFDocColorTool.cxx
+DFBrowserPaneXDE_XCAFDocColorTool.hxx
+DFBrowserPaneXDE_XCAFDocDatum.cxx
+DFBrowserPaneXDE_XCAFDocDatum.hxx
+DFBrowserPaneXDE_XCAFDocDimension.cxx
+DFBrowserPaneXDE_XCAFDocDimension.hxx
+DFBrowserPaneXDE_XCAFDocDimTol.cxx
+DFBrowserPaneXDE_XCAFDocDimTol.hxx
+DFBrowserPaneXDE_XCAFDocDimTolTool.cxx
+DFBrowserPaneXDE_XCAFDocDimTolTool.hxx
+DFBrowserPaneXDE_XCAFDocDocumentTool.cxx
+DFBrowserPaneXDE_XCAFDocDocumentTool.hxx
+DFBrowserPaneXDE_XCAFDocGeomTolerance.cxx
+DFBrowserPaneXDE_XCAFDocGeomTolerance.hxx
+DFBrowserPaneXDE_XCAFDocGraphNode.cxx
+DFBrowserPaneXDE_XCAFDocGraphNode.hxx
+DFBrowserPaneXDE_XCAFDocLayerTool.cxx
+DFBrowserPaneXDE_XCAFDocLayerTool.hxx
+DFBrowserPaneXDE_XCAFDocLocation.cxx
+DFBrowserPaneXDE_XCAFDocLocation.hxx
+DFBrowserPaneXDE_XCAFDocMaterial.cxx
+DFBrowserPaneXDE_XCAFDocMaterial.hxx
+DFBrowserPaneXDE_XCAFDocMaterialTool.cxx
+DFBrowserPaneXDE_XCAFDocMaterialTool.hxx
+DFBrowserPaneXDE_XCAFDocShapeMapTool.cxx
+DFBrowserPaneXDE_XCAFDocShapeMapTool.hxx
+DFBrowserPaneXDE_XCAFDocShapeTool.cxx
+DFBrowserPaneXDE_XCAFDocShapeTool.hxx
+DFBrowserPaneXDE_XDEDRAW.cxx
+DFBrowserPaneXDE_XDEDRAW.hxx
--- /dev/null
+ShapeView.qrc
+ShapeView_Communicator.cxx
+ShapeView_Communicator.hxx
+ShapeView_ItemBase.hxx
+ShapeView_ItemRoot.cxx
+ShapeView_ItemRoot.hxx
+ShapeView_ItemShape.cxx
+ShapeView_ItemShape.hxx
+ShapeView_OpenFileDialog.cxx
+ShapeView_OpenFileDialog.hxx
+ShapeView_OpenFileViewModel.cxx
+ShapeView_OpenFileViewModel.hxx
+ShapeView_Tools.cxx
+ShapeView_Tools.hxx
+ShapeView_TreeModel.cxx
+ShapeView_TreeModel.hxx
+ShapeView_Window.cxx
+ShapeView_Window.hxx
--- /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 <ShapeView_Communicator.hxx>
+
+#include <ShapeView_Window.hxx>
+#include <OSD_Directory.hxx>
+#include <OSD_Environment.hxx>
+#include <OSD_Path.hxx>
+#include <OSD_Protection.hxx>
+
+#include <QApplication>
+#include <QMainWindow>
+#include <QDir>
+
+// =======================================================================
+// function : CreateCommunicator
+// purpose : Creates a communicator by the library loading
+// =======================================================================
+Standard_EXPORTEXTERNC TInspectorAPI_Communicator* CreateCommunicator()
+{
+ return new ShapeView_Communicator();
+}
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+ShapeView_Communicator::ShapeView_Communicator()
+: TInspectorAPI_Communicator(), myWindow (0)
+{
+ // main window creation
+ TCollection_AsciiString aTmpDir;
+#ifdef _WIN32
+ OSD_Environment anEnvironment ("TEMP");
+ aTmpDir = anEnvironment.Value();
+ if (aTmpDir.IsEmpty() )
+ {
+ anEnvironment.SetName("TMP");
+ aTmpDir = anEnvironment.Value();
+ if (aTmpDir.IsEmpty())
+ aTmpDir = "C:\\";
+ }
+ if (!aTmpDir.EndsWith ("\\"))
+ aTmpDir += "\\";
+ OSD_Path aTmpPath (aTmpDir);
+ OSD_Directory aTmpDirectory;
+#else
+ OSD_Directory aTmpDirectory = OSD_Directory::BuildTemporary();
+ OSD_Path aTmpPath;
+ aTmpDirectory.Path (aTmpPath);
+#endif
+ aTmpPath.DownTrek ("ShapeView");
+ aTmpDirectory.SetPath (aTmpPath);
+ if (!aTmpDirectory.Exists())
+ aTmpDirectory.Build (OSD_Protection());
+
+ aTmpDirectory.Path (aTmpPath);
+ TCollection_AsciiString aTmpDirectoryName;
+ aTmpPath.SystemName(aTmpDirectoryName);
+ myWindow = new ShapeView_Window (0, aTmpDirectoryName);
+}
+
+ShapeView_Communicator::~ShapeView_Communicator()
+{
+ myWindow->RemoveAllShapes(); // removes all cached shapes and files in temporary directory
+ OSD_Path aPath (myWindow->GetTemporaryDirectory());
+ OSD_Directory aTmpDirectory (aPath);
+ // temporary directory can be removed only if is empty
+ aTmpDirectory.Remove();
+}
+
--- /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 ShapeView_Communicator_H
+#define ShapeView_Communicator_H
+
+#include <ShapeView_Window.hxx>
+#include <TInspectorAPI_Communicator.hxx>
+
+//! \class ShapeView_Communicator.
+//! \brief This is a connector from TInspector application to ShapeView window
+class ShapeView_Communicator : public TInspectorAPI_Communicator
+{
+public:
+
+ //! Constructor
+ Standard_EXPORT ShapeView_Communicator();
+
+ //! Destructor
+ Standard_EXPORT virtual ~ShapeView_Communicator() Standard_OVERRIDE;
+
+ //! Provides the container with a parent where this container should be inserted.
+ //! If Qt implementation, it should be QWidget with QLayout set inside
+ //! \param theParent a parent class
+ virtual void SetParent (void* theParent) Standard_OVERRIDE { myWindow->SetParent (theParent); }
+
+ //! Sets parameters container, it should be used when the plugin is initialized or in update content
+ //! \param theParameters a parameters container
+ virtual void SetParameters (const Handle(TInspectorAPI_PluginParameters)& theParameters) Standard_OVERRIDE
+ { myWindow->SetParameters (theParameters); }
+
+ //! Calls update of the plugin's content
+ virtual void UpdateContent() Standard_OVERRIDE { myWindow->UpdateContent(); }
+
+private:
+
+ ShapeView_Window* myWindow; //!< current window
+};
+
+#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.
+
+#ifndef ShapeView_ItemBase_H
+#define ShapeView_ItemBase_H
+
+#include <Standard.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TreeModel_ItemBase.hxx>
+
+class ShapeView_ItemBase;
+typedef QExplicitlySharedDataPointer<ShapeView_ItemBase> ShapeView_ItemBasePtr;
+
+//! \class ShapeView_ItemBase
+// \brief Declaration of the tree model base item.
+class ShapeView_ItemBase : public TreeModel_ItemBase
+{
+public:
+
+ //! Resets cached values
+ virtual void Reset() Standard_OVERRIDE { TreeModel_ItemBase::Reset(); }
+
+protected:
+
+ //! Initialize the current item. It creates a backup of the specific item information
+ virtual void initItem() const {};
+
+ //! Constructor
+ //! param theParent a parent item
+ //! \param theRow the item row positition in the parent item
+ //! \param theColumn the item column positition in the parent item
+ ShapeView_ItemBase(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ : TreeModel_ItemBase (theParent, theRow, theColumn) {}
+};
+
+#endif
\ 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 <ShapeView_ItemRoot.hxx>
+#include <ShapeView_ItemShape.hxx>
+
+// =======================================================================
+// function : GetShape
+// purpose :
+// =======================================================================
+const TopoDS_Shape& ShapeView_ItemRoot::GetShape (const int theRowId)
+{
+ NCollection_List<TopoDS_Shape>::Iterator aShapesIt (myShapes);
+ for (int aRowId = 0; aShapesIt.More(); aShapesIt.Next(), aRowId++)
+ {
+ if (aRowId == theRowId)
+ break;
+ }
+ return aShapesIt.Value();
+}
+
+// =======================================================================
+// function : initValue
+// purpose :
+// =======================================================================
+QVariant ShapeView_ItemRoot::initValue(const int theRole) const
+{
+ if (Column() != 0)
+ return QVariant();
+
+ if (theRole == Qt::DisplayRole || theRole == Qt::EditRole)
+ return "TopoDS_Shapes";
+
+ return QVariant();
+}
+
+// =======================================================================
+// function : createChild
+// purpose :
+// =======================================================================
+TreeModel_ItemBasePtr ShapeView_ItemRoot::createChild (int theRow, int theColumn)
+{
+ return ShapeView_ItemShape::CreateItem (currentItem(), theRow, theColumn);
+}
+
--- /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 ShapeView_ItemRoot_H
+#define ShapeView_ItemRoot_H
+
+#include <NCollection_List.hxx>
+#include <ShapeView_ItemBase.hxx>
+#include <Standard.hxx>
+#include <TopoDS_Shape.hxx>
+
+class ShapeView_ItemRoot;
+typedef QExplicitlySharedDataPointer<ShapeView_ItemRoot> ShapeView_ItemRootPtr;
+
+//! \class ShapeView_ItemRoot
+//! Collects shapes that should be visualized in tree view. Shapes are cached and if shapes are not needed,
+//! cache should be cleared using RemoveAllShapes.
+//! Parent is NULL, children are ShapeView_ItemShape items.
+class ShapeView_ItemRoot : public ShapeView_ItemBase
+{
+public:
+
+ //! Creates an item wrapped by a shared pointer
+ static ShapeView_ItemRootPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ { return ShapeView_ItemRootPtr (new ShapeView_ItemRoot (theParent, theRow, theColumn)); }
+
+ //! Destructor
+ virtual ~ShapeView_ItemRoot() Standard_OVERRIDE {};
+
+ //! Appends new shape
+ //! \param theShape a shape instance
+ void AddShape (const TopoDS_Shape& theShape) { myShapes.Append (theShape); }
+
+ //! Clears internal container of added shapes
+ void RemoveAllShapes() { myShapes.Clear(); }
+
+ //! Returns shape by the number
+ //! \param theRowId an index of the shape in the internal container.
+ Standard_EXPORT const TopoDS_Shape& GetShape (const int theRowId);
+
+protected:
+
+ //! Return data value for the role.
+ //! \param theItemRole a value role
+ //! \return the value
+ virtual QVariant initValue(const int theItemRole) const;
+
+ //! \return number of children.
+ virtual int initRowCount() const Standard_OVERRIDE { return myShapes.Size(); }
+
+ //! Creates a child item in the given position.
+ //! \param theRow the child row position
+ //! \param theColumn the child column position
+ //! \return the created item
+ virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
+
+private:
+
+ //! Constructor
+ //! param theParent a parent item
+ ShapeView_ItemRoot(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ : ShapeView_ItemBase (theParent, theRow, theColumn) {}
+
+private:
+
+ NCollection_List<TopoDS_Shape> myShapes; //!< shapes presented in tree view
+};
+
+#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 <ShapeView_ItemShape.hxx>
+
+#include <Adaptor3d_Curve.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepAdaptor_Curve.hxx>
+
+#include <GCPnts_AbscissaPoint.hxx>
+#include <Geom_Curve.hxx>
+#include <GeomAdaptor_Curve.hxx>
+
+#include <ShapeView_ItemRoot.hxx>
+#include <ShapeView_ItemShape.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Iterator.hxx>
+#include <TopoDS_Vertex.hxx>
+
+#include <QObject>
+#include <QStringList>
+
+// =======================================================================
+// function : ToString
+// purpose :
+// =======================================================================
+QString ToString (const Standard_Boolean& theValue)
+{
+ return theValue ? "1" : "0";
+}
+
+// =======================================================================
+// function : ToString
+// purpose :
+// =======================================================================
+QString ToString (const gp_Pnt& thePoint)
+{
+ return QString ("(%1, %2, %3)").arg (thePoint.X()).arg (thePoint.Y()).arg (thePoint.Z());
+}
+
+// =======================================================================
+// function : ToName
+// purpose :
+// =======================================================================
+QString ToName (const TopAbs_ShapeEnum& theShapeType)
+{
+ Standard_SStream aSStream;
+ TopAbs::Print (theShapeType, aSStream);
+ return QString (aSStream.str().c_str());
+}
+
+// =======================================================================
+// function : ToName
+// purpose :
+// =======================================================================
+QString ToName (const TopAbs_Orientation& theOrientation)
+{
+ Standard_SStream aSStream;
+ TopAbs::Print(theOrientation, aSStream);
+ return QString (aSStream.str().c_str());
+}
+
+// =======================================================================
+// function : ToName
+// purpose :
+// =======================================================================
+QString ToName (const GeomAbs_Shape& theType)
+{
+ switch (theType)
+ {
+ case GeomAbs_C0: return "GeomAbs_C0";
+ case GeomAbs_G1: return "GeomAbs_G1";
+ case GeomAbs_C1: return "GeomAbs_C1";
+ case GeomAbs_G2: return "GeomAbs_G2";
+ case GeomAbs_C2: return "GeomAbs_C2";
+ case GeomAbs_C3: return "GeomAbs_C3";
+ case GeomAbs_CN: return "GeomAbs_CN";
+ default: break;
+ }
+ return QString();
+}
+
+// =======================================================================
+// function : ToFlags
+// purpose :
+// =======================================================================
+void ToFlags (const TopoDS_Shape& theShape, QVariant& theValue, QVariant& theInfo)
+{
+ QStringList aValues;
+ aValues << ToString (theShape.Checked()) << ToString (theShape.Closed())
+ << ToString (theShape.Infinite()) << ToString (theShape.Locked())
+ << ToString (theShape.Modified()) << ToString (theShape.Orientable());
+
+ theValue = aValues.join ("/");
+ theInfo = "Checked/Closed/Infinite/Locked/Modified/Orientable";
+}
+
+// =======================================================================
+// function : ToOtherInfo
+// purpose :
+// =======================================================================
+void ToOtherInfo (const TopoDS_Shape& theShape, QVariant& theValue, QVariant& theInfo)
+{
+ switch (theShape.ShapeType())
+ {
+ case TopAbs_COMPOUND:
+ case TopAbs_COMPSOLID:
+ case TopAbs_SOLID:
+ case TopAbs_SHELL:
+ case TopAbs_FACE:
+ case TopAbs_WIRE:
+ break;
+ case TopAbs_EDGE:
+ {
+ TopoDS_Edge anEdge = TopoDS::Edge(theShape);
+ double aFirst, aLast;
+ Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, aFirst, aLast);
+
+ GeomAdaptor_Curve aAdaptor(aCurve, aFirst, aLast);
+ gp_Pnt aFirstPnt = aAdaptor.Value(aFirst);
+ gp_Pnt aLastPnt = aAdaptor.Value(aLast);
+
+ BRepAdaptor_Curve aBRepAdaptor = BRepAdaptor_Curve(anEdge);
+ Adaptor3d_Curve* anAdaptor3d = &aBRepAdaptor;
+
+ QStringList aValues, anInfo;
+ aValues.append (QString::number (GCPnts_AbscissaPoint::Length(*anAdaptor3d)));
+ anInfo.append ("Length");
+
+ aValues.append (aCurve->DynamicType()->Name());
+ anInfo.append ("DynamicType");
+
+ aValues.append (ToString (aFirstPnt));
+ anInfo.append (QString ("First" + QString::number (aFirst)));
+
+ aValues.append (ToString (aLastPnt));
+ anInfo.append (QString ("Last" + QString::number (aLast)));
+
+ aValues.append (ToName (aCurve->Continuity()));
+ anInfo.append ("Continuity");
+
+ aValues.append (ToString (aCurve->IsClosed()));
+ anInfo.append ("IsClosed");
+
+ if (aCurve->IsPeriodic()) {
+ aValues.append (QString::number (aCurve->Period()));
+ anInfo.append ("IsPeriodic");
+ }
+ else
+ {
+ aValues.append (ToString (aCurve->IsPeriodic()));
+ anInfo.append ("IsPeriodic");
+ }
+ theValue = aValues.join (" / ");
+ theInfo = QString ("%1:\n%2").arg (anInfo.join (" / ")).arg (aValues.join ("\n"));
+ break;
+ }
+ case TopAbs_VERTEX:
+ {
+ TopoDS_Vertex aVertex = TopoDS::Vertex (theShape);
+ gp_Pnt aPoint = BRep_Tool::Pnt (aVertex);
+ theValue = ToString (aPoint);
+ theInfo = "(X, Y, Z) of gp_Pnt";
+ break;
+ }
+ case TopAbs_SHAPE:
+ default:
+ break;
+ }
+}
+
+// =======================================================================
+// function : locationInfo
+// purpose :
+// =======================================================================
+QString locationInfo (const TopLoc_Location& theLocation)
+{
+ QString anInfo;
+
+ gp_Trsf aTrsf = theLocation.Transformation();
+ QStringList aValues, aRowValues;
+ for (int aRowId = 1; aRowId <= 3; aRowId++)
+ {
+ aRowValues.clear();
+ for (int aColumnId = 1; aColumnId <= 4; aColumnId++)
+ aRowValues.append (QString::number (aTrsf.Value(aRowId, aColumnId)));
+ aValues.append (aRowValues.join (","));
+ }
+ anInfo.append (aValues.join (" "));
+ return anInfo;
+}
+
+// =======================================================================
+// function : GetShape
+// purpose :
+// =======================================================================
+TopoDS_Shape ShapeView_ItemShape::GetShape (const int theRowId) const
+{
+ TopoDS_Iterator aSubShapeIt (myShape);
+ for (int aCurrentIndex = 0; aSubShapeIt.More(); aSubShapeIt.Next(), aCurrentIndex++)
+ {
+ if (aCurrentIndex != theRowId)
+ continue;
+ break;
+ }
+ return aSubShapeIt.Value();
+}
+
+// =======================================================================
+// function : initValue
+// purpose :
+// =======================================================================
+QVariant ShapeView_ItemShape::initValue(const int theRole) const
+{
+ TopoDS_Shape aShape = getShape();
+ if (aShape.IsNull())
+ return QVariant();
+
+ if (theRole != Qt::DisplayRole && theRole != Qt::ToolTipRole)
+ return QVariant();
+
+ bool isDisplayRole = theRole == Qt::DisplayRole;
+ switch (Column())
+ {
+ case 0: return isDisplayRole ? ToName (aShape.ShapeType()) : "ShapeType";
+ case 1: return isDisplayRole ? (rowCount() > 0 ? QVariant (rowCount()) : QVariant())
+ : QVariant ("Number of sub shapes");
+ case 2: return isDisplayRole ? TShapePointer().ToCString() : "TShape pointer";
+ case 3: return isDisplayRole ? ToName(aShape.Orientation()) : "Orientation";
+ case 4: return isDisplayRole ? locationInfo(aShape.Location()) : "Location";
+ case 5:
+ case 6:
+ case 7:
+ {
+ QVariant aDataInfo, aTooTipInfo;
+ if (Column() == 5)
+ ToFlags(aShape, aDataInfo, aTooTipInfo);
+ else if (Column() == 6)
+ ToOtherInfo(aShape, aDataInfo, aTooTipInfo);
+ return isDisplayRole ? aDataInfo : aTooTipInfo;
+ }
+ default: break;
+ }
+ return QVariant();
+}
+
+// =======================================================================
+// function : initRowCount
+// purpose :
+// =======================================================================
+int ShapeView_ItemShape::initRowCount() const
+{
+ TopoDS_Shape aShape = getShape();
+ if (aShape.IsNull())
+ return 0;
+
+ int aRowsCount = 0;
+ for (TopoDS_Iterator aSubShapeIt(aShape); aSubShapeIt.More(); aSubShapeIt.Next())
+ aRowsCount++;
+ return aRowsCount;
+}
+
+// =======================================================================
+// function : createChild
+// purpose :
+// =======================================================================
+TreeModel_ItemBasePtr ShapeView_ItemShape::createChild (int theRow, int theColumn)
+{
+ return ShapeView_ItemShape::CreateItem (currentItem(), theRow, theColumn);
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void ShapeView_ItemShape::Init()
+{
+ ShapeView_ItemRootPtr aRootItem = itemDynamicCast<ShapeView_ItemRoot> (Parent());
+ ShapeView_ItemShapePtr aShapeItem = itemDynamicCast<ShapeView_ItemShape> (Parent());
+ myShape = aRootItem ? aRootItem->GetShape (Row()) : aShapeItem->GetShape (Row());
+}
+
+// =======================================================================
+// function : getShape
+// purpose :
+// =======================================================================
+TopoDS_Shape ShapeView_ItemShape::getShape() const
+{
+ initItem();
+ return myShape;
+}
+
+// =======================================================================
+// function : getPointerInfo
+// purpose :
+// =======================================================================
+TCollection_AsciiString ShapeView_ItemShape::getPointerInfo (const Handle(Standard_Transient)& thePointer, const bool isShortInfo)
+{
+ std::ostringstream aPtrStr;
+ aPtrStr << thePointer.operator->();
+ if (!isShortInfo)
+ return aPtrStr.str().c_str();
+
+ TCollection_AsciiString anInfoPtr (aPtrStr.str().c_str());
+ for (int aSymbolId = 1; aSymbolId < anInfoPtr.Length(); aSymbolId++)
+ {
+ if (anInfoPtr.Value(aSymbolId) != '0')
+ {
+ anInfoPtr = anInfoPtr.SubString(aSymbolId, anInfoPtr.Length());
+ anInfoPtr.Prepend("0x");
+ return anInfoPtr;
+ }
+ }
+ return aPtrStr.str().c_str();
+}
+
+// =======================================================================
+// function : Reset
+// purpose :
+// =======================================================================
+void ShapeView_ItemShape::Reset()
+{
+ myFileName = QString();
+
+ ShapeView_ItemBase::Reset();
+}
+
+// =======================================================================
+// function : initItem
+// purpose :
+// =======================================================================
+void ShapeView_ItemShape::initItem() const
+{
+ if (IsInitialized())
+ return;
+ const_cast<ShapeView_ItemShape*>(this)->Init();
+}
+
--- /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 ShapeView_ItemShape_H
+#define ShapeView_ItemShape_H
+
+#include <ShapeView_ItemBase.hxx>
+#include <Standard.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TopoDS_Shape.hxx>
+
+#include <QMap>
+#include <QVariant>
+
+class ShapeView_ItemShape;
+typedef QExplicitlySharedDataPointer<ShapeView_ItemShape> ShapeView_ItemShapePtr;
+
+//! \class ShapeView_ItemShape
+//! This item is connected to TopoDS_Shape.
+//! Parent is either ShapeView_ItemRoot or ShapeView_ItemShape, children are ShapeView_ItemShape or no children
+class ShapeView_ItemShape : public ShapeView_ItemBase
+{
+public:
+
+ //! Creates an item wrapped by a shared pointer
+ //! \param theRow the item row positition in the parent item
+ //! \param theColumn the item column positition in the parent item
+ //! \return the pointer to the created item
+ static ShapeView_ItemShapePtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ { return ShapeView_ItemShapePtr (new ShapeView_ItemShape (theParent, theRow, theColumn)); }
+
+ //! Destructor
+ virtual ~ShapeView_ItemShape() Standard_OVERRIDE {};
+
+ //! Returns the current shape
+ const TopoDS_Shape& GetItemShape() const { return myShape; }
+
+ //! Returns child(extracted) shape for the current shape by the index
+ //! \param theRowId an index of child shape
+ //! \returns shape instance or NULL
+ Standard_EXPORT TopoDS_Shape GetShape (const int theRowId) const;
+
+ //! Returns name of BREP file for the shape if exists
+ //! \return string valuie
+ QString GetFileName() const { return myFileName; }
+
+ //! Sets name of BREP file for the shape if exists
+ //! \return string valuie
+ void SetFileName (const QString& theFileName) { myFileName = theFileName; }
+
+ //! Returns TShape pointer info of the current TopoDS Shape
+ //! \return string value
+ TCollection_AsciiString TShapePointer() const { return getPointerInfo (myShape.TShape()); }
+
+ //! Inits the item, fills internal containers
+ Standard_EXPORT virtual void Init() Standard_OVERRIDE;
+
+ //! Resets cached values
+ Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
+
+ //! Return data value for the role.
+ //! \param theRole a value role
+ //! \return the value
+ Standard_EXPORT virtual QVariant initValue(const int theRole) const;
+
+ //! \return number of children.
+ Standard_EXPORT virtual int initRowCount() const Standard_OVERRIDE;
+
+protected:
+
+ //! Initialize the current item. It is empty because Reset() is also empty.
+ virtual void initItem() const Standard_OVERRIDE;
+
+ //! Creates a child item in the given position.
+ //! \param theRow the child row position
+ //! \param theColumn the child column position
+ //! \return the created item
+ virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
+
+ //! Returns number of child shapes. Init item if it is not initialized
+ //! \return integer value
+ int getRowCount() const;
+
+ //! Returns current shape, initialized item if it has not been initialized yet
+ //! \return shape value
+ TopoDS_Shape getShape() const;
+
+ //! Convert pointer to string value
+ //! \param thePointer a pointer
+ //! \param isShortInfo if true, all '0' symbols in the beginning of the pointer are skipped
+ //! \return the string value
+ static TCollection_AsciiString getPointerInfo (const Handle(Standard_Transient)& thePointer, const bool isShortInfo = true);
+
+private:
+
+ //! Constructor
+ ShapeView_ItemShape(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ : ShapeView_ItemBase(theParent, theRow, theColumn) {}
+
+private:
+
+ TopoDS_Shape myShape; //!< current shape
+ QString myFileName; //!< BREP file name
+};
+
+#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 <ShapeView_OpenFileDialog.hxx>
+#include <ShapeView_OpenFileViewModel.hxx>
+
+#include <QGroupBox>
+#include <QHBoxLayout>
+#include <QHeaderView>
+#include <QItemSelectionModel>
+#include <QLabel>
+#include <QLineEdit>
+#include <QScrollBar>
+#include <QTableView>
+#include <QVBoxLayout>
+#include <QWidget>
+
+#include <QApplication>
+#include <QCompleter>
+#include <QDir>
+#include <QFileDialog>
+#include <QFileSystemModel>
+#include <QPushButton>
+#include <QToolButton>
+
+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;
+
+// =======================================================================
+// function : StartButton
+// purpose :
+// =======================================================================
+QPushButton* ShapeView_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 ShapeView_OpenButton::onStartButtonClicked()
+{
+ QString aDataDirName = QDir::currentPath();
+
+ QString aFileName = ShapeView_OpenFileDialog::OpenFile (0, aDataDirName);
+ aFileName = QDir().toNativeSeparators (aFileName);
+ if (!aFileName.isEmpty())
+ {
+ QApplication::setOverrideCursor (Qt::WaitCursor);
+ emit OpenFile (aFileName);
+ 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 :
+// =======================================================================
+ShapeView_OpenFileDialog::ShapeView_OpenFileDialog (QWidget* theParent, const QString& theDataDirName)
+: QDialog (theParent)
+{
+ setWindowTitle (theDataDirName);
+ myDataDir = 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 ShapeView_OpenFileDialog::OpenFile (QWidget* theParent, const QString& theDataDirName)
+{
+ QString aFileName;
+ ShapeView_OpenFileDialog* aDialog = new ShapeView_OpenFileDialog(theParent, theDataDirName);
+ if (aDialog->exec() == QDialog::Accepted)
+ aFileName = aDialog->GetFileName();
+
+ return aFileName;
+}
+
+// =======================================================================
+// function : onSampleSelectionChanged
+// purpose :
+// =======================================================================
+void ShapeView_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 ShapeView_OpenFileDialog::onNameChanged (const QString& theText)
+{
+ QFileInfo aFileInfo (theText);
+ bool anExists = aFileInfo.exists() && aFileInfo.isFile();
+ myFolderApplyOpen->setEnabled (anExists);
+}
+
+// =======================================================================
+// function : onSelectClicked
+// purpose :
+// =======================================================================
+void ShapeView_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 ShapeView_OpenFileDialog::onApplySelectClicked()
+{
+ myFileName = mySelectedName->text();
+ accept();
+}
+
+// =======================================================================
+// function : createTableView
+// purpose :
+// =======================================================================
+QTableView* ShapeView_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 ShapeView_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* ShapeView_OpenFileDialog::createModel (const QStringList& theFileNames)
+{
+ ShapeView_OpenFileViewModel* aModel = new ShapeView_OpenFileViewModel(this);
+ aModel->Init (theFileNames);
+ return aModel;
+}
+
+// =======================================================================
+// function : readSampleNames
+// purpose :
+// =======================================================================
+QStringList ShapeView_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 ShapeView_OpenFileDialog_H
+#define ShapeView_OpenFileDialog_H
+
+#include <Standard.hxx>
+#include <Standard_Macro.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 QAbstractItemModel;
+class QLineEdit;
+class QPushButton;
+class QTableView;
+class QToolButton;
+class QWidget;
+
+//! \class ShapeView_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 ShapeView_OpenButton : public QObject
+{
+ Q_OBJECT
+public:
+
+ //! Constructor
+ ShapeView_OpenButton (QObject* theParent) : QObject (theParent), myStartButton (0) {}
+
+ //! Destructor
+ virtual ~ShapeView_OpenButton() {}
+
+ //! Returns the start button, if this is the first call, it creates the button and connect it to the slot
+ Standard_EXPORT QPushButton* StartButton();
+
+ //! Sets the default directory of plugin.
+ void SetPluginDir (const TCollection_AsciiString& thePluginName, const TCollection_AsciiString& theDefaultDir)
+ { myDefaultDirs[thePluginName] = theDefaultDir; }
+
+private slots:
+
+ //! Processes the button click, open default/current directory to select open file, calls OpenFile of communicator
+ void onStartButtonClicked();
+
+signals:
+
+ //! Signals about opening file clicked
+ //! \param theFileName an output file name
+ void OpenFile (const QString& theFileName);
+
+private:
+
+ QPushButton* myStartButton; //!< processed button
+ std::map<TCollection_AsciiString, TCollection_AsciiString> myDefaultDirs; //!< plugins default directories
+};
+
+//! \class ShapeView_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 ShapeView_OpenFileDialog : public QDialog
+{
+ Q_OBJECT
+private:
+
+ //! Constructor
+ ShapeView_OpenFileDialog (QWidget* theParent, const QString& theDataDirName);
+
+public:
+
+ //! Destructor
+ virtual ~ShapeView_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; }
+
+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 <ShapeView_OpenFileViewModel.hxx>
+
+#include <QApplication>
+#include <QFileInfo>
+#include <QIcon>
+#include <QPainter>
+
+const int ICON_SIZE = 40;
+// =======================================================================
+// function : paint
+// purpose :
+// =======================================================================
+void ShapeView_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 ShapeView_OpenFileViewModel::Init (const QStringList& theValues)
+{
+ myValues = theValues;
+}
+
+// =======================================================================
+// function : data
+// purpose :
+// =======================================================================
+QVariant ShapeView_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 ShapeView_OpenFileViewModel_H
+#define ShapeView_OpenFileViewModel_H
+
+#include <Standard.hxx>
+#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 ShapeView_OpenFileItemDelegate : public QItemDelegate
+{
+public:
+
+ //! Constructor
+ ShapeView_OpenFileItemDelegate (QObject* theParent, const QColor& theHighlight)
+ : QItemDelegate (theParent), myColor(theHighlight) {}
+
+ //! Destructor
+ virtual ~ShapeView_OpenFileItemDelegate() {}
+
+ //! Draw an icon in the cell
+ //! \param thePainter a painter
+ //! \param theOption a paint options
+ //! \param theIndex a view index
+ Standard_EXPORT void paint (QPainter* thePainter, const QStyleOptionViewItem& theOption,
+ const QModelIndex& theIndex) const;
+
+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 ShapeView_OpenFileViewModel : public QAbstractTableModel
+{
+public:
+
+ //! Constructor
+ ShapeView_OpenFileViewModel (QObject* theParent = 0) : QAbstractTableModel (theParent) {}
+
+ //! Destructor
+ virtual ~ShapeView_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
+// 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 <ShapeView_Tools.hxx>
+
+#include <BRep_Builder.hxx>
+#include <BRepTools.hxx>
+
+#include <AIS_Shape.hxx>
+// =======================================================================
+// function : ReadShape
+// purpose :
+// =======================================================================
+TopoDS_Shape ShapeView_Tools::ReadShape (const TCollection_AsciiString& theFileName)
+{
+ TopoDS_Shape aShape;
+
+ BRep_Builder aBuilder;
+ BRepTools::Read (aShape, theFileName.ToCString(), aBuilder);
+ return aShape;
+}
+
+// =======================================================================
+// function : CreatePresentation
+// purpose :
+// =======================================================================
+Handle(Standard_Transient) ShapeView_Tools::CreatePresentation (const TopoDS_Shape& theShape)
+{
+ return new AIS_Shape (theShape);
+}
--- /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 ShapeView_Tools_H
+#define ShapeView_Tools_H
+
+#include <Standard.hxx>
+
+#include <TCollection_AsciiString.hxx>
+#include <Standard_Transient.hxx>
+#include <TopoDS_Shape.hxx>
+
+//! \class ShapeView_Tools
+//! It gives auxiliary methods for TopoDS_Shape manipulation
+class ShapeView_Tools
+{
+public:
+
+ //! Read Shape using BREP reader
+ //! \param theFileName a file name
+ //! \return shape or NULL
+ Standard_EXPORT static TopoDS_Shape ReadShape (const TCollection_AsciiString& theFileName);
+
+ //! Creates AIS_Shape for the shape
+ //! \param theShape a shape
+ //! \return presentation
+ Standard_EXPORT static Handle(Standard_Transient) CreatePresentation (const TopoDS_Shape& theShape);
+};
+
+#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 <ShapeView_TreeModel.hxx>
+#include <ShapeView_ItemRoot.hxx>
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+ShapeView_TreeModel::ShapeView_TreeModel (QObject* theParent)
+: TreeModel_ModelBase (theParent)
+{
+ for (int aColumnId = 0, aNbColumns = columnCount(); aColumnId < aNbColumns; aColumnId++)
+ myRootItems.insert(aColumnId, ShapeView_ItemRoot::CreateItem(TreeModel_ItemBasePtr(), 0, aColumnId));
+
+ m_pRootItem = myRootItems[0];
+}
+
+// =======================================================================
+// function : AddShape
+// purpose :
+// =======================================================================
+void ShapeView_TreeModel::AddShape(const TopoDS_Shape& theShape)
+{
+ for (int aColId = 0, aNbColumns = columnCount(); aColId < aNbColumns; aColId++)
+ {
+ ShapeView_ItemRootPtr aRootItem = itemDynamicCast<ShapeView_ItemRoot>(RootItem (aColId));
+ aRootItem->AddShape(theShape);
+ }
+
+ Reset();
+ EmitLayoutChanged();
+}
+
+// =======================================================================
+// function : RemoveAllShapes
+// purpose :
+// =======================================================================
+void ShapeView_TreeModel::RemoveAllShapes()
+{
+ for (int aColId = 0, aNbColumns = columnCount(); aColId < aNbColumns; aColId++)
+ {
+ ShapeView_ItemRootPtr aRootItem = itemDynamicCast<ShapeView_ItemRoot>(RootItem (aColId));
+ aRootItem->RemoveAllShapes();
+ }
+ Reset();
+ EmitLayoutChanged();
+}
+
+// =======================================================================
+// function : headerData
+// purpose :
+// =======================================================================
+QVariant ShapeView_TreeModel::headerData (int theSection, Qt::Orientation theOrientation, int theRole) const
+{
+ if (theOrientation != Qt::Horizontal || theRole != Qt::DisplayRole)
+ return QVariant();
+ {
+ switch (theSection)
+ {
+ case 0: return "Name";
+ case 1: return "Size";
+ case 2: return "Pointer";
+ case 3: return "Orientation";
+ case 4: return "Location";
+ case 5: return "Flags"; // Checked/Closed/Infinite/Locked/Modified/Orientable
+ case 7: return "Other";
+ //Auto Triangulation
+ 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 ShapeView_TreeModel_H
+#define ShapeView_TreeModel_H
+
+#include <ShapeView_ItemBase.hxx>
+#include <Standard.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TreeModel_ModelBase.hxx>
+
+#include <QMap>
+#include <QObject>
+
+class ShapeView_TreeModel;
+
+//! \class ShapeView_TreeModel
+//! View model to visualize content of TopoDS_Shape
+class ShapeView_TreeModel : public TreeModel_ModelBase
+{
+public:
+
+ //! Constructor
+ Standard_EXPORT ShapeView_TreeModel (QObject* theParent);
+
+ //! Destructor
+ virtual ~ShapeView_TreeModel() Standard_OVERRIDE {};
+
+ //! Add shape, append it to the model root item
+ //! \param theShape a shape instance
+ Standard_EXPORT void AddShape (const TopoDS_Shape& theShape);
+
+ //! Remove all shapes in the model root item
+ Standard_EXPORT void RemoveAllShapes();
+
+ //! Returns root item by column
+ //! \param theColumn an index of the column
+ //! \return root item instance
+ virtual TreeModel_ItemBasePtr RootItem(const int theColumn) const Standard_OVERRIDE
+ { return myRootItems[theColumn]; }
+
+ //! Returns count of columns in the model.
+ //! \param theParent an index of the parent item
+ //! \return integer value
+ virtual int columnCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
+ { (void)theParent; return 7; }
+
+ //! Returns the header data for the given role and section in the header with the specified orientation.
+ //! \param theSection the header section. For horizontal headers - column number, for vertical headers - row number.
+ //! \param theOrientation a header orientation
+ //! \param theRole a data role
+ //! \return the header data
+ Standard_EXPORT virtual QVariant headerData (int theSection, Qt::Orientation theOrientation,
+ int theRole = Qt::DisplayRole ) const Standard_OVERRIDE;
+
+private:
+ QMap<int, TreeModel_ItemBasePtr> myRootItems; //!< container of root items, for each column own root item
+};
+
+#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 <ShapeView_Window.hxx>
+#include <ShapeView_ItemShape.hxx>
+#include <ShapeView_TreeModel.hxx>
+
+#include <View_Displayer.hxx>
+#include <View_ToolBar.hxx>
+#include <View_Widget.hxx>
+#include <View_Window.hxx>
+#include <View_Viewer.hxx>
+
+#include <ShapeView_OpenFileDialog.hxx>
+#include <ShapeView_Tools.hxx>
+
+#include <BRep_Builder.hxx>
+#include <BRepTools.hxx>
+
+#include <QApplication>
+#include <QAction>
+#include <QComboBox>
+#include <QDockWidget>
+#include <QDir>
+#include <QFile>
+#include <QFileDialog>
+#include <QMainWindow>
+#include <QMenu>
+#include <QPlainTextEdit>
+#include <QPushButton>
+#include <QTextEdit>
+#include <QTextStream>
+#include <QToolBar>
+#include <QToolButton>
+#include <QTreeView>
+#include <QWidget>
+#include <QVBoxLayout>
+
+const int FIRST_COLUMN_WIDTH = 200;
+const int SIZE_COLUMN_WIDTH = 30;
+const int POINTER_COLUMN_WIDTH = 110;
+const int ORIENTATION_COLUMN_WIDTH = 70;
+const int LOCATION_COLUMN_WIDTH = 120;
+const int FLAGS_COLUMN_WIDTH = 70;
+
+const int DEFAULT_TEXT_VIEW_WIDTH = 800;
+const int DEFAULT_TEXT_VIEW_HEIGHT = 700;
+const int DEFAULT_TEXT_VIEW_POSITION_X = 430;
+const int DEFAULT_TEXT_VIEW_POSITION_Y = 30;
+const int DEFAULT_TEXT_VIEW_DELTA = 100;
+
+const int DEFAULT_SHAPE_VIEW_WIDTH = 900;
+const int DEFAULT_SHAPE_VIEW_HEIGHT = 450;
+const int DEFAULT_SHAPE_VIEW_POSITION_X = 60;
+const int DEFAULT_SHAPE_VIEW_POSITION_Y = 60;
+
+const int SHAPEVIEW_DEFAULT_TREE_VIEW_WIDTH = 600;
+const int SHAPEVIEW_DEFAULT_TREE_VIEW_HEIGHT = 500;
+
+const int SHAPEVIEW_DEFAULT_VIEW_WIDTH = 400;
+const int SHAPEVIEW_DEFAULT_VIEW_HEIGHT = 1000;
+
+//! \class ShapeView_TreeView
+//! Extended tree view control with possibility to set predefined size.
+class ShapeView_TreeView : public QTreeView
+{
+public:
+ //! Constructor
+ ShapeView_TreeView (QWidget* theParent) : QTreeView (theParent), myDefaultWidth (-1), myDefaultHeight (-1) {}
+
+ //! Destructor
+ virtual ~ShapeView_TreeView() {}
+
+ //! Sets default size of control, that is used by the first control show
+ //! \param theDefaultWidth the width value
+ //! \param theDefaultHeight the height value
+ void SetPredefinedSize (int theDefaultWidth, int theDefaultHeight);
+
+ //! Returns predefined size if both values are positive, otherwise parent size hint
+ virtual QSize sizeHint() const Standard_OVERRIDE;
+
+private:
+
+ int myDefaultWidth; //!< default width, -1 if it should not be used
+ int myDefaultHeight; //!< default height, -1 if it should not be used
+};
+
+// =======================================================================
+// function : SetPredefinedSize
+// purpose :
+// =======================================================================
+void ShapeView_TreeView::SetPredefinedSize (int theDefaultWidth, int theDefaultHeight)
+{
+ myDefaultWidth = theDefaultWidth;
+ myDefaultHeight = theDefaultHeight;
+}
+
+// =======================================================================
+// function : sizeHint
+// purpose :
+// =======================================================================
+QSize ShapeView_TreeView::sizeHint() const
+{
+ if (myDefaultWidth > 0 && myDefaultHeight > 0)
+ return QSize (myDefaultWidth, myDefaultHeight);
+ return QTreeView::sizeHint();
+}
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+ShapeView_Window::ShapeView_Window (QWidget* theParent, const TCollection_AsciiString& theTemporaryDirectory)
+: QObject (theParent), myTemporaryDirectory (theTemporaryDirectory), myNextPosition (0)
+{
+ myMainWindow = new QMainWindow (theParent);
+
+ QWidget* aCentralWidget = new QWidget (myMainWindow);
+ QGridLayout* aParentLay = new QGridLayout (aCentralWidget);
+ aParentLay->setContentsMargins (0, 0, 0, 0);
+ myMainWindow->setCentralWidget (aCentralWidget);
+
+ ShapeView_OpenButton* aButton = new ShapeView_OpenButton (0);
+ connect (aButton, SIGNAL (OpenFile (const QString&)), this, SLOT (onOpenFile (const QString&)));
+ aButton->setObjectName ("TKShapeView");
+ aParentLay->addWidget (aButton->StartButton(), 0, 2);
+
+ myTreeView = new ShapeView_TreeView (myMainWindow);
+ ((ShapeView_TreeView*)myTreeView)->SetPredefinedSize (SHAPEVIEW_DEFAULT_TREE_VIEW_WIDTH,
+ SHAPEVIEW_DEFAULT_TREE_VIEW_HEIGHT);
+ myTreeView->setContextMenuPolicy (Qt::CustomContextMenu);
+ connect (myTreeView, SIGNAL (customContextMenuRequested (const QPoint&)),
+ this, SLOT (onTreeViewContextMenuRequested (const QPoint&)));
+ ShapeView_TreeModel* aModel = new ShapeView_TreeModel (myTreeView);
+ myTreeView->setModel (aModel);
+
+ QItemSelectionModel* aSelectionModel = new QItemSelectionModel (aModel);
+ myTreeView->setSelectionMode (QAbstractItemView::ExtendedSelection);
+ myTreeView->setSelectionModel (aSelectionModel);
+ connect (aSelectionModel, SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
+ this, SLOT (onTreeViewSelectionChanged (const QItemSelection&, const QItemSelection&)));
+
+ QModelIndex aParentIndex = myTreeView->model()->index (0, 0);
+ myTreeView->setExpanded (aParentIndex, true);
+ myTreeView->setColumnWidth (0, FIRST_COLUMN_WIDTH);
+ myTreeView->setColumnWidth (1, SIZE_COLUMN_WIDTH);
+ myTreeView->setColumnWidth (2, POINTER_COLUMN_WIDTH);
+ myTreeView->setColumnWidth (3, ORIENTATION_COLUMN_WIDTH);
+ myTreeView->setColumnWidth (4, LOCATION_COLUMN_WIDTH);
+ myTreeView->setColumnWidth (5, FLAGS_COLUMN_WIDTH);
+
+ QDockWidget* aTreeViewWidget = new QDockWidget (tr ("ShapeView"), myMainWindow);
+ aTreeViewWidget->setFeatures (QDockWidget::NoDockWidgetFeatures);
+ aTreeViewWidget->setWidget (myTreeView);
+ myMainWindow->addDockWidget (Qt::LeftDockWidgetArea, aTreeViewWidget);
+ myMainWindow->setCorner (Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
+
+ // view
+ myViewWindow = new View_Window (myMainWindow);
+ myViewWindow->GetView()->SetPredefinedSize (SHAPEVIEW_DEFAULT_VIEW_WIDTH, SHAPEVIEW_DEFAULT_VIEW_HEIGHT);
+
+ QDockWidget* aViewDockWidget = new QDockWidget (tr ("View"), myMainWindow);
+ aViewDockWidget->setWidget (myViewWindow);
+ myMainWindow->addDockWidget (Qt::BottomDockWidgetArea, aViewDockWidget);
+
+ myMainWindow->resize (DEFAULT_SHAPE_VIEW_WIDTH, DEFAULT_SHAPE_VIEW_HEIGHT);
+ myMainWindow->move (DEFAULT_SHAPE_VIEW_POSITION_X, DEFAULT_SHAPE_VIEW_POSITION_Y);
+}
+
+// =======================================================================
+// function : Destructor
+// purpose :
+// =======================================================================
+ShapeView_Window::~ShapeView_Window()
+{
+ onCloseAllBREPViews();
+}
+
+// =======================================================================
+// function : SetParent
+// purpose :
+// =======================================================================
+void ShapeView_Window::SetParent (void* theParent)
+{
+ QWidget* aParent = (QWidget*)theParent;
+ if (aParent)
+ {
+ QLayout* aLayout = aParent->layout();
+ if (aLayout)
+ aLayout->addWidget (GetMainWindow());
+ }
+}
+
+// =======================================================================
+// function : UpdateContent
+// purpose :
+// =======================================================================
+void ShapeView_Window::UpdateContent()
+{
+ TCollection_AsciiString aName = "TKShapeView";
+ if (myParameters->FindParameters (aName))
+ {
+ NCollection_List<Handle(Standard_Transient)> aParameters = myParameters->Parameters (aName);
+ // Init will remove from parameters those, that are processed only one time (TShape)
+ Init(aParameters);
+ myParameters->SetParameters (aName, aParameters);
+ }
+ if (myParameters->FindFileNames(aName))
+ {
+ for (NCollection_List<TCollection_AsciiString>::Iterator aFilesIt(myParameters->FileNames(aName));
+ aFilesIt.More(); aFilesIt.Next())
+ OpenFile (aFilesIt.Value());
+
+ NCollection_List<TCollection_AsciiString> aNames;
+ myParameters->SetFileNames (aName, aNames);
+ }
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void ShapeView_Window::Init (NCollection_List<Handle(Standard_Transient)>& theParameters)
+{
+ Handle(AIS_InteractiveContext) aContext;
+ NCollection_List<Handle(Standard_Transient)> aParameters;
+ for (NCollection_List<Handle(Standard_Transient)>::Iterator aParamsIt (theParameters);
+ aParamsIt.More(); aParamsIt.Next())
+ {
+ Handle(Standard_Transient) anObject = aParamsIt.Value();
+ Handle(TopoDS_TShape) aShapePointer = Handle(TopoDS_TShape)::DownCast (anObject);
+ if (!aShapePointer.IsNull())
+ {
+ TopoDS_Shape aShape;
+ aShape.TShape (aShapePointer);
+ addShape (aShape);
+ }
+ else
+ {
+ aParameters.Append (anObject);
+ if (aContext.IsNull())
+ aContext = Handle(AIS_InteractiveContext)::DownCast (anObject);
+ }
+ }
+ if (!aContext.IsNull())
+ myViewWindow->SetContext (View_ContextType_External, aContext);
+
+ theParameters = aParameters;
+}
+
+// =======================================================================
+// function : OpenFile
+// purpose :
+// =======================================================================
+void ShapeView_Window::OpenFile(const TCollection_AsciiString& theFileName)
+{
+ TopoDS_Shape aShape = ShapeView_Tools::ReadShape (theFileName);
+ if (!aShape.IsNull())
+ addShape(aShape);
+}
+
+// =======================================================================
+// function : RemoveAllShapes
+// purpose :
+// =======================================================================
+void ShapeView_Window::RemoveAllShapes()
+{
+ ShapeView_TreeModel* aModel = dynamic_cast<ShapeView_TreeModel*> (myTreeView->model());
+ aModel->RemoveAllShapes();
+
+ onCloseAllBREPViews();
+}
+
+// =======================================================================
+// function : addShape
+// purpose :
+// =======================================================================
+void ShapeView_Window::addShape (const TopoDS_Shape& theShape)
+{
+ ShapeView_TreeModel* aModel = dynamic_cast<ShapeView_TreeModel*> (myTreeView->model());
+ aModel->AddShape (theShape);
+}
+
+// =======================================================================
+// function : onTreeViewContextMenuRequested
+// purpose :
+// =======================================================================
+void ShapeView_Window::onTreeViewContextMenuRequested (const QPoint& thePosition)
+{
+ QMenu* aMenu = new QMenu(myMainWindow);
+ aMenu->addAction (createAction ("Clear view", SLOT (onClearView())));
+ if (!myTemporaryDirectory.IsEmpty())
+ aMenu->addAction (createAction ("BREP view", SLOT (onBREPView())));
+ aMenu->addAction (createAction ("Close All BREP views", SLOT (onCloseAllBREPViews())));
+ aMenu->addAction (createAction ("BREP directory", SLOT (onBREPDirectory())));
+
+ QPoint aPoint = myTreeView->mapToGlobal (thePosition);
+ aMenu->exec (aPoint);
+}
+
+// =======================================================================
+// function : onBREPDirectory
+// purpose :
+// =======================================================================
+void ShapeView_Window::onBREPDirectory()
+{
+ QString aFilter (tr ("BREP file (*.brep*)"));
+ QString aSelectedFilter;
+ QString aFileName = QFileDialog::getOpenFileName (0, tr ("Export shape to BREP file"),
+ myTemporaryDirectory.ToCString(), aSelectedFilter);
+ if (!aFileName.isEmpty())
+ viewFile (aFileName);
+}
+
+// =======================================================================
+// function : onBREPView
+// purpose :
+// =======================================================================
+void ShapeView_Window::onBREPView()
+{
+ if (myTemporaryDirectory.IsEmpty())
+ return;
+
+ QItemSelectionModel* aModel = myTreeView->selectionModel();
+ if (!aModel)
+ return;
+
+ QModelIndexList aSelectedRows = aModel->selectedRows();
+ if (aSelectedRows.size() == 0)
+ return;
+
+ QModelIndex aSelectedIndex = aSelectedRows.at (0);
+ TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (aSelectedIndex);
+ if (!anItemBase)
+ return;
+
+ ShapeView_ItemShapePtr anItem = itemDynamicCast<ShapeView_ItemShape>(anItemBase);
+ if (!anItem)
+ return;
+
+ QString aFileName = anItem->GetFileName();
+ QDir aDir;
+ if (aFileName.isEmpty() || !aDir.exists (aFileName))
+ {
+ TCollection_AsciiString aFileNameIndiced = myTemporaryDirectory + TCollection_AsciiString ("\\") +
+ getNextTmpName (anItem->TShapePointer());
+ const TopoDS_Shape& aShape = anItem->GetItemShape();
+ BRepTools::Write (aShape, aFileNameIndiced.ToCString());
+ anItem->SetFileName (aFileNameIndiced.ToCString());
+ aFileName = aFileNameIndiced.ToCString();
+ }
+ viewFile (aFileName);
+}
+
+// =======================================================================
+// function : onCloseAllBREPViews
+// purpose :
+// =======================================================================
+void ShapeView_Window::onCloseAllBREPViews()
+{
+ removeBREPFiles();
+
+ for (int aViewId = myBREPViews.size()-1; aViewId >= 0; aViewId--)
+ delete myBREPViews[aViewId];
+
+ myBREPViews.clear();
+}
+
+// =======================================================================
+// function : onEditorDestroyed
+// purpose :
+// =======================================================================
+void ShapeView_Window::onEditorDestroyed(QObject* theObject)
+{
+ QWidget* aWidget = dynamic_cast<QWidget*> (theObject);
+
+ for (int aViewId = myBREPViews.size()-1; aViewId >= 0; aViewId--)
+ {
+ if (myBREPViews[aViewId] == aWidget)
+ myBREPViews.removeAll(aWidget);
+ }
+}
+
+// =======================================================================
+// function : displaySelectedShapes
+// purpose :
+// =======================================================================
+void ShapeView_Window::displaySelectedShapes (const QModelIndexList& theSelected)
+{
+ for (QModelIndexList::const_iterator aSelIt = theSelected.begin(); aSelIt != theSelected.end(); aSelIt++)
+ {
+ QModelIndex anIndex = *aSelIt;
+ if (anIndex.column() != 0)
+ continue;
+
+ TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex);
+ if (!anItemBase)
+ continue;
+
+ ShapeView_ItemShapePtr aShapeItem = itemDynamicCast<ShapeView_ItemShape>(anItemBase);
+ if (!aShapeItem)
+ continue;
+ TopoDS_Shape aShape = aShapeItem->GetItemShape();
+ myViewWindow->GetDisplayer()->DisplayPresentation (ShapeView_Tools::CreatePresentation(aShape),
+ View_PresentationType_Main, true);
+ }
+ myViewWindow->GetDisplayer()->UpdateViewer();
+}
+
+// =======================================================================
+// function : viewFile
+// purpose :
+// =======================================================================
+void ShapeView_Window::viewFile (const QString& theFileName)
+{
+ QApplication::setOverrideCursor (Qt::WaitCursor);
+ QString aFileText;
+ QFile aFile (theFileName);
+ if (aFile.open (QIODevice::ReadOnly | QIODevice::Text))
+ {
+ QTextStream aStream(&aFile);
+ QString aLine = aStream.readLine();
+ while (!aLine.isNull())
+ {
+ aLine = aStream.readLine();
+ aFileText.append (aLine + QString ("\n"));
+ }
+ if (!aFileText.isEmpty())
+ {
+ QPlainTextEdit* anEditor = new QPlainTextEdit (0);
+ anEditor->setAttribute (Qt::WA_DeleteOnClose, true);
+ connect (anEditor, SIGNAL (destroyed(QObject*)), this, SLOT (onEditorDestroyed(QObject*)));
+ anEditor->setPlainText (aFileText);
+ anEditor->resize (DEFAULT_TEXT_VIEW_WIDTH, DEFAULT_TEXT_VIEW_HEIGHT);
+ anEditor->move (DEFAULT_TEXT_VIEW_POSITION_X + myNextPosition, DEFAULT_TEXT_VIEW_POSITION_Y);
+ myNextPosition += DEFAULT_TEXT_VIEW_DELTA;
+ anEditor->show();
+ myBREPViews.append (anEditor);
+ }
+ }
+ QApplication::restoreOverrideCursor();
+}
+
+// =======================================================================
+// function : removeBREPFiles
+// purpose :
+// =======================================================================
+void ShapeView_Window::removeBREPFiles()
+{
+ QDir aDir (myTemporaryDirectory.ToCString());
+
+ QStringList anEntries = aDir.entryList();
+ QString aPrefix(viewBREPPrefix().ToCString());
+ for (int anEntryId = 0, aSize = anEntries.size(); anEntryId < aSize; anEntryId++)
+ {
+ if (anEntries[anEntryId].contains (aPrefix))
+ aDir.remove (anEntries[anEntryId]);
+ }
+}
+
+// =======================================================================
+// function : createAction
+// purpose :
+// =======================================================================
+QAction* ShapeView_Window::createAction (const QString& theText, const char* theSlot)
+{
+ QAction* anAction = new QAction (theText, myMainWindow);
+ connect (anAction, SIGNAL (triggered(bool)), this, theSlot);
+ return anAction;
+}
+
+// =======================================================================
+// function : getNextTmpName
+// purpose :
+// =======================================================================
+TCollection_AsciiString ShapeView_Window::getNextTmpName (const TCollection_AsciiString& thePointerInfo)
+{
+ TCollection_AsciiString aTmpName(viewBREPPrefix());
+ aTmpName += thePointerInfo;
+ return aTmpName;
+}
--- /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 ShapeView_Window_H
+#define ShapeView_Window_H
+
+#include <Standard.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TInspectorAPI_PluginParameters.hxx>
+#include <TopoDS_Shape.hxx>
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4127) // conditional expression is constant
+#endif
+#include <QItemSelection>
+#include <QList>
+#include <QModelIndexList>
+#include <QObject>
+#include <QPoint>
+#include <QString>
+#include <QTreeView>
+
+class View_Displayer;
+class View_Window;
+
+class QAction;
+class QMainWindow;
+class QWidget;
+
+//! \class ShapeView_Window
+//! Window that unites all ShapeView controls.
+class ShapeView_Window : public QObject
+{
+ Q_OBJECT
+public:
+
+ //! Constructor
+ Standard_EXPORT ShapeView_Window (QWidget* theParent, const TCollection_AsciiString& theTemporaryDirectory);
+
+ //! Destructor
+ Standard_EXPORT virtual ~ShapeView_Window();
+
+ //! Provides the container with a parent where this container should be inserted.
+ //! If Qt implementation, it should be QWidget with QLayout set inside
+ //! \param theParent a parent class
+ Standard_EXPORT void SetParent (void* theParent);
+
+ //! Sets parameters container, it should be used when the plugin is initialized or in update content
+ //! \param theParameters a parameters container
+ void SetParameters (const Handle(TInspectorAPI_PluginParameters)& theParameters) { myParameters = theParameters; }
+
+ //! Applyes parameters to Init controls, opens files if there are in parameters, updates OCAF tree view model
+ Standard_EXPORT void UpdateContent();
+
+ //! Returns main control
+ QMainWindow* GetMainWindow() const { return myMainWindow; }
+
+ //! Returns current tree view
+ QTreeView* GetTreeView() const { return myTreeView; }
+
+ //! Returns path to temporary directory
+ TCollection_AsciiString GetTemporaryDirectory() const { return myTemporaryDirectory; }
+
+ //! Removes all shapes in tree view model, remove all stored BREP files
+ Standard_EXPORT void RemoveAllShapes();
+
+protected:
+ //! Appends shape into tree view model
+ //! \param theShape a shape instance
+ Standard_EXPORT void addShape (const TopoDS_Shape& theShape);
+
+private:
+
+ //! Fills controls of the plugin by parameters:
+ //! - Fine AIS_InteractiveObject and fills View if it if it differs from the current context
+ //! \param theParameters a parameters container
+ void Init (NCollection_List<Handle(Standard_Transient)>& theParameters);
+
+ //! Read Shape from the file name, add Shape into tree view
+ //! \param theFileName BREP file name
+ void OpenFile (const TCollection_AsciiString& theFileName);
+
+protected slots:
+
+ //! Displays shapes obtained by selected indices
+ //! \param theSelected a container of selected indices in tree view
+ //! \param theDeselected a container of deselected indices in tree view
+ void onTreeViewSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected)
+ { (void)theDeselected; displaySelectedShapes(theSelected.indexes()); }
+
+ //! Shows context menu for tree view selected item. It contains expand/collapse actions.
+ //! \param thePosition a clicked point
+ void onTreeViewContextMenuRequested (const QPoint& thePosition);
+
+ //! Exports shape to BREP file and view result file
+ void onBREPDirectory();
+
+ //! Removes all shapes in tree view
+ void onClearView() { RemoveAllShapes(); }
+
+ //! View BREP files of selected items if exist
+ void onBREPView();
+
+ //! Remove BREP views, close views
+ void onCloseAllBREPViews();
+
+ //! Remove all BREP Viewse excepting active
+ void onEditorDestroyed (QObject* theObject);
+
+ //! Convers file name to Ascii String and perform opeging file
+ //! \param theFileName a file name to be opened
+ void onOpenFile(const QString& theFileName) { OpenFile (TCollection_AsciiString (theFileName.toUtf8().data())); }
+
+protected:
+
+ //! Views file name content in a text editor. It creates new Qt free control with content.
+ //! \param theFileName a file name
+ void viewFile (const QString& theFileName);
+
+ //! Removes all BREP files in tmp directory
+ void removeBREPFiles();
+
+ //! Creates new action and connect it to the given slot
+ //! \param theText an action text
+ //! \param theSlot a listener method
+ QAction* createAction (const QString& theText, const char* theSlot);
+
+ //! Key that uses to generate BREP file name
+ //! \return string value
+ static TCollection_AsciiString viewBREPPrefix() { return "ShapeView_Window"; }
+
+ //! Returns newxt temporary name using BREPPrefix and pointer information
+ //! \param thePointerInfo a pointer value
+ //! \return string value
+ TCollection_AsciiString getNextTmpName (const TCollection_AsciiString& thePointerInfo);
+
+ //! Finds shapes for selected items in tree view and display presentations for the shapes
+ //! \param theSelected a list of selected indices in tree view
+ void displaySelectedShapes (const QModelIndexList& theSelected);
+
+private:
+
+ QMainWindow* myMainWindow; //!< main control, parent for all ShapeView controls
+ View_Window* myViewWindow; //!< OCC 3d view to visualize presentations
+ QTreeView* myTreeView; //!< tree view visualized shapes
+
+ TCollection_AsciiString myTemporaryDirectory; //!< path to the temporary directory
+ int myNextPosition; //!< delta of moving control of view BREP file
+
+ QList<QWidget*> myBREPViews; //!< list of view BREP file controls
+ Handle(TInspectorAPI_PluginParameters) myParameters; //!< plugins parameters container
+};
+
+#endif
--- /dev/null
+TInspector.qrc
+TInspector_Communicator.cxx
+TInspector_Communicator.hxx
+TInspector_Window.cxx
+TInspector_Window.hxx
--- /dev/null
+<!DOCTYPE RCC><RCC version="1.0">
+ <qresource>
+ <file>icons/item_algo_folder.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 <TInspector_Communicator.hxx>
+
+#include <OSD_Environment.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TInspector_Window.hxx>
+
+#include <QApplication>
+#include <QDir>
+#include <QMainWindow>
+#include <QWidget>
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+TInspector_Communicator::TInspector_Communicator()
+{
+ if (!qApp)
+ {
+ 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());
+#endif
+ new QApplication (argc, argv);
+ }
+ myWindow = new TInspector_Window();
+ QObject::connect (qApp, SIGNAL (lastWindowClosed()), myWindow, SLOT (OnLastApplicationWindowClosed()));
+}
+
+// =======================================================================
+// function : SetVisible
+// purpose :
+// =======================================================================
+void TInspector_Communicator::SetVisible (const bool theVisible)
+{
+ myWindow->GetMainWindow()->setVisible (theVisible);
+#ifndef _WIN32
+ // window is not visualized on X11 patform under DRAW tool without the next row
+ QApplication::processEvents();
+#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.
+
+#ifndef TInspector_Communicator_H
+#define TInspector_Communicator_H
+
+#include <TInspector_Window.hxx>
+
+#include <NCollection_List.hxx>
+#include <Standard.hxx>
+#include <Standard_Transient.hxx>
+#include <TCollection_AsciiString.hxx>
+
+class QPushButton;
+
+//! \class TInspector_Communicator.
+//! \brief This is a connector from TInspector window to:
+//! - register tool plugin
+//! - give parameters into plugin
+class TInspector_Communicator
+{
+public:
+
+ //! Constructor
+ Standard_EXPORT TInspector_Communicator();
+
+ //! Destructor
+ virtual ~TInspector_Communicator() {}
+
+ //! Registers plugin into TInspector window
+ //! \param thePluginName a name of the plugin
+ void RegisterPlugin (const TCollection_AsciiString& thePluginName) { myWindow->RegisterPlugin (thePluginName); }
+
+ //! Stores parameters for the plugin
+ //! \param theParameters container of parameters(e.g. AIS_InteractiveContext, TDocStd_Application)
+ void Init (const NCollection_List<Handle(Standard_Transient)>& theParameters) { myWindow->Init ("", theParameters); }
+
+ //! Stores parameters for the plugin
+ //! \param thePluginName a name of the plugin
+ //! \param theParameters container of parameters(e.g. AIS_InteractiveContext, TDocStd_Application)
+ void Init (const TCollection_AsciiString& thePluginName,
+ const NCollection_List<Handle(Standard_Transient)>& theParameters)
+ { myWindow->Init (thePluginName, theParameters); }
+
+ //! UpdateContent for the TInspector window
+ void UpdateContent() { myWindow->UpdateContent(); }
+
+ //! SetOpenButton for the TInspector window
+ void SetOpenButton (QPushButton* theButton) { myWindow->SetOpenButton (theButton); }
+
+ //! OpenFile in TInspector window
+ void OpenFile (const TCollection_AsciiString& thePluginName, const TCollection_AsciiString& theFileName)
+ { myWindow->OpenFile (thePluginName, theFileName); }
+
+ //! Activates plugin
+ //! \param thePluginName a name of the plugin
+ void Activate (const TCollection_AsciiString& thePluginName) { myWindow->ActivateTool (thePluginName); }
+
+ //! Change window visibility
+ //! \param theVisible boolean state
+ Standard_EXPORT virtual void SetVisible (const bool theVisible);
+
+private:
+
+ TInspector_Window* myWindow; //!< current window
+};
+
+#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 <TInspector_Window.hxx>
+
+#include <TInspectorAPI_Communicator.hxx>
+
+#include <QApplication>
+#include <QDockWidget>
+#include <QLabel>
+#include <QMainWindow>
+#include <QPushButton>
+#include <QStackedWidget>
+#include <QVBoxLayout>
+
+const int TINSPECTOR_DEFAULT_WIDTH = 900;
+const int TINSPECTOR_DEFAULT_HEIGHT = 700;
+const int TINSPECTOR_DEFAULT_POSITION_X = 200;
+const int TINSPECTOR_DEFAULT_POSITION_Y = 60;
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+TInspector_Window::TInspector_Window()
+: QObject(), myOpenButton (0)
+{
+ myMainWindow = new QMainWindow();
+
+ QWidget* aCentralWidget = new QWidget (myMainWindow);
+ myMainWindow->setCentralWidget (aCentralWidget);
+ QVBoxLayout* aCentralLayout = new QVBoxLayout (aCentralWidget);
+ aCentralLayout->setContentsMargins (0, 0, 0, 0);
+ aCentralLayout->setSpacing (0);
+
+ myToolsStack = new QStackedWidget (aCentralWidget);
+ myToolsStack->setFrameShape (QFrame::Box);
+ aCentralLayout->addWidget (myToolsStack);
+
+ myEmptyWidget = new QWidget (aCentralWidget);
+ myToolsStack->addWidget (myEmptyWidget);
+
+ myButtonWidget = new QWidget (aCentralWidget);
+ myButtonLay = new QHBoxLayout (myButtonWidget);
+ myButtonLay->setContentsMargins (0, 0, 0, 0);
+ myButtonLay->setSpacing (0);
+ myButtonLay->insertStretch (0, 1);
+
+ aCentralLayout->addWidget (myButtonWidget);
+ aCentralLayout->addWidget (myToolsStack);
+
+ myMainWindow->resize (TINSPECTOR_DEFAULT_WIDTH, TINSPECTOR_DEFAULT_HEIGHT);
+ myMainWindow->move (TINSPECTOR_DEFAULT_POSITION_X, TINSPECTOR_DEFAULT_POSITION_Y);
+ myMainWindow->setDockOptions (QMainWindow::VerticalTabs);
+
+ myParameters = new TInspectorAPI_PluginParameters();
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void TInspector_Window::Init (const TCollection_AsciiString& thePluginName,
+ const NCollection_List<Handle(Standard_Transient)>& theParameters)
+{
+ if (thePluginName.IsEmpty())
+ {
+ // Init all plugins by the given parameters
+ for (int aToolId = 0, aSize = myToolNames.size(); aToolId < aSize; aToolId++)
+ Init (myToolNames[aToolId].myName, theParameters);
+
+ // temporary activation of the first tool
+ if (!myToolNames.isEmpty())
+ ActivateTool (myToolNames[0].myName);
+ return;
+ }
+
+ myParameters->SetParameters (thePluginName, theParameters);
+
+ for (int aToolId = 0, aSize = myToolNames.size(); aToolId < aSize; aToolId++)
+ {
+ TInspector_ToolInfo anInfo = myToolNames[aToolId];
+ if (anInfo.myName != thePluginName)
+ continue;
+
+ if (anInfo.myCommunicator)
+ break;
+
+ QPushButton* aButton = new QPushButton(anInfo.myName.ToCString(), myButtonWidget);
+ connect (aButton, SIGNAL (clicked (bool)), this, SLOT (onButtonClicked()));
+ myButtonLay->insertWidget (myButtonLay->count()-1, aButton);
+ anInfo.myButton = aButton;
+ myToolNames[aToolId] = anInfo;
+ break;
+ }
+}
+
+// =======================================================================
+// function : ActivateTool
+// purpose :
+// =======================================================================
+void TInspector_Window::ActivateTool (const TCollection_AsciiString& thePluginName)
+{
+ int aToolIndex = -1;
+ for (int aToolId = 0, aSize = myToolNames.size(); aToolId < aSize; aToolId++)
+ {
+ if (myToolNames[aToolId].myName != thePluginName)
+ continue;
+ aToolIndex = aToolId;
+ break;
+ }
+
+ if (aToolIndex < 0)
+ return;
+
+ TInspector_ToolInfo anInfo = myToolNames[aToolIndex];
+ if (!anInfo.myWidget)
+ {
+ if (!LoadPlugin (thePluginName, anInfo))
+ {
+ anInfo.myButton->setEnabled (false);
+ return;
+ }
+ myToolsStack->addWidget (anInfo.myWidget);
+ myToolNames[aToolIndex] = anInfo;
+ }
+
+ QWidget* aWidget = anInfo.myWidget;
+ myToolsStack->setCurrentWidget (aWidget);
+ if (myOpenButton)
+ myOpenButton->setObjectName (thePluginName.ToCString());
+
+ anInfo.myCommunicator->UpdateContent();
+ onCommuncatorNameChanged();
+}
+
+// =======================================================================
+// function : SetOpenButton
+// purpose :
+// =======================================================================
+void TInspector_Window::SetOpenButton (QPushButton* theButton)
+{
+ myOpenButton = theButton;
+ TInspector_ToolInfo anInfo;
+ if (ActiveToolInfo (anInfo))
+ myOpenButton->setObjectName (anInfo.myName.ToCString());
+ myButtonLay->insertWidget (0, theButton);
+}
+
+// =======================================================================
+// function : OpenFile
+// purpose :
+// =======================================================================
+void TInspector_Window::OpenFile (const TCollection_AsciiString& thePluginName,
+ const TCollection_AsciiString& theFileName)
+{
+ myParameters->AddFileName (thePluginName, theFileName);
+
+ TInspector_ToolInfo anInfo;
+ if (!ActiveToolInfo (anInfo) || anInfo.myName != thePluginName)
+ return;
+
+ TInspectorAPI_Communicator* aCommunicator = anInfo.myCommunicator;
+ if (aCommunicator)
+ aCommunicator->UpdateContent();
+}
+
+// =======================================================================
+// function : UpdateContent
+// purpose :
+// =======================================================================
+void TInspector_Window::UpdateContent()
+{
+ TInspector_ToolInfo anInfo;
+ if (!ActiveToolInfo (anInfo) || !anInfo.myCommunicator)
+ return;
+
+ anInfo.myCommunicator->UpdateContent();
+}
+
+// =======================================================================
+// function : LoadPlugin
+// purpose :
+// =======================================================================
+bool TInspector_Window::LoadPlugin (const TCollection_AsciiString& thePluginName, TInspector_ToolInfo& theInfo)
+{
+ bool aLoaded = false;
+
+ QApplication::setOverrideCursor (Qt::WaitCursor);
+ TInspectorAPI_Communicator* aCommunicator = TInspectorAPI_Communicator::LoadPluginLibrary (thePluginName);
+
+ if (aCommunicator)
+ {
+ aCommunicator->SetParameters (myParameters);
+ QWidget* aParentWidget = new QWidget (myMainWindow);
+ QVBoxLayout* aLayout = new QVBoxLayout (aParentWidget);
+ aLayout->setContentsMargins (0, 0, 0, 0);
+ aLayout->setSpacing (0);
+ aParentWidget->setLayout (aLayout);
+ aCommunicator->SetParent (aParentWidget);
+ theInfo.myWidget = aParentWidget;
+ theInfo.myCommunicator = aCommunicator;
+#if QT_VERSION >= 0x050000
+ connect (aParentWidget, SIGNAL (objectNameChanged (const QString&)), this, SLOT (onCommuncatorNameChanged()));
+#endif
+ aLoaded = true;
+ }
+ QApplication::restoreOverrideCursor();
+ return aLoaded;
+}
+
+// =======================================================================
+// function : onLastApplicationWindowClosed
+// purpose :
+// =======================================================================
+void TInspector_Window::OnLastApplicationWindowClosed()
+{
+ for (int aToolId = 0, aSize = myToolNames.size(); aToolId < aSize; aToolId++)
+ delete myToolNames[aToolId].myCommunicator;
+}
+
+// =======================================================================
+// function : onButtonClicked
+// purpose :
+// =======================================================================
+void TInspector_Window::onButtonClicked()
+{
+ QPushButton* aButton = (QPushButton*)sender();
+ ActivateTool (TCollection_AsciiString (aButton->text().toStdString().c_str()));
+}
+
+// =======================================================================
+// function : onCommuncatorNameChanged
+// purpose :
+// =======================================================================
+void TInspector_Window::onCommuncatorNameChanged()
+{
+#if QT_VERSION >= 0x050000
+ TInspector_ToolInfo anInfo;
+ if (!ActiveToolInfo (anInfo))
+ return;
+ myMainWindow->setWindowTitle (anInfo.myWidget->objectName());
+#endif
+}
+
+// =======================================================================
+// function : ActiveToolInfo
+// purpose :
+// =======================================================================
+bool TInspector_Window::ActiveToolInfo (TInspector_Window::TInspector_ToolInfo& theToolInfo) const
+{
+ QWidget* anActiveWidget = myToolsStack->currentWidget();
+ if (anActiveWidget == myEmptyWidget)
+ return false;
+
+ for (int aToolId = 0, aSize = myToolNames.size(); aToolId < aSize; aToolId++)
+ {
+ if (myToolNames[aToolId].myWidget && myToolNames[aToolId].myWidget == anActiveWidget)
+ {
+ theToolInfo = myToolNames[aToolId];
+ return true;
+ }
+ }
+ return false;
+}
--- /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 TInspector_Window_H
+#define TInspector_Window_H
+
+#include <NCollection_List.hxx>
+#include <Standard.hxx>
+#include <Standard_Transient.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TInspectorAPI_PluginParameters.hxx>
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4127) // conditional expression is constant
+#endif
+#include <QMap>
+#include <QObject>
+#include <QString>
+
+class TInspectorAPI_Communicator;
+
+class QMainWindow;
+class QHBoxLayout;
+class QPushButton;
+class QStackedWidget;
+
+//! \class Inspector_Window
+//! Control that contains:
+//! - stacked widget of loaded plugins
+//! - Open button to open file in an active plugin
+//! - plugin parameters container
+class TInspector_Window : public QObject
+{
+ Q_OBJECT
+private:
+
+ //! Container of plugin information
+ struct TInspector_ToolInfo
+ {
+
+ //! Constructor
+ TInspector_ToolInfo (const TCollection_AsciiString& theName = TCollection_AsciiString())
+ : myName(theName), myCommunicator (0), myButton (0), myWidget (0) {}
+
+ TCollection_AsciiString myName; //!< plugin name
+ TInspectorAPI_Communicator* myCommunicator; //!< plugin communicator
+ QPushButton* myButton; //!< button with plugin name, that will be added into TInspector window layout
+ QWidget* myWidget; //!< parent widget of the plugin
+ };
+
+public:
+
+ //! Constructor
+ Standard_EXPORT TInspector_Window();
+
+ //! Destructor
+ virtual ~TInspector_Window() Standard_OVERRIDE {}
+
+ //! Appends the plugin names into internal conainer
+ //! \param thePluginName a name of the plugin
+ void RegisterPlugin (const TCollection_AsciiString& thePluginName)
+ { myToolNames.append (TInspector_ToolInfo(thePluginName)); }
+
+ //! Stores parameters for the plugin. If the plugin name is empty, it inits all plugins with the parameters
+ //! \param thePluginName a name of the plugin
+ //! \param theParameters container of parameters(e.g. AIS_InteractiveContext, TDocStd_Application)
+ Standard_EXPORT void Init (const TCollection_AsciiString& thePluginName,
+ const NCollection_List<Handle(Standard_Transient)>& theParameters);
+
+ //! Appends to container of parameters the given name, if the given parameter is active, cal UpdateContent
+ //! \param thePluginName a name of the plugin
+ //! \param theParameters container of parameters(e.g. AIS_InteractiveContext, TDocStd_Application)
+ Standard_EXPORT void OpenFile (const TCollection_AsciiString& thePluginName,
+ const TCollection_AsciiString& theFileName);
+
+ //! Calls UpdateContent for the active plugin
+ Standard_EXPORT void UpdateContent();
+
+ //! Returns the main TInspector window
+ QMainWindow* GetMainWindow() const { return myMainWindow; }
+
+ //! Activates the plugin. Loads the plugin if it has not been loaded yet
+ //! \param thePluginName a name of the plugin
+ Standard_EXPORT void ActivateTool (const TCollection_AsciiString& thePluginName);
+
+ //! Sets open button. Stores into objectName for the button the name of the current plugin to know where
+ //! the file should be applied
+ //! \param theButton a button
+ Standard_EXPORT void SetOpenButton (QPushButton* theButton);
+
+ //! Loads plugin, appends the plugin widget into layout, stores the plugin information
+ //! \param thePluginName a name of the plugin
+ //! \param theInfo an output parameter for plugin info
+ Standard_EXPORT bool LoadPlugin (const TCollection_AsciiString& thePluginName, TInspector_ToolInfo& theInfo);
+
+public slots:
+
+ //! Destroys loaded communicators
+ Standard_EXPORT void OnLastApplicationWindowClosed();
+
+protected slots:
+
+ //! Activates plugin correspnded to the clicked button
+ void onButtonClicked();
+
+ //! Updates the TInspector window title giving object name of plugin widget (available only in Qt5)
+ void onCommuncatorNameChanged();
+
+protected:
+
+ //! Activates plugin by the plugin info
+ //! \param theToolInfo an information about plugin
+ bool ActiveToolInfo (TInspector_ToolInfo& theToolInfo) const;
+
+private:
+
+ QWidget* myEmptyWidget; //!< widget that is active in tools stack while no one plugin is loaded
+ QMainWindow* myMainWindow; //!< main control of the window
+ QStackedWidget* myToolsStack; //!< stack widget of plugin windows
+ QWidget* myButtonWidget; //!< container of plugin buttons
+ QPushButton* myOpenButton; //!< button to open file for the active plugin
+ QHBoxLayout* myButtonLay; //!< layout of plugin buttons
+ QList<TInspector_ToolInfo> myToolNames; //!< container of plugin names
+ Handle(TInspectorAPI_PluginParameters) myParameters; //!< plugins parameters container
+};
+
+#endif
--- /dev/null
+TInspectorAPI_Communicator.cxx
+TInspectorAPI_Communicator.hxx
+TInspectorAPI_PluginParameters.cxx
+TInspectorAPI_PluginParameters.hxx
--- /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 <TInspectorAPI_Communicator.hxx>
+
+#include <cstdio>
+#include <map>
+#include <iostream>
+
+#ifdef _WIN32
+#include <windows.h>
+#else
+#include <dlfcn.h>
+#endif
+
+#define LIB_HANDLE HINSTANCE
+
+// =======================================================================
+// function : LoadPluginLibrary
+// purpose :
+// =======================================================================
+TInspectorAPI_Communicator* TInspectorAPI_Communicator::LoadPluginLibrary
+ (const TCollection_AsciiString& thePluginName)
+{
+ if (thePluginName.IsEmpty())
+ std::cout << thePluginName.ToCString() << "%s plugin could not be loaded." << std::endl;
+ TCollection_AsciiString aPluginLibraryName = thePluginName;
+#ifdef _WIN32
+ aPluginLibraryName += ".dll";
+#else
+ aPluginLibraryName.Prepend ("lib");
+ aPluginLibraryName += ".so";
+#endif
+
+ COMMUNICATOR_INSTANCE crtInst = 0;
+#ifdef _WIN32
+ HINSTANCE modLib = ::LoadLibraryA((LPCSTR)aPluginLibraryName.ToCString());
+#else
+ void* modLib = dlopen(aPluginLibraryName.ToCString(), RTLD_LAZY | RTLD_GLOBAL);
+#endif
+
+ if (!modLib)
+ std::cout << "Failed to load plugin." << aPluginLibraryName.ToCString() << std::endl;
+ else
+ {
+#ifdef _WIN32
+ crtInst = (COMMUNICATOR_INSTANCE)::GetProcAddress(modLib, CREATE_COMMUNICATOR_FUNCTION_NAME);
+#else
+ crtInst = (COMMUNICATOR_INSTANCE)dlsym(modLib, CREATE_COMMUNICATOR_FUNCTION_NAME);
+#endif
+ if (!crtInst)
+ std::cout << "Failed to find " << CREATE_COMMUNICATOR_FUNCTION_NAME << " function." << std::endl;
+ }
+ TInspectorAPI_Communicator* aModule = crtInst ? crtInst() : 0;
+ return aModule;
+}
--- /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 TInspectorAPI_Communicator_H
+#define TInspectorAPI_Communicator_H
+
+#include <NCollection_List.hxx>
+#include <Standard_Transient.hxx>
+#include <Standard_Version.hxx>
+#if OCC_VERSION_HEX > 0x060901
+ #include <Standard_Handle.hxx>
+#endif
+#include <TInspectorAPI_PluginParameters.hxx>
+
+//! The Communicator is an interface that should be implemented for a separate plugin
+//! It will be placed in layout of the given parent. After the plugin is created, it is possible to
+//! set container of parameters into plugin to provide the plugin's initialization by some external
+//! objects(e.g. Interactive Context or OCAF Application). If the parameters are changed, it may be
+//! applyed in UpdateContent function. The communicator can change parameters in the following cases:
+//! - the plugin removes own processed parameters (e.g. file names, that was opened by the plugin)
+//! - the plugin sends some parameters to another plugin(by name) (e.g. shape to be analized)
+//! (at the same time we should be careful here to do not change essential parameters of other plugins)
+class TInspectorAPI_Communicator
+{
+public:
+
+ //! Loads the plugin library
+ //! \param thePluginName the name of the library
+ //! \return an instance of the communicator or NULL
+ static Standard_EXPORT TInspectorAPI_Communicator* LoadPluginLibrary (const TCollection_AsciiString& thePluginName);
+
+ //! Sets parameters container, it should be used when the plugin is initialized or in update content
+ //! \param theParameters a parameters container
+ Standard_EXPORT virtual void SetParameters (const Handle(TInspectorAPI_PluginParameters)& theParameters) = 0;
+
+ //! Provides the container with a parent where this container should be inserted.
+ //! If Qt implementation, it should be QWidget with QLayout set inside
+ //! \param theParent a parent class
+ Standard_EXPORT virtual void SetParent (void* theParent) = 0;
+
+ //! Calls update of the plugin's content
+ Standard_EXPORT virtual void UpdateContent() = 0;
+
+ //! Constructs the communicator.
+ TInspectorAPI_Communicator() {}
+
+ //! Destructor
+ virtual ~TInspectorAPI_Communicator() {}
+};
+
+//! Declare plugin method
+extern "C"
+{
+ //! Declares function to create an instance of communicator
+ //! It should be implemented in a child plugin
+ typedef TInspectorAPI_Communicator* (*COMMUNICATOR_INSTANCE)();
+}
+//! Defines name of the function that should be implemented in a child plugin
+#define CREATE_COMMUNICATOR_FUNCTION_NAME "CreateCommunicator"
+
+#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 <TInspectorAPI_PluginParameters.hxx>
+
+#if OCC_VERSION_HEX <= 0x060901
+IMPLEMENT_STANDARD_HANDLE (TInspectorAPI_PluginParameters, Standard_Transient)
+IMPLEMENT_STANDARD_RTTIEXT (TInspectorAPI_PluginParameters, Standard_Transient)
+#else
+IMPLEMENT_STANDARD_RTTIEXT (TInspectorAPI_PluginParameters, Standard_Transient)
+#endif
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+TInspectorAPI_PluginParameters::TInspectorAPI_PluginParameters()
+{
+}
+
+// =======================================================================
+// function : SetParameters
+// purpose :
+// =======================================================================
+void TInspectorAPI_PluginParameters::SetParameters (const TCollection_AsciiString& thePluginName,
+ const NCollection_List<Handle(Standard_Transient)>& theParameters)
+{
+ if (theParameters.Size() > 0)
+ myParameters.Bind (thePluginName, theParameters);
+ else
+ myParameters.UnBind (thePluginName);
+}
+
+// =======================================================================
+// function : AddFileName
+// purpose :
+// =======================================================================
+void TInspectorAPI_PluginParameters::AddFileName (const TCollection_AsciiString& thePluginName,
+ const TCollection_AsciiString& theFileName)
+{
+ if (myFileNames.IsBound(thePluginName))
+ myFileNames.ChangeFind(thePluginName).Append (theFileName);
+ else
+ {
+ NCollection_List<TCollection_AsciiString> aNames;
+ aNames.Append (theFileName);
+ myFileNames.Bind (thePluginName, aNames);
+ }
+}
+
+// =======================================================================
+// function : SetFileNames
+// purpose :
+// =======================================================================
+void TInspectorAPI_PluginParameters::SetFileNames (const TCollection_AsciiString& thePluginName,
+ const NCollection_List<TCollection_AsciiString>& theFileNames)
+{
+ if (theFileNames.Size() > 0)
+ myFileNames.Bind (thePluginName, theFileNames);
+ else
+ myFileNames.UnBind(thePluginName);
+
+}
+
+// =======================================================================
+// function : FindParameters
+// purpose :
+// =======================================================================
+bool TInspectorAPI_PluginParameters::FindParameters (const TCollection_AsciiString& thePluginName)
+{
+ return myParameters.IsBound(thePluginName);
+}
+
+// =======================================================================
+// function : Parameters
+// purpose :
+// =======================================================================
+const NCollection_List<Handle(Standard_Transient)>& TInspectorAPI_PluginParameters::Parameters
+ (const TCollection_AsciiString& thePluginName)
+{
+ return myParameters.Find (thePluginName);
+}
+
+// =======================================================================
+// function : FindFileNames
+// purpose :
+// =======================================================================
+bool TInspectorAPI_PluginParameters::FindFileNames (const TCollection_AsciiString& thePluginName)
+{
+ return myFileNames.IsBound(thePluginName);
+}
+
+// =======================================================================
+// function : FileNames
+// purpose :
+// =======================================================================
+const NCollection_List<TCollection_AsciiString>& TInspectorAPI_PluginParameters::FileNames
+ (const TCollection_AsciiString& thePluginName)
+{
+ return myFileNames.Find (thePluginName);
+}
--- /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 TInspectorAPI_PluginParameters_H
+#define TInspectorAPI_PluginParameters_H
+
+#include <NCollection_DataMap.hxx>
+#include <NCollection_List.hxx>
+#include <Standard_Version.hxx>
+#include <Standard_Transient.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_AsciiString.hxx>
+
+class TInspectorAPI_PluginParameters;
+DEFINE_STANDARD_HANDLE (TInspectorAPI_PluginParameters, Standard_Transient)
+
+//! The container of parameters for all possible plugins. It stores list of parameters for each plugin, even
+//! it was not be loaded yet. There is a map of plugin name into plugin parameters.
+//! The parameters may be:
+//! - child of Standard_Transient
+//! - file name to be opened by the plugin
+class TInspectorAPI_PluginParameters : public Standard_Transient
+{
+public:
+
+ //! Constructs the container.
+ Standard_EXPORT TInspectorAPI_PluginParameters();
+
+ //! Destructor
+ Standard_EXPORT virtual ~TInspectorAPI_PluginParameters() Standard_OVERRIDE {}
+
+ //! Stores the parameters for plugin
+ //! \param thePluginName a plugin name
+ //! \param theParameters a list of parameters
+ Standard_EXPORT void SetParameters (const TCollection_AsciiString& thePluginName,
+ const NCollection_List<Handle(Standard_Transient)>& theParameters);
+
+ //! Add a file name for the plugin
+ //! \param thePluginName a plugin name
+ //! \param theFileName a name
+ Standard_EXPORT void AddFileName (const TCollection_AsciiString& thePluginName,
+ const TCollection_AsciiString& theFileName);
+
+ //! Set file names for the plugin
+ //! \param thePluginName a plugin name
+ //! \param theFileNames container of names
+ Standard_EXPORT void SetFileNames (const TCollection_AsciiString& thePluginName,
+ const NCollection_List<TCollection_AsciiString>& theFileNames);
+
+ //! Returns true if there are parameters set for the given plugin
+ //! \param thePluginName a plugin name
+ //! \return boolean result
+ Standard_EXPORT bool FindParameters (const TCollection_AsciiString& thePluginName);
+
+ //! Returns parameters set for the given plugin
+ //! \param thePluginName a plugin name
+ //! \return container of objects
+ Standard_EXPORT const NCollection_List<Handle(Standard_Transient)>& Parameters (
+ const TCollection_AsciiString& thePluginName);
+
+ //! Returns true if there are file names set for the given plugin
+ //! \param thePluginName a plugin name
+ //! \return boolean result
+ Standard_EXPORT bool FindFileNames (const TCollection_AsciiString& thePluginName);
+
+ //! Returns file names set for the given plugin
+ //! \param thePluginName a plugin name
+ //! \return container of names
+ Standard_EXPORT const NCollection_List<TCollection_AsciiString>& FileNames(
+ const TCollection_AsciiString& thePluginName);
+
+#if OCC_VERSION_HEX <= 0x060901
+ DEFINE_STANDARD_RTTI (TInspectorAPI_PluginParameters)
+#else
+ DEFINE_STANDARD_RTTIEXT (TInspectorAPI_PluginParameters, Standard_Transient)
+#endif
+private:
+ //! container of parameters
+ NCollection_DataMap<TCollection_AsciiString, NCollection_List<Handle(Standard_Transient)> > myParameters;
+ //! container of names
+ NCollection_DataMap<TCollection_AsciiString, NCollection_List<TCollection_AsciiString> > myFileNames;
+};
+
+#endif
--- /dev/null
+project(TKDFBrowser)
+
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_tool)
--- /dev/null
+TKBin
+TKBinL
+TKBinXCAF
+TKCAF
+TKCDF
+TKG3d
+TKernel
+TKLCAF
+TKService
+TKStd
+TKStdL
+TKVCAF
+TKView
+TKXSBase
+TKXCAF
+TKXDESTEP
+TKXmlXCAF
+TKXml
+TKXmlL
+TKMath
+TKBRep
+TKOpenGl
+TKV3d
+TKTInspectorAPI
+TKTreeModel
+TKShapeView
+CSF_QT
\ No newline at end of file
--- /dev/null
+EXTERNLIB
+PACKAGES
--- /dev/null
+DFBrowserPane
+DFBrowserPaneXDE
+DFBrowser
--- /dev/null
+project(TKShapeView)
+
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_tool)
\ No newline at end of file
--- /dev/null
+TKTInspectorAPI
+TKMath
+TKBRep
+TKGeomBase
+TKG3d
+TKService
+TKTreeModel
+TKView
+CSF_QT
--- /dev/null
+EXTERNLIB
+PACKAGES
--- /dev/null
+project(TKTInspector)
+
+set (INSTALL_API ON)
+
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_tool)
+
+unset (INSTALL_API)
--- /dev/null
+TKTInspectorAPI
+TKernel
+CSF_QT
\ No newline at end of file
--- /dev/null
+EXTERNLIB
+PACKAGES
--- /dev/null
+TInspector
--- /dev/null
+project(TKTInspectorAPI)
+
+SET (TOOL_API_LIBRARY ON)
+
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_tool)
+
+UNSET (TOOL_API_LIBRARY)
+
--- /dev/null
+TKernel
+TKLCAF
\ No newline at end of file
--- /dev/null
+EXTERNLIB
+PACKAGES
--- /dev/null
+TInspectorAPI
--- /dev/null
+project(TKToolsDraw)
+
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_tool)
--- /dev/null
+TKDCAF
+TKTInspector
+TKTInspectorAPI
+TKService
+TKV3d
+TKViewerTest
+CSF_QT
\ No newline at end of file
--- /dev/null
+EXTERNLIB
+PACKAGES
--- /dev/null
+ToolsDraw
\ No newline at end of file
--- /dev/null
+project(TKTreeModel)
+
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_tool)
--- /dev/null
+CSF_QT
\ No newline at end of file
--- /dev/null
+EXTERNLIB
+PACKAGES
--- /dev/null
+project(TKVInspector)
+
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_tool)
\ No newline at end of file
--- /dev/null
+TKTInspectorAPI
+TKBRep
+TKG3d
+TKernel
+TKMath
+TKV3d
+TKView
+TKService
+TKTreeModel
+TKBO
+CSF_QT
\ No newline at end of file
--- /dev/null
+EXTERNLIB
+PACKAGES
--- /dev/null
+VInspector
\ No newline at end of file
--- /dev/null
+project(TKView)
+
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_tool)
--- /dev/null
+TKernel
+TKMath
+TKService
+TKOpenGl
+TKV3d
+CSF_QT
\ No newline at end of file
--- /dev/null
+EXTERNLIB
+PACKAGES
--- /dev/null
+View
\ No newline at end of file
--- /dev/null
+ToolsDraw.cxx
+ToolsDraw.hxx
--- /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 <ToolsDraw.hxx>
+
+#include <AIS_InteractiveContext.hxx>
+#include <DDocStd.hxx>
+#include <Draw_PluginMacro.hxx>
+#include <Standard_Stream.hxx>
+#include <TDocStd_Application.hxx>
+#include <TInspector_Communicator.hxx>
+#include <ViewerTest.hxx>
+#include <DDocStd.hxx>
+
+static TInspector_Communicator* MyCommunicator;
+
+// =======================================================================
+// function : tinspector
+// purpose :
+// =======================================================================
+static int tinspector (Draw_Interpretor&/* di*/, Standard_Integer theArgsNb, const char** theArgs)
+{
+ if (theArgsNb < 1)
+ {
+ std::cerr << "Error: wrong number of arguments.\n";
+ return 1;
+ }
+
+ if (!MyCommunicator)
+ MyCommunicator = new TInspector_Communicator();
+ NCollection_List<Handle(Standard_Transient)> aParameters;
+
+ NCollection_List<TCollection_AsciiString> aPlugins;
+ bool aNeedToUpdateContent = false, aNeedToActivateAllPlugins = false;
+ for (Standard_Integer anIt = 1; anIt < theArgsNb; ++anIt)
+ {
+ TCollection_AsciiString aParam (theArgs[anIt]);
+ aParam.LowerCase();
+
+ TCollection_AsciiString aPluginName;
+ if (aParam == "-dfbrowser")
+ aPluginName = "TKDFBrowser";
+ else if (aParam == "-shapeview")
+ aPluginName = "TKShapeView";
+ else if (aParam == "-vinspector")
+ aPluginName = "TKVInspector";
+ else if (aParam == "-all")
+ aNeedToActivateAllPlugins = true;
+ else if (aParam == "-update")
+ aNeedToUpdateContent = true;
+
+ if (!aPluginName.IsEmpty() && !aPlugins.Contains (aPluginName))
+ aPlugins.Append (aPluginName);
+ }
+
+ // DFBrowser only parameter
+ const Handle(TDocStd_Application)& anApplication = DDocStd::GetApplication();
+ // Initialize standard document formats at creation - they should
+ // be available even if this DRAW plugin is not loaded by pload command
+ if (!anApplication.IsNull())
+ aParameters.Append (anApplication);
+
+ const Handle(AIS_InteractiveContext)& aContext = ViewerTest::GetAISContext();
+ if (!aContext.IsNull())
+ aParameters.Append (aContext);
+
+ if (aNeedToActivateAllPlugins)
+ {
+ MyCommunicator->RegisterPlugin ("TKDFBrowser");
+ MyCommunicator->RegisterPlugin ("TKShapeView");
+ MyCommunicator->RegisterPlugin ("TKVInspector");
+
+ TCollection_AsciiString aLastPluginName = "TKDFBrowser";
+ MyCommunicator->Init (aParameters);
+ MyCommunicator->Activate (aLastPluginName);
+ }
+
+ if (!aNeedToActivateAllPlugins)
+ {
+ TCollection_AsciiString aLastPluginName;
+ for (NCollection_List<TCollection_AsciiString>::Iterator aPluginNameIt (aPlugins);
+ aPluginNameIt.More(); aPluginNameIt.Next())
+ {
+ aLastPluginName = aPluginNameIt.Value();
+ MyCommunicator->RegisterPlugin (aLastPluginName);
+ MyCommunicator->Init (aLastPluginName, aParameters);
+ }
+ MyCommunicator->Activate (aLastPluginName);
+ }
+
+ if (aNeedToUpdateContent)
+ MyCommunicator->UpdateContent();
+
+ MyCommunicator->SetVisible (true);
+ return 0;
+}
+
+// =======================================================================
+// function : Commands
+// purpose :
+// =======================================================================
+void ToolsDraw::Commands(Draw_Interpretor& theCommands)
+{
+ const char *group = "Tools";
+
+ // display
+ theCommands.Add ("tinspector",
+ "tinspector\n"
+ "[-all]\n"
+ "[-tinspector]\n"
+ "[-dfbrowser]\n"
+ "[-shaperview]\n"
+ "[-vinspector]\n"
+ "[-update]\n"
+ "\tStarts tool of inspection.\n",
+ __FILE__, tinspector, group);
+}
+
+// =======================================================================
+// function : Factory
+// purpose :
+// =======================================================================
+void ToolsDraw::Factory (Draw_Interpretor& theDI)
+{
+ // definition of Tools Command
+ ToolsDraw::Commands (theDI);
+
+#ifdef OCCT_DEBUG
+ theDI << "Draw Plugin : OCC Tools commands are loaded\n";
+#endif
+}
+
+// Declare entry point PLUGINFACTORY
+DPLUGIN (ToolsDraw)
--- /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 ToolsDraw_H
+#define ToolsDraw_H
+
+#include <Draw_Interpretor.hxx>
+#include <Standard.hxx>
+
+//! \class ToolsDraw
+//! \brief Registers DRAW commands to connect to TInspector tools
+class ToolsDraw
+{
+public:
+
+ DEFINE_STANDARD_ALLOC
+
+ //! Loads all Draw commands of tools. Used for plugin.
+ //! \param theDI Draw interpretor
+ Standard_EXPORT static void Factory (Draw_Interpretor& theDI);
+
+ //! Add all tools command in the Draw_Interpretor
+ //! \param theCommands
+ Standard_EXPORT static void Commands (Draw_Interpretor& theCommands);
+
+private:
+};
+
+#endif //ToolsDraw_H
--- /dev/null
+TreeModel_ItemBase.cxx
+TreeModel_ItemBase.hxx
+TreeModel_ItemRole.hxx
+TreeModel_ModelBase.cxx
+TreeModel_ModelBase.hxx
--- /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 <TreeModel_ItemBase.hxx>
+
+#include <TreeModel_ItemRole.hxx>
+
+#include <QStringList>
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+TreeModel_ItemBase::TreeModel_ItemBase (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ : m_bInitialized (false)
+{
+ m_pParent = theParent;
+ m_iRow = theRow;
+ m_iColumn = theColumn;
+}
+
+// =======================================================================
+// function : reset
+// purpose :
+// =======================================================================
+void TreeModel_ItemBase::Reset()
+{
+ for (PositionToItemHash::const_iterator aChildrenIt = m_ChildItems.begin(); aChildrenIt != m_ChildItems.end(); aChildrenIt++)
+ {
+ TreeModel_ItemBasePtr anItem = aChildrenIt.value();
+ if (anItem)
+ anItem->Reset();
+ }
+ m_bInitialized = false;
+ mycachedValues.clear();
+
+}
+
+// =======================================================================
+// function : child
+// purpose :
+// =======================================================================
+TreeModel_ItemBasePtr TreeModel_ItemBase::Child (int theRow, int theColumn, const bool isToCreate)
+{
+ QPair<int, int> aPos = qMakePair (theRow, theColumn);
+
+ if (m_ChildItems.contains (aPos))
+ return m_ChildItems[aPos];
+
+ TreeModel_ItemBasePtr anItem;
+ if (isToCreate) {
+ anItem = createChild (theRow, theColumn);
+ if (anItem)
+ m_ChildItems[aPos] = anItem;
+ }
+ return anItem;
+}
+
+// =======================================================================
+// function : currentItem
+// purpose :
+// =======================================================================
+const TreeModel_ItemBasePtr TreeModel_ItemBase::currentItem()
+{
+ return TreeModel_ItemBasePtr (this);
+}
+
+// =======================================================================
+// function : cachedValue
+// purpose :
+// =======================================================================
+QVariant TreeModel_ItemBase::cachedValue (const int theItemRole) const
+{
+ if (mycachedValues.contains (theItemRole))
+ return mycachedValues[theItemRole];
+
+ const_cast<TreeModel_ItemBase*>(this)->mycachedValues.insert (theItemRole,
+ theItemRole == TreeModel_ItemRole_RowCountRole ? QVariant (initRowCount()) : initValue (theItemRole));
+
+ return mycachedValues.contains (theItemRole) ? mycachedValues[theItemRole] : 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 TreeModel_ItemBase_H
+#define TreeModel_ItemBase_H
+
+#include <Standard.hxx>
+#include <Standard_Macro.hxx>
+#include <TreeModel_ItemRole.hxx>
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4127) // conditional expression is constant
+#endif
+#include <QExplicitlySharedDataPointer>
+#include <QHash>
+#include <QMap>
+#include <QModelIndex>
+#include <QObject>
+#include <QPair>
+#include <QSharedData>
+#include <QVariant>
+
+class TreeModel_ItemBase;
+
+typedef QExplicitlySharedDataPointer<TreeModel_ItemBase> TreeModel_ItemBasePtr;
+
+//! \class TreeModel_ItemBase
+//! \brief Declaration of an abstract interface of model item.
+//!
+//! The TreeModel_ItemBase class defines the standard interface that model items must use
+//! to be able to provide the model information in the tree view architecture.
+//! It is not supposed to be instantiated directly. Instead, you should subclass it to
+//! create new items.
+//!
+//! The goal of the item is to be an data container of a custom model, based on the
+//! QAbstractItemModel. It provides the items architecture in order to realize the model
+//! functionality to find a parent model index by a child index and vise versa.
+//!
+//! The item should be created by the model and is saved in the internal pointer of the
+//! QModelIndex. Only model knows when the index is removed/created. By this cause,
+//! the item is wrapped in the QExplicitlySharedDataPointer. It is a counter on the pointer
+//! and if there is no index that refers to the item, it is removed automatically. So,
+//! there is no necessity to remove the item manually.
+//!
+//! The item knows a pointer to the parent item and its position into.
+//! Some methods of the item should be realized to fill the item content.
+//! These are: the children count, a child creation and a child data.
+//!
+//! The best way of the item using is to request the content of the item from some
+//! information object without the caching it. But it can be very expensive realisation,
+//! because method data, for example, is called by the viewer repaint, in other words,
+//! constantly.
+//!
+//! It is possible to cache some information in the item. Do not give it throught the item
+//! constructor. Realize method Init() to save the values in the item internal fields.
+//! If the information model is changed, call Reset() for this item, or the item's parent.
+//! It leads the item to non initialized state and by the next get of the item content,
+//! call Init() method to fulfill the item content again.
+class TreeModel_ItemBase : public QSharedData
+{
+public:
+
+ //! Destructor
+ virtual ~TreeModel_ItemBase() {}
+
+ //! Gets whether the item is already initialized.The initialized state is thrown down
+ //! by the reset method and get back after the method Init().
+ //! \return if the item is initialized
+ bool IsInitialized() const { return m_bInitialized; }
+
+ //! Sets the item internal initialized state to the true. If the item has internal values,
+ //! there should be initialized here.
+ virtual void Init() { m_bInitialized = true; }
+
+ //! Resets the item and the child items content. Sets the initialized state to false.
+ //! If the item has internal values, there should be reseted here.
+ Standard_EXPORT virtual void Reset();
+
+ //! Gets the parent of the item, or TreeModel_ItemBasePtr() if it has no parent.
+ //! \return pointer to the item
+ TreeModel_ItemBasePtr Parent() const { return m_pParent; };
+
+ //! Gets the row of the item in the parent
+ //! \return the row position
+ int Row() const { return m_iRow; }
+
+ //! Gets the column of the item in the parent
+ //! \return the column position
+ int Column() const { return m_iColumn; }
+
+ //! Gets a child tree item in the given position. Find an item in the children hash.
+ //! Creates a new child item, if there is no a cached item in the given position and
+ //! if the flag about the creation is true.
+ //! \param theRow the row of the child item
+ //! \param theColumn the column of the child item
+ //! \param isToCreate the flag whether the item should be created if it is not created yet
+ //! \return the child item or TreeModel_ItemBasePtr() if it does not exist
+ Standard_EXPORT TreeModel_ItemBasePtr Child (int theRow, int theColumn, const bool isToCreate = true);
+
+ //! Returns the data stored under the given role for the current item
+ //! \param theIndex the item model index
+ //! \param theRole the item model role
+ virtual QVariant data (const QModelIndex& theIndex, int theRole = Qt::DisplayRole) const
+ { (void)theIndex; return cachedValue(theRole); }
+
+ //! Returns number of rows where the children are
+ //! \return the row count
+ int rowCount() const { return cachedValue(TreeModel_ItemRole_RowCountRole).toInt(); }
+
+protected:
+
+ //! \param theParent the parent item
+ //! \param theRow the item row positition in the parent item
+ //! \param theColumn the item column positition in the parent item
+ Standard_EXPORT TreeModel_ItemBase (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn);
+
+ //! Creates a child item in the given position.
+ //! \param theRow the child row position
+ //! \param theColumn the child column position
+ //! \return the created item
+ virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) = 0;
+
+ //! Wraps the currrent item by shared pointer
+ //! \return the shared pointer to the current item
+ Standard_EXPORT const TreeModel_ItemBasePtr currentItem();
+
+ //! Returns the cached value for the role. Init the value if it is requested the first time
+ //! By default, it calls initRowCount(TreeModel_ItemRole_RowCountRole) or initValue for the item role
+ //! \param theItemRole a value role
+ //! \return the value
+ Standard_EXPORT QVariant cachedValue (const int theItemRole) const;
+
+ //! \return number of children. It should be reimplemented in child
+ virtual int initRowCount() const = 0;
+
+ //! Return data value for the role. It should be reimplemented in child
+ //! \param theItemRole a value role
+ //! \return the value
+ virtual QVariant initValue (const int theItemRole) const = 0;
+
+private:
+
+ typedef QHash< QPair<int, int>, TreeModel_ItemBasePtr > PositionToItemHash;
+ PositionToItemHash m_ChildItems; //!< the hash of item children
+
+ QMap<int, QVariant> mycachedValues; //!< cached values, should be cleared by reset
+ TreeModel_ItemBasePtr m_pParent; //!< the parent item
+ int m_iRow; //!< the item row position in the parent item
+ int m_iColumn; //!< the item column position in the parent item
+ bool m_bInitialized; //!< the state whether the item content is already initialized
+};
+
+//! Returns an explicitly shared pointer to the pointer held by other, using a
+//! dynamic cast to type X to obtain an internal pointer of the appropriate type.
+//! If the dynamic_cast fails, the object returned will be null.
+//! Example of using:
+//! TreeModel_ItemBase* aParent;
+//! TreeModel_CustomItemPtr aParentItem = itemDynamicCast<TreeModel_CustomItem>(aParent);
+//! \param theItem a source item
+//! \return a converted item
+template <class X, class T> QExplicitlySharedDataPointer<X> itemDynamicCast (const QExplicitlySharedDataPointer<T>& theItem)
+{
+ X* ptr = dynamic_cast<X*> (theItem.data());
+
+ QExplicitlySharedDataPointer<X> result;
+ result = ptr;
+
+ return result;
+}
+
+#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.
+
+#ifndef TreeModel_ItemRole_H
+#define TreeModel_ItemRole_H
+
+#include <Qt>
+
+//! Sets custom item role of Tree view wmodel
+enum TreeModel_ItemRole
+{
+ TreeModel_ItemRole_RowCountRole = Qt::UserRole + 1 //! additional column with row count for item (cached value)
+};
+
+#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 <TreeModel_ModelBase.hxx>
+
+#include <TreeModel_ItemBase.hxx>
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+TreeModel_ModelBase::TreeModel_ModelBase (QObject* theParent)
+: QAbstractItemModel (theParent), m_pRootItem (0)
+{
+}
+
+// =======================================================================
+// function : GetItemByIndex
+// purpose :
+// =======================================================================
+TreeModel_ItemBasePtr TreeModel_ModelBase::GetItemByIndex (const QModelIndex& theIndex)
+{
+ TreeModel_ItemBase* anItem = (TreeModel_ItemBase*)theIndex.internalPointer();
+ return TreeModel_ItemBasePtr (anItem);
+}
+
+// =======================================================================
+// function : reset
+// purpose :
+// =======================================================================
+void TreeModel_ModelBase::Reset()
+{
+ for (int aColId = 0, aNbColumns = columnCount(); aColId < aNbColumns; aColId++)
+ RootItem (aColId)->Reset();
+}
+
+// =======================================================================
+// function : index
+// purpose :
+// =======================================================================
+QModelIndex TreeModel_ModelBase::index (int theRow, int theColumn, const QModelIndex& theParent) const
+{
+ if (!hasIndex (theRow, theColumn, theParent))
+ return QModelIndex();
+
+ // to create index on the root item
+ if (!theParent.isValid())
+ return createIndex (theRow, theColumn, getIndexValue (RootItem (theColumn)));
+
+ TreeModel_ItemBasePtr aParentItem;
+ if (!theParent.isValid())
+ aParentItem = RootItem (theColumn);
+ else
+ aParentItem = GetItemByIndex (theParent);
+
+ TreeModel_ItemBasePtr aChildItem = aParentItem->Child (theRow, theColumn);
+ return aChildItem ? createIndex (theRow, theColumn, getIndexValue (aChildItem)) : QModelIndex();
+}
+
+// =======================================================================
+// function : data
+// purpose :
+// =======================================================================
+QVariant TreeModel_ModelBase::data (const QModelIndex& theIndex, int theRole) const
+{
+ if (!theIndex.isValid())
+ return QVariant ("undefined");
+
+ TreeModel_ItemBasePtr anItem = GetItemByIndex (theIndex);
+ return anItem->data (theIndex, theRole);
+}
+
+// =======================================================================
+// function : parent
+// purpose :
+// =======================================================================
+QModelIndex TreeModel_ModelBase::parent (const QModelIndex& theIndex) const
+{
+ if (!theIndex.isValid())
+ return QModelIndex();
+
+ TreeModel_ItemBasePtr aChildItem = GetItemByIndex (theIndex);
+ TreeModel_ItemBasePtr aParentItem = aChildItem ? aChildItem->Parent() : TreeModel_ItemBasePtr();
+
+ if (!aParentItem)
+ return QModelIndex();
+
+ return createIndex (aParentItem->Row(), aParentItem->Column(), getIndexValue (aParentItem));
+}
+
+// =======================================================================
+// function : flags
+// purpose :
+// =======================================================================
+Qt::ItemFlags TreeModel_ModelBase::flags (const QModelIndex& theIndex) const
+{
+ if (!theIndex.isValid())
+ return 0;
+ return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
+}
+
+// =======================================================================
+// function : rowCount
+// purpose :
+// =======================================================================
+int TreeModel_ModelBase::rowCount (const QModelIndex& theParent) const
+{
+ // to create index on the root item
+ if (!theParent.isValid())
+ return 1;
+
+ TreeModel_ItemBasePtr aParentItem;
+ if (!theParent.isValid())
+ aParentItem = RootItem (0);
+ else
+ aParentItem = GetItemByIndex (theParent);
+
+ return aParentItem ? aParentItem->rowCount() : 0;
+}
+
+// =======================================================================
+// function : emitLayoutChanged
+// purpose :
+// =======================================================================
+void TreeModel_ModelBase::EmitLayoutChanged()
+{
+ emit layoutChanged();
+}
+
+// =======================================================================
+// function : getIndexValue
+// purpose :
+// =======================================================================
+void* TreeModel_ModelBase::getIndexValue (const TreeModel_ItemBasePtr& theItem)
+{
+ return theItem.data();
+}
--- /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 TreeModel_ModelBase_H
+#define TreeModel_ModelBase_H
+
+#include <Standard.hxx>
+#include <TreeModel_ItemBase.hxx>
+
+#include <QAbstractItemModel>
+#include <QExplicitlySharedDataPointer>
+#include <QModelIndex>
+#include <QVariant>
+
+//! \class TreeModel_ModelBase
+//! \brief Implementation of the tree item based model of QAbstractItemModel.
+//! The TreeModel_ModelBase class defines the abstract model realization throught the base item architecture.
+//! By the model index creation, a base item is created and attached to the index.
+//! Each item contains an iformation about the item parent, position in the parent and
+//! the item's children. So, it is possible to get the model index relation from the item.
+class TreeModel_ModelBase : public QAbstractItemModel
+{
+public:
+
+ //! Constructor
+ //! \param theParent the parent object
+ Standard_EXPORT TreeModel_ModelBase (QObject* theParent = 0);
+
+ //! Destructor
+ virtual ~TreeModel_ModelBase() {}
+
+ //! Returns the item shared pointer by the model index
+ //! if it is in the index internal pointer
+ //! @param theIndex a model index
+ Standard_EXPORT static TreeModel_ItemBasePtr GetItemByIndex (const QModelIndex& theIndex);
+
+ //! Resets the model items content. Calls the same method of the root item.
+ //! It leads to reset of all child/sub child items.
+ Standard_EXPORT virtual void Reset();
+
+ //! Returns the model root item.
+ //! It is realized for OCAFBrowser
+ virtual TreeModel_ItemBasePtr RootItem (const int theColumn) const { (void)theColumn; return m_pRootItem; }
+
+ //! Emits the layoutChanged signal from outside of this class
+ Standard_EXPORT void EmitLayoutChanged();
+
+ //! Returns the index of the item in the model specified by the given row, column and parent index.
+ //! Saves an internal pointer at the createIndex. This pointer is a shared pointer to the class,
+ //! that realizes a base item interface. If the parent is invalid, a root item is used, otherwise a new item
+ //! is created by the pointer item saved the parent model index
+ //! \param theRow the index row position
+ //! \param theColummn the index column position
+ //! \param theParent the parent index
+ //! \return the model index
+ Standard_EXPORT virtual QModelIndex index (int theRow, int theColumn,
+ const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE;
+
+ //! Returns the data stored under the given role for the item referred to by the index.
+ //! \param theIndex a model index
+ //! \param theRole an enumeration value of role for data obtaining
+ Standard_EXPORT virtual QVariant data (const QModelIndex& theIndex, int theRole = Qt::DisplayRole) const Standard_OVERRIDE;
+
+ //! Returns the parent index by the child index. Founds the item, saved in the index;
+ //! obtains the parent item by the item. Create a new index by the item and containing it.
+ //! \param theIndex a model index
+ Standard_EXPORT virtual QModelIndex parent (const QModelIndex& theIndex) const Standard_OVERRIDE;
+
+ //! Returns the item flags for the given index. The base class implementation returns a combination of flags that
+ //! enables the item (ItemIsEnabled) and allows it to be selected (ItemIsSelectable)
+ //! \param theIndex the model index
+ //! \return Qt flag combination
+ Standard_EXPORT virtual Qt::ItemFlags flags (const QModelIndex& theIndex) const Standard_OVERRIDE;
+
+ //! Returns the header data for the given role and section in the header with the specified orientation.
+ //! \param theSection the header section. For horizontal headers - column number, for vertical headers - row number.
+ //! \param theOrientation a header orientation
+ //! \param theRole a data role
+ //! \return the header data
+ Standard_EXPORT virtual QVariant headerData (int theSection, Qt::Orientation theOrientation,
+ int theRole = Qt::DisplayRole) const Standard_OVERRIDE
+ { (void)theSection, (void)theOrientation; (void)theRole; return QVariant(); }
+
+ //! Returns the number of rows under the given parent. When the parent is valid it means that rowCount is returning
+ //! the number of children of parent.
+ //! \param theParent a parent model index
+ //! \return the number of rows
+ Standard_EXPORT virtual int rowCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE;
+
+ //! Returns the number of columns for the children of the given parent.
+ //! \param theParent a parent model index
+ //! \return the number of columns
+ virtual int columnCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
+ { (void)theParent; return 1; }
+
+protected:
+
+ //! Converts the item shared pointer to void* type
+ //! \param theItem
+ //! \return an item pointer
+ Standard_EXPORT static void* getIndexValue (const TreeModel_ItemBasePtr& theItem);
+
+protected:
+
+ TreeModel_ItemBasePtr m_pRootItem; //!< the model root item. It should be created in the
+ //!< model subclass. The model is fulfilled by this item content
+};
+
+#endif
--- /dev/null
+VInspector_CallBack.cxx
+VInspector_CallBack.hxx
+VInspector_CallBackMode.hxx
+VInspector_Communicator.cxx
+VInspector_Communicator.hxx
+VInspector_ItemBase.cxx
+VInspector_ItemBase.hxx
+VInspector_ItemContext.cxx
+VInspector_ItemContext.hxx
+VInspector_ItemEntityOwner.cxx
+VInspector_ItemEntityOwner.hxx
+VInspector_ItemHistoryElement.cxx
+VInspector_ItemHistoryElement.hxx
+VInspector_ItemHistoryRoot.cxx
+VInspector_ItemHistoryRoot.hxx
+VInspector_ItemHistoryType.cxx
+VInspector_ItemHistoryType.hxx
+VInspector_ItemHistoryTypeInfo.hxx
+VInspector_ItemPresentableObject.cxx
+VInspector_ItemPresentableObject.hxx
+VInspector_ItemSelection.cxx
+VInspector_ItemSelection.hxx
+VInspector_ItemSensitiveEntity.cxx
+VInspector_ItemSensitiveEntity.hxx
+VInspector_SelectionType.hxx
+VInspector_ToolActionType.hxx
+VInspector_ToolBar.cxx
+VInspector_ToolBar.hxx
+VInspector_Tools.cxx
+VInspector_Tools.hxx
+VInspector_ViewModel.cxx
+VInspector_ViewModel.hxx
+VInspector_ViewModelHistory.cxx
+VInspector_ViewModelHistory.hxx
+VInspector_Window.cxx
+VInspector_Window.hxx
+VInspectorAPI_CallBack.cxx
+VInspectorAPI_CallBack.hxx
--- /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 <VInspectorAPI_CallBack.hxx>
+
+#if OCC_VERSION_HEX <= 0x060901
+IMPLEMENT_STANDARD_HANDLE(VInspectorAPI_CallBack, Standard_Transient)
+IMPLEMENT_STANDARD_RTTIEXT(VInspectorAPI_CallBack, Standard_Transient)
+#else
+IMPLEMENT_STANDARD_RTTIEXT(VInspectorAPI_CallBack, Standard_Transient)
+#endif
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+VInspectorAPI_CallBack::VInspectorAPI_CallBack()
+{
+}
--- /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 VInspectorAPI_CallBack_H
+#define VInspectorAPI_CallBack_H
+
+#include <Standard.hxx>
+#include <Standard_Integer.hxx>
+#include <Standard_Version.hxx>
+#include <Standard_Transient.hxx>
+#include <TColStd_ListOfInteger.hxx>
+#include <TopoDS_Shape.hxx>
+
+#if OCC_VERSION_HEX > 0x060901
+class AIS_InteractiveObject;
+#else
+#include <AIS_InteractiveObject.hxx>
+#endif
+class SelectMgr_EntityOwner;
+
+DEFINE_STANDARD_HANDLE(VInspectorAPI_CallBack, Standard_Transient)
+
+//! \class VInspectorAPI_CallBack
+//! API of AIS_InteractiveContext methods to provide information about the actions
+class VInspectorAPI_CallBack : public Standard_Transient
+{
+
+public:
+
+ //! Constructor
+ Standard_EXPORT VInspectorAPI_CallBack();
+
+ //! Destructor
+ virtual ~VInspectorAPI_CallBack() {}
+
+ //! Processing method of context
+ virtual void Display(Handle(AIS_InteractiveObject) thePrs) = 0;
+
+ //! Processing method of context
+ virtual void Redisplay(Handle(AIS_InteractiveObject) thePrs) = 0;
+
+ //! Processing method of context
+ virtual void Remove(Handle(AIS_InteractiveObject) thePrs) = 0;
+
+ //! Processing method of context
+ virtual void Load(Handle(AIS_InteractiveObject) thePrs) = 0;
+
+ //! Processing method of context
+ virtual void ActivatedModes (Handle(AIS_InteractiveObject) thePrs, TColStd_ListOfInteger& theList) = 0;
+
+ //! Processing method of context
+ virtual void Activate(Handle(AIS_InteractiveObject) thePrs, const Standard_Integer theMode) = 0;
+
+ //! Processing method of context
+ virtual void Deactivate(Handle(AIS_InteractiveObject) thePrs) = 0;
+
+ //! Processing method of context
+ virtual void Deactivate(Handle(AIS_InteractiveObject) thePrs, const Standard_Integer theMode) = 0;
+
+ //! Processing method of context
+ virtual void AddOrRemoveSelected (const TopoDS_Shape& theShape) = 0;
+
+ //! Processing method of context
+ virtual void AddOrRemoveSelected (Handle(AIS_InteractiveObject) thePrs) = 0;
+
+ //! Processing method of context
+ virtual void AddOrRemoveSelected (Handle(SelectMgr_EntityOwner) theOwner) = 0;
+
+ //! Processing method of context
+ virtual void ClearSelected() = 0;
+
+ //! Processing method of context
+ virtual void ClearSelected(Handle(AIS_InteractiveObject) thePrs) = 0;
+
+ //! Processing method of context
+ virtual void MoveTo (const Standard_Integer theXPix, const Standard_Integer theYPix) = 0;
+
+ //! Processing method of context
+ virtual void SetSelected(Handle(AIS_InteractiveObject) thePrs) = 0;
+
+ //! Processing method of context
+ virtual void Select() = 0;
+
+ //! Processing method of context
+ virtual void ShiftSelect() = 0;
+
+#if OCC_VERSION_HEX <= 0x060901
+ DEFINE_STANDARD_RTTI(VInspectorAPI_CallBack)
+#else
+ DEFINE_STANDARD_RTTIEXT(VInspectorAPI_CallBack, Standard_Transient)
+#endif
+};
+
+#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 <VInspector_CallBack.hxx>
+
+#include <AIS_InteractiveContext.hxx>
+#include <AIS_InteractiveObject.hxx>
+
+#include <SelectMgr_EntityOwner.hxx>
+#include <Standard_Version.hxx>
+
+#include <VInspector_CallBackMode.hxx>
+#include <VInspector_Tools.hxx>
+#include <VInspector_ViewModelHistory.hxx>
+
+#include <QStringList>
+
+#if OCC_VERSION_HEX <= 0x060901
+IMPLEMENT_STANDARD_HANDLE(VInspector_CallBack, Standard_Transient)
+IMPLEMENT_STANDARD_RTTIEXT(VInspector_CallBack, VInspectorAPI_CallBack)
+#else
+IMPLEMENT_STANDARD_RTTIEXT(VInspector_CallBack, VInspectorAPI_CallBack)
+#endif
+
+// =======================================================================
+// function : Activate
+// purpose :
+// =======================================================================
+void VInspector_CallBack::Activate (Handle(AIS_InteractiveObject) thePrs, const Standard_Integer theMode)
+{
+ QList<QVariant> anInfo = VInspector_Tools::GetInfo (thePrs);
+ anInfo[0] = QString ("%1: %2").arg (anInfo[0].toString()).arg (theMode);
+ myHistoryModel->AddElement (VInspector_CallBackMode_Activate, anInfo);
+}
+
+// =======================================================================
+// function : AddOrRemoveSelected
+// purpose :
+// =======================================================================
+void VInspector_CallBack::AddOrRemoveSelected (const TopoDS_Shape& theShape)
+{
+ QList<QVariant> aValues;
+ aValues.append (""); // Name
+ aValues.append (""); // Pointer
+ aValues.append (VInspector_Tools::GetShapeTypeInfo (theShape.ShapeType()).ToCString()); // Shape Type
+ aValues.append (VInspector_Tools::GetSelectedInfoPointers (myContext)); // SelectionInfo
+ myHistoryModel->AddElement (VInspector_CallBackMode_AddOrRemoveSelectedShape, aValues);
+}
+
+// =======================================================================
+// function : AddOrRemoveSelected
+// purpose :
+// =======================================================================
+void VInspector_CallBack::AddOrRemoveSelected (Handle(AIS_InteractiveObject) thePrs)
+{
+ QList<QVariant> aValues = VInspector_Tools::GetInfo (thePrs);
+ aValues.append (VInspector_Tools::GetSelectedInfoPointers (myContext)); // SelectionInfo
+ myHistoryModel->AddElement (VInspector_CallBackMode_AddOrRemoveSelected, aValues);
+}
+
+// =======================================================================
+// function : AddOrRemoveSelected
+// purpose :
+// =======================================================================
+void VInspector_CallBack::AddOrRemoveSelected (Handle(SelectMgr_EntityOwner) theOwner)
+{
+ QList<QVariant> aValues;
+ aValues.append (""); // Name
+ aValues.append (VInspector_Tools::GetPointerInfo (theOwner, true).ToCString()); // Pointer
+ aValues.append (""); // Shape type
+ aValues.append (VInspector_Tools::GetSelectedInfoPointers (myContext)); // SelectionInfo
+
+ myHistoryModel->AddElement (VInspector_CallBackMode_AddOrRemoveSelectedOwner, aValues);
+}
+
+// =======================================================================
+// function : ClearSelected
+// purpose :
+// =======================================================================
+void VInspector_CallBack::ClearSelected()
+{
+ QList<QVariant> aValues;
+ myHistoryModel->AddElement (VInspector_CallBackMode_ClearSelected, aValues);
+}
+
+// =======================================================================
+// function : MoveTo
+// purpose :
+// =======================================================================
+void VInspector_CallBack::MoveTo (const Standard_Integer/* theXPix*/, const Standard_Integer/* theYPix*/)
+{
+ QList<QVariant> aValues;
+ aValues = VInspector_Tools::GetHighlightInfo (myContext);
+ myHistoryModel->AddElement (VInspector_CallBackMode_MoveTo, aValues);
+}
+
+// =======================================================================
+// function : Select
+// purpose :
+// =======================================================================
+void VInspector_CallBack::Select()
+{
+ QList<QVariant> aValues;
+ aValues = VInspector_Tools::GetSelectedInfo (myContext);
+ myHistoryModel->AddElement (VInspector_CallBackMode_Select, aValues);
+}
+
+// =======================================================================
+// function : ShiftSelect
+// purpose :
+// =======================================================================
+void VInspector_CallBack::ShiftSelect()
+{
+ QList<QVariant> aValues;
+ aValues = VInspector_Tools::GetSelectedInfo (myContext);
+ myHistoryModel->AddElement (VInspector_CallBackMode_ShiftSelect, aValues);
+}
+
+// =======================================================================
+// function : GetInfo
+// purpose :
+// =======================================================================
+QString VInspector_CallBack::GetInfo (const VInspector_CallBackMode& theMode)
+{
+ switch (theMode)
+ {
+ case VInspector_CallBackMode_None: return "None";
+ case VInspector_CallBackMode_Display: return "Display";
+ case VInspector_CallBackMode_Redisplay: return "Redisplay";
+ case VInspector_CallBackMode_Remove: return "Remove";
+ case VInspector_CallBackMode_Load: return "Load";
+ case VInspector_CallBackMode_ActivatedModes: return "ActivatedModes";
+ case VInspector_CallBackMode_Activate: return "Activate";
+ case VInspector_CallBackMode_Deactivate: return "Deactivate";
+ case VInspector_CallBackMode_AddOrRemoveSelectedShape: return "AddOrRemoveSelectedShape";
+ case VInspector_CallBackMode_AddOrRemoveSelected: return "AddOrRemoveSelected";
+ case VInspector_CallBackMode_AddOrRemoveSelectedOwner: return "AddOrRemoveSelectedOwner";
+ case VInspector_CallBackMode_ClearSelected: return "ClearSelected";
+ case VInspector_CallBackMode_MoveTo: return "MoveTo";
+ case VInspector_CallBackMode_SetSelected: return "SetSelected";
+ case VInspector_CallBackMode_Select: return "Select";
+ case VInspector_CallBackMode_ShiftSelect: return "ShiftSelect";
+ default: break;
+ }
+ return QString();
+}
--- /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 VInspector_CallBack_H
+#define VInspector_CallBack_H
+
+#include <AIS_InteractiveContext.hxx>
+#include <Standard.hxx>
+#include <VInspectorAPI_CallBack.hxx>
+#include <VInspector_CallBackMode.hxx>
+#include <VInspector_ViewModelHistory.hxx>
+#include <VInspector_Tools.hxx>
+
+class AIS_InteractiveObject;
+class SelectMgr_EntityOwner;
+
+DEFINE_STANDARD_HANDLE(VInspector_CallBack, VInspectorAPI_CallBack)
+
+//! \class VInspector_CallBack
+//! Updates inspector state on actions in context
+class VInspector_CallBack : public VInspectorAPI_CallBack
+{
+public:
+
+ //! Constructor
+ VInspector_CallBack() : VInspectorAPI_CallBack() {}
+
+ //! Destructor
+ virtual ~VInspector_CallBack() Standard_OVERRIDE {}
+
+ //! Appends displayed presentation into history model
+ //! \param thePrs the presentation
+ virtual void Display (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
+ { myHistoryModel->AddElement (VInspector_CallBackMode_Display, VInspector_Tools::GetInfo (thePrs)); }
+
+ //! Appends redisplayed presentation into history model
+ //! \param thePrs the presentation
+ virtual void Redisplay (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
+ { myHistoryModel->AddElement (VInspector_CallBackMode_Redisplay, VInspector_Tools::GetInfo (thePrs)); }
+
+ //! Appends removed presentation into history model
+ //! \param thePrs the presentation
+ virtual void Remove (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
+ { myHistoryModel->AddElement (VInspector_CallBackMode_Remove, VInspector_Tools::GetInfo (thePrs)); }
+
+ //! Appends loaded presentation into history model
+ //! \param thePrs the presentation
+ virtual void Load (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
+ { myHistoryModel->AddElement (VInspector_CallBackMode_Load, VInspector_Tools::GetInfo (thePrs)); }
+
+ //! Appends information about modes activation
+ //! \param thePrs the presentation
+ //! \param theModes the selection modes
+ virtual void ActivatedModes (Handle(AIS_InteractiveObject) thePrs, TColStd_ListOfInteger& theModes) Standard_OVERRIDE
+ { (void)thePrs; (void)theModes; }
+
+ //! Appends information about mode activation
+ //! \param thePrs the presentation
+ //! \param theModes the selection mode
+ Standard_EXPORT virtual void Activate (Handle(AIS_InteractiveObject) thePrs,
+ const Standard_Integer theMode) Standard_OVERRIDE;
+
+ //! Appends information about modes deactivation
+ //! \param thePrs the presentation
+ virtual void Deactivate (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
+ { myHistoryModel->AddElement (VInspector_CallBackMode_Deactivate, VInspector_Tools::GetInfo (thePrs)); }
+
+ //! Appends information about modes deactivation
+ //! \param thePrs the presentation
+ //! \param theMode the selection mode
+ virtual void Deactivate (Handle(AIS_InteractiveObject) thePrs, const Standard_Integer theMode) Standard_OVERRIDE
+ { (void)theMode; myHistoryModel->AddElement (VInspector_CallBackMode_Deactivate, VInspector_Tools::GetInfo (thePrs)); }
+
+ //! Appends information about selection change
+ //! \param theShape the selected shape
+ Standard_EXPORT virtual void AddOrRemoveSelected (const TopoDS_Shape& theShape) Standard_OVERRIDE;
+
+ //! Appends information about selection change
+ //! \param thePrs the selected presentation
+ Standard_EXPORT virtual void AddOrRemoveSelected (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE;
+
+ //! Appends information about selection change
+ //! \param theOwner the selected owner
+ Standard_EXPORT virtual void AddOrRemoveSelected (Handle(SelectMgr_EntityOwner) theOwner) Standard_OVERRIDE;
+
+ //! Appends information about selection clear
+ Standard_EXPORT virtual void ClearSelected() Standard_OVERRIDE;
+
+ //! Appends information about selection clear
+ //! \param thePrs the selected presentation
+ virtual void ClearSelected (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
+ { myHistoryModel->AddElement (VInspector_CallBackMode_ClearSelected, VInspector_Tools::GetInfo (thePrs)); }
+
+ //! Appends information about moving to point
+ //! \param theXPix a pixels on horizontal
+ //! \param theYPix a pixels on vertical
+ Standard_EXPORT virtual void MoveTo (const Standard_Integer theXPix, const Standard_Integer theYPix) Standard_OVERRIDE;
+
+ //! Appends information about setting selection
+ //! \param thePrs the selected presentation
+ virtual void SetSelected (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
+ { myHistoryModel->AddElement (VInspector_CallBackMode_SetSelected, VInspector_Tools::GetInfo (thePrs)); }
+
+ //! Appends information about select
+ Standard_EXPORT virtual void Select() Standard_OVERRIDE;
+
+ //! Appends information about shift select
+ Standard_EXPORT virtual void ShiftSelect() Standard_OVERRIDE;
+
+ //! Sets history model, it will be filled by actions in context
+ //! \param theHistoryModel the view model
+ void SetHistoryModel (VInspector_ViewModelHistory* theHistoryModel) { myHistoryModel = theHistoryModel; }
+
+ //! Sets context, where actions happen
+ //! \param theContext a context instance
+ void SetContext (const Handle(AIS_InteractiveContext)& theContext) { myContext = theContext; }
+#if OCC_VERSION_HEX <= 0x060901
+ DEFINE_STANDARD_RTTI(VInspector_CallBack)
+#else
+ DEFINE_STANDARD_RTTIEXT(VInspector_CallBack, VInspectorAPI_CallBack)
+#endif
+
+ //! Returns string information of call back mode
+ //! \param theMode type of AIS action
+ //! \return information text
+ static QString GetInfo (const VInspector_CallBackMode& theMode);
+
+private:
+ VInspector_ViewModelHistory* myHistoryModel; //!< the current history model, fulfilled by context actions
+ Handle(AIS_InteractiveContext) myContext; //!< the listened context
+};
+
+#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.
+
+#ifndef VInspector_CallBackMode_H
+#define VInspector_CallBackMode_H
+
+//! History context modes corresponding to actions in AIS_InteractiveContext
+enum VInspector_CallBackMode
+{
+ VInspector_CallBackMode_None, //!< undefined
+ VInspector_CallBackMode_Display, //!< Display
+ VInspector_CallBackMode_Redisplay, //!< Redisplay
+ VInspector_CallBackMode_Remove, //!< Remove
+ VInspector_CallBackMode_Load, //!< Load
+ VInspector_CallBackMode_ActivatedModes, //!< ActivatedModes
+ VInspector_CallBackMode_Activate, //!< Activate
+ VInspector_CallBackMode_Deactivate, //!< Deactivate
+ VInspector_CallBackMode_AddOrRemoveSelectedShape, //!< AddOrRemoveSelectedShape for TopoDS_Shape
+ VInspector_CallBackMode_AddOrRemoveSelected, //!< AddOrRemoveSelectedShape for Presentation
+ VInspector_CallBackMode_AddOrRemoveSelectedOwner, //!< AddOrRemoveSelectedShape for Owner
+ VInspector_CallBackMode_ClearSelected, //!< ClearSelected
+ VInspector_CallBackMode_MoveTo, //!< MoveTo
+ VInspector_CallBackMode_SetSelected, //!< SetSelected
+ VInspector_CallBackMode_Select, //!< Select
+ VInspector_CallBackMode_ShiftSelect //!< ShiftSelect
+};
+
+#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 <VInspector_Communicator.hxx>
+
+#include <VInspector_CallBack.hxx>
+#include <VInspector_Window.hxx>
+
+#include <AIS_InteractiveContext.hxx>
+
+#include <QApplication>
+#include <QDir>
+#include <QLayout>
+#include <QMainWindow>
+#include <QWidget>
+
+// =======================================================================
+// function : CreateCommunicator
+// purpose : Creates a communicator by the library loading
+// =======================================================================
+Standard_EXPORTEXTERNC TInspectorAPI_Communicator* CreateCommunicator()
+{
+ return new VInspector_Communicator();
+}
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+VInspector_Communicator::VInspector_Communicator()
+: TInspectorAPI_Communicator(), myWindow (0)
+{
+ myWindow = new VInspector_Window();
+}
--- /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 VInspector_Communicator_H
+#define VInspector_Communicator_H
+
+#include <Standard.hxx>
+#include <Standard_Macro.hxx>
+#include <VInspector_Window.hxx>
+
+#include <TInspectorAPI_Communicator.hxx>
+
+//! \class VInspector_Communicator.
+//! \brief This is a connector from TInspector application to VInspector view
+class VInspector_Communicator : public TInspectorAPI_Communicator
+{
+public:
+
+ //! Constructor
+ Standard_EXPORT VInspector_Communicator();
+
+ //! Destructor
+ virtual ~VInspector_Communicator() Standard_OVERRIDE {}
+
+ //! Provides the container with a parent where this container should be inserted.
+ //! If Qt implementation, it should be QWidget with QLayout set inside
+ //! \param theParent a parent class
+ virtual void SetParent (void* theParent) Standard_OVERRIDE { myWindow->SetParent (theParent); }
+
+ //! Sets parameters container, it should be used when the plugin is initialized or in update content
+ //! \param theParameters a parameters container
+ virtual void SetParameters (const Handle(TInspectorAPI_PluginParameters)& theParameters) Standard_OVERRIDE
+ { myWindow->SetParameters (theParameters); }
+
+ //! Calls update of the plugin's content
+ virtual void UpdateContent() Standard_OVERRIDE { myWindow->UpdateContent(); }
+
+private:
+ VInspector_Window* myWindow; //!< current window
+};
+
+#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 <VInspector_ItemBase.hxx>
+#include <VInspector_ItemContext.hxx>
+
+// =======================================================================
+// function : GetContext
+// purpose :
+// =======================================================================
+const Handle(AIS_InteractiveContext)& VInspector_ItemBase::GetContext() const
+{
+ if (!myContext.IsNull())
+ return myContext;
+
+ Handle(AIS_InteractiveContext) aContext;
+ if (const VInspector_ItemContext* aThisContextItem = dynamic_cast<const VInspector_ItemContext*> (this))
+ {
+ aContext = aThisContextItem->GetContext();
+ }
+ else
+ {
+ TreeModel_ItemBasePtr anItem = Parent();
+ while (anItem)
+ {
+ if (VInspector_ItemContextPtr aContextItem = itemDynamicCast<VInspector_ItemContext>(anItem))
+ {
+ aContext = aContextItem->GetContext();
+ break;
+ }
+ anItem = anItem->Parent();
+ }
+ }
+ if (!aContext.IsNull())
+ const_cast<VInspector_ItemBase*>(this)->SetContext (aContext);
+
+ return myContext;
+}
--- /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 VInspector_ItemBase_H
+#define VInspector_ItemBase_H
+
+#include <AIS_InteractiveContext.hxx>
+#include <Standard.hxx>
+#include <TreeModel_ItemBase.hxx>
+
+class VInspector_ItemBase;
+typedef QExplicitlySharedDataPointer<VInspector_ItemBase> VInspector_ItemBasePtr;
+
+//! \class VInspector_ItemBase
+//! Parent item for all ShapeView items
+class VInspector_ItemBase : public TreeModel_ItemBase
+{
+public:
+ //! Resets cached values
+ virtual void Reset() Standard_OVERRIDE { TreeModel_ItemBase::Reset(); }
+
+ //! Sets the context
+ //! \param theLabel an object where the child items structure is found
+ void SetContext (const Handle(AIS_InteractiveContext)& theContext) { myContext = theContext; }
+
+ //! Returns true if the current context is not null
+ //! \return a boolean value
+ bool HasContext() const { return !GetContext().IsNull(); }
+
+ //! Returns the current contex. It iterates up by list of parents to found context item and return context
+ //! \return a context
+ Standard_EXPORT const Handle(AIS_InteractiveContext)& GetContext() const;
+
+protected:
+
+ //! Initialize the current item. It creates a backup of the specific item information
+ virtual void initItem() const {};// = 0;
+
+protected:
+
+ //! Constructor
+ //! param theParent a parent item
+ //! \param theRow the item row positition in the parent item
+ //! \param theColumn the item column positition in the parent item
+ VInspector_ItemBase (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ : TreeModel_ItemBase (theParent, theRow, theColumn), myContext (0) {}
+
+protected:
+
+ Handle(AIS_InteractiveContext) myContext; //!< the current context
+};
+
+#endif
\ 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 <VInspector_ItemContext.hxx>
+
+#include <AIS_ListOfInteractive.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <VInspector_ItemPresentableObject.hxx>
+#include <VInspector_Tools.hxx>
+
+#include <QStringList>
+
+//#define DEBUG_FREE_OWNERS
+
+// =======================================================================
+// function : initRowCount
+// purpose :
+// =======================================================================
+int VInspector_ItemContext::initRowCount() const
+{
+ if (Column() != 0)
+ return 0;
+
+ int aNbPresentations = 0;
+ if (!GetContext().IsNull())
+ {
+ AIS_ListOfInteractive aListOfIO;
+ GetContext()->DisplayedObjects (aListOfIO);
+ GetContext()->ErasedObjects(aListOfIO);
+ aNbPresentations = aListOfIO.Extent();
+ }
+ // owners without Presentation
+#ifdef DEBUG_FREE_OWNERS
+ int aRows = 0;
+ // only local context is processed: TODO for global context
+ Handle(AIS_InteractiveContext) aContext = GetContext();
+ if (!aContext.IsNull()) {
+ NCollection_List<Handle(SelectBasics_EntityOwner)> anActiveOwners;
+ aContext->MainSelector()->ActiveOwners(anActiveOwners);
+
+ Handle(SelectMgr_EntityOwner) anOwner;
+ for (NCollection_List<Handle(SelectBasics_EntityOwner)>::Iterator anOwnersIt(anActiveOwners);
+ anOwnersIt.More(); anOwnersIt.Next())
+ {
+ anOwner = Handle(SelectMgr_EntityOwner)::DownCast(anOwnersIt.Value());
+ if (anOwner.IsNull())
+ continue;
+ Handle(AIS_InteractiveObject) anAISObj = Handle(AIS_InteractiveObject)::DownCast(anOwner->Selectable());
+ if (anAISObj.IsNull())
+ aRows++;
+ }
+ }
+
+ // owners in Global Context
+ if (!aContext.IsNull())
+ {
+ NCollection_List<Handle(SelectBasics_EntityOwner)> anActiveOwners;
+ aContext->MainSelector()->ActiveOwners(anActiveOwners);
+ }
+ if (aRows > 0)
+ aNbPresentations += aRows;
+#endif
+#ifdef DEBUG_FREE_OWNERS
+ NCollection_List<Handle(SelectBasics_EntityOwner)> anEmptySelectableOwners;
+ NCollection_List<Handle(SelectBasics_EntityOwner)> anOwners =
+ VInspector_Tools::ActiveOwners (GetContext(), anEmptySelectableOwners);
+ if (anEmptySelectableOwners.Size() > 0)
+ aNbPresentations += 1;
+#endif
+ return aNbPresentations;
+}
+
+// =======================================================================
+// function : initValue
+// purpose :
+// =======================================================================
+QVariant VInspector_ItemContext::initValue (const int theItemRole) const
+{
+ if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
+ return QVariant();
+
+ switch (Column())
+ {
+ case 0: return GetContext()->DynamicType()->Name();
+ case 1: return rowCount();
+ case 4:
+ {
+ if (theItemRole == Qt::ToolTipRole)
+ return "Selected Owners";
+ else
+ {
+ Handle(AIS_InteractiveObject) anEmptyIO;
+ int aSelectedCount = VInspector_Tools::SelectedOwners (GetContext(), anEmptyIO, false);
+ return aSelectedCount > 0 ? QString::number (aSelectedCount) : "";
+ }
+ }
+ case 7:
+ {
+ if (theItemRole == Qt::ToolTipRole)
+ return QString ("All Owners/Active Owners");
+ else
+ {
+ NCollection_List<Handle(SelectBasics_EntityOwner)> anEmptySelectableOwners;
+ NCollection_List<Handle(SelectBasics_EntityOwner)> anOwners =
+ VInspector_Tools::ActiveOwners (GetContext(), anEmptySelectableOwners);
+ int anActiveOwners = anOwners.Size();
+ anOwners = VInspector_Tools::ContextOwners (GetContext());
+ return QString ("%1 / %2").arg (anOwners.Size()).arg (anActiveOwners);
+ }
+ }
+ case 8:
+ {
+ if (theItemRole == Qt::ToolTipRole)
+ return QString ("DeviationCoefficient");
+ else
+ return GetContext()->DeviationCoefficient();
+ }
+ default:
+ break;
+ }
+ return QVariant();
+}
+
+// =======================================================================
+// function : createChild
+// purpose :
+// =======================================================================
+TreeModel_ItemBasePtr VInspector_ItemContext::createChild (int theRow, int theColumn)
+{
+ return VInspector_ItemPresentableObject::CreateItem (currentItem(), theRow, theColumn);
+}
--- /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 VInspector_ItemContext_H
+#define VInspector_ItemContext_H
+
+#include <Standard.hxx>
+#include <VInspector_ItemBase.hxx>
+
+class VInspector_ItemContext;
+typedef QExplicitlySharedDataPointer<VInspector_ItemContext> VInspector_ItemContextPtr;
+
+//! \class VInspector_ItemContext
+//! Parent item, that corresponds to AIS_InteractiveContext
+class VInspector_ItemContext : public VInspector_ItemBase
+{
+public:
+
+ //! Creates an item wrapped by a shared pointer
+ static VInspector_ItemContextPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ { return VInspector_ItemContextPtr (new VInspector_ItemContext (theParent, theRow, theColumn)); }
+
+ //! Destructor
+ virtual ~VInspector_ItemContext() Standard_OVERRIDE {};
+
+ //! Returns number of displayed presentations
+ //! \return rows count
+ Standard_EXPORT virtual int initRowCount() const Standard_OVERRIDE;
+
+ //! Returns item information for the given role. Fills internal container if it was not filled yet
+ //! \param theItemRole a value role
+ //! \return the value
+ Standard_EXPORT virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
+
+protected:
+
+ //! Initialize the current item. It creates a backup of the specific item information
+ //! Do nothing as context has been already set into item
+ virtual void initItem() const Standard_OVERRIDE {}
+
+protected:
+
+ //! Creates a child item in the given position.
+ //! \param theRow the child row position
+ //! \param theColumn the child column position
+ //! \return the created item
+ virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
+
+private:
+
+ //! Constructor
+ //! param theParent a parent item
+ //! \param theRow the item row positition in the parent item
+ //! \param theColumn the item column positition in the parent item
+ VInspector_ItemContext(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ : VInspector_ItemBase(theParent, theRow, theColumn) {}
+};
+
+#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 <VInspector_ItemEntityOwner.hxx>
+#include <VInspector_ItemSensitiveEntity.hxx>
+#include <VInspector_ItemPresentableObject.hxx>
+#include <VInspector_Tools.hxx>
+
+#include <SelectMgr_SensitiveEntity.hxx>
+#include <SelectBasics_SensitiveEntity.hxx>
+#include <Standard_Version.hxx>
+#include <StdSelect_BRepOwner.hxx>
+
+#include <QItemSelectionModel>
+#include <QColor>
+
+// =======================================================================
+// function : initValue
+// purpose :
+// =======================================================================
+QVariant VInspector_ItemEntityOwner::initValue(int theItemRole) const
+{
+ switch (theItemRole)
+ {
+ case Qt::DisplayRole:
+ case Qt::EditRole:
+ case Qt::ToolTipRole:
+ {
+ Handle(SelectBasics_EntityOwner) anOwner = getEntityOwner();
+ if (anOwner.IsNull())
+ return QVariant();
+
+ switch (Column())
+ {
+ case 0: return anOwner->DynamicType()->Name();
+ case 2: return theItemRole == Qt::ToolTipRole ? "Owner pointer"
+ : VInspector_Tools::GetPointerInfo (anOwner, true).ToCString();
+ case 3:
+ {
+ if (theItemRole == Qt::ToolTipRole)
+ return "Owner Shape type";
+ else
+ {
+ Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast (anOwner);
+ if (!BROwnr.IsNull())
+ {
+ const TopoDS_Shape& aShape = BROwnr->Shape();
+ if (!aShape.IsNull())
+ return VInspector_Tools::GetShapeTypeInfo (aShape.ShapeType()).ToCString();
+ }
+ }
+ break;
+ }
+ case 5:
+ {
+ if (theItemRole == Qt::ToolTipRole)
+ return "TShape pointer";
+ else
+ {
+ Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast (anOwner);
+ if (!BROwnr.IsNull())
+ {
+ const TopoDS_Shape& aShape = BROwnr->Shape();
+ if (!aShape.IsNull())
+ return VInspector_Tools::GetPointerInfo (aShape.TShape(), true).ToCString();
+ }
+ }
+ break;
+ }
+ case 8:
+ {
+ if (theItemRole == Qt::ToolTipRole)
+ return "Shape Location : Shape Orientation";
+ else
+ {
+ Handle(StdSelect_BRepOwner) aBROwnr = Handle(StdSelect_BRepOwner)::DownCast (anOwner);
+ if (!aBROwnr.IsNull())
+ {
+ const TopoDS_Shape& aShape = aBROwnr->Shape();
+ if (!aShape.IsNull())
+ return QString ("%1 : %2")
+ .arg (VInspector_Tools::LocationToName(aShape.Location()).ToCString())
+ .arg (VInspector_Tools::OrientationToName(aShape.Orientation()).ToCString());
+ return VInspector_Tools::GetShapeTypeInfo (aShape.ShapeType()).ToCString();
+ }
+ }
+ break;
+ }
+ default: break;
+ }
+ break;
+ }
+ case Qt::BackgroundRole:
+ case Qt::ForegroundRole:
+ {
+ if (Column() == 2)
+ {
+ Handle(AIS_InteractiveContext) aContext = GetContext();
+ if (!aContext.IsNull())
+ {
+ if (VInspector_Tools::IsOwnerSelected(aContext, getEntityOwner()))
+ return (theItemRole == Qt::BackgroundRole) ? QColor (Qt::darkBlue) : QColor (Qt::white);
+ }
+ }
+ VInspector_ItemSensitiveEntityPtr aParentItem = itemDynamicCast<VInspector_ItemSensitiveEntity>(Parent());
+ if (aParentItem)
+ return aParentItem->data(QModelIndex(), theItemRole);
+ break;
+ }
+ }
+ return QVariant();
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void VInspector_ItemEntityOwner::Init()
+{
+ Handle(SelectBasics_EntityOwner) anOwner;
+
+ VInspector_ItemSensitiveEntityPtr aParentItem = itemDynamicCast<VInspector_ItemSensitiveEntity>(Parent());
+ if (aParentItem)
+ {
+ Handle(SelectMgr_SensitiveEntity) anEntity = aParentItem->GetSensitiveEntity();
+ anOwner = anEntity->BaseSensitive()->OwnerId();
+ }
+ else
+ {
+ VInspector_ItemPresentableObjectPtr aPOItem = itemDynamicCast<VInspector_ItemPresentableObject>(Parent());
+ if (aPOItem)
+ {
+ Handle(AIS_InteractiveObject) anIO = aPOItem->GetInteractiveObject();
+
+ int aRowId = Row();
+ int aCurrentIndex = 0;
+ for (anIO->Init(); anIO->More() && anOwner.IsNull(); anIO->Next())
+ {
+ const Handle(SelectMgr_Selection)& aSelection = anIO->CurrentSelection();
+ for (aSelection->Init(); aSelection->More() && anOwner.IsNull(); aSelection->Next())
+ {
+ Handle(SelectMgr_SensitiveEntity) anEntity = aSelection->Sensitive();
+ const Handle(SelectBasics_SensitiveEntity)& aBase = anEntity->BaseSensitive();
+ if (!aBase.IsNull())
+ {
+ if (aRowId == aCurrentIndex)
+ anOwner = aBase->OwnerId();
+ aCurrentIndex++;
+ }
+ }
+ }
+ }
+ }
+ myOwner = anOwner;
+ TreeModel_ItemBase::Init();
+}
+
+// =======================================================================
+// function : Reset
+// purpose :
+// =======================================================================
+void VInspector_ItemEntityOwner::Reset()
+{
+ VInspector_ItemBase::Reset();
+ SetContext (NULL);
+}
+
+// =======================================================================
+// function : initItem
+// purpose :
+// =======================================================================
+void VInspector_ItemEntityOwner::initItem() const
+{
+ if (IsInitialized())
+ return;
+ const_cast<VInspector_ItemEntityOwner*>(this)->Init();
+}
+
+// =======================================================================
+// function : getEntityOwner
+// purpose :
+// =======================================================================
+Handle(SelectBasics_EntityOwner) VInspector_ItemEntityOwner::getEntityOwner() const
+{
+ initItem();
+ return myOwner;
+}
--- /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 VInspector_ItemEntityOwner_H
+#define VInspector_ItemEntityOwner_H
+
+#include <AIS_InteractiveObject.hxx>
+#include <Standard.hxx>
+#include <VInspector_ItemBase.hxx>
+
+class QItemSelectionModel;
+
+class VInspector_ItemEntityOwner;
+typedef QExplicitlySharedDataPointer<VInspector_ItemEntityOwner> VInspector_ItemEntityOwnerPtr;
+
+//! \class VInspector_ItemPresentableObject
+//! Item for selection entity owner. The parent is sensitive entity item, there are no children
+class VInspector_ItemEntityOwner : public VInspector_ItemBase
+{
+
+public:
+
+ //! Creates an item wrapped by a shared pointer
+ static VInspector_ItemEntityOwnerPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ { return VInspector_ItemEntityOwnerPtr (new VInspector_ItemEntityOwner (theParent, theRow, theColumn)); }
+
+ //! Destructor
+ virtual ~VInspector_ItemEntityOwner() Standard_OVERRIDE {};
+
+ //! Inits the item, fills internal containers
+ Standard_EXPORT virtual void Init() Standard_OVERRIDE;
+
+ //! Resets cached values
+ Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
+
+ //! Returns the current entity owner
+ Handle(SelectBasics_EntityOwner) EntityOwner() const { return myOwner; }
+
+protected:
+ //! \return number of children.
+ virtual int initRowCount() const Standard_OVERRIDE{ return 0; }
+
+ //! Returns item information for the given role. Fills internal container if it was not filled yet
+ //! \param theItemRole a value role
+ //! \return the value
+ virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
+
+ //! Initialize the current item. It is empty because Reset() is also empty.
+ virtual void initItem() const Standard_OVERRIDE;
+
+protected:
+
+ //! Creates a child item in the given position.
+ //! \param theRow the child row position
+ //! \param theColumn the child column position
+ //! \return the created item
+ virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE
+ { (void)theRow; (void)theColumn; return TreeModel_ItemBasePtr(); }
+
+private:
+
+ //! Constructor
+ //! param theParent a parent item
+ VInspector_ItemEntityOwner(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ : VInspector_ItemBase(theParent, theRow, theColumn) {}
+
+private:
+
+ //! Returns the current entity owner. Initializes the item if it was not initialized yet
+ Handle(SelectBasics_EntityOwner) getEntityOwner() const;
+
+private:
+
+ Handle(SelectBasics_EntityOwner) myOwner; //!< the current entity owner
+};
+
+#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 <VInspector_ItemHistoryElement.hxx>
+
+#include <VInspector_ItemHistoryRoot.hxx>
+#include <VInspector_ItemHistoryType.hxx>
+#include <VInspector_ItemHistoryElement.hxx>
+#include <VInspector_Tools.hxx>
+
+// =======================================================================
+// function : data
+// purpose :
+// =======================================================================
+QVariant VInspector_ItemHistoryElement::initValue(const int theRole) const
+{
+ if (theRole != Qt::DisplayRole && theRole != Qt::EditRole && theRole != Qt::ToolTipRole)
+ return QVariant();
+
+ switch (Column())
+ {
+ case 0: return getName();
+ case 1: return QVariant();
+ case 2: return GetPointerInfo();
+ case 3: return GetShapeTypeInfo();
+ default: break;
+ }
+ return QVariant();
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void VInspector_ItemHistoryElement::Init()
+{
+ VInspector_ItemHistoryTypePtr aParentItem = itemDynamicCast<VInspector_ItemHistoryType>(Parent());
+ VInspector_ItemHistoryRootPtr aRootItem = itemDynamicCast<VInspector_ItemHistoryRoot>(aParentItem->Parent());
+
+ const VInspector_ItemHistoryTypeInfo& aTypeInfo = aRootItem->GetTypeInfo (aParentItem->Row());
+ QList<QList<QVariant>> anElements = aTypeInfo.myElements;
+
+ int aRowId = Row();
+ QList<QVariant> anInfo = anElements.at(aRowId);
+ int anInfoSize = anInfo.size();
+
+ myName = anInfoSize > 0 ? anInfo[0].toString() : QString ("Element: %1").arg (aRowId);
+ myPointerInfo = anInfoSize > 1 ? anInfo[1].toString() : QString();
+ myShapeTypeInfo = anInfoSize > 2 ? anInfo[2].toString() : QString();
+
+ TreeModel_ItemBase::Init();
+}
+
+// =======================================================================
+// function : initItem
+// purpose :
+// =======================================================================
+void VInspector_ItemHistoryElement::initItem() const
+{
+ if (IsInitialized())
+ return;
+ const_cast<VInspector_ItemHistoryElement*>(this)->Init();
+ // an empty method to don't initialize the main label, as it was not cleared in Reset()
+}
+
+// =======================================================================
+// function : getName
+// purpose :
+// =======================================================================
+QString VInspector_ItemHistoryElement::getName() const
+{
+ initItem();
+ return myName;
+}
+
+// =======================================================================
+// function : GetPointerInfo
+// purpose :
+// =======================================================================
+QString VInspector_ItemHistoryElement::GetPointerInfo() const
+{
+ initItem();
+ return myPointerInfo;
+}
+
+// =======================================================================
+// function : GetShapeTypeInfo
+// purpose :
+// =======================================================================
+QString VInspector_ItemHistoryElement::GetShapeTypeInfo() const
+{
+ initItem();
+ return myShapeTypeInfo;
+}
--- /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 VInspector_ItemHistoryElement_H
+#define VInspector_ItemHistoryElement_H
+
+#include <Standard.hxx>
+#include <VInspector_ItemBase.hxx>
+
+class VInspector_ItemHistoryElement;
+typedef QExplicitlySharedDataPointer<VInspector_ItemHistoryElement> VInspector_ItemHistoryElementPtr;
+
+//! \class VInspector_ItemHistoryElement
+//! Item shows name, pointer and shape type values of item history type information
+//! Parent is item history type, there are no children.
+class VInspector_ItemHistoryElement : public VInspector_ItemBase
+{
+
+public:
+
+ //! Creates an item wrapped by a shared pointer
+ static VInspector_ItemHistoryElementPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ { return VInspector_ItemHistoryElementPtr (new VInspector_ItemHistoryElement (theParent, theRow, theColumn)); }
+
+ //! Destructor
+ virtual ~VInspector_ItemHistoryElement() Standard_OVERRIDE {};
+
+ //! Inits the item, fills internal containers
+ Standard_EXPORT virtual void Init() Standard_OVERRIDE;
+
+ //! Resets cached values
+ virtual void Reset() Standard_OVERRIDE { TreeModel_ItemBase::Reset(); }
+
+ //! Returns pointer string value
+ QString PointerInfo() const { return myPointerInfo; }
+
+ //! \return number of children.
+ virtual int initRowCount() const Standard_OVERRIDE { return 0; }
+
+ //! Returns item information for the given role. Fills internal container if it was not filled yet
+ //! \param theItemRole a value role
+ //! \return the value
+ Standard_EXPORT virtual QVariant initValue(const int theItemRole) const Standard_OVERRIDE;
+
+protected:
+
+ //! Initialize the current item. It is empty because Reset() is also empty.
+ virtual void initItem() const Standard_OVERRIDE;
+
+ //! Creates a child item in the given position.
+ //! \param theRow the child row position
+ //! \param theColumn the child column position
+ //! \return the created item
+ virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE
+ { (void)theRow; (void)theColumn; return TreeModel_ItemBasePtr(); }
+
+ //! Returns the item text value, initialize item if it has not been initialized yet
+ QString getName() const;
+
+ //! Returns the item pointer value, initialize item if it has not been initialized yet
+ QString GetPointerInfo() const;
+
+ //! Returns the shape type text value, initialize item if it has not been initialized yet
+ QString GetShapeTypeInfo() const;
+
+private:
+
+ //! Constructor
+ //! param theParent a parent item
+ VInspector_ItemHistoryElement(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ : VInspector_ItemBase(theParent, theRow, theColumn) {}
+
+private:
+
+ QString myName; //!< cached text value
+ QString myPointerInfo; //!< cached pointer text value
+ QString myShapeTypeInfo; //!<cached shape type text value
+};
+
+#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 <VInspector_ItemHistoryRoot.hxx>
+
+#include <VInspector_ItemHistoryType.hxx>
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+VInspector_ItemHistoryRoot::VInspector_ItemHistoryRoot(TreeModel_ItemBasePtr theParent,
+ const int theRow, const int theColumn)
+: VInspector_ItemBase (theParent, theRow, theColumn), myFirstIndex (0), myLastIndex (0), myInfoMaxSize (10)
+{
+}
+
+// =======================================================================
+// function : AddElement
+// purpose :
+// =======================================================================
+void VInspector_ItemHistoryRoot::AddElement (const VInspector_CallBackMode& theMode, const QList<QVariant>& theInfo)
+{
+ if (!myLastIndex)
+ {
+ myInfoMap[myLastIndex] = VInspector_ItemHistoryTypeInfo(theMode, theInfo);
+ myLastIndex++;
+ }
+ else
+ {
+ if (myInfoMap[myLastIndex].myMode == theMode)
+ myInfoMap[myLastIndex].AddElement(theInfo);
+ else
+ {
+ myLastIndex++;
+ myInfoMap[myLastIndex] = VInspector_ItemHistoryTypeInfo(theMode, theInfo);
+ }
+ }
+
+ // clear cache
+ if (myInfoMap.size() >= myInfoMaxSize)
+ {
+ myInfoMap.remove (myFirstIndex);
+ myFirstIndex++;
+ }
+}
+
+// =======================================================================
+// function : GetTypeInfo
+// purpose :
+// =======================================================================
+const VInspector_ItemHistoryTypeInfo& VInspector_ItemHistoryRoot::GetTypeInfo (const int theChildRowIndex)
+{
+ int anInfoMapIndex = theChildRowIndex + myFirstIndex;
+ return myInfoMap[anInfoMapIndex];
+}
+
+// =======================================================================
+// function : initValue
+// purpose :
+// =======================================================================
+QVariant VInspector_ItemHistoryRoot::initValue (const int theRole) const
+{
+ if (theRole != Qt::DisplayRole && theRole != Qt::EditRole && theRole != Qt::ToolTipRole)
+ return QVariant();
+
+ switch (Column())
+ {
+ case 0: return "History";
+ case 1: return theRole == Qt::ToolTipRole ? QVariant ("Count of children") : QVariant (rowCount());
+ default:
+ break;
+ }
+ return QVariant();
+}
+
+// =======================================================================
+// function : createChild
+// purpose :
+// =======================================================================
+TreeModel_ItemBasePtr VInspector_ItemHistoryRoot::createChild (int theRow, int theColumn)
+{
+ return VInspector_ItemHistoryType::CreateItem (currentItem(), theRow, theColumn);
+}
+
--- /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 VInspector_ItemHistoryRoot_H
+#define VInspector_ItemHistoryRoot_H
+
+#include <Standard.hxx>
+#include <VInspector_ItemBase.hxx>
+#include <VInspector_ItemHistoryTypeInfo.hxx>
+#include <VInspector_CallBackMode.hxx>
+
+class VInspector_ItemHistoryRoot;
+typedef QExplicitlySharedDataPointer<VInspector_ItemHistoryRoot> VInspector_ItemHistoryRootPtr;
+
+//! \class VInspector_ItemHistoryRoot
+//! Item in history tree model. Has container of VInspector_ItemHistoryTypeInfo. Each element is a child item.
+//! Parent item is NULL, children are ItemHistoryType items
+class VInspector_ItemHistoryRoot : public VInspector_ItemBase
+{
+
+public:
+
+ //! Creates an item wrapped by a shared pointer
+ static VInspector_ItemHistoryRootPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ { return VInspector_ItemHistoryRootPtr (new VInspector_ItemHistoryRoot (theParent, theRow, theColumn)); }
+
+ //! Destructor
+ virtual ~VInspector_ItemHistoryRoot() Standard_OVERRIDE {};
+
+ //! Sets maximum count of history elements in internal container.
+ //! \param theSize a size value
+ void SetHistoryTypesMaxAmount (const int theSize) { myInfoMaxSize = theSize; }
+
+ //! Appends new history element into internal container. If the container already has maximum number
+ //! of values, the first container is removed.
+ //! \param theMode a type of the element
+ //! \param theInfo a history information element
+ Standard_EXPORT void AddElement (const VInspector_CallBackMode& theMode, const QList<QVariant>& theInfo);
+
+ //! Returns history item information for the child item
+ //! \param theChildRowIndex a child index
+ Standard_EXPORT const VInspector_ItemHistoryTypeInfo& GetTypeInfo (const int theChildRowIndex);
+
+protected:
+
+ //! Return data value for the role. It should be reimplemented in child
+ //! \param theRole a value role
+ //! \return the value
+ virtual QVariant initValue(const int theRole) const;
+
+ //! \return number of children. It should be reimplemented in child
+ virtual int initRowCount() const Standard_OVERRIDE { return myInfoMap.size(); }
+
+ //! Creates a child item in the given position.
+ //! \param theRow the child row position
+ //! \param theColumn the child column position
+ //! \return the created item
+ virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
+
+private:
+
+ //! Constructor
+ //! param theParent a parent item
+ VInspector_ItemHistoryRoot(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn);
+
+private:
+
+ QMap<int, VInspector_ItemHistoryTypeInfo> myInfoMap; //!< container of whole callback info, bounded by maximum size value
+ int myFirstIndex; //!< the first index in the information map, the first index is incremented if max value of container is achieved
+ int myLastIndex; //!< the last index in the information map, is incremented when new element is added
+ int myInfoMaxSize; //!< maximum number of elements in information map
+};
+
+#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 <VInspector_ItemHistoryType.hxx>
+
+#include <VInspector_CallBack.hxx>
+#include <VInspector_ItemHistoryRoot.hxx>
+#include <VInspector_ItemHistoryElement.hxx>
+#include <VInspector_Tools.hxx>
+
+// =======================================================================
+// function : PointerInfo
+// purpose :
+// =======================================================================
+QString VInspector_ItemHistoryType::PointerInfo() const
+{
+ if (rowCount() <= 0)
+ return QString();
+
+ VInspector_ItemHistoryRootPtr aParentItem = itemDynamicCast<VInspector_ItemHistoryRoot>(Parent());
+ const VInspector_ItemHistoryTypeInfo& aTypeInfo = aParentItem->GetTypeInfo(Row());
+ QList<QVariant> anElements = aTypeInfo.myElements[rowCount() - 1]; // the last item
+ return anElements.size() > 1 ? anElements[1].toString() : QString();
+}
+
+// =======================================================================
+// function : PointerInfo
+// purpose :
+// =======================================================================
+QString VInspector_ItemHistoryType::OwnerInfo() const
+{
+ if (rowCount() <= 0)
+ return QString();
+
+ VInspector_ItemHistoryRootPtr aParentItem = itemDynamicCast<VInspector_ItemHistoryRoot>(Parent());
+ const VInspector_ItemHistoryTypeInfo& aTypeInfo = aParentItem->GetTypeInfo(Row());
+ QList<QVariant> anElements = aTypeInfo.myElements[rowCount() - 1]; // the last item
+ return anElements.size() > 3 ? anElements[3].toString() : QString();
+}
+
+// =======================================================================
+// function : data
+// purpose :
+// =======================================================================
+QVariant VInspector_ItemHistoryType::initValue(const int theRole) const
+{
+ if (theRole != Qt::DisplayRole && theRole != Qt::EditRole && theRole != Qt::ToolTipRole)
+ return QVariant();
+
+ VInspector_ItemHistoryRootPtr aParentItem = itemDynamicCast<VInspector_ItemHistoryRoot>(Parent());
+ const VInspector_ItemHistoryTypeInfo& aTypeInfo = aParentItem->GetTypeInfo(Row());
+ QList<QVariant> anElements = rowCount() > 0 ? aTypeInfo.myElements[rowCount() - 1] : QList<QVariant>(); // the last item
+ int anInfoSize = anElements.size();
+ switch (Column())
+ {
+ case 0: return VInspector_CallBack::GetInfo(aTypeInfo.myMode);
+ case 1: return rowCount();
+ case 2: return anInfoSize > 1 ? anElements[1].toString() : QVariant(); // pointer info
+ case 3: return anInfoSize > 2 ? anElements[2].toString() : QVariant(); // shape type
+ case 4: return anInfoSize > 0 ? anElements[0].toString() : QVariant(); // AIS name
+ case 5: return anInfoSize > 3 ? anElements[3].toString() : QVariant(); // owner info
+ default: break;
+ }
+ return QVariant();
+}
+
+// =======================================================================
+// function : rowCount
+// purpose :
+// =======================================================================
+int VInspector_ItemHistoryType::initRowCount() const
+{
+ VInspector_ItemHistoryRootPtr aParentItem = itemDynamicCast<VInspector_ItemHistoryRoot>(Parent());
+ const VInspector_ItemHistoryTypeInfo& aTypeInfo = aParentItem->GetTypeInfo(Row());
+ return aTypeInfo.myElements.size();
+}
+
+// =======================================================================
+// function : createChild
+// purpose :
+// =======================================================================
+TreeModel_ItemBasePtr VInspector_ItemHistoryType::createChild (int theRow, int theColumn)
+{
+ return VInspector_ItemHistoryElement::CreateItem (currentItem(), theRow, theColumn);
+}
+
+// =======================================================================
+// function : initItem
+// purpose :
+// =======================================================================
+void VInspector_ItemHistoryType::initItem() const
+{
+ if (IsInitialized())
+ return;
+ const_cast<VInspector_ItemHistoryType*>(this)->Init();
+ // an empty method to don't initialize the main label, as it was not cleared in Reset()
+}
--- /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 VInspector_ItemHistoryType_H
+#define VInspector_ItemHistoryType_H
+
+#include <Standard.hxx>
+#include <VInspector_ItemBase.hxx>
+
+class VInspector_ItemHistoryType;
+typedef QExplicitlySharedDataPointer<VInspector_ItemHistoryType> VInspector_ItemHistoryTypePtr;
+
+//! \class VInspector_ItemHistoryType
+//! Item to show history type. Also it shows the element information of the first sub-item
+//! Parent is item history root item, children are item history elements
+class VInspector_ItemHistoryType : public VInspector_ItemBase
+{
+
+public:
+
+ //! Creates an item wrapped by a shared pointer
+ static VInspector_ItemHistoryTypePtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ { return VInspector_ItemHistoryTypePtr (new VInspector_ItemHistoryType (theParent, theRow, theColumn)); }
+
+ //! Destructor
+ virtual ~VInspector_ItemHistoryType() Standard_OVERRIDE {};
+
+ //! Returns the pointer info of the first child item, initialize item if it has not been initialized yet.
+ Standard_EXPORT QString PointerInfo() const;
+
+ //! Returns the owner info of the first child item, initialize item if it has not been initialized yet.
+ Standard_EXPORT QString OwnerInfo() const;
+
+protected:
+
+ //! Return data value for the role.
+ //! \param theRole a value role
+ //! \return the value
+ virtual QVariant initValue(const int theRole) const;
+
+ //! \return number of children.
+ virtual int initRowCount() const Standard_OVERRIDE;
+
+ //! Initialize the current item. It is empty because Reset() is also empty.
+ virtual void initItem() const Standard_OVERRIDE;
+
+protected:
+
+ //! Creates a child item in the given position.
+ //! \param theRow the child row position
+ //! \param theColumn the child column position
+ //! \return the created item
+ virtual TreeModel_ItemBasePtr createChild(int theRow, int theColumn) Standard_OVERRIDE;
+
+private:
+
+ //! Constructor
+ //! param theParent a parent item
+ VInspector_ItemHistoryType(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ : VInspector_ItemBase(theParent, theRow, theColumn) {}
+
+};
+
+#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.
+
+#ifndef VInspector_ItemHistoryTypeInfo_H
+#define VInspector_ItemHistoryTypeInfo_H
+
+#include <VInspector_CallBackMode.hxx>
+
+//! \class VInspector_ItemHistoryTypeInfo
+//! History info for a type item. It contains container of information for the element
+struct VInspector_ItemHistoryTypeInfo
+{
+
+ //! Constructor
+ VInspector_ItemHistoryTypeInfo() : myMode(VInspector_CallBackMode_None) {}
+
+ //! Destructor
+ VInspector_ItemHistoryTypeInfo (const VInspector_CallBackMode& theMode, const QList<QVariant>& theInfo)
+ : myMode(theMode) { AddElement(theInfo); }
+
+ //! Append new element
+ //! \param theInfo an information element
+ void AddElement (const QList<QVariant>& theInfo) { myElements.append(theInfo); }
+
+ VInspector_CallBackMode myMode; //!< history element mode
+ QList<QList<QVariant>> myElements; //!< container of elements information
+};
+
+#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 <VInspector_ItemPresentableObject.hxx>
+
+#include <AIS_Shape.hxx>
+#include <AIS_ListOfInteractive.hxx>
+#include <AIS_ListIteratorOfListOfInteractive.hxx>
+#include <VInspector_ItemContext.hxx>
+#include <VInspector_ItemEntityOwner.hxx>
+#include <VInspector_ItemSelection.hxx>
+#include <VInspector_Tools.hxx>
+#include <VInspector_ViewModel.hxx>
+
+#include <NCollection_List.hxx>
+#include <Prs3d.hxx>
+#include <Prs3d_Drawer.hxx>
+#include <SelectBasics_EntityOwner.hxx>
+#include <StdSelect_BRepOwner.hxx>
+#include <Standard_Version.hxx>
+
+#include <QColor>
+#include <QItemSelectionModel>
+
+// =======================================================================
+// function : initValue
+// purpose :
+// =======================================================================
+QVariant VInspector_ItemPresentableObject::initValue (int theItemRole) const
+{
+ if (theItemRole == Qt::DisplayRole || theItemRole == Qt::ToolTipRole)
+ {
+ Handle(AIS_InteractiveObject) anIO = GetInteractiveObject();
+ bool aNullIO = anIO.IsNull();
+ switch (Column())
+ {
+ case 0:
+ {
+ if (aNullIO)
+ return theItemRole == Qt::ToolTipRole ? QVariant ("Owners where Selectable is empty")
+ : QVariant ("Free Owners");
+ else
+ return theItemRole == Qt::ToolTipRole ? QVariant ("")
+ : QVariant (anIO->DynamicType()->Name());
+ }
+ case 1:
+ return rowCount();
+ case 2:
+ {
+ if (!aNullIO)
+ return VInspector_Tools::GetPointerInfo (anIO, true).ToCString();
+ break;
+ }
+ case 3:
+ {
+ Handle(AIS_Shape) aShapeIO = Handle(AIS_Shape)::DownCast (anIO);
+ if (!aShapeIO.IsNull())
+ {
+ const TopoDS_Shape& aShape = aShapeIO->Shape();
+ if (!aShape.IsNull())
+ return VInspector_Tools::GetShapeTypeInfo (aShape.ShapeType()).ToCString();
+ }
+ break;
+ }
+ case 4:
+ {
+ if (theItemRole == Qt::ToolTipRole)
+ return "SelectedOwners";
+ else
+ {
+ Handle(AIS_InteractiveContext) aContext = GetContext();
+ int aCount = VInspector_Tools::SelectedOwners (aContext, anIO, false);
+ if (aCount > 0)
+ return aCount;
+ }
+ break;
+ }
+ case 8:
+ {
+ if (theItemRole == Qt::ToolTipRole)
+ return QString ("%1 / %2 / %3").arg ("OwnDeviationCoefficient")
+ .arg ("ShapeDeflection")
+ .arg ("IsAutoTriangulation");
+ else
+ {
+ double aDeviationCoefficient = 0;
+ Handle(AIS_Shape) anAISShape = Handle(AIS_Shape)::DownCast (anIO);
+ if (!anAISShape.IsNull())
+ {
+ Standard_Real aPreviousCoefficient;
+ anAISShape->OwnDeviationCoefficient(aDeviationCoefficient, aPreviousCoefficient);
+ }
+ double aShapeDeflection = 0;
+ Handle(AIS_Shape) aShapeIO = Handle(AIS_Shape)::DownCast (anIO);
+ if (!aShapeIO.IsNull())
+ {
+ const TopoDS_Shape& aShape = aShapeIO->Shape();
+ if (!aShape.IsNull())
+ aShapeDeflection = Prs3d::GetDeflection(aShape, anIO->Attributes());
+ }
+ bool anIsAutoTriangulation = anIO->Attributes()->IsAutoTriangulation();
+ return QString ("%1 / %2 / %3").arg (aDeviationCoefficient)
+ .arg (aShapeDeflection)
+ .arg (anIsAutoTriangulation);
+ }
+ break;
+ }
+ default: break;
+ }
+ }
+ if (theItemRole == Qt::BackgroundRole || theItemRole == Qt::ForegroundRole)
+ {
+ Handle(AIS_InteractiveContext) aContext = GetContext();
+ if (Column() == 2 && VInspector_Tools::SelectedOwners(aContext, GetInteractiveObject(), false) > 0)
+ {
+ return (theItemRole == Qt::BackgroundRole) ? QColor(Qt::darkBlue) : QColor(Qt::white);
+ }
+ else if (theItemRole == Qt::ForegroundRole)
+ {
+ Handle(AIS_InteractiveObject) anIO = GetInteractiveObject();
+ if (anIO.IsNull())
+ return QVariant();
+
+ AIS_ListOfInteractive aListOfIO;
+ GetContext()->ErasedObjects(aListOfIO);
+ for (AIS_ListIteratorOfListOfInteractive anIOIt(aListOfIO); anIOIt.More(); anIOIt.Next())
+ {
+ if (anIO == anIOIt.Value())
+ return QColor(Qt::darkGray);
+ }
+ return QColor(Qt::black);
+ }
+ }
+ return QVariant();
+}
+
+// =======================================================================
+// function : initRowCount
+// purpose :
+// =======================================================================
+int VInspector_ItemPresentableObject::initRowCount() const
+{
+ int aRows = 0;
+ Handle(AIS_InteractiveObject) anIO = GetInteractiveObject();
+ if (anIO.IsNull())
+ return aRows;
+ // iteration through sensitive privitives
+ for (anIO->Init(); anIO->More(); anIO->Next())
+ aRows++;
+
+ return aRows;
+}
+
+// =======================================================================
+// function : createChild
+// purpose :
+// =======================================================================
+TreeModel_ItemBasePtr VInspector_ItemPresentableObject::createChild (int theRow, int theColumn)
+{
+ return VInspector_ItemSelection::CreateItem(currentItem(), theRow, theColumn);
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void VInspector_ItemPresentableObject::Init()
+{
+ VInspector_ItemContextPtr aParentItem = itemDynamicCast<VInspector_ItemContext>(Parent());
+ Handle(AIS_InteractiveContext) aContext = aParentItem->GetContext();
+ SetContext (aContext);
+
+ Handle(AIS_InteractiveObject) anIO;
+ if (!GetContext().IsNull())
+ {
+ int aRowId = Row();
+ AIS_ListOfInteractive aListOfIO;
+ GetContext()->DisplayedObjects (aListOfIO); // the presentation is in displayed objects of Context
+ GetContext()->ErasedObjects (aListOfIO); // the presentation is in erased objects of Context
+ int aCurrentIndex = 0;
+ for (AIS_ListIteratorOfListOfInteractive anIOIt (aListOfIO); anIOIt.More(); anIOIt.Next(), aCurrentIndex++)
+ {
+ if (aCurrentIndex != aRowId)
+ continue;
+ anIO = anIOIt.Value();
+ break;
+ }
+ }
+
+ setInteractiveObject (anIO);
+ TreeModel_ItemBase::Init(); // to use getIO() without circling initialization
+}
+
+// =======================================================================
+// function : Reset
+// purpose :
+// =======================================================================
+void VInspector_ItemPresentableObject::Reset()
+{
+ VInspector_ItemBase::Reset();
+
+ SetContext (NULL);
+ setInteractiveObject (NULL);
+}
+
+// =======================================================================
+// function : initItem
+// purpose :
+// =======================================================================
+void VInspector_ItemPresentableObject::initItem() const
+{
+ if (IsInitialized())
+ return;
+ const_cast<VInspector_ItemPresentableObject*>(this)->Init();
+}
+
+// =======================================================================
+// function : GetInteractiveObject
+// purpose :
+// =======================================================================
+Handle(AIS_InteractiveObject) VInspector_ItemPresentableObject::GetInteractiveObject() const
+{
+ initItem();
+ return myIO;
+}
+
+// =======================================================================
+// function : PointerInfo
+// purpose :
+// =======================================================================
+QString VInspector_ItemPresentableObject::PointerInfo() const
+{
+ return VInspector_Tools::GetPointerInfo (GetInteractiveObject(), true).ToCString();
+}
+
+// =======================================================================
+// function : GetSelectedPresentations
+// purpose :
+// =======================================================================
+NCollection_List<Handle(AIS_InteractiveObject)> VInspector_ItemPresentableObject::GetSelectedPresentations
+ (QItemSelectionModel* theSelectionModel)
+{
+ NCollection_List<Handle(AIS_InteractiveObject)> aResultList;
+ if (!theSelectionModel)
+ return aResultList;
+
+ QList<TreeModel_ItemBasePtr> anItems;
+
+ QModelIndexList anIndices = theSelectionModel->selectedIndexes();
+ for (QModelIndexList::const_iterator anIndicesIt = anIndices.begin(); anIndicesIt != anIndices.end(); anIndicesIt++)
+ {
+ TreeModel_ItemBasePtr anItem = TreeModel_ModelBase::GetItemByIndex (*anIndicesIt);
+ if (!anItem || anItems.contains (anItem))
+ continue;
+ anItems.append (anItem);
+ }
+
+ QList<size_t> aSelectedIds; // Remember of selected address in order to avoid duplicates
+ for (QList<TreeModel_ItemBasePtr>::const_iterator anItemIt = anItems.begin(); anItemIt != anItems.end(); anItemIt++)
+ {
+ TreeModel_ItemBasePtr anItem = *anItemIt;
+ VInspector_ItemPresentableObjectPtr aPrsItem = itemDynamicCast<VInspector_ItemPresentableObject>(anItem);
+ if (!aPrsItem)
+ continue;
+ Handle(AIS_InteractiveObject) aPresentation = aPrsItem->GetInteractiveObject();
+ if (aSelectedIds.contains ((size_t)aPresentation.operator->()))
+ continue;
+ aSelectedIds.append ((size_t)aPresentation.operator->());
+ if (!aPresentation.IsNull())
+ aResultList.Append (aPresentation);
+ }
+ return aResultList;
+}
--- /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 VInspector_ItemPresentableObject_H
+#define VInspector_ItemPresentableObject_H
+
+#include <Standard.hxx>
+#include <VInspector_ItemBase.hxx>
+
+#include <AIS_InteractiveObject.hxx>
+#include <NCollection_List.hxx>
+
+class QItemSelectionModel;
+
+class VInspector_ItemPresentableObject;
+typedef QExplicitlySharedDataPointer<VInspector_ItemPresentableObject> VInspector_ItemPresentableObjectPtr;
+
+//! \class VInspector_ItemPresentableObject
+//! Item presents information about AIS_InteractiveObject.
+//! Parent is item context, children are item selections.
+class VInspector_ItemPresentableObject : public VInspector_ItemBase
+{
+
+public:
+
+ //! Creates an item wrapped by a shared pointer
+ static VInspector_ItemPresentableObjectPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ { return VInspector_ItemPresentableObjectPtr (new VInspector_ItemPresentableObject (theParent, theRow, theColumn)); }
+ //! Destructor
+ virtual ~VInspector_ItemPresentableObject() Standard_OVERRIDE {};
+
+ //! Returns the current interactive object, init item if it was not initialized yet
+ //! \return interactive object
+ Standard_EXPORT Handle(AIS_InteractiveObject) GetInteractiveObject() const;
+
+ //! Returns pointer information for the current interactive object, init item if it was not initialized yet
+ //! \return string value
+ Standard_EXPORT QString PointerInfo() const;
+
+ //! Inits the item, fills internal containers
+ Standard_EXPORT virtual void Init() Standard_OVERRIDE;
+
+ //! Resets cached values
+ Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
+
+ //! Returns presentations, which items are selected in tree view
+ //! \param theSelectionModel a selection model
+ //! \return container of presentations
+ Standard_EXPORT static NCollection_List<Handle(AIS_InteractiveObject)> GetSelectedPresentations
+ (QItemSelectionModel* theSelectionModel);
+
+protected:
+
+ //! Initialize the current item. It is empty because Reset() is also empty.
+ virtual void initItem() const Standard_OVERRIDE;
+
+ //! Returns number of item selected
+ //! \return rows count
+ virtual int initRowCount() const Standard_OVERRIDE;
+
+ //! Returns item information for the given role. Fills internal container if it was not filled yet
+ //! \param theItemRole a value role
+ //! \return the value
+ virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
+
+ //! Creates a child item in the given position.
+ //! \param theRow the child row position
+ //! \param theColumn the child column position
+ //! \return the created item
+ virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
+
+private:
+
+ //! Set interactive object into the current field
+ //! \param theIO a presentation
+ void setInteractiveObject (Handle(AIS_InteractiveObject) theIO) { myIO = theIO; }
+
+private:
+
+ //! Constructor
+ //! param theParent a parent item
+ VInspector_ItemPresentableObject(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ : VInspector_ItemBase(theParent, theRow, theColumn) {}
+
+protected:
+
+ Handle(AIS_InteractiveObject) myIO; //!< the current interactive context
+};
+
+#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 <VInspector_ItemSelection.hxx>
+
+#include <AIS_ListOfInteractive.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <SelectMgr_Selection.hxx>
+#include <SelectMgr_SensitiveEntity.hxx>
+#include <VInspector_ItemContext.hxx>
+#include <VInspector_ItemPresentableObject.hxx>
+#include <VInspector_ItemSensitiveEntity.hxx>
+#include <VInspector_Tools.hxx>
+
+#include <QStringList>
+
+#include <QColor>
+
+// =======================================================================
+// function : getSelection
+// purpose :
+// =======================================================================
+Handle(SelectMgr_Selection) VInspector_ItemSelection::getSelection() const
+{
+ initItem();
+ return mySelection;
+}
+
+// =======================================================================
+// function : initRowCount
+// purpose :
+// =======================================================================
+int VInspector_ItemSelection::initRowCount() const
+{
+ int aRows = 0;
+ Handle(SelectMgr_Selection) aSelection = getSelection();
+ for (aSelection->Init(); aSelection->More(); aSelection->Next())
+ aRows++;
+
+ return aRows;
+}
+
+// =======================================================================
+// function : initValue
+// purpose :
+// =======================================================================
+QVariant VInspector_ItemSelection::initValue (int theItemRole) const
+{
+ switch (theItemRole)
+ {
+ case Qt::DisplayRole:
+ case Qt::EditRole:
+ case Qt::ToolTipRole:
+ {
+ switch (Column())
+ {
+ case 0: return getSelection()->DynamicType()->Name();
+ case 1: return rowCount();
+ case 3:
+ {
+ if (theItemRole == Qt::ToolTipRole)
+ return "Mode";
+ else
+ {
+ VInspector_ItemPresentableObjectPtr aParentItem = itemDynamicCast<VInspector_ItemPresentableObject>(Parent());
+ return VInspector_Tools::SelectionModeToName(getSelection()->Mode(), aParentItem->GetInteractiveObject()).ToCString();
+ }
+ }
+ case 4:
+ {
+ if (theItemRole == Qt::ToolTipRole)
+ return "SelectMgr_StateOfSelection";
+ else {
+ int aNbSelected = 0;
+ SelectMgr_StateOfSelection aState = getSelection()->GetSelectionState();
+ if (aState == SelectMgr_SOS_Activated || aState == SelectMgr_SOS_Any)
+ {
+ Handle(AIS_InteractiveContext) aContext = GetContext();
+ for (mySelection->Init(); mySelection->More(); mySelection->Next())
+ {
+ const Handle(SelectBasics_EntityOwner)& anOwner = mySelection->Sensitive()->BaseSensitive()->OwnerId();
+ if (VInspector_Tools::IsOwnerSelected(aContext, anOwner))
+ aNbSelected++;
+ }
+ }
+ QString aStateValue = VInspector_Tools::ToName (VInspector_SelectionType_StateOfSelection, aState).ToCString();
+ return QVariant (aNbSelected > 0 ? QString ("%1 : %2").arg (aStateValue).arg (aNbSelected) : aStateValue);
+ }
+ }
+ case 6: return theItemRole == Qt::ToolTipRole ? "Sensitivity" : QString::number (getSelection()->Sensitivity());
+ case 8:
+ {
+ if (theItemRole == Qt::ToolTipRole)
+ return QString ("%1 / %2").arg ("SelectMgr_TypeOfUpdate").arg ("SelectMgr_TypeOfBVHUpdate");
+ else
+ return QString ("%1 / %2").arg (VInspector_Tools::ToName (VInspector_SelectionType_TypeOfUpdate,
+ getSelection()->UpdateStatus()).ToCString())
+ .arg (VInspector_Tools::ToName (VInspector_SelectionType_TypeOfBVHUpdate,
+ getSelection()->BVHUpdateStatus()).ToCString());
+ }
+ default:
+ break;
+ }
+ break;
+ }
+ case Qt::ForegroundRole:
+ {
+ SelectMgr_StateOfSelection aState = getSelection()->GetSelectionState();
+ return QVariant (aState == SelectMgr_SOS_Activated ? QColor (Qt::black) : QColor (Qt::darkGray));
+ }
+ }
+ return QVariant();
+}
+
+// =======================================================================
+// function : createChild
+// purpose :
+// =======================================================================
+TreeModel_ItemBasePtr VInspector_ItemSelection::createChild (int theRow, int theColumn)
+{
+ return VInspector_ItemSensitiveEntity::CreateItem (currentItem(), theRow, theColumn);
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void VInspector_ItemSelection::Init()
+{
+ VInspector_ItemPresentableObjectPtr aParentItem = itemDynamicCast<VInspector_ItemPresentableObject>(Parent());
+
+ Handle(AIS_InteractiveObject) anIO = aParentItem->GetInteractiveObject();
+
+ int aRowId = Row();
+ int aCurrentId = 0;
+ for (anIO->Init(); anIO->More(); anIO->Next(), aCurrentId++)
+ {
+ if (aCurrentId != aRowId)
+ continue;
+ mySelection = anIO->CurrentSelection();
+ break;
+ }
+ TreeModel_ItemBase::Init();
+}
+
+// =======================================================================
+// function : Reset
+// purpose :
+// =======================================================================
+void VInspector_ItemSelection::Reset()
+{
+ // an empty method to don't clear the main label, otherwise the model will be empty
+ TreeModel_ItemBase::Reset();
+
+ mySelection = NULL;
+}
+
+// =======================================================================
+// function : initItem
+// purpose :
+// =======================================================================
+void VInspector_ItemSelection::initItem() const
+{
+ if (IsInitialized())
+ return;
+ const_cast<VInspector_ItemSelection*>(this)->Init();
+ // an empty method to don't initialize the main label, as it was not cleared in Reset()
+}
--- /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 VInspector_ItemSelection_H
+#define VInspector_ItemSelection_H
+
+#include <Standard.hxx>
+#include <VInspector_ItemBase.hxx>
+
+#include <SelectMgr_Selection.hxx>
+
+class VInspector_ItemSelection;
+typedef QExplicitlySharedDataPointer<VInspector_ItemSelection> VInspector_ItemSelectionPtr;
+
+//! \class VInspector_ItemSelection
+//! Item about SelectMgr_Selection.
+//! Parent is presentable object item, children are sensitive entity items
+class VInspector_ItemSelection : public VInspector_ItemBase
+{
+public:
+
+ //! Creates an item wrapped by a shared pointer
+ static VInspector_ItemSelectionPtr CreateItem(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ { return VInspector_ItemSelectionPtr (new VInspector_ItemSelection (theParent, theRow, theColumn)); }
+
+ //! Destructor
+ virtual ~VInspector_ItemSelection() {};
+
+ //! \return current selection value
+ Standard_EXPORT Handle(SelectMgr_Selection) getSelection() const;
+
+ //! Inits the item, fills internal containers
+ Standard_EXPORT virtual void Init() Standard_OVERRIDE;
+
+ //! Resets cached values
+ Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
+
+protected:
+
+ //! Initializes the current item. It is empty because Reset() is also empty.
+ virtual void initItem() const Standard_OVERRIDE;
+
+ //! Initializes number of children
+ //! \return integer value
+ virtual int initRowCount() const Standard_OVERRIDE;
+
+ //! Returns item information for the given role. Fills internal container if it was not filled yet
+ //! \param theItemRole a value role
+ //! \return the value
+ virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
+
+protected:
+
+ //! Creates a child item in the given position.
+ //! \param theRow the child row position
+ //! \param theColumn the child column position
+ //! \return the created item
+ virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
+
+private:
+
+ //! Constructor
+ //! param theParent a parent item
+ VInspector_ItemSelection(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ : VInspector_ItemBase(theParent, theRow, theColumn) {}
+
+private:
+
+ Handle(SelectMgr_Selection) mySelection; //!< the current selection
+};
+
+#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 <VInspector_ItemSensitiveEntity.hxx>
+
+#include <AIS_ListOfInteractive.hxx>
+#include <SelectBasics_SensitiveEntity.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <SelectMgr_Selection.hxx>
+#include <SelectMgr_SensitiveEntity.hxx>
+#include <Standard_Version.hxx>
+#include <StdSelect_BRepOwner.hxx>
+#include <TopoDS_Shape.hxx>
+#include <VInspector_ItemContext.hxx>
+#include <VInspector_ItemEntityOwner.hxx>
+#include <VInspector_ItemSelection.hxx>
+#include <VInspector_Tools.hxx>
+
+#include <QStringList>
+#include <QColor>
+
+// =======================================================================
+// function : GetSensitiveEntity
+// purpose :
+// =======================================================================
+Handle(SelectMgr_SensitiveEntity) VInspector_ItemSensitiveEntity::GetSensitiveEntity() const
+{
+ initItem();
+ return myEntity;
+}
+
+// =======================================================================
+// function : initValue
+// purpose :
+// =======================================================================
+QVariant VInspector_ItemSensitiveEntity::initValue (int theItemRole) const
+{
+ Handle(SelectMgr_SensitiveEntity) aBase = GetSensitiveEntity();
+ Handle(SelectBasics_EntityOwner) anOwner = aBase->BaseSensitive()->OwnerId();
+
+ switch (theItemRole)
+ {
+ case Qt::DisplayRole:
+ case Qt::EditRole:
+ case Qt::ToolTipRole:
+ {
+ switch (Column())
+ {
+ case 0:
+ return myEntity->DynamicType()->Name();
+ case 2:
+ {
+ return theItemRole == Qt::ToolTipRole ? "Owner pointer" : VInspector_Tools::GetPointerInfo (
+ GetSensitiveEntity()->BaseSensitive()->OwnerId(), true).ToCString();
+ }
+ case 3:
+ {
+ if (theItemRole == Qt::ToolTipRole)
+ return "Owner Shape type";
+ else
+ {
+ Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast (anOwner);
+ if (!BROwnr.IsNull())
+ {
+ const TopoDS_Shape& aShape = BROwnr->Shape();
+ if (!aShape.IsNull())
+ return VInspector_Tools::GetShapeTypeInfo (aShape.ShapeType()).ToCString();
+ }
+ }
+ break;
+ }
+ case 4: return theItemRole == Qt::ToolTipRole ? "IsActiveForSelection"
+#if OCC_VERSION_HEX <= 0x060901
+ : ("none");
+#else
+ : myEntity->IsActiveForSelection() ? QString ("true") : QString ("false");
+#endif
+ case 5: return theItemRole == Qt::ToolTipRole ? "SelectBasics_SensitiveEntity"
+ : getEntityOwner()->DynamicType()->Name();
+ case 6: return theItemRole == Qt::ToolTipRole ? "SensitivityFactor"
+ : QString::number (GetSensitiveEntity()->BaseSensitive()->SensitivityFactor());
+ case 7: return theItemRole == Qt::ToolTipRole ? "NbSubElements"
+ : QString::number (GetSensitiveEntity()->BaseSensitive()->NbSubElements());
+ case 8:
+ {
+ if (theItemRole == Qt::ToolTipRole)
+ return "Owner priority";
+ else
+ {
+ Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast (anOwner);
+ if (!BROwnr.IsNull())
+ return anOwner->Priority();
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ break;
+ }
+ case Qt::BackgroundRole:
+ case Qt::ForegroundRole:
+ {
+ if (Column() == 2)
+ {
+ Handle(AIS_InteractiveContext) aContext = GetContext();
+ if (!aContext.IsNull())
+ {
+ if (VInspector_Tools::IsOwnerSelected(aContext, getEntityOwner()))
+ return QVariant ((theItemRole == Qt::BackgroundRole) ? QColor (Qt::darkBlue) : QColor (Qt::white));
+ }
+ }
+ VInspector_ItemSelectionPtr aParentItem = itemDynamicCast<VInspector_ItemSelection>(Parent());
+ if (aParentItem)
+ return aParentItem->data(QModelIndex(), theItemRole);
+ break;
+ }
+ default:
+ break;
+ }
+ return QVariant();
+}
+
+// =======================================================================
+// function : createChild
+// purpose :
+// =======================================================================
+TreeModel_ItemBasePtr VInspector_ItemSensitiveEntity::createChild (int theRow, int theColumn)
+{
+ return VInspector_ItemEntityOwner::CreateItem (currentItem(), theRow, theColumn);
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void VInspector_ItemSensitiveEntity::Init()
+{
+ VInspector_ItemSelectionPtr aParentItem = itemDynamicCast<VInspector_ItemSelection>(Parent());
+
+ Handle(SelectMgr_Selection) aSelection = aParentItem->getSelection();
+
+ int aRowId = Row();
+ int aCurrentId = 0;
+ for (aSelection->Init(); aSelection->More(); aSelection->Next(), aCurrentId++)
+ {
+ if (aCurrentId != aRowId)
+ continue;
+ myEntity = aSelection->Sensitive();
+ break;
+ }
+ TreeModel_ItemBase::Init();
+}
+
+// =======================================================================
+// function : Reset
+// purpose :
+// =======================================================================
+void VInspector_ItemSensitiveEntity::Reset()
+{
+ // an empty method to don't clear the main label, otherwise the model will be empty
+ TreeModel_ItemBase::Reset();
+ myEntity = NULL;
+}
+
+// =======================================================================
+// function : initItem
+// purpose :
+// =======================================================================
+void VInspector_ItemSensitiveEntity::initItem() const
+{
+ if (IsInitialized())
+ return;
+ const_cast<VInspector_ItemSensitiveEntity*>(this)->Init();
+}
+
+// =======================================================================
+// function : getEntityOwner
+// purpose :
+// =======================================================================
+Handle(SelectBasics_EntityOwner) VInspector_ItemSensitiveEntity::getEntityOwner() const
+{
+ initItem();
+
+ Handle(SelectBasics_EntityOwner) anOwner;
+ const Handle(SelectBasics_SensitiveEntity)& aBase = myEntity->BaseSensitive();
+ if (aBase.IsNull())
+ return anOwner;
+ return aBase->OwnerId();
+}
--- /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 VInspector_ItemSensitiveEntity_H
+#define VInspector_ItemSensitiveEntity_H
+
+#include <SelectMgr_SensitiveEntity.hxx>
+#include <SelectBasics_SensitiveEntity.hxx>
+#include <Standard.hxx>
+#include <VInspector_ItemBase.hxx>
+
+class SelectBasics_EntityOwner;
+class VInspector_ItemSensitiveEntity;
+
+typedef QExplicitlySharedDataPointer<VInspector_ItemSensitiveEntity> VInspector_ItemSensitiveEntityPtr;
+
+//! \class VInspector_ItemSensitiveEntity
+//! The item shows information about SelectBasics_EntityOwner.
+//! The parent is item selection, children are item entity owners
+class VInspector_ItemSensitiveEntity : public VInspector_ItemBase
+{
+
+public:
+
+ //! Creates an item wrapped by a shared pointer
+ static VInspector_ItemSensitiveEntityPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ { return VInspector_ItemSensitiveEntityPtr (new VInspector_ItemSensitiveEntity (theParent, theRow, theColumn)); }
+
+ //! Destructor
+ virtual ~VInspector_ItemSensitiveEntity() Standard_OVERRIDE {};
+
+ //! \return the current sensitive entity
+ Standard_EXPORT Handle(SelectMgr_SensitiveEntity) GetSensitiveEntity() const;
+
+ //! Inits the item, fills internal containers
+ Standard_EXPORT virtual void Init() Standard_OVERRIDE;
+
+ //! Resets cached values
+ Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
+
+protected:
+
+ //! Initialize the current item. It is empty because Reset() is also empty.
+ virtual void initItem() const Standard_OVERRIDE;
+
+ //! \return number of children.
+ virtual int initRowCount() const Standard_OVERRIDE { return !GetSensitiveEntity()->BaseSensitive().IsNull() ? 1 : 0; }
+
+ //! Returns item information for the given role. Fills internal container if it was not filled yet
+ //! \param theItemRole a value role
+ //! \return the value
+ virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
+
+protected:
+
+ //! Creates a child item in the given position.
+ //! \param theRow the child row position
+ //! \param theColumn the child column position
+ //! \return the created item
+ virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
+
+ //! Returns owner of the current sensitive entity
+ //! \return owner
+ Handle(SelectBasics_EntityOwner) getEntityOwner() const;
+
+private:
+
+ //! Constructor
+ //! param theParent a parent item
+ VInspector_ItemSensitiveEntity(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ : VInspector_ItemBase(theParent, theRow, theColumn) {}
+
+private:
+
+ Handle(SelectMgr_SensitiveEntity) myEntity; //!< the current entity owner
+};
+
+#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.
+
+#ifndef VInspector_SelectionType_H
+#define VInspector_SelectionType_H
+
+//! Type of SelectMgr enumeration types
+enum VInspector_SelectionType
+{
+ VInspector_SelectionType_TypeOfUpdate, //!< Values of SelectMgr_TypeOfUpdate
+ VInspector_SelectionType_StateOfSelection, //!< Values of SelectMgr_StateOfSelection
+ VInspector_SelectionType_TypeOfBVHUpdate //!< Values of SelectMgr_TypeOfBVHUpdate
+};
+
+#endif
+
\ 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.
+
+#ifndef VInspector_ToolActionType_H
+#define VInspector_ToolActionType_H
+
+//! \enum VInspector_ToolActionType
+enum VInspector_ToolActionType
+{
+ VInspector_ToolActionType_NoneId, //!< No action activated
+ VInspector_ToolActionType_UpdateId, //!< Update content of tree view (content of AIS_InteractiveContext)
+ VInspector_ToolActionType_SelectPresentationsId, //!< Selects presentation in context by selection in tree view
+ VInspector_ToolActionType_SelectOwnersId //!< Selects owners in context by selection in tree view
+};
+
+#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 <VInspector_ToolBar.hxx>
+
+#include <QHBoxLayout>
+#include <QToolButton>
+#include <QWidget>
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+VInspector_ToolBar::VInspector_ToolBar (QWidget* theParent)
+: QObject (theParent)
+{
+ myActionsMap[VInspector_ToolActionType_UpdateId] = new QToolButton (theParent);
+ myActionsMap[VInspector_ToolActionType_UpdateId]->setText ("Update");
+
+ myActionsMap[VInspector_ToolActionType_SelectPresentationsId] = new QToolButton (theParent);
+ myActionsMap[VInspector_ToolActionType_SelectPresentationsId]->setText ("Select Presentations");
+ myActionsMap[VInspector_ToolActionType_SelectPresentationsId]->setCheckable (true);
+
+ myActionsMap[VInspector_ToolActionType_SelectOwnersId] = new QToolButton (theParent);
+ myActionsMap[VInspector_ToolActionType_SelectOwnersId]->setText ("Select Owners");
+ myActionsMap[VInspector_ToolActionType_SelectOwnersId]->setCheckable (true);
+
+ myMainWindow = new QWidget (theParent);
+
+ QHBoxLayout* aLay = new QHBoxLayout (myMainWindow);
+ for (QMap<VInspector_ToolActionType, QToolButton*>::ConstIterator anActionsIt = myActionsMap.begin();
+ anActionsIt != myActionsMap.end(); anActionsIt++)
+ {
+ QToolButton* aBtn = anActionsIt.value();
+ connect (aBtn, SIGNAL (clicked()), this, SLOT (onActionClicked()));
+ aLay->addWidget (aBtn);
+ }
+}
+
+// =======================================================================
+// function : GetToolButton
+// purpose :
+// =======================================================================
+QToolButton* VInspector_ToolBar::GetToolButton (const VInspector_ToolActionType& theActionId ) const
+{
+ return myActionsMap.contains (theActionId) ? myActionsMap[theActionId] : 0;
+}
+
+// =======================================================================
+// function : onActionClicked
+// purpose :
+// =======================================================================
+void VInspector_ToolBar::onActionClicked()
+{
+ int anId = -1;
+ QToolButton* aSenderBtn = (QToolButton*)sender();
+
+ for (QMap<VInspector_ToolActionType, QToolButton*>::ConstIterator anActionsIt = myActionsMap.begin();
+ anActionsIt != myActionsMap.end(); anActionsIt++)
+ {
+ if (anActionsIt.value() != aSenderBtn)
+ continue;
+ anId = anActionsIt.key();
+ break;
+ }
+
+ if (anId == VInspector_ToolActionType_SelectPresentationsId && myActionsMap[VInspector_ToolActionType_SelectOwnersId]->isChecked())
+ myActionsMap[VInspector_ToolActionType_SelectOwnersId]->setChecked(false);
+ else if (anId == VInspector_ToolActionType_SelectOwnersId && myActionsMap[VInspector_ToolActionType_SelectPresentationsId]->isChecked())
+ myActionsMap[VInspector_ToolActionType_SelectPresentationsId]->setChecked(false);
+
+ if (anId != -1)
+ emit actionClicked (anId);
+}
--- /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 VInspector_ToolBar_H
+#define VInspector_ToolBar_H
+
+#include <Standard.hxx>
+#include <Standard_Macro.hxx>
+#include <VInspector_ToolActionType.hxx>
+
+#ifdef _MSC_VER
+ #pragma warning(disable : 4127 4718) // conditional expression is constant, recursive call has no side effects
+#endif
+#include <QMap>
+#include <QObject>
+
+class QWidget;
+class QToolButton;
+
+//! \class VInspector_ToolBar
+//! Container of View tool bar actions
+class VInspector_ToolBar : public QObject
+{
+ Q_OBJECT
+
+public:
+
+ //! Constructor
+ Standard_EXPORT VInspector_ToolBar (QWidget* theParent);
+
+ //! Destructor
+ virtual ~VInspector_ToolBar() Standard_OVERRIDE {}
+
+ //! Returns main control
+ QWidget* GetControl() const { return myMainWindow; }
+
+ //! Returns tool button by action index
+ //! \param theActionId index of action
+ Standard_EXPORT QToolButton* GetToolButton (const VInspector_ToolActionType& theActionId) const;
+
+signals:
+
+ //! Signal about action click
+ //! \param theActionId an action index
+ void actionClicked (int theActionId);
+
+private slots:
+
+ //! Provides switch for action. Emits signal about action click
+ void onActionClicked();
+
+private:
+
+ QWidget* myMainWindow; //!< the main control
+ QMap<VInspector_ToolActionType, QToolButton*> myActionsMap; //!< container of type into button
+};
+
+#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 <VInspector_Tools.hxx>
+
+#include <AIS_ListIteratorOfListOfInteractive.hxx>
+#include <AIS_ListOfInteractive.hxx>
+#if OCC_VERSION_HEX < 0x060901
+#include <AIS_LocalContext.hxx>
+#endif
+#include <AIS_Selection.hxx>
+#include <AIS_Shape.hxx>
+#include <AIS_Trihedron.hxx>
+#include <BRep_Builder.hxx>
+#include <BRepTools.hxx>
+#include <gp_Trsf.hxx>
+#include <SelectMgr_StateOfSelection.hxx>
+#include <SelectMgr_TypeOfUpdate.hxx>
+#include <SelectMgr_TypeOfBVHUpdate.hxx>
+#include <Standard_Version.hxx>
+#include <StdSelect_BRepOwner.hxx>
+
+#include <QStringList>
+
+#include <sstream>
+
+// =======================================================================
+// function : GetShapeTypeInfo
+// purpose :
+// =======================================================================
+TCollection_AsciiString VInspector_Tools::GetShapeTypeInfo (const TopAbs_ShapeEnum& theType)
+{
+ Standard_SStream aSStream;
+ TopAbs::Print (theType, aSStream);
+ return aSStream.str().c_str();
+}
+
+// =======================================================================
+// function : GetPointerInfo
+// purpose :
+// =======================================================================
+TCollection_AsciiString VInspector_Tools::GetPointerInfo (const Handle(Standard_Transient)& thePointer, const bool isShortInfo)
+{
+ std::ostringstream aPtrStr;
+ aPtrStr << thePointer.operator->();
+ if (!isShortInfo)
+ return aPtrStr.str().c_str();
+
+ TCollection_AsciiString anInfoPtr (aPtrStr.str().c_str());
+ for (int aSymbolId = 1; aSymbolId < anInfoPtr.Length(); aSymbolId++)
+ {
+ if (anInfoPtr.Value(aSymbolId) != '0')
+ {
+ anInfoPtr = anInfoPtr.SubString(aSymbolId, anInfoPtr.Length());
+ anInfoPtr.Prepend("0x");
+ return anInfoPtr;
+ }
+ }
+ return aPtrStr.str().c_str();
+}
+
+// =======================================================================
+// function : SelectedOwners
+// purpose :
+// =======================================================================
+int VInspector_Tools::SelectedOwners (const Handle(AIS_InteractiveContext)& theContext,
+ const Handle(AIS_InteractiveObject)& theObject,
+ const bool theShapeInfoOnly)
+{
+ QStringList anObjects;
+ if (theContext.IsNull())
+ return 0;
+
+ QList<size_t> aSelectedIds; // Remember of selected address in order to avoid duplicates
+ for (theContext->InitSelected(); theContext->MoreSelected(); theContext->NextSelected())
+ {
+ Handle(SelectMgr_EntityOwner) anOwner = theContext->SelectedOwner();
+ if (anOwner.IsNull()) // TODO: check why it is possible
+ continue;
+
+ if (!theObject.IsNull())
+ {
+ Handle(AIS_InteractiveObject) anOwnerPresentation =
+ Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
+ if (anOwnerPresentation != theObject)
+ continue;
+ }
+ Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast (anOwner);
+ if (theShapeInfoOnly && BROwnr.IsNull())
+ continue;
+
+ Standard_Transient* anOwnerPtr = anOwner.operator->();
+ if (aSelectedIds.contains ((size_t)anOwnerPtr))
+ continue;
+ aSelectedIds.append ((size_t)anOwnerPtr);
+
+ anObjects.append (VInspector_Tools::GetPointerInfo (anOwnerPtr, true).ToCString());
+ }
+ return anObjects.size();
+}
+
+// =======================================================================
+// function : IsOwnerSelected
+// purpose :
+// =======================================================================
+bool VInspector_Tools::IsOwnerSelected (const Handle(AIS_InteractiveContext)& theContext,
+ const Handle(SelectBasics_EntityOwner)& theOwner)
+{
+ bool anIsSelected = false;
+ Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (theOwner);
+ for (theContext->InitSelected(); theContext->MoreSelected() && !anIsSelected; theContext->NextSelected())
+ anIsSelected = theContext->SelectedOwner() == anOwner;
+ return anIsSelected;
+}
+
+// =======================================================================
+// function : ContextOwners
+// purpose :
+// =======================================================================
+NCollection_List<Handle(SelectBasics_EntityOwner)> VInspector_Tools::ContextOwners (
+ const Handle(AIS_InteractiveContext)& theContext)
+{
+ NCollection_List<Handle(SelectBasics_EntityOwner)> aResultOwners;
+ if (theContext.IsNull())
+ return aResultOwners;
+
+ AIS_ListOfInteractive aListOfIO;
+ theContext->DisplayedObjects (aListOfIO);
+ QList<size_t> aSelectedIds; // Remember of selected address in order to avoid duplicates
+ for (AIS_ListIteratorOfListOfInteractive aIt(aListOfIO); aIt.More(); aIt.Next())
+ {
+ Handle(AIS_InteractiveObject) anIO = aIt.Value();
+ if (anIO.IsNull())
+ continue;
+ for (anIO->Init(); anIO->More(); anIO->Next())
+ {
+ Handle(SelectMgr_Selection) aSelection = anIO->CurrentSelection();
+ if (aSelection.IsNull())
+ continue;
+ for (aSelection->Init(); aSelection->More(); aSelection->Next())
+ {
+ Handle(SelectMgr_SensitiveEntity) anEntity = aSelection->Sensitive();
+ if (anEntity.IsNull())
+ continue;
+ const Handle(SelectBasics_SensitiveEntity)& aBase = anEntity->BaseSensitive();
+ Handle(SelectBasics_EntityOwner) anOwner = aBase->OwnerId();
+ Standard_Transient* anOwnerPtr = anOwner.operator->();
+ if (aSelectedIds.contains ((size_t)anOwnerPtr))
+ continue;
+ aSelectedIds.append ((size_t)anOwnerPtr);
+ aResultOwners.Append (anOwner);
+ }
+ }
+ }
+ return aResultOwners;
+}
+
+// =======================================================================
+// function : ActiveOwners
+// purpose :
+// =======================================================================
+NCollection_List<Handle(SelectBasics_EntityOwner)> VInspector_Tools::ActiveOwners (
+ const Handle(AIS_InteractiveContext)& theContext,
+ NCollection_List<Handle(SelectBasics_EntityOwner)>& theEmptySelectableOwners)
+{
+ NCollection_List<Handle(SelectBasics_EntityOwner)> aResultOwners;
+
+ // only local context is processed: TODO for global context
+ Handle(AIS_InteractiveContext) aContext = theContext;
+ if (aContext.IsNull())
+ return aResultOwners;
+ NCollection_List<Handle(SelectBasics_EntityOwner)> anActiveOwners;
+ // OCCT BUG:1 - equal pointer owners are appears in the list
+#if OCC_VERSION_HEX > 0x060901
+ aContext->MainSelector()->ActiveOwners (anActiveOwners);
+#else
+ anActiveOwners = aContext->MainSelector()->ActiveOwners();
+#endif
+ QList<size_t> aSelectedIds; // Remember of selected address in order to avoid duplicates
+ Handle(SelectMgr_EntityOwner) anOwner;
+ for (NCollection_List<Handle(SelectBasics_EntityOwner)>::Iterator anOwnersIt (anActiveOwners);
+ anOwnersIt.More(); anOwnersIt.Next())
+ {
+ anOwner = Handle(SelectMgr_EntityOwner)::DownCast (anOwnersIt.Value());
+ if (anOwner.IsNull())
+ continue;
+
+ Standard_Transient* anOwnerPtr = anOwner.operator->();
+ if (aSelectedIds.contains ((size_t)anOwnerPtr))
+ continue;
+ aSelectedIds.append ((size_t)anOwnerPtr);
+
+ aResultOwners.Append (anOwner);
+ Handle(SelectMgr_SelectableObject) aSelectable = anOwner->Selectable();
+ if (aSelectable.IsNull() ||
+ !theContext->IsDisplayed(Handle(AIS_InteractiveObject)::DownCast (aSelectable)))
+ theEmptySelectableOwners.Append (anOwner);
+ }
+ return aResultOwners;
+}
+
+// =======================================================================
+// function : AddOrRemoveSelectedShapes
+// purpose :
+// =======================================================================
+void VInspector_Tools::AddOrRemoveSelectedShapes (const Handle(AIS_InteractiveContext)& theContext,
+ const NCollection_List<Handle(SelectBasics_EntityOwner)>& theOwners)
+{
+ // TODO: the next two rows are to be removed later
+ theContext->UnhilightSelected(false);
+ theContext->ClearSelected(false);
+
+ theContext->UnhilightSelected(Standard_False);
+
+ //TODO: processing in local context only
+#if OCC_VERSION_HEX < 0x060901
+ Handle(AIS_LocalContext) aLContext = theContext->LocalContext();
+ TCollection_AsciiString aSelectionName = aLContext->SelectionName();
+ aLContext->UnhilightPicked(Standard_False);
+#endif
+
+ for (NCollection_List<Handle(SelectBasics_EntityOwner)>::Iterator anOwnersIt(theOwners);
+ anOwnersIt.More(); anOwnersIt.Next())
+ {
+ Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (anOwnersIt.Value());
+#if OCC_VERSION_HEX > 0x060901
+ theContext->AddOrRemoveSelected (anOwner, Standard_False);
+#else
+ AIS_Selection::Selection(aSelectionName.ToCString())->Select(anOwner);
+ anOwner->SetSelected(Standard_True);
+#endif
+ }
+ theContext->UpdateCurrentViewer();
+}
+
+// =======================================================================
+// function : AddOrRemovePresentations
+// purpose :
+// =======================================================================
+void VInspector_Tools::AddOrRemovePresentations (const Handle(AIS_InteractiveContext)& theContext,
+ const NCollection_List<Handle(AIS_InteractiveObject)>& thePresentations)
+{
+ // TODO: the next two rows are to be removed later
+ theContext->UnhilightSelected(false);
+ theContext->ClearSelected(false);
+
+ for (NCollection_List<Handle(AIS_InteractiveObject)>::Iterator anIOIt (thePresentations); anIOIt.More(); anIOIt.Next())
+ theContext->AddOrRemoveSelected (anIOIt.Value(), false);
+
+ theContext->UpdateCurrentViewer();
+}
+
+// =======================================================================
+// function : GetInfo
+// purpose :
+// =======================================================================
+QList<QVariant> VInspector_Tools::GetInfo (Handle(AIS_InteractiveObject)& theObject)
+{
+ QList<QVariant> anInfo;
+ anInfo.append (theObject->DynamicType()->Name());
+ anInfo.append (VInspector_Tools::GetPointerInfo (theObject, true).ToCString());
+
+ Handle(AIS_Shape) aShapeIO = Handle(AIS_Shape)::DownCast (theObject);
+ if (aShapeIO.IsNull())
+ return anInfo;
+
+ const TopoDS_Shape& aShape = aShapeIO->Shape();
+ if (!aShape.IsNull())
+ anInfo.append (VInspector_Tools::GetShapeTypeInfo (aShape.ShapeType()).ToCString());
+
+ return anInfo;
+}
+
+// =======================================================================
+// function : GetHighlightInfo
+// purpose :
+// =======================================================================
+QList<QVariant> VInspector_Tools::GetHighlightInfo (const Handle(AIS_InteractiveContext)& theContext)
+{
+ QList<QVariant> aValues;
+ if (theContext.IsNull())
+ return aValues;
+
+ QStringList aSelectedNames;
+ QStringList aSelectedPointers;
+ QStringList aSelectedTypes;
+ QStringList aSelectedOwners;
+ QList<size_t> aSelectedIds; // Remember of selected address in order to avoid duplicates
+ for (theContext->InitDetected(); theContext->MoreDetected(); theContext->NextDetected())
+ {
+ Handle(SelectMgr_EntityOwner) anOwner = theContext->DetectedOwner();
+ if (anOwner.IsNull())
+ continue;
+ Standard_Transient* anOwnerPtr = anOwner.operator->();
+ if (aSelectedIds.contains ((size_t)anOwnerPtr))
+ continue;
+ aSelectedIds.append ((size_t)anOwnerPtr);
+ Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
+ if (anIO.IsNull())
+ continue;
+ QList<QVariant> anIOInfo = VInspector_Tools::GetInfo (anIO);
+ if (anIOInfo.size() == 3)
+ {
+ aSelectedNames.append (anIOInfo[0].toString());
+ aSelectedPointers.append (anIOInfo[1].toString());
+ aSelectedTypes.append (anIOInfo[2].toString());
+ }
+ aSelectedOwners.append (VInspector_Tools::GetPointerInfo (anOwnerPtr, true).ToCString());
+ }
+ aValues.append (aSelectedNames.join (", "));
+ aValues.append (aSelectedPointers.join (", "));
+ aValues.append (aSelectedTypes.join (", "));
+ aValues.append (aSelectedOwners.join (", "));
+
+ return aValues;
+}
+
+// =======================================================================
+// function : GetSelectedInfo
+// purpose :
+// =======================================================================
+QList<QVariant> VInspector_Tools::GetSelectedInfo (const Handle(AIS_InteractiveContext)& theContext)
+{
+ QList<QVariant> aValues;
+ if (theContext.IsNull())
+ return aValues;
+
+ QStringList aSelectedNames;
+ QStringList aSelectedPointers;
+ QStringList aSelectedTypes;
+ QStringList aSelectedOwners;
+ QList<size_t> aSelectedIds; // Remember of selected address in order to avoid duplicates
+ for (theContext->InitSelected(); theContext->MoreSelected(); theContext->NextSelected())
+ {
+ Handle(SelectMgr_EntityOwner) anOwner = theContext->SelectedOwner();
+ if (anOwner.IsNull())
+ continue;
+ Standard_Transient* anOwnerPtr = anOwner.operator->();
+ if (aSelectedIds.contains ((size_t)anOwnerPtr))
+ continue;
+ aSelectedIds.append ((size_t)anOwnerPtr);
+ Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
+ if (anIO.IsNull())
+ continue;
+
+ QList<QVariant> anIOInfo = VInspector_Tools::GetInfo (anIO);
+ if (anIOInfo.size() == 3)
+ {
+ aSelectedNames.append (anIOInfo[0].toString());
+ aSelectedPointers.append (anIOInfo[1].toString());
+ aSelectedTypes.append (anIOInfo[2].toString());
+ }
+ aSelectedOwners.append (VInspector_Tools::GetPointerInfo (anOwnerPtr, true).ToCString());
+ }
+ aValues.append (aSelectedNames.join (", "));
+ aValues.append (aSelectedPointers.join (", "));
+ aValues.append (aSelectedTypes.join (", "));
+ aValues.append (aSelectedOwners.join (", "));
+ return aValues;
+}
+
+// =======================================================================
+// function : GetSelectedInfoPointers
+// purpose :
+// =======================================================================
+QString VInspector_Tools::GetSelectedInfoPointers (const Handle(AIS_InteractiveContext)& theContext)
+{
+ QList<QVariant> aSelectedInfo = VInspector_Tools::GetSelectedInfo (theContext);
+ return aSelectedInfo.size() > 2 ? aSelectedInfo[1].toString() : QString();
+}
+
+// =======================================================================
+// function : ToName
+// purpose :
+// =======================================================================
+TCollection_AsciiString VInspector_Tools::ToName (const VInspector_SelectionType theType, const int theValue)
+{
+ switch (theType)
+ {
+ case VInspector_SelectionType_TypeOfUpdate:
+ {
+ switch (theValue)
+ {
+ case SelectMgr_TOU_Full: return "Full";
+ case SelectMgr_TOU_Partial: return "Partial";
+ case SelectMgr_TOU_None: return "None";
+ default: break;
+ }
+ }
+ break;
+ case VInspector_SelectionType_StateOfSelection:
+ {
+ switch (theValue)
+ {
+ case SelectMgr_SOS_Activated: return "Activated";
+ case SelectMgr_SOS_Deactivated: return "Deactivated";
+ case SelectMgr_SOS_Sleeping: return "Sleeping";
+ case SelectMgr_SOS_Any: return "Any";
+ case SelectMgr_SOS_Unknown: return "Unknown";
+ default: break;
+ }
+ }
+ break;
+ case VInspector_SelectionType_TypeOfBVHUpdate:
+ {
+ switch (theValue)
+ {
+ case SelectMgr_TBU_Add: return "Add";
+ case SelectMgr_TBU_Remove: return "Remove";
+ case SelectMgr_TBU_Renew: return "Renew";
+ case SelectMgr_TBU_Invalidate: return "Invalidate";
+ case SelectMgr_TBU_None: return "None";
+ default: break;
+ }
+ }
+ default: break;
+ }
+ return "";
+}
+
+// =======================================================================
+// function : SelectionModeToName
+// purpose :
+// =======================================================================
+TCollection_AsciiString VInspector_Tools::SelectionModeToName (int theMode, const Handle(AIS_InteractiveObject)& thePresentation)
+{
+ // types are obtained by comment of SelectMgr_Selection class;
+ Handle(AIS_Shape) aShapePresentation = Handle(AIS_Shape)::DownCast (thePresentation);
+ if (!aShapePresentation.IsNull())
+ return VInspector_Tools::GetShapeTypeInfo (AIS_Shape::SelectionType (theMode)).ToCString();
+ else
+ {
+ Handle(AIS_Trihedron) aTrihedronPresentation = Handle(AIS_Trihedron)::DownCast (thePresentation);
+ if (!aTrihedronPresentation.IsNull())
+ {
+ switch (theMode)
+ {
+ case 0: return "Trihedron";
+ case 1: return "Trihedron Origin";
+ case 2: return "Trihedron Axes";
+ case 3: return "Trihedron Planes";
+ default: break;
+ }
+ }
+ }
+ return TCollection_AsciiString (theMode);
+}
+
+// =======================================================================
+// function : OrientationToName
+// purpose :
+// =======================================================================
+TCollection_AsciiString VInspector_Tools::OrientationToName (const TopAbs_Orientation& theOrientation)
+{
+ Standard_SStream aSStream;
+ TopAbs::Print(theOrientation, aSStream);
+ return aSStream.str().c_str();
+}
+
+// =======================================================================
+// function : LocationToName
+// purpose :
+// =======================================================================
+TCollection_AsciiString VInspector_Tools::LocationToName (const TopLoc_Location& theLocation)
+{
+ gp_Trsf aTrsf = theLocation.Transformation();
+
+ TCollection_AsciiString aValues;
+ for (int aRowId = 1; aRowId <= 3; aRowId++)
+ {
+ for (int aColId = 1; aColId <= 4; aColId++) {
+ aValues += TCollection_AsciiString (aTrsf.Value(aRowId, aColId));
+ if (aColId != 4)
+ aValues += ",";
+ }
+ if (aRowId != 3)
+ aValues += " ";
+ }
+ return aValues;
+}
+
+// =======================================================================
+// function : ReadShape
+// purpose :
+// =======================================================================
+TopoDS_Shape VInspector_Tools::ReadShape (const TCollection_AsciiString& theFileName)
+{
+ TopoDS_Shape aShape;
+
+ BRep_Builder aBuilder;
+ BRepTools::Read (aShape, theFileName.ToCString(), aBuilder);
+
+ return aShape;
+}
--- /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 VInspector_Tools_H
+#define VInspector_Tools_H
+
+#include <AIS_InteractiveContext.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <Standard.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TopAbs_Orientation.hxx>
+#include <TopAbs_ShapeEnum.hxx>
+#include <TopLoc_Location.hxx>
+#include <TopoDS_Shape.hxx>
+
+#include <VInspector_CallBackMode.hxx>
+#include <VInspector_SelectionType.hxx>
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4127) // conditional expression is constant
+#endif
+
+#include <QList>
+#include <QVariant>
+
+//! \class VInspector_Tools
+//! The class that gives auxiliary methods for Visualization elements manipulation
+class VInspector_Tools
+{
+
+public:
+
+ //! Returns string value of enumeration value
+ //! \param theType a shape type
+ //! \return text value
+ Standard_EXPORT static TCollection_AsciiString GetShapeTypeInfo (const TopAbs_ShapeEnum& theType);
+
+ //! Convert pointer to string value
+ //! \param thePointer a pointer
+ //! \param isShortInfo if true, all '0' symbols in the beginning of the pointer are skipped
+ //! \return the string value
+ Standard_EXPORT static TCollection_AsciiString GetPointerInfo (const Handle(Standard_Transient)& thePointer,
+ const bool isShortInfo);
+
+ //! Returns number of selected owners for presentation
+ //! \param theContext an interactive context
+ //! \param theObject a presentation
+ //! \param theShapeInfoOnly if true, only BRep owners are taken
+ Standard_EXPORT static int SelectedOwners (const Handle(AIS_InteractiveContext)& theContext,
+ const Handle(AIS_InteractiveObject)& theObject,
+ const bool theShapeInfoOnly);
+
+ //! Returns true if the owner is selected in the context
+ //! \param theContext an interactive context
+ //! \param theOwner a selectable owner
+ //! \return boolean value
+ Standard_EXPORT static bool IsOwnerSelected (const Handle(AIS_InteractiveContext)& theContext,
+ const Handle(SelectBasics_EntityOwner)& theOwner);
+
+ //! Returns all owners present in the context
+ //! \param theContext an interactive context
+ //! \return container of owners
+ Standard_EXPORT static NCollection_List<Handle(SelectBasics_EntityOwner)> ContextOwners (
+ const Handle(AIS_InteractiveContext)& theContext);
+
+ //! Returns active owners in main selector of context
+ //! \param theContext an interactive context
+ //! \param theEmptySelectableOwners container of owners with NULL presentation or not displayed presentation
+ //! \return container of owners
+ Standard_EXPORT static NCollection_List<Handle(SelectBasics_EntityOwner)> ActiveOwners (
+ const Handle(AIS_InteractiveContext)& theContext,
+ NCollection_List<Handle(SelectBasics_EntityOwner)>& theEmptySelectableOwners);
+
+ //! Unhighlight selected, set selected the owners
+ //! \param theContext an interactive context
+ //! \param theOwners a container of owners
+ Standard_EXPORT static void AddOrRemoveSelectedShapes (const Handle(AIS_InteractiveContext)& theContext,
+ const NCollection_List<Handle(SelectBasics_EntityOwner)>& theOwners);
+
+ //! Unhighlight selected, set selected presentations
+ //! \param theContext an interactive context
+ //! \param thePresentations a container of presentations
+ Standard_EXPORT static void AddOrRemovePresentations (const Handle(AIS_InteractiveContext)& theContext,
+ const NCollection_List<Handle(AIS_InteractiveObject)>& thePresentations);
+
+ //! Returns information about presentation: Dynamic Type, Pointer info, Shape type info
+ //! \param theObject a presentation
+ //! \return container of values
+ Standard_EXPORT static QList<QVariant> GetInfo (Handle(AIS_InteractiveObject)& theObject);
+
+ //! Returns information about current highlight: Names, Owners, Pointers, Owners
+ //! \param theContext an interactive context
+ //! \return container of values
+ Standard_EXPORT static QList<QVariant> GetHighlightInfo (const Handle(AIS_InteractiveContext)& theContext);
+
+ //! Returns information about current selection: Names, Owners, Pointers, Owners
+ //! \param theContext an interactive context
+ //! \return container of values
+ Standard_EXPORT static QList<QVariant> GetSelectedInfo (const Handle(AIS_InteractiveContext)& theContext);
+
+ //! Returns the first pointer of selection in the context
+ Standard_EXPORT static QString GetSelectedInfoPointers (const Handle(AIS_InteractiveContext)& theContext);
+
+ //! Returns string information of call back mode
+ //! \param theMode type of selection
+ //! \param theValue a value in selection enumeration
+ //! \return information text
+ Standard_EXPORT static TCollection_AsciiString ToName (const VInspector_SelectionType theType, const int theValue);
+
+ //! Returns selection information
+ //! \param theMode a selection mode
+ //! \param thePresentation a presentation
+ //! \return text value
+ Standard_EXPORT static TCollection_AsciiString SelectionModeToName (int theMode, const Handle(AIS_InteractiveObject)& thePresentation);
+
+ //! Returns text of orientation
+ //! \param theOrientation an orientation value
+ //! \return text value
+ Standard_EXPORT static TCollection_AsciiString OrientationToName (const TopAbs_Orientation& theOrientation);
+
+ //! Returns text of orientation
+ //! \param theLocation a location value
+ //! \return text value
+ Standard_EXPORT static TCollection_AsciiString LocationToName (const TopLoc_Location& theLocation);
+
+ //! Read Shape using BREP reader
+ //! \param theFileName a file name
+ //! \return shape or NULL
+ Standard_EXPORT static TopoDS_Shape ReadShape (const TCollection_AsciiString& theFileName);
+};
+
+#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 <VInspector_ViewModel.hxx>
+
+#include <VInspector_ItemContext.hxx>
+#include <VInspector_ItemEntityOwner.hxx>
+#include <VInspector_ItemPresentableObject.hxx>
+#include <VInspector_ItemSensitiveEntity.hxx>
+#include <SelectBasics_EntityOwner.hxx>
+
+#include <QItemSelectionModel>
+#include <QStringList>
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+VInspector_ViewModel::VInspector_ViewModel (QObject* theParent)
+ : TreeModel_ModelBase (theParent)
+{
+ for (int aColumnId = 0, aNbColumns = columnCount(); aColumnId < aNbColumns; aColumnId++)
+ myRootItems.insert (aColumnId, VInspector_ItemContext::CreateItem (TreeModel_ItemBasePtr(), 0, aColumnId));
+
+ m_pRootItem = myRootItems[0];
+}
+
+// =======================================================================
+// function : GetContext
+// purpose :
+// =======================================================================
+const Handle(AIS_InteractiveContext)& VInspector_ViewModel::GetContext() const
+{
+ return itemDynamicCast<VInspector_ItemContext>(RootItem (0))->GetContext();
+}
+
+// =======================================================================
+// function : SetContext
+// purpose :
+// =======================================================================
+void VInspector_ViewModel::SetContext (const Handle(AIS_InteractiveContext)& theContext)
+{
+ // fill root item by the application
+ for (int aColId = 0, aNbColumns = columnCount(); aColId < aNbColumns; aColId++)
+ itemDynamicCast<VInspector_ItemContext>(myRootItems[aColId])->SetContext (theContext);
+ EmitLayoutChanged();
+}
+
+// =======================================================================
+// function : FindPointers
+// purpose :
+// =======================================================================
+QModelIndexList VInspector_ViewModel::FindPointers (const QStringList& thePointers)
+{
+ QModelIndexList anIndices;
+ QModelIndex aParentIndex = index (0, 0);
+ TreeModel_ItemBasePtr aParentItem = TreeModel_ModelBase::GetItemByIndex (aParentIndex); // context item
+ for (int aRowId = 0, aCount = aParentItem->rowCount(); aRowId < aCount; aRowId++)
+ {
+ QModelIndex anIndex = index (aRowId, 0, aParentIndex);
+ TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex);
+ VInspector_ItemPresentableObjectPtr anItemPrs = itemDynamicCast<VInspector_ItemPresentableObject>(anItemBase);
+ if (!anItemPrs)
+ continue;
+ if (thePointers.contains (anItemPrs->PointerInfo()))
+ anIndices.append (anIndex);
+ }
+ return anIndices;
+}
+
+// =======================================================================
+// function : headerData
+// purpose :
+// =======================================================================
+QVariant VInspector_ViewModel::headerData (int theSection, Qt::Orientation theOrientation, int theRole) const
+{
+ if (theOrientation != Qt::Horizontal || theRole != Qt::DisplayRole)
+ return QVariant();
+
+ switch (theSection)
+ {
+ case 0: return "Name";
+ case 1: return "Size";
+ case 2: return "Pointer";
+ case 3: return "Shape type";
+ case 4: return "Selection";
+ case 5: return "Base Sensitive";
+ case 6: return "Sensitivity";
+ case 7: return "SubElements";
+ case 8: return "Deviation/Deflectiton/Update/Priority";
+ //Auto Triangulation
+ default: break;
+ }
+ return QVariant();
+}
+
+// =======================================================================
+// function : GetSelectedOwners
+// purpose :
+// =======================================================================
+void VInspector_ViewModel::GetSelectedOwners (QItemSelectionModel* theSelectionModel,
+ NCollection_List<Handle(SelectBasics_EntityOwner)>& theOwners)
+{
+ if (!theSelectionModel)
+ return;
+ QList<TreeModel_ItemBasePtr> anItems;
+
+ QModelIndexList anIndices = theSelectionModel->selectedIndexes();
+ for (QModelIndexList::const_iterator anIndicesIt = anIndices.begin(); anIndicesIt != anIndices.end(); anIndicesIt++)
+ {
+ TreeModel_ItemBasePtr anItem = TreeModel_ModelBase::GetItemByIndex (*anIndicesIt);
+ if (!anItem || anItems.contains (anItem))
+ continue;
+ anItems.append (anItem);
+ }
+
+ QList<size_t> aSelectedIds; // Remember of selected address in order to avoid duplicates
+ for (QList<TreeModel_ItemBasePtr>::const_iterator anItemIt = anItems.begin(); anItemIt != anItems.end(); anItemIt++)
+ {
+ TreeModel_ItemBasePtr anItem = *anItemIt;
+ Handle(SelectBasics_EntityOwner) anEntityOwner;
+ if (VInspector_ItemEntityOwnerPtr anOwnerItem = itemDynamicCast<VInspector_ItemEntityOwner>(anItem))
+ {
+ anEntityOwner = anOwnerItem->EntityOwner();
+ }
+ else if (VInspector_ItemSensitiveEntityPtr aSensItem = itemDynamicCast<VInspector_ItemSensitiveEntity>(anItem))
+ {
+ anEntityOwner = aSensItem->GetSensitiveEntity()->BaseSensitive()->OwnerId();
+ }
+ if (anEntityOwner.IsNull())
+ continue;
+ if (aSelectedIds.contains ((size_t)anEntityOwner.operator->()))
+ continue;
+ aSelectedIds.append ((size_t)anEntityOwner.operator->());
+ if (!anEntityOwner.IsNull())
+ theOwners.Append (anEntityOwner);
+ }
+}
--- /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 VInspector_ViewModel_H
+#define VInspector_ViewModel_H
+
+#include <AIS_InteractiveContext.hxx>
+#include <NCollection_List.hxx>
+#include <SelectBasics_EntityOwner.hxx>
+#include <Standard.hxx>
+#include <TreeModel_ModelBase.hxx>
+#include <VInspector_ItemBase.hxx>
+
+#include <QByteArray>
+#include <QHash>
+#include <QMap>
+#include <QObject>
+
+class OCAFSampleAPI_Module;
+class OCAFSampleModel_DocumentMgr;
+
+class QItemSelectionModel;
+
+//! \class VInspector_ViewModel
+//! The class that visualizes the AIS context content
+class VInspector_ViewModel : public TreeModel_ModelBase
+{
+ Q_OBJECT
+
+public:
+
+ //! Constructor
+ Standard_EXPORT VInspector_ViewModel (QObject* theParent);
+
+ //! Destructor
+ virtual ~VInspector_ViewModel() Standard_OVERRIDE {};
+
+ //! Initialize the model by the given context
+ //! \param theContext viewer context
+ Standard_EXPORT const Handle(AIS_InteractiveContext)& GetContext() const;
+
+ //! Initialize the model by the given context
+ //! \param theContext viewer context
+ Standard_EXPORT void SetContext (const Handle(AIS_InteractiveContext)& theContext);
+
+ //! Returns tree view indices for the given pointers of presentable object
+ //! \param thePointers a list of presentation pointers
+ //! \return container of indices
+ Standard_EXPORT QModelIndexList FindPointers (const QStringList& thePointers);
+
+ //! Returns root item by column
+ //! \param theColumn an index of the column
+ //! \return root item instance
+ Standard_EXPORT virtual TreeModel_ItemBasePtr RootItem (const int theColumn) const Standard_OVERRIDE
+ { return myRootItems[theColumn]; }
+
+ //! Returns count of columns in the model
+ //! \param theParent an index of the parent item
+ //! \return integer value
+ Standard_EXPORT virtual int columnCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
+ { (void)theParent; return 9; }
+
+ //! Returns the header data for the given role and section in the header with the specified orientation.
+ //! \param theSection the header section. For horizontal headers - column number, for vertical headers - row number.
+ //! \param theOrientation a header orientation
+ //! \param theRole a data role
+ //! \return the header data
+ Standard_EXPORT virtual QVariant headerData (int theSection, Qt::Orientation theOrientation,
+ int theRole = Qt::DisplayRole ) const Standard_OVERRIDE;
+
+ //! Returns select owners for tree view selected items
+ //! \param theSelectionModel a selection model
+ //! \param theOwners an output list of owners
+ Standard_EXPORT static void GetSelectedOwners (QItemSelectionModel* theSelectionModel,
+ NCollection_List<Handle(SelectBasics_EntityOwner)>& theOwners);
+
+private:
+
+ QMap<int, TreeModel_ItemBasePtr> myRootItems; //!< container of root items, for each column own root item
+};
+
+#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 <VInspector_ViewModelHistory.hxx>
+
+#include <VInspector_ItemHistoryElement.hxx>
+#include <VInspector_ItemHistoryRoot.hxx>
+#include <VInspector_ItemHistoryType.hxx>
+
+#include <QStringList>
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+VInspector_ViewModelHistory::VInspector_ViewModelHistory (QObject* theParent, const int theHistoryTypesMaxAmount)
+: TreeModel_ModelBase (theParent)
+{
+ for (int aColumnId = 0, aNbColumns = columnCount(); aColumnId < aNbColumns; aColumnId++)
+ {
+ myRootItems.insert(aColumnId, VInspector_ItemHistoryRoot::CreateItem(TreeModel_ItemBasePtr(), 0, aColumnId));
+ VInspector_ItemHistoryRootPtr aRootItem = itemDynamicCast<VInspector_ItemHistoryRoot>(myRootItems[aColumnId]);
+ aRootItem->SetHistoryTypesMaxAmount(theHistoryTypesMaxAmount);
+ }
+ m_pRootItem = myRootItems[0];
+}
+
+// =======================================================================
+// function : AddElement
+// purpose :
+// =======================================================================
+void VInspector_ViewModelHistory::AddElement (const VInspector_CallBackMode& theMode, const QList<QVariant>& theInfo)
+{
+ // fill root item by the application
+ for (int aColId = 0, aNbColumns = columnCount(); aColId < aNbColumns; aColId++)
+ {
+ VInspector_ItemHistoryRootPtr aRootItem = itemDynamicCast<VInspector_ItemHistoryRoot>(myRootItems[aColId]);
+ aRootItem->AddElement(theMode, theInfo);
+ }
+ Reset();
+ EmitLayoutChanged();
+}
+
+// =======================================================================
+// function : GetSelectedPointers
+// purpose :
+// =======================================================================
+QStringList VInspector_ViewModelHistory::GetSelectedPointers (const QModelIndex& theIndex)
+{
+ QStringList aPointers;
+ TreeModel_ItemBasePtr anItem = TreeModel_ModelBase::GetItemByIndex (theIndex);
+ if (!anItem)
+ return aPointers;
+
+ VInspector_ItemHistoryTypePtr aHistoryItem = itemDynamicCast<VInspector_ItemHistoryType>(anItem);
+ if (aHistoryItem)
+ {
+ QString aPointerInfo = aHistoryItem->PointerInfo();
+ QString anOwnerInfo = aHistoryItem->OwnerInfo();
+
+ if (!aPointerInfo.isEmpty())
+ aPointers.append (aPointerInfo);
+ if (!anOwnerInfo.isEmpty())
+ aPointers.append (anOwnerInfo.split (", "));
+ }
+ else
+ {
+ VInspector_ItemHistoryElementPtr anElementItem = itemDynamicCast<VInspector_ItemHistoryElement>(anItem);
+ if (anElementItem)
+ {
+ QString aPointerInfo = anElementItem->PointerInfo();
+ if (!aPointerInfo.isEmpty())
+ aPointers.append (aPointerInfo);
+ }
+ }
+ return aPointers;
+}
+
+// =======================================================================
+// function : headerData
+// purpose :
+// =======================================================================
+QVariant VInspector_ViewModelHistory::headerData (int theSection, Qt::Orientation theOrientation, int theRole) const
+{
+ if (theOrientation != Qt::Horizontal || theRole != Qt::DisplayRole)
+ return QVariant();
+
+ switch (theSection)
+ {
+ case 0: return "Name";
+ case 1: return "Size";
+ case 2: return "Pointer";
+ case 3: return "Shape type";
+ case 4: return "AIS Name";
+ case 5: return "Selected/Highlighted";
+ 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 VInspector_ViewModelHistory_H
+#define VInspector_ViewModelHistory_H
+
+#include <Standard.hxx>
+#include <VInspector_ItemBase.hxx>
+#include <VInspector_CallBackMode.hxx>
+
+#include <QByteArray>
+#include <QHash>
+#include <QMap>
+#include <QObject>
+
+#include <TreeModel_ModelBase.hxx>
+
+//! \class VInspector_ViewModelHistory
+//! The class that visualizes methods called in AIS interactive context.
+class VInspector_ViewModelHistory : public TreeModel_ModelBase
+{
+ Q_OBJECT
+
+public:
+
+ //! Constructor
+ Standard_EXPORT VInspector_ViewModelHistory (QObject* theParent, const int theHistoryTypesMaxAmount = 50);
+
+ //! Destructor
+ virtual ~VInspector_ViewModelHistory() Standard_OVERRIDE {};
+
+ //! Append new element under the root item
+ Standard_EXPORT void AddElement (const VInspector_CallBackMode& theMode, const QList<QVariant>& theInfo);
+
+ //! Returns container of pointer information for selected presentation or owner item
+ //! \param theIndex an index of tree view model
+ //! \param container of strings
+ Standard_EXPORT QStringList GetSelectedPointers (const QModelIndex& theIndex);
+
+ //! Returns root item by column
+ //! \param theColumn an index of the column
+ //! \return root item instance
+ virtual TreeModel_ItemBasePtr RootItem(const int theColumn) const Standard_OVERRIDE { return myRootItems[theColumn]; }
+
+ //! Returns count of columns in the model
+ //! \param theParent an index of the parent item
+ //! \return integer value
+ virtual int columnCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
+ { (void)theParent; return 6; }
+
+ //! Returns the header data for the given role and section in the header with the specified orientation.
+ //! \param theSection the header section. For horizontal headers - column number, for vertical headers - row number.
+ //! \param theOrientation a header orientation
+ //! \param theRole a data role
+ //! \return the header data
+ Standard_EXPORT virtual QVariant headerData (int theSection, Qt::Orientation theOrientation,
+ int theRole = Qt::DisplayRole ) const Standard_OVERRIDE;
+
+private:
+
+ QMap<int, TreeModel_ItemBasePtr> myRootItems; //!< container of root items, for each column own root item
+};
+
+#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 <VInspector_Window.hxx>
+
+#include <AIS_Shape.hxx>
+#include <VInspector_CallBack.hxx>
+#include <VInspector_Communicator.hxx>
+#include <VInspector_ItemEntityOwner.hxx>
+#include <VInspector_ItemPresentableObject.hxx>
+#include <VInspector_ToolBar.hxx>
+#include <VInspector_Tools.hxx>
+#include <VInspector_ViewModel.hxx>
+#include <VInspector_ViewModelHistory.hxx>
+
+#include <QApplication>
+#include <QDockWidget>
+#include <QHeaderView>
+#include <QGridLayout>
+#include <QItemSelectionModel>
+#include <QMainWindow>
+#include <QMenu>
+#include <QMessageBox>
+#include <QToolButton>
+#include <QTreeView>
+#include <QWidget>
+
+const int FIRST_COLUMN_WIDTH = 250;
+
+const int COLUMN_1_WIDTH = 30;
+const int COLUMN_2_WIDTH = 70;
+const int COLUMN_3_WIDTH = 130;
+const int COLUMN_4_WIDTH = 90;
+const int COLUMN_5_WIDTH = 180;
+const int COLUMN_6_WIDTH = 70;
+const int COLUMN_7_WIDTH = 70;
+
+const int HISTORY_AIS_NAME_COLUMN_WIDTH = 140;
+
+const int VINSPECTOR_DEFAULT_WIDTH = 1250;
+const int VINSPECTOR_DEFAULT_HEIGHT = 800;
+
+const int VINSPECTOR_DEFAULT_POSITION_X = 200;
+const int VINSPECTOR_DEFAULT_POSITION_Y = 60;
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+VInspector_Window::VInspector_Window()
+{
+ myMainWindow = new QMainWindow (0);
+
+ QWidget* aCentralWidget = new QWidget (myMainWindow);
+ QGridLayout* aParentLay = new QGridLayout (aCentralWidget);
+ aParentLay->setContentsMargins (0, 0, 0, 0);
+
+ // tool bar: on the bottom of the window
+ myToolBar = new VInspector_ToolBar(aCentralWidget);
+ connect (myToolBar, SIGNAL (actionClicked (int)), this, SLOT (onToolBarActionClicked (int)));
+ aParentLay->addWidget (myToolBar->GetControl(), 0, 0);
+
+ // tree view
+ myTreeView = new QTreeView (aCentralWidget);
+ myTreeView->setSelectionBehavior (QAbstractItemView::SelectRows);
+ myTreeView->setSelectionMode (QAbstractItemView::ExtendedSelection);
+ myTreeView->header()->setStretchLastSection (true);
+ myTreeView->setContextMenuPolicy(Qt::CustomContextMenu);
+ connect (myTreeView, SIGNAL(customContextMenuRequested(const QPoint&)),
+ this, SLOT (onTreeViewContextMenuRequested(const QPoint&)));
+ aParentLay->addWidget(myTreeView, 1, 0);
+ aParentLay->setRowStretch (1, 1);
+ myMainWindow->setCentralWidget (aCentralWidget);
+
+ // history view in bottom dock widget
+ myHistoryView = new QTreeView (aCentralWidget);
+ myHistoryView->setSelectionBehavior (QAbstractItemView::SelectRows);
+ myHistoryView->setSelectionMode (QAbstractItemView::ExtendedSelection);
+ VInspector_ViewModelHistory* aHistoryModel = new VInspector_ViewModelHistory (myHistoryView);
+ myHistoryView->setModel (aHistoryModel);
+
+ QItemSelectionModel* aSelectionModel = new QItemSelectionModel (myTreeView->model());
+ myHistoryView->setSelectionModel (aSelectionModel);
+ connect (aSelectionModel, SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
+ this, SLOT (onHistoryViewSelectionChanged (const QItemSelection&, const QItemSelection&)));
+
+ myHistoryView->setColumnWidth (0, FIRST_COLUMN_WIDTH);
+ myHistoryView->setColumnWidth (1, COLUMN_1_WIDTH);
+ myHistoryView->setColumnWidth (2, COLUMN_2_WIDTH);
+ myHistoryView->setColumnWidth (3, COLUMN_3_WIDTH);
+ myHistoryView->setColumnWidth (4, HISTORY_AIS_NAME_COLUMN_WIDTH);
+
+ QDockWidget* aHistoryDockWidget = new QDockWidget (tr ("Tree Level Line"), myMainWindow);
+ aHistoryDockWidget->setWidget (myHistoryView);
+ myMainWindow->addDockWidget (Qt::BottomDockWidgetArea, aHistoryDockWidget);
+
+ myMainWindow->resize (450, 800);
+ myMainWindow->move (60, 20);
+
+ myMainWindow->resize (VINSPECTOR_DEFAULT_WIDTH, VINSPECTOR_DEFAULT_HEIGHT);
+ myMainWindow->move (VINSPECTOR_DEFAULT_POSITION_X, VINSPECTOR_DEFAULT_POSITION_Y);
+}
+
+// =======================================================================
+// function : SetParent
+// purpose :
+// =======================================================================
+void VInspector_Window::SetParent (void* theParent)
+{
+ QWidget* aParent = (QWidget*)theParent;
+ if (!aParent)
+ return;
+
+ QLayout* aLayout = aParent->layout();
+ if (aLayout)
+ aLayout->addWidget (GetMainWindow());
+}
+
+// =======================================================================
+// function : UpdateContent
+// purpose :
+// =======================================================================
+void VInspector_Window::UpdateContent()
+{
+ TCollection_AsciiString aName = "TKVInspector";
+
+ if (myParameters->FindParameters (aName))
+ Init(myParameters->Parameters (aName));
+ if (myParameters->FindFileNames(aName))
+ {
+ for (NCollection_List<TCollection_AsciiString>::Iterator aFileNamesIt(myParameters->FileNames(aName));
+ aFileNamesIt.More(); aFileNamesIt.Next())
+ OpenFile (aFileNamesIt.Value());
+
+ NCollection_List<TCollection_AsciiString> aNames;
+ myParameters->SetFileNames(aName, aNames);
+ }
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void VInspector_Window::Init (const NCollection_List<Handle(Standard_Transient)>& theParameters)
+{
+ Handle(AIS_InteractiveContext) aContext;
+ Handle(VInspector_CallBack) aCallBack;
+
+ for (NCollection_List<Handle(Standard_Transient)>::Iterator aParamsIt (theParameters); aParamsIt.More(); aParamsIt.Next())
+ {
+ Handle(Standard_Transient) anObject = aParamsIt.Value();
+ if (aContext.IsNull())
+ aContext = Handle(AIS_InteractiveContext)::DownCast (anObject);
+
+ if (aCallBack.IsNull())
+ aCallBack = Handle(VInspector_CallBack)::DownCast (anObject);
+ }
+ if (aContext.IsNull())
+ return;
+ SetContext (aContext);
+
+ if (!aCallBack.IsNull())
+ {
+ myCallBack = aCallBack;
+ VInspector_ViewModelHistory* aHistoryModel = dynamic_cast<VInspector_ViewModelHistory*>
+ (myHistoryView->model());
+ myCallBack->SetContext (aContext);
+ myCallBack->SetHistoryModel(aHistoryModel);
+ }
+}
+
+// =======================================================================
+// function : SetContext
+// purpose :
+// =======================================================================
+void VInspector_Window::SetContext (const Handle(AIS_InteractiveContext)& theContext)
+{
+ VInspector_ViewModel* aViewModel = new VInspector_ViewModel (myTreeView);
+ aViewModel->SetContext (theContext);
+ myTreeView->setModel (aViewModel);
+
+ myTreeView->setExpanded (aViewModel->index (0, 0), true);
+ myTreeView->setColumnWidth (0, FIRST_COLUMN_WIDTH);
+
+ if (!myCallBack.IsNull())
+ myCallBack->SetContext (theContext);
+
+ QItemSelectionModel* aSelModel = new QItemSelectionModel (aViewModel, myTreeView);
+ myTreeView->setSelectionModel (aSelModel);
+ connect (aSelModel, SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
+ this, SLOT (onSelectionChanged (const QItemSelection&, const QItemSelection&)));
+
+ myTreeView->setColumnWidth (1, COLUMN_1_WIDTH);
+ myTreeView->setColumnWidth (2, COLUMN_2_WIDTH);
+ myTreeView->setColumnWidth (3, COLUMN_3_WIDTH);
+ myTreeView->setColumnWidth (4, COLUMN_4_WIDTH);
+ myTreeView->setColumnWidth (5, COLUMN_5_WIDTH);
+ myTreeView->setColumnWidth (6, COLUMN_6_WIDTH);
+ myTreeView->setColumnWidth (7, COLUMN_7_WIDTH);
+}
+
+// =======================================================================
+// function : OpenFile
+// purpose :
+// =======================================================================
+void VInspector_Window::OpenFile(const TCollection_AsciiString& theFileName)
+{
+ VInspector_ViewModel* aViewModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
+ if (!aViewModel)
+ return;
+
+ Handle(AIS_InteractiveContext) aContext = aViewModel->GetContext();
+ if (aContext.IsNull())
+ return;
+
+ TopoDS_Shape aShape = VInspector_Tools::ReadShape (theFileName);
+ if (aShape.IsNull())
+ return;
+
+ Handle(AIS_Shape) aPresentation = new AIS_Shape (aShape);
+ aContext->Display (aPresentation, false);
+ aContext->Load (aPresentation, -1/*selection mode*/, true);
+ aContext->UpdateCurrentViewer();
+
+ UpdateTreeModel();
+ myTreeView->setExpanded (aViewModel->index (0, 0), true);
+}
+
+// =======================================================================
+// function : onTreeViewContextMenuRequested
+// purpose :
+// =======================================================================
+void VInspector_Window::onTreeViewContextMenuRequested(const QPoint& thePosition)
+{
+ QMenu* aMenu = new QMenu (GetMainWindow());
+ aMenu->addAction (createAction (tr ("Export to ShapeView"), SLOT(onExportToShapeView())));
+ aMenu->addAction (createAction (tr ("Show"), SLOT(onShow())));
+ aMenu->addAction (createAction (tr ("Hide"), SLOT(onHide())));
+ QPoint aPoint = myTreeView->mapToGlobal (thePosition);
+ aMenu->exec(aPoint);
+}
+
+// =======================================================================
+// function : onToolBarActionClicked
+// purpose :
+// =======================================================================
+void VInspector_Window::onToolBarActionClicked (const int theActionId)
+{
+ switch (theActionId)
+ {
+ case VInspector_ToolActionType_UpdateId:
+ {
+ VInspector_ViewModel* aViewModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
+ if (aViewModel)
+ UpdateTreeModel();
+ break;
+ }
+ case VInspector_ToolActionType_SelectPresentationsId:
+ {
+ bool isChecked = myToolBar->GetToolButton((VInspector_ToolActionType)theActionId)->isChecked();
+ NCollection_List<Handle(AIS_InteractiveObject)> aPresentationsForViewer;
+ if (isChecked)
+ aPresentationsForViewer = VInspector_ItemPresentableObject::GetSelectedPresentations(myTreeView->selectionModel());
+ VInspector_ViewModel* aViewModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
+ Handle(AIS_InteractiveContext) aContext = aViewModel->GetContext();
+ VInspector_Tools::AddOrRemovePresentations(aContext, aPresentationsForViewer);
+ break;
+ }
+ case VInspector_ToolActionType_SelectOwnersId:
+ {
+ NCollection_List<Handle(SelectBasics_EntityOwner)> anOwnersForViewer;
+ if (myToolBar->GetToolButton((VInspector_ToolActionType)theActionId)->isChecked())
+ VInspector_ViewModel::GetSelectedOwners(myTreeView->selectionModel(), anOwnersForViewer);
+ VInspector_ViewModel* aViewModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
+ VInspector_Tools::AddOrRemoveSelectedShapes(aViewModel->GetContext(), anOwnersForViewer);
+ break;
+ }
+ default:
+ break;
+ }
+}
+
+// =======================================================================
+// function : onSelectionChanged
+// purpose :
+// =======================================================================
+void VInspector_Window::onSelectionChanged (const QItemSelection&,
+ const QItemSelection&)
+{
+ QApplication::setOverrideCursor (Qt::WaitCursor);
+
+ if (myToolBar->GetToolButton(VInspector_ToolActionType_SelectPresentationsId)->isChecked())
+ onToolBarActionClicked(VInspector_ToolActionType_SelectPresentationsId);
+ else if (myToolBar->GetToolButton(VInspector_ToolActionType_SelectOwnersId)->isChecked())
+ onToolBarActionClicked(VInspector_ToolActionType_SelectOwnersId);
+
+ QApplication::restoreOverrideCursor();
+}
+
+// =======================================================================
+// function : onHistoryViewSelectionChanged
+// purpose :
+// =======================================================================
+void VInspector_Window::onHistoryViewSelectionChanged (const QItemSelection& theSelected,
+ const QItemSelection&)
+{
+ VInspector_ViewModelHistory* aHistoryModel = dynamic_cast<VInspector_ViewModelHistory*> (myHistoryView->model());
+ if (!aHistoryModel)
+ return;
+
+ if (theSelected.size() == 0)
+ return;
+
+ QModelIndexList aSelectedIndices = theSelected.indexes();
+ QStringList aPointers = aHistoryModel->GetSelectedPointers(aSelectedIndices.first());
+
+ VInspector_ViewModel* aTreeModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
+
+ QModelIndexList anIndices = aTreeModel->FindPointers (aPointers);
+ QItemSelectionModel* aSelectionModel = myTreeView->selectionModel();
+ aSelectionModel->clear();
+ for (int anIndicesId = 0, aSize = anIndices.size(); anIndicesId < aSize; anIndicesId++)
+ {
+ QModelIndex anIndex = anIndices[anIndicesId];
+ myTreeView->setExpanded (aTreeModel->parent (anIndex), true);
+ aSelectionModel->select (anIndex, QItemSelectionModel::Select);
+ }
+}
+
+// =======================================================================
+// function : onExportToShapeView
+// purpose :
+// =======================================================================
+void VInspector_Window::onExportToShapeView()
+{
+ NCollection_List<Handle(AIS_InteractiveObject)> aSelectedPresentations =
+ VInspector_ItemPresentableObject::GetSelectedPresentations(myTreeView->selectionModel());
+ if (aSelectedPresentations.Extent() <= 0)
+ return;
+
+ TCollection_AsciiString aPluginName ("TKShapeView");
+ if (myParameters->FindParameters(aPluginName))
+ {
+ NCollection_List<Handle(Standard_Transient)> aPluginParameters = myParameters->Parameters(aPluginName);
+
+ QStringList anExportedPointers;
+ for (NCollection_List<Handle(AIS_InteractiveObject)>::Iterator anIOIt (aSelectedPresentations); anIOIt.More(); anIOIt.Next())
+ {
+ Handle(AIS_Shape) aShapePresentation = Handle(AIS_Shape)::DownCast (anIOIt.Value());
+ if (aShapePresentation.IsNull())
+ continue;
+
+ const TopoDS_Shape& aShape = aShapePresentation->Shape();
+ if (aShape.IsNull())
+ continue;
+ aPluginParameters.Append (aShape.TShape());
+ anExportedPointers.append (VInspector_Tools::GetPointerInfo (aShape.TShape(), true).ToCString());
+ }
+ if (anExportedPointers.empty())
+ return;
+ myParameters->SetParameters (aPluginName, aPluginParameters);
+ QMessageBox::information (0, "Information", QString("TShapes '%1' are sent to %2 tool.")
+ .arg (anExportedPointers.join(", ").arg (QString (aPluginName.ToCString()))));
+ }
+}
+
+// =======================================================================
+// function : onShow
+// purpose :
+// =======================================================================
+void VInspector_Window::onShow()
+{
+ displaySelectedPresentations (true);
+}
+
+// =======================================================================
+// function : onHide
+// purpose :
+// =======================================================================
+void VInspector_Window::onHide()
+{
+ displaySelectedPresentations (false);
+}
+
+// =======================================================================
+// function : UpdateTreeModel
+// purpose :
+// =======================================================================
+void VInspector_Window::UpdateTreeModel()
+{
+ VInspector_ViewModel* aViewModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
+ if (!aViewModel)
+ return;
+ aViewModel->Reset();
+ aViewModel->EmitLayoutChanged();
+}
+
+// =======================================================================
+// function : createAction
+// purpose :
+// =======================================================================
+QAction* VInspector_Window::createAction(const QString& theText, const char* theSlot)
+{
+ QAction* anAction = new QAction(theText, GetMainWindow());
+ connect(anAction, SIGNAL(triggered(bool)), this, theSlot);
+ return anAction;
+}
+
+// =======================================================================
+// function : displaySelectedPresentations
+// purpose :
+// =======================================================================
+void VInspector_Window::displaySelectedPresentations(const bool theToDisplay)
+{
+ VInspector_ViewModel* aViewModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
+ if (!aViewModel)
+ return;
+
+ Handle(AIS_InteractiveContext) aContext = aViewModel->GetContext();
+ if (aContext.IsNull())
+ return;
+
+ NCollection_List<Handle(AIS_InteractiveObject)> aSelectedPresentations =
+ VInspector_ItemPresentableObject::GetSelectedPresentations(myTreeView->selectionModel());
+ if (aSelectedPresentations.Extent() <= 0)
+ return;
+
+ for (NCollection_List<Handle(AIS_InteractiveObject)>::Iterator anIOIt(aSelectedPresentations); anIOIt.More(); anIOIt.Next())
+ {
+ Handle(AIS_InteractiveObject) aPresentation = Handle(AIS_Shape)::DownCast(anIOIt.Value());
+ if (aPresentation.IsNull())
+ continue;
+ if (theToDisplay) {
+ aContext->Display(aPresentation, false);
+ aContext->Load(aPresentation, -1, true);
+ }
+ else
+ aContext->Erase(aPresentation, false);
+ }
+ aContext->UpdateCurrentViewer();
+}
--- /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 VInspector_Window_H
+#define VInspector_Window_H
+
+#include <AIS_InteractiveContext.hxx>
+#include <NCollection_List.hxx>
+#include <SelectBasics_EntityOwner.hxx>
+#include <Standard.hxx>
+#include <TInspectorAPI_PluginParameters.hxx>
+#include <VInspector_CallBack.hxx>
+
+#include <QObject>
+#include <QItemSelection>
+#include <QMainWindow>
+
+class VInspector_ToolBar;
+
+class QAbstractItemModel;
+class QAction;
+class QMainWindow;
+class QTreeView;
+class QWidget;
+
+//! \class VInspector_Window
+//! Window that unites all VInspector controls.
+class VInspector_Window : public QObject
+{
+ Q_OBJECT
+
+public:
+
+ //! Constructor
+ Standard_EXPORT VInspector_Window();
+
+ //! Destructor
+ virtual ~VInspector_Window() Standard_OVERRIDE {}
+
+ //! Provides the container with a parent where this container should be inserted.
+ //! If Qt implementation, it should be QWidget with QLayout set inside
+ //! \param theParent a parent class
+ Standard_EXPORT void SetParent (void* theParent);
+
+ //! Sets parameters container, it should be used when the plugin is initialized or in update content
+ //! \param theParameters a parameters container
+ void SetParameters (const Handle(TInspectorAPI_PluginParameters)& theParameters) { myParameters = theParameters; }
+
+ //! Applyes parameters to Init controls, opens files if there are in parameters, updates OCAF tree view model
+ Standard_EXPORT void UpdateContent();
+
+ //! Returns main control
+ QWidget* GetMainWindow() const { return myMainWindow; }
+
+private:
+
+ //! Fills controls of the plugin by parameters:
+ //! - Fine AIS_InteractiveObject and fills View if it if it differs from the current context
+ //! \param theParameters a parameters container
+ void Init (const NCollection_List<Handle(Standard_Transient)>& theParameters);
+
+ //! Read BREP file, creates AIS presentation for the shape and visualize it in the current context
+ //! \param theFileName a name of BREP file
+ void OpenFile (const TCollection_AsciiString& theFileName);
+
+private slots:
+
+ //! Shows context menu for tree view selected item. It contains clear view or BREP operations items
+ //! \param thePosition a clicked point
+ void onTreeViewContextMenuRequested(const QPoint& thePosition);
+
+ //! Performs the functionality of the clicked action
+ //! \param theActionId an action identifier in tool bar
+ void onToolBarActionClicked (const int theActionId);
+
+ //! Synchronization selection between history and tree view. Selection by history view
+ //! \param theSelected a selected items
+ //! \param theDeselected a deselected items
+ void onHistoryViewSelectionChanged (const QItemSelection& theSelected,
+ const QItemSelection& theDeselected);
+
+ //! Processes selection in tree view: make presentation or owner selected in the context if corresponding
+ //! check box is checked
+ //! \param theSelected a selected items
+ //! \param theDeselected a deselected items
+ void onSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
+
+ //! Exports the first selected shape into ShapeViewer plugin.
+ void onExportToShapeView();
+
+ //! Shows selected presentation if it is not shown yet
+ void onShow();
+
+ //! Erase selected presentation if it is shown
+ void onHide();
+
+private:
+
+ //! Inits the window content by the given context
+ //! \param theContext a context
+ void SetContext (const Handle(AIS_InteractiveContext)& theContext);
+
+ //! Updates tree model
+ void UpdateTreeModel();
+
+ //! Creates an action with the given text connected to the slot
+ //! \param theText an action text value
+ //! \param theSlot a listener of triggered signal of the new action
+ //! \return a new action
+ QAction* createAction(const QString& theText, const char* theSlot);
+
+ //! Set selected in tree view presentations displayed or erased in the current context. Note that erased presentations
+ //! still belongs to the current context until Remove is called.
+ //! \param theToDisplay if true, presentation is displayed otherwise erased
+ void displaySelectedPresentations (const bool theToDisplay);
+
+private:
+
+ QMainWindow* myMainWindow; //!< main control
+ VInspector_ToolBar* myToolBar; //!< tool bar actions
+ QTreeView* myTreeView; //!< tree view of AIS content
+ QTreeView* myHistoryView; //!< history of AIS context calls
+ Handle(VInspector_CallBack) myCallBack; //!< AIS context call back, if set
+
+ Handle(TInspectorAPI_PluginParameters) myParameters; //!< plugins parameters container
+};
+
+#endif
--- /dev/null
+View.qrc
+View_ContextType.hxx
+View_Displayer.cxx
+View_Displayer.hxx
+View_PresentationType.hxx
+View_ToolActionType.hxx
+View_ToolBar.cxx
+View_ToolBar.hxx
+View_ViewActionType.hxx
+View_Viewer.cxx
+View_Viewer.hxx
+View_Widget.cxx
+View_Widget.hxx
+View_Window.cxx
+View_Window.hxx
--- /dev/null
+<!DOCTYPE RCC><RCC version="1.0">
+ <qresource>
+ <file>icons/cursor_rotate.png</file>
+ <file>icons/cursor_zoom.png</file>
+ <file>icons/keep_view_off.png</file>
+ <file>icons/keep_view_on.png</file>
+ <file>icons/view_clear.png</file>
+ <file>icons/view_dm_shading.png</file>
+ <file>icons/view_dm_wireframe.png</file>
+ <file>icons/view_fitall.png</file>
+ <file>icons/view_fitarea.png</file>
+ <file>icons/view_pan.png</file>
+ <file>icons/view_rotate.png</file>
+ <file>icons/view_zoom.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.
+
+#ifndef View_ConextType_H
+#define View_ConextType_H
+
+//! Type of context used in a tool library
+enum View_ContextType
+{
+ View_ContextType_Own, //!< View widget context is used
+ View_ContextType_None, //!< no context (is useful if visualization is not needed, for better performance)
+ View_ContextType_External //!< context is set from outside
+};
+
+#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 <View_Displayer.hxx>
+
+#include <AIS_InteractiveContext.hxx>
+#include <AIS_InteractiveObject.hxx>
+#include <AIS_ListIteratorOfListOfInteractive.hxx>
+#include <V3d_View.hxx>
+#include <V3d_Viewer.hxx>
+#include <View_Viewer.hxx>
+#include <View_Widget.hxx>
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+View_Displayer::View_Displayer()
+: myIsKeepPresentations (false), myDisplayMode (-1)
+{
+}
+
+// =======================================================================
+// function : SetContext
+// purpose :
+// =======================================================================
+void View_Displayer::SetContext (const Handle(AIS_InteractiveContext)& theContext)
+{
+ NCollection_DataMap<View_PresentationType, NCollection_Shared<AIS_ListOfInteractive> > aDisplayed = myDisplayed;
+ EraseAllPresentations (true);
+ myContext = theContext;
+
+ for (NCollection_DataMap<View_PresentationType, NCollection_Shared<AIS_ListOfInteractive> >::Iterator aDisplayedIt(aDisplayed);
+ aDisplayedIt.More(); aDisplayedIt.Next())
+ {
+ View_PresentationType aType = aDisplayedIt.Key();
+ for (AIS_ListIteratorOfListOfInteractive aPresentationsIt (aDisplayedIt.Value());
+ aPresentationsIt.More(); aPresentationsIt.Next())
+ DisplayPresentation (aPresentationsIt.Value(), aType, false);
+ }
+ UpdateViewer();
+}
+
+// =======================================================================
+// function : SetDisplayMode
+// purpose :
+// =======================================================================
+void View_Displayer::SetDisplayMode (const int theDisplayMode,
+ const View_PresentationType theType,
+ const bool theToUpdateViewer)
+{
+ myDisplayMode = theDisplayMode;
+ if (GetContext().IsNull())
+ return;
+
+ NCollection_Shared<AIS_ListOfInteractive> aDisplayed;
+ DisplayedPresentations (aDisplayed, theType);
+
+ for (AIS_ListIteratorOfListOfInteractive aDisplayedIt (aDisplayed); aDisplayedIt.More(); aDisplayedIt.Next())
+ GetContext()->SetDisplayMode (aDisplayedIt.Value(), theDisplayMode, Standard_False);
+
+ if (theToUpdateViewer)
+ UpdateViewer();
+}
+
+// =======================================================================
+// function : DisplayPresentation
+// purpose :
+// =======================================================================
+void View_Displayer::DisplayPresentation (const Handle(Standard_Transient)& thePresentation,
+ const View_PresentationType theType,
+ const bool theToUpdateViewer)
+{
+ if (GetContext().IsNull())
+ return;
+
+ NCollection_Shared<AIS_ListOfInteractive> aDisplayed;
+ DisplayedPresentations (aDisplayed, theType);
+ if (!myIsKeepPresentations)
+ ErasePresentations (theType, false);
+
+ Handle(AIS_InteractiveObject) aPresentation = Handle(AIS_InteractiveObject)::DownCast (thePresentation);
+ if (!aPresentation.IsNull() && aPresentation->GetContext().IsNull())
+ {
+ // one presentation can not be shown in several contexts
+ if (theType == View_PresentationType_Additional)
+ {
+ Quantity_Color aColor;
+ if (myColorAttributes.Find (View_PresentationType_Additional, aColor))
+ aPresentation->SetColor (aColor);
+ }
+ GetContext()->Display (aPresentation, false);
+ if (myDisplayMode != -1)
+ GetContext()->SetDisplayMode (aPresentation, myDisplayMode, false);
+ aDisplayed.Append (aPresentation);
+ }
+
+ if (!myIsKeepPresentations)
+ {
+ Handle(V3d_View) aView = GetView();
+ if (!aView.IsNull())
+ {
+ aView->FitAll();
+ aView->Redraw();
+ }
+ }
+ myDisplayed.Bind (theType, aDisplayed);
+
+ if (theToUpdateViewer)
+ UpdateViewer();
+}
+
+// =======================================================================
+// function : EraseAllPresentations
+// purpose :
+// =======================================================================
+void View_Displayer::EraseAllPresentations (const bool theToUpdateViewer)
+{
+ for (NCollection_DataMap<View_PresentationType, NCollection_Shared<AIS_ListOfInteractive> >::Iterator aDisplayedIt(myDisplayed);
+ aDisplayedIt.More(); aDisplayedIt.Next())
+ ErasePresentations (aDisplayedIt.Key(), false);
+
+ if (theToUpdateViewer)
+ UpdateViewer();
+}
+
+// =======================================================================
+// function : ErasePresentations
+// purpose :
+// =======================================================================
+void View_Displayer::ErasePresentations (const View_PresentationType theType, const bool theToUpdateViewer)
+{
+ if (GetContext().IsNull())
+ return;
+
+ NCollection_Shared<AIS_ListOfInteractive> aDisplayed;
+ DisplayedPresentations (aDisplayed, theType);
+
+ for (AIS_ListIteratorOfListOfInteractive aDisplayedIt (aDisplayed); aDisplayedIt.More(); aDisplayedIt.Next())
+ GetContext()->Remove (aDisplayedIt.Value(), Standard_False);
+
+ if (theToUpdateViewer)
+ UpdateViewer();
+}
+
+// =======================================================================
+// function : UpdateViewer
+// purpose :
+// =======================================================================
+void View_Displayer::UpdateViewer()
+{
+ if (GetContext().IsNull())
+ return;
+
+ GetContext()->UpdateCurrentViewer();
+}
+
+// =======================================================================
+// function : SetAttributeColor
+// purpose :
+// =======================================================================
+void View_Displayer::SetAttributeColor (const Quantity_Color& theColor, const View_PresentationType theType)
+{
+ myColorAttributes.Bind (theType, theColor);
+}
+
+// =======================================================================
+// function : DisplayedPresentations
+// purpose :
+// =======================================================================
+void View_Displayer::DisplayedPresentations (NCollection_Shared<AIS_ListOfInteractive>& thePresentations,
+ const View_PresentationType theType)
+{
+ myDisplayed.Find (theType, thePresentations);
+}
+
+// =======================================================================
+// function : getView
+// purpose :
+// =======================================================================
+Handle(V3d_View) View_Displayer::GetView() const
+{
+ Handle(V3d_View) aView;
+ if (GetContext().IsNull())
+ return aView;
+
+ const Handle(V3d_Viewer)& aViewer = GetContext()->CurrentViewer();
+ if (!aViewer.IsNull())
+ {
+ aViewer->InitActiveViews();
+ if (aViewer->MoreActiveViews())
+ aView = aViewer->ActiveView();
+ }
+ return aView;
+}
--- /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 View_Displayer_H
+#define View_Displayer_H
+
+#include <AIS_ListOfInteractive.hxx>
+#include <AIS_InteractiveContext.hxx>
+
+#include <NCollection_DataMap.hxx>
+#include <NCollection_Shared.hxx>
+#include <Quantity_Color.hxx>
+#include <View_PresentationType.hxx>
+
+class V3d_View;
+
+//! \class View_Displayer
+//! \brief It is responsible for communication with AIS Interactive Context to:
+//! - display/erase presentations;
+//! - change display mode of visualized presentations (Shaded or WireFrame mode)
+//!
+//! It contains containers of visualized presentations to obtain presentations relating only to this displayer.
+//! Displayer is connected to AIS Interactive Context
+class View_Displayer
+{
+public:
+
+ //! Constructor
+ Standard_EXPORT View_Displayer();
+
+ //! Destructor
+ virtual ~View_Displayer() {}
+
+ //! Stores the current context where the presentations will be displayed/erased.
+ //! Erases previuously displayd presentations if there were some displayed
+ //! \param theContext a context instance
+ Standard_EXPORT void SetContext (const Handle(AIS_InteractiveContext)& theContext);
+
+ //! Stores boolean value if presentations should be keeped. If true, new displayed presentation is added to already
+ //! displayed ones, otherwise the displayed presentation is shown only.
+ //! \param theToKeepPresentation boolean state
+ void KeepPresentations (const bool theToKeepPresentations) { myIsKeepPresentations = theToKeepPresentations; }
+
+ //! Stores display mode and changes display mode of displayed presentations
+ //! \param theDisplayMode a mode: 0 - AIS_WireFrame, 1 - AIS_Shaded
+ //! \param theType presentation type
+ //! \param isToUpdateView boolean state if viewer should be updated
+ Standard_EXPORT void SetDisplayMode (const int theDisplayMode,
+ const View_PresentationType theType = View_PresentationType_Main,
+ const bool theToUpdateViewer = true);
+
+ //! Displays presentation in context, erase previous presentations if KeepPresentations is false,
+ //! Color of presentation is from attribute color if exists or the default color
+ //! Display mode is equal to the view state
+ //! If KeepPresentations is false, the viewer is fit all
+ //! Displayed presentation is stored in an internal map of displayed presentations
+ //! \param thePresentation a presentation, it will be casted to AIS_InteractiveObject
+ //! \param theType presentation type
+ //! \param isToUpdateView boolean state if viewer should be updated
+ Standard_EXPORT void DisplayPresentation (const Handle(Standard_Transient)& thePresentation,
+ const View_PresentationType theType = View_PresentationType_Main,
+ const bool theToUpdateViewer = true);
+
+ //! Erases all presentations from viewer. Iterates by internal map of displayed presentations and
+ //! erase these presentations.
+ //! \param isToUpdateView boolean state if viewer should be updated
+ Standard_EXPORT void EraseAllPresentations (const bool theToUpdateViewer = true);
+
+ //! Erases presentations of the given type
+ //! \param theType presentation type
+ //! \param isToUpdateView boolean state if viewer should be updated
+ Standard_EXPORT void ErasePresentations (const View_PresentationType theType = View_PresentationType_Main,
+ const bool theToUpdateViewer = true);
+
+ //! Calls UpdateCurrentViewer of context
+ Standard_EXPORT void UpdateViewer();
+
+ //! Stores color for type of presentation. During display of presentation of the given type, the color is used
+ //! \param theColor a presentation color
+ //! \param theType presentation type
+ Standard_EXPORT void SetAttributeColor (const Quantity_Color& theColor,
+ const View_PresentationType theType = View_PresentationType_Main);
+
+ //! Returns container of displayed presentations for the given type
+ //! \param thePresentations a container to be filled
+ //! \param theType presentation type
+ Standard_EXPORT void DisplayedPresentations (NCollection_Shared<AIS_ListOfInteractive>& thePresentations,
+ const View_PresentationType theType = View_PresentationType_Main);
+
+ //! Returns all displayed by the trihedron objects
+ const NCollection_DataMap<View_PresentationType, NCollection_Shared<AIS_ListOfInteractive>>& GetDisplayed() const { return myDisplayed; }
+
+private:
+
+ //! Returns the current context
+ const Handle(AIS_InteractiveContext)& GetContext() const { return myContext; }
+
+ //! Returns 3d view
+ Handle(V3d_View) GetView() const;
+
+private:
+
+ Handle(AIS_InteractiveContext) myContext; //!< context, where the displayer works
+ NCollection_DataMap<View_PresentationType, NCollection_Shared<AIS_ListOfInteractive>> myDisplayed; //!< visualized presentations
+ NCollection_DataMap<View_PresentationType, Quantity_Color> myColorAttributes; //!< color properties of presentations
+
+ bool myIsKeepPresentations; //!< flag if previously shown presentations stays in the context by displaying a new one
+ int myDisplayMode; //!< display mode: 0 - AIS_WireFrame, 1 - AIS_Shaded
+};
+
+#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.
+
+#ifndef View_PresentationType_H
+#define View_PresentationType_H
+
+//! Type of displayed presentation in View displayed in AIS_InteractiveContext
+enum View_PresentationType
+{
+ View_PresentationType_Main, //!< general presentation, mostly used
+ View_PresentationType_Additional //!< additional presentation
+};
+
+#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.
+
+#ifndef View_ToolActionType_H
+#define View_ToolActionType_H
+
+//! Actions of view tool bar
+enum View_ToolActionType
+{
+ View_ToolActionType_KeepViewId, //!< Do not clear previously shown presentations
+ View_ToolActionType_KeepViewOffId, //!< Do show only for new displayed presentation
+ View_ToolActionType_ClearViewId //!< Erase all displayed presentations
+};
+
+#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 <View_ToolBar.hxx>
+
+#include <QComboBox>
+#include <QHBoxLayout>
+#include <QLabel>
+#include <QToolButton>
+#include <QWidget>
+
+const int DEFAULT_COMBO_WIDTH_MINIMUM = 80;
+const int DEFAULT_SPACING = 3;
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+View_ToolBar::View_ToolBar (QWidget* theParent)
+: QObject (theParent)
+{
+ myMainWindow = new QWidget (theParent);
+
+ QHBoxLayout* aLay = new QHBoxLayout (myMainWindow);
+ aLay->setContentsMargins (0, 0, 0, 0);
+ aLay->setSpacing (DEFAULT_SPACING);
+
+ QWidget* aViewSelectorWidget = new QWidget (myMainWindow);
+ QHBoxLayout* aViewSelectorLay = new QHBoxLayout (aViewSelectorWidget);
+ aViewSelectorLay->setContentsMargins (0, 0, 0, 0);
+ aViewSelectorLay->setContentsMargins (0, 0, 0, 0);
+ aViewSelectorLay->addWidget (new QLabel (tr ("View: "), aViewSelectorWidget));
+ myViewSelector = new QComboBox (aViewSelectorWidget);
+ myViewSelector->setMinimumWidth (DEFAULT_COMBO_WIDTH_MINIMUM);
+ aViewSelectorLay->addWidget (myViewSelector);
+ aLay->addWidget (aViewSelectorWidget);
+ connect (myViewSelector, SIGNAL (activated (int)), this, SIGNAL (contextChanged()));
+
+ myViewContextNames[View_ContextType_None] = tr ("None");
+ myViewContextNames[View_ContextType_Own] = tr ("Own");
+ myViewContextNames[View_ContextType_External] = tr ("External");
+
+ myViewSelector->insertItem(View_ContextType_None, myViewContextNames[View_ContextType_None]);
+ myViewSelector->insertItem(View_ContextType_Own, myViewContextNames[View_ContextType_Own]);
+
+ myViewSelector->setCurrentIndex(View_ContextType_Own);
+ myViewContexts[View_ContextType_None] = Handle(AIS_InteractiveContext)();
+ myViewContexts[View_ContextType_Own] = Handle(AIS_InteractiveContext)();
+ myViewContexts[View_ContextType_External] = Handle(AIS_InteractiveContext)();
+
+ myActionsMap[View_ToolActionType_KeepViewId] = new QToolButton (theParent);
+ myActionsMap[View_ToolActionType_KeepViewId]->setIcon (QIcon (":/icons/keep_view_on.png"));
+ myActionsMap[View_ToolActionType_KeepViewId]->setText (tr ("Keep View On"));
+ myActionsMap[View_ToolActionType_KeepViewId]->setToolTip (tr ("Keep View On: does not clear previously shown presentation"));
+ myActionsMap[View_ToolActionType_KeepViewId]->setCheckable (true);
+ myActionsMap[View_ToolActionType_KeepViewId]->setChecked (false);
+
+ myActionsMap[View_ToolActionType_KeepViewOffId] = new QToolButton (theParent);
+ myActionsMap[View_ToolActionType_KeepViewOffId]->setIcon (QIcon (":/icons/keep_view_off.png"));
+ myActionsMap[View_ToolActionType_KeepViewOffId]->setText (QObject::tr ("Keep View Off"));
+ myActionsMap[View_ToolActionType_KeepViewOffId]->setToolTip (tr ("Keep View Off: clear previously shown presentation"));
+ myActionsMap[View_ToolActionType_KeepViewOffId]->setCheckable (true);
+ myActionsMap[View_ToolActionType_KeepViewOffId]->setChecked (true);
+
+ myActionsMap[View_ToolActionType_ClearViewId] = new QToolButton (theParent);
+ myActionsMap[View_ToolActionType_ClearViewId]->setIcon (QIcon (":/icons/view_clear.png"));
+ myActionsMap[View_ToolActionType_ClearViewId]->setText (tr ( "Clear View"));
+ myActionsMap[View_ToolActionType_ClearViewId]->setToolTip (tr ("Remove all visualized presentations from view context"));
+
+ for (QMap<View_ToolActionType, QToolButton*>::ConstIterator anActionsIt = myActionsMap.begin(),
+ anActionsLast = myActionsMap.end(); anActionsIt != anActionsLast; anActionsIt++)
+ {
+ QToolButton* aBtn = anActionsIt.value();
+ connect (aBtn, SIGNAL (clicked()), this, SLOT (onActionClicked()));
+ aLay->addWidget (aBtn);
+ }
+ aLay->addStretch (1);
+}
+
+TCollection_AsciiString getPointerInfo (const Handle(Standard_Transient)& thePointer, const bool isShortInfo)
+{
+ std::ostringstream aPtrStr;
+ aPtrStr << thePointer.operator->();
+ if (!isShortInfo)
+ return aPtrStr.str().c_str();
+
+ TCollection_AsciiString anInfoPtr (aPtrStr.str().c_str());
+ for (int aSymbolId = 1; aSymbolId < anInfoPtr.Length(); aSymbolId++)
+ {
+ if (anInfoPtr.Value(aSymbolId) != '0')
+ {
+ anInfoPtr = anInfoPtr.SubString(aSymbolId, anInfoPtr.Length());
+ anInfoPtr.Prepend("0x");
+ return anInfoPtr;
+ }
+ }
+ return aPtrStr.str().c_str();
+}
+
+// =======================================================================
+// function : SetContext
+// purpose :
+// =======================================================================
+void View_ToolBar::SetContext (View_ContextType theType, const Handle(AIS_InteractiveContext)& theContext)
+{
+ myViewContexts[theType] = theContext;
+
+ QString aViewContextName = myViewContextNames[theType];
+ if (!theContext.IsNull())
+ aViewContextName = QString ("%1 : [%2]").arg (myViewContextNames[theType])
+ .arg (getPointerInfo (theContext, true).ToCString());
+ // there are only "Own" and "None" items
+ if (!theContext.IsNull() && theType == View_ContextType_External && myViewSelector->count() == 2)
+ myViewSelector->insertItem (View_ContextType_External, aViewContextName);
+ else
+ myViewSelector->setItemText (theType, aViewContextName);
+}
+
+// =======================================================================
+// function : getCurrentContextType
+// purpose :
+// =======================================================================
+View_ContextType View_ToolBar::GetCurrentContextType() const
+{
+ return (View_ContextType)myViewSelector->currentIndex();
+}
+
+// =======================================================================
+// function : GetCurrentContext
+// purpose :
+// =======================================================================
+Handle(AIS_InteractiveContext) View_ToolBar::GetCurrentContext() const
+{
+ View_ContextType aCurrentType = (View_ContextType)myViewSelector->currentIndex();
+ return myViewContexts[aCurrentType];
+}
+
+// =======================================================================
+// function : IsActionChecked
+// purpose :
+// =======================================================================
+bool View_ToolBar::IsActionChecked (const int theActionId) const
+{
+ View_ToolActionType anActionId = (View_ToolActionType)theActionId;
+ return myActionsMap.contains (anActionId) ? myActionsMap[anActionId]->isChecked() : false;
+}
+
+// =======================================================================
+// function : onActionClicked
+// purpose :
+// =======================================================================
+void View_ToolBar::onActionClicked()
+{
+ int anId = -1;
+ QToolButton* aSenderBtn = (QToolButton*)sender();
+
+ for (QMap<View_ToolActionType, QToolButton*>::ConstIterator anActionsIt = myActionsMap.begin(),
+ anActionsLast = myActionsMap.end(); anActionsIt != anActionsLast; anActionsIt++)
+ {
+ if (anActionsIt.value() == aSenderBtn)
+ {
+ anId = anActionsIt.key();
+ break;
+ }
+ }
+ if (anId != -1)
+ emit actionClicked (anId);
+
+ if (anId == View_ToolActionType_KeepViewId || anId == View_ToolActionType_KeepViewOffId)
+ {
+ if (anId == View_ToolActionType_KeepViewId)
+ myActionsMap[View_ToolActionType_KeepViewOffId]->setChecked (!aSenderBtn->isChecked());
+ else
+ myActionsMap[View_ToolActionType_KeepViewId]->setChecked (!aSenderBtn->isChecked());
+ }
+}
--- /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 View_ToolBar_H
+#define View_ToolBar_H
+
+#include <AIS_InteractiveContext.hxx>
+#include <Standard.hxx>
+#include <View_ContextType.hxx>
+#include <View_ToolActionType.hxx>
+
+#ifdef _MSC_VER
+ #pragma warning(disable : 4127 4718) // conditional expression is constant, recursive call has no side effects
+#endif
+#include <QObject>
+#include <QMap>
+
+class QComboBox;
+class QToolButton;
+class QWidget;
+
+//! \class View_ToolBar
+//! \brief This is a container of the next view actions:
+//! - selection of interactive context
+//! - actions of View_ToolActionType enumeration
+//!
+//! It contains container of possible interactive contexts where the presentations may be visualized
+//! and choice control to select an active context.
+//! If action is clicked, a signal about is sent.
+class View_ToolBar : public QObject
+{
+ Q_OBJECT
+
+public:
+ //! Constructor
+ Standard_EXPORT View_ToolBar (QWidget* theParent);
+
+ //! Destructor
+ virtual ~View_ToolBar() Standard_OVERRIDE {}
+
+ //! \returns parent widget of actions
+ QWidget* GetControl() const { return myMainWindow; }
+
+ //! Append context for the given type
+ //! \param theType a context type
+ //! \param theContext a context
+ Standard_EXPORT void SetContext (View_ContextType theType, const Handle(AIS_InteractiveContext)& theContext);
+
+ //! \returns type of active item of context selector
+ Standard_EXPORT View_ContextType GetCurrentContextType() const;
+
+ //! \returns an active context of context selector
+ Standard_EXPORT Handle(AIS_InteractiveContext) GetCurrentContext() const;
+
+ //! \returns whether the action is checked(toggled). Acceptable only if the action is checkable.
+ Standard_EXPORT bool IsActionChecked (const int theActionId) const;
+
+signals:
+
+ //! Signal about click on action of View_ToolActionType enumeration
+ void actionClicked (int theActionId);
+
+ //! Signal about selection of context
+ void contextChanged();
+
+private slots:
+
+ //! Processes clicked action and emit signal with action identifier
+ void onActionClicked();
+
+private:
+
+ QWidget* myMainWindow; //!< tool bar parent widget
+ QComboBox* myViewSelector; //!< container of possible contexts
+
+ QMap<View_ToolActionType, QToolButton*> myActionsMap; //!< tool actions
+ QMap<View_ContextType, Handle(AIS_InteractiveContext)> myViewContexts; //!< contexts
+ QMap<View_ContextType, QString> myViewContextNames; //!< names of contexts
+};
+
+#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.
+
+#ifndef View_ViewActionType_H
+#define View_ViewActionType_H
+
+//! Actions of view widget
+enum View_ViewActionType
+{
+ View_ViewActionType_FitAllId, //!< fits the view to wrap the bounding box of displayed objects
+ View_ViewActionType_FitAreaId, //!< zoom the view to the given area
+ View_ViewActionType_ZoomId, //!< zoom in/out the view by some delta
+ View_ViewActionType_PanId, //!< move position of the view camera
+ View_ViewActionType_RotationId, //!< rotate the view
+ View_ViewActionType_DisplayModeId //!< change display mode of visualized presentations (to wireframe or shading)
+};
+
+#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 <View_Viewer.hxx>
+
+#include <OpenGl_GraphicDriver.hxx>
+#include <Standard_ExtString.hxx>
+#include <Standard_Version.hxx>
+
+// =======================================================================
+// function : CreateView
+// purpose :
+// =======================================================================
+void View_Viewer::CreateView()
+{
+ if (myView.IsNull())
+ myView = myContext->CurrentViewer()->CreateView();
+}
+
+// =======================================================================
+// function : CreateView
+// purpose :
+// =======================================================================
+void View_Viewer::SetWindow(const Handle(Aspect_Window)& theWindow)
+{
+ myView->SetWindow (theWindow);
+ if (!theWindow->IsMapped())
+ theWindow->Map();
+}
+
+// =======================================================================
+// function : InitStandardViewer
+// purpose :
+// =======================================================================
+void View_Viewer::InitStandardViewer()
+{
+ Handle(Aspect_DisplayConnection) aDisplayConnection = new Aspect_DisplayConnection();
+ static Handle(OpenGl_GraphicDriver) aGraphicDriver = new OpenGl_GraphicDriver (aDisplayConnection);
+
+#if OCC_VERSION_HEX > 0x060901
+ myViewer = new V3d_Viewer (aGraphicDriver);
+#else
+ TCollection_AsciiString a3DName ("Visu3D");
+ myViewer = new V3d_Viewer (aGraphicDriver, a3DName.ToExtString(), "", 1000.0, V3d_XposYnegZpos, Quantity_NOC_GRAY30,
+ V3d_ZBUFFER, V3d_GOURAUD, V3d_WAIT, Standard_True, Standard_False);
+#endif
+
+ myViewer->SetDefaultLights();
+ myViewer->SetLightOn();
+ myViewer->SetDefaultBackgroundColor (Quantity_NOC_GRAY30);
+
+ myContext = new AIS_InteractiveContext (myViewer);
+ myContext->UpdateCurrentViewer();
+}
--- /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 View_Viewer_H
+#define View_Viewer_H
+
+#include <Aspect_Window.hxx>
+#include <AIS_InteractiveContext.hxx>
+#include <Quantity_Color.hxx>
+#include <Standard_Macro.hxx>
+#include <V3d_Viewer.hxx>
+#include <V3d_View.hxx>
+
+//! \class View_Viewer
+//! \brief It is responsible for context/viewer/view creation and accepting access to:
+class View_Viewer
+{
+public:
+
+ //! Constructor
+ View_Viewer (const Quantity_Color& theColor) : myDefaultColor(theColor) {}
+
+ //! Destructor
+ virtual ~View_Viewer() {}
+
+ //! Returns the view default colors
+ static Quantity_Color DefaultColor() { return Quantity_Color(Quantity_NOC_BLACK); }
+
+ //! Returns the view default colors
+ static Quantity_Color DisabledColor() { return Quantity_Color(195 / 255., 195 / 255., 195 / 255., Quantity_TOC_RGB); }
+
+ //! Creates V3d view
+ Standard_EXPORT void CreateView();
+
+ //! Fills V3d view by the given window
+ //! \param depending on platform it is either WNT_Window or Xw_Window
+ Standard_EXPORT void SetWindow (const Handle(Aspect_Window)& theWindow);
+
+ //! Creates OCC components on the window
+ //! \param theWindowHandle an id of the application window
+ Standard_EXPORT void InitStandardViewer();
+
+ //! Returns an OCC viewer
+ const Handle(V3d_Viewer)& GetViewer() { return myViewer; }
+
+ //! Returns active view
+ const Handle(V3d_View)& GetView() { return myView; }
+
+ //! Returns OCCT context to provide display and selection mechanism
+ const Handle(AIS_InteractiveContext)& GetContext() const { return myContext; }
+
+private:
+
+ Handle(V3d_Viewer) myViewer; //!< the OCCT viewer
+ Handle(V3d_View) myView; //!< the OCCT view window
+ Handle(AIS_InteractiveContext) myContext; //!< OCCT context to provide display and selection mechanism
+ Quantity_Color myDefaultColor; //!< the default color of the viewer
+};
+
+#endif // View_Viewer_H
--- /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.
+
+#if !defined _WIN32
+#define QT_CLEAN_NAMESPACE /* avoid definition of INT32 and INT8 */
+#endif
+
+#include <View_Widget.hxx>
+
+#include <Graphic3d_GraphicDriver.hxx>
+#include <Standard_Version.hxx>
+#include <View_ViewActionType.hxx>
+#include <View_Viewer.hxx>
+
+#include <QColorDialog>
+#include <QCursor>
+#include <QFileInfo>
+#include <QMdiSubWindow>
+#include <QMenu>
+#include <QMessageBox>
+#include <QMouseEvent>
+#include <QPainter>
+#include <QRubberBand>
+#include <QStatusBar>
+#include <QStyleFactory>
+
+#include <stdio.h>
+
+#ifdef _WIN32
+#include <WNT_Window.hxx>
+#elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
+#include <Cocoa_Window.hxx>
+#else
+#include <Xw_Window.hxx>
+#endif
+
+// the key for multi selection :
+#define MULTISELECTIONKEY Qt::ShiftModifier
+// the key for shortcut (use to activate dynamic onRotate, panning)
+#define CASCADESHORTCUTKEY Qt::ControlModifier
+// for elastic bean selection
+#define ValZWMin 1
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+View_Widget::View_Widget (QWidget* theParent)
+: QWidget (theParent), myCurrentMode (View_CurrentAction3d_Nothing), myFirst (true), myDefaultWidth (-1),
+ myDefaultHeight (-1), myViewIsEnabled (true), myXmin (0), myYmin (0), myXmax (0), myYmax (0), myDragButtonDownX (0),
+ myDragButtonDownY (0), myDragMultiButtonDownX (0), myDragMultiButtonDownY (0), myIsRectVisible (false), myRectBand (0)
+{
+ myViewer = new View_Viewer (View_Viewer::DefaultColor());
+ myViewer->InitStandardViewer();
+
+ setAttribute (Qt::WA_PaintOnScreen);
+ setAttribute (Qt::WA_NoSystemBackground);
+
+ setMouseTracking (true);
+ setBackgroundRole (QPalette::NoRole);
+ // set focus policy to threat QContextMenuEvent from keyboard
+ setFocusPolicy (Qt::StrongFocus);
+
+ initViewActions();
+ initCursors();
+}
+
+// =======================================================================
+// function : SetPredefinedSize
+// purpose :
+// =======================================================================
+void View_Widget::SetPredefinedSize (int theDefaultWidth, int theDefaultHeight)
+{
+ myDefaultWidth = theDefaultWidth;
+ myDefaultHeight = theDefaultHeight;
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void View_Widget::Init()
+{
+ myViewer->CreateView();
+
+#ifdef _WIN32
+ Aspect_Handle aWindowHandle = (Aspect_Handle)winId();
+ Handle(Aspect_Window) aWnd = new WNT_Window (aWindowHandle);
+#if OCC_VERSION_HEX <= 0x060901
+ myViewer->GetView()->SetZClippingDepth (0.5);
+ myViewer->GetView()->SetZClippingWidth (0.5);
+#endif
+#elif defined (__APPLE__) && !defined (MACOSX_USE_GLX)
+ NSView* aViewHandle = (NSView*)winId();
+ Handle(Aspect_Window) aWnd = new Cocoa_Window (aViewHandle);
+#else
+ Window aWindowHandle = (Window)winId();
+ Handle(Aspect_DisplayConnection) aDispConnection = myViewer->GetContext()->CurrentViewer()->Driver()->GetDisplayConnection();
+ Handle(Aspect_Window) aWnd = new Xw_Window (aDispConnection, aWindowHandle);
+#endif
+ myViewer->SetWindow (aWnd);
+
+ myViewer->GetView()->SetBackgroundColor (View_Viewer::DefaultColor());
+ myViewer->GetView()->MustBeResized();
+}
+
+// =======================================================================
+// function : GetDisplayMode
+// purpose :
+// =======================================================================
+int View_Widget::GetDisplayMode() const
+{
+ return myViewActions[View_ViewActionType_DisplayModeId]->isChecked() ? AIS_Shaded : AIS_WireFrame;
+}
+
+// =======================================================================
+// function : paintEvent
+// purpose :
+// =======================================================================
+void View_Widget::paintEvent (QPaintEvent* /*theEvent*/)
+{
+#if QT_VERSION < 0x050000
+ if (myFirst)
+ {
+ Init();
+ myFirst = false;
+ }
+#endif
+ if (myViewer->GetView())
+ myViewer->GetView()->Redraw();
+}
+
+// =======================================================================
+// function : resizeEvent
+// purpose :
+// =======================================================================
+void View_Widget::resizeEvent (QResizeEvent* /*theEvent*/)
+{
+#if QT_VERSION > 0x050000
+ if (myFirst)
+ {
+ Init();
+ myFirst = false;
+ }
+#endif
+ if (myViewer->GetView())
+ myViewer->GetView()->MustBeResized();
+}
+
+// =======================================================================
+// function : sizeHint
+// purpose :
+// =======================================================================
+QSize View_Widget::sizeHint() const
+{
+ if (myDefaultWidth > 0 && myDefaultHeight > 0)
+ return QSize (myDefaultWidth, myDefaultHeight);
+
+ return QWidget::sizeHint();
+}
+
+// =======================================================================
+// function : SetEnabledView
+// purpose :
+// =======================================================================
+void View_Widget::SetEnabledView (const bool theIsEnabled)
+{
+ myViewIsEnabled = theIsEnabled;
+
+ if (myViewer->GetView())
+ myViewer->GetView()->SetBackgroundColor (theIsEnabled ? View_Viewer::DefaultColor()
+ : View_Viewer::DisabledColor());
+ for (int anActionId = View_ViewActionType_FitAllId; anActionId <= View_ViewActionType_DisplayModeId; anActionId++)
+ GetViewAction ((View_ViewActionType)anActionId)->setEnabled (theIsEnabled);
+}
+
+// =======================================================================
+// function : OnUpdateToggled
+// purpose :
+// =======================================================================
+void View_Widget::OnUpdateToggled (bool isOn)
+{
+ QAction* sentBy = (QAction*)sender();
+
+ if (sentBy == myViewActions[View_ViewActionType_DisplayModeId])
+ {
+ sentBy->setIcon (isOn ? QIcon (":/icons/view_dm_wireframe.png")
+ : QIcon (":/icons/view_dm_shading.png"));
+ return;
+ }
+
+ if (!isOn)
+ return;
+
+ for (int anActionId = View_ViewActionType_FitAllId; anActionId <= View_ViewActionType_RotationId; anActionId++)
+ {
+ QAction* anAction = myViewActions[(View_ViewActionType)anActionId];
+ if ((anAction == myViewActions[View_ViewActionType_FitAreaId]) ||
+ (anAction == myViewActions[View_ViewActionType_ZoomId]) ||
+ (anAction == myViewActions[View_ViewActionType_PanId]) ||
+ (anAction == myViewActions[View_ViewActionType_RotationId]))
+ {
+ if (anAction && (anAction != sentBy))
+ {
+ anAction->setChecked (false);
+ }
+ else
+ {
+ if (sentBy == myViewActions[View_ViewActionType_FitAreaId])
+ setActiveCursor (View_CursorMode_HandCursor);
+ else if (sentBy == myViewActions[View_ViewActionType_ZoomId])
+ setActiveCursor (View_CursorMode_ZoomCursor);
+ else if (sentBy == myViewActions[View_ViewActionType_PanId])
+ setActiveCursor (View_CursorMode_PanCursor);
+ else if (sentBy == myViewActions[View_ViewActionType_RotationId])
+ setActiveCursor (View_CursorMode_RotationCursor);
+ else
+ setActiveCursor (View_CursorMode_DefaultCursor);
+ }
+ }
+ }
+}
+
+// =======================================================================
+// function : initViewActions
+// purpose :
+// =======================================================================
+void View_Widget::initViewActions()
+{
+ if (!myViewActions.empty())
+ return;
+
+ createAction (View_ViewActionType_FitAllId, ":/icons/view_fitall.png", tr ("Fit All"), SLOT (OnFitAll()));
+ createAction (View_ViewActionType_FitAreaId, ":/icons/view_fitarea.png", tr ("Fit Area"), SLOT (OnFitArea()), true);
+ createAction (View_ViewActionType_ZoomId, ":/icons/view_zoom.png", tr ("Zoom"), SLOT (OnZoom()), true);
+ createAction (View_ViewActionType_PanId, ":/icons/view_pan.png", tr ("Pan"), SLOT (OnPan()), true);
+ createAction (View_ViewActionType_RotationId, ":/icons/view_rotate.png", tr ("Rotation"), SLOT (OnRotate()), true);
+ createAction (View_ViewActionType_DisplayModeId, ":/icons/view_dm_shading.png", tr ("Display Mode"),
+ SIGNAL (displayModeClicked()), true);
+
+ for (int anActionId = View_ViewActionType_FitAreaId; anActionId <= View_ViewActionType_RotationId; anActionId++)
+ connect (myViewActions[(View_ViewActionType)anActionId], SIGNAL (toggled(bool)), this, SLOT (OnUpdateToggled(bool)));
+}
+
+// =======================================================================
+// function : initCursors
+// purpose :
+// =======================================================================
+void View_Widget::initCursors()
+{
+ if (!myCursors.empty())
+ return;
+
+ myCursors[View_CursorMode_DefaultCursor] = QCursor (Qt::ArrowCursor);
+ myCursors[View_CursorMode_HandCursor] = QCursor (Qt::PointingHandCursor);
+ myCursors[View_CursorMode_PanCursor] = QCursor (Qt::SizeAllCursor);
+ myCursors[View_CursorMode_ZoomCursor] = QCursor(QIcon (":/icons/cursor_zoom.png").pixmap (20, 20));
+ myCursors[View_CursorMode_RotationCursor] = QCursor(QIcon (":/icons/cursor_rotate.png").pixmap (20, 20));
+}
+
+// =======================================================================
+// function : mousePressEvent
+// purpose :
+// =======================================================================
+void View_Widget::mousePressEvent (QMouseEvent* theEvent)
+{
+ if (theEvent->button() == Qt::LeftButton)
+ processLeftButtonDown (theEvent->buttons() | theEvent->modifiers(), theEvent->pos());
+ else if (theEvent->button() == Qt::MidButton)
+ processMiddleButtonDown (theEvent->buttons() | theEvent->modifiers(), theEvent->pos());
+ else if (theEvent->button() == Qt::RightButton)
+ processRightButtonDown (theEvent->buttons() | theEvent->modifiers(), theEvent->pos());
+}
+
+// =======================================================================
+// function : mouseReleaseEvent
+// purpose :
+// =======================================================================
+void View_Widget::mouseReleaseEvent (QMouseEvent* theEvent)
+{
+ if (theEvent->button() == Qt::LeftButton)
+ processLeftButtonUp (theEvent->buttons() | theEvent->modifiers(), theEvent->pos());
+ else if (theEvent->button() == Qt::MidButton)
+ processMiddleButtonUp (theEvent->buttons() | theEvent->modifiers(), theEvent->pos());
+ else if (theEvent->button() == Qt::RightButton)
+ processRightButtonUp (theEvent->buttons() | theEvent->modifiers(), theEvent->pos());
+}
+
+// =======================================================================
+// function : mouseMoveEvent
+// purpose :
+// =======================================================================
+void View_Widget::mouseMoveEvent (QMouseEvent* theEvent)
+{
+ processMouseMove (theEvent->buttons() | theEvent->modifiers(), theEvent->pos());
+}
+
+// =======================================================================
+// function : activateCursor
+// purpose :
+// =======================================================================
+void View_Widget::activateCursor (const View_CurrentAction3d theMode)
+{
+ switch (theMode)
+ {
+ case View_CurrentAction3d_DynamicPanning:
+ {
+ setActiveCursor (View_CursorMode_PanCursor);
+ break;
+ }
+ case View_CurrentAction3d_DynamicZooming:
+ {
+ setActiveCursor (View_CursorMode_ZoomCursor);
+ break;
+ }
+ case View_CurrentAction3d_DynamicRotation:
+ {
+ setActiveCursor (View_CursorMode_RotationCursor);
+ break;
+ }
+ case View_CurrentAction3d_WindowZooming:
+ {
+ setActiveCursor (View_CursorMode_HandCursor);
+ break;
+ }
+ case View_CurrentAction3d_Nothing:
+ default:
+ {
+ setActiveCursor (View_CursorMode_DefaultCursor);
+ break;
+ }
+ }
+}
+
+// =======================================================================
+// function : processLeftButtonDown
+// purpose :
+// =======================================================================
+void View_Widget::processLeftButtonDown (const int theFlags, const QPoint thePoint)
+{
+ // save the current mouse coordinate in min
+ myXmin = thePoint.x();
+ myYmin = thePoint.y();
+ myXmax = thePoint.x();
+ myYmax = thePoint.y();
+
+ if (theFlags & CASCADESHORTCUTKEY)
+ {
+ myCurrentMode = View_CurrentAction3d_DynamicZooming;
+ OnUpdateToggled(true);
+ }
+ else
+ {
+ switch (myCurrentMode)
+ {
+ case View_CurrentAction3d_Nothing:
+ {
+ if (theFlags & MULTISELECTIONKEY)
+ processDragMultiEvent (myXmax, myYmax, View_DragMode_ButtonDown);
+ else
+ processDragEvent (myXmax, myYmax, View_DragMode_ButtonDown);
+ break;
+ }
+ case View_CurrentAction3d_DynamicZooming:
+ case View_CurrentAction3d_WindowZooming:
+ case View_CurrentAction3d_DynamicPanning:
+ break;
+ case View_CurrentAction3d_DynamicRotation:
+ {
+ myViewer->GetView()->StartRotation (thePoint.x(), thePoint.y());
+ break;
+ }
+ default:
+ {
+ throw Standard_ProgramError ("View_Widget::processLeftButtonDown : Incompatible Current Mode");
+ break;
+ }
+ }
+ }
+ activateCursor (myCurrentMode);
+}
+
+// =======================================================================
+// function : processMiddleButtonDown
+// purpose :
+// =======================================================================
+void View_Widget::processMiddleButtonDown (const int theFlags, const QPoint /*thePoint*/)
+{
+ if (theFlags & CASCADESHORTCUTKEY) {
+ myCurrentMode = View_CurrentAction3d_DynamicPanning;
+ OnUpdateToggled(true);
+ }
+ activateCursor (myCurrentMode);
+}
+
+// =======================================================================
+// function : processRightButtonDown
+// purpose :
+// =======================================================================
+void View_Widget::processRightButtonDown (const int theFlags, const QPoint thePoint)
+{
+ if (theFlags & CASCADESHORTCUTKEY)
+ {
+ myCurrentMode = View_CurrentAction3d_DynamicRotation;
+ myViewer->GetView()->StartRotation (thePoint.x(), thePoint.y());
+ OnUpdateToggled(true);
+ }
+ else
+ {
+ popup (thePoint.x(), thePoint.y());
+ }
+ activateCursor (myCurrentMode);
+}
+
+// =======================================================================
+// function : processLeftButtonUp
+// purpose :
+// =======================================================================
+void View_Widget::processLeftButtonUp (const int theFlags, const QPoint thePoint)
+{
+ switch (myCurrentMode)
+ {
+ case View_CurrentAction3d_Nothing:
+ {
+ if (thePoint.x() == myXmin && thePoint.y() == myYmin)
+ {
+ // no offset between down and up --> selectEvent
+ myXmax = thePoint.x();
+ myYmax = thePoint.y();
+ if (theFlags & MULTISELECTIONKEY)
+ processInputMultiEvent (thePoint.x(), thePoint.y());
+ else
+ processInputEvent (thePoint.x(), thePoint.y());
+ }
+ else
+ {
+ drawRectangle (myXmin, myYmin, myXmax, myYmax, Standard_False);
+ myXmax = thePoint.x();
+ myYmax = thePoint.y();
+ if (theFlags & MULTISELECTIONKEY)
+ processDragMultiEvent (thePoint.x(), thePoint.y(), View_DragMode_ButtonUp);
+ else
+ processDragEvent (thePoint.x(), thePoint.y(), View_DragMode_ButtonUp);
+ }
+ break;
+ }
+ case View_CurrentAction3d_DynamicZooming:
+ break;
+ case View_CurrentAction3d_WindowZooming:
+ {
+ drawRectangle (myXmin, myYmin, myXmax, myYmax, Standard_False);
+ myXmax = thePoint.x();
+ myYmax = thePoint.y();
+ if ((abs(myXmin - myXmax) > ValZWMin) ||
+ (abs(myYmin - myYmax) > ValZWMin))
+ myViewer->GetView()->WindowFitAll (myXmin, myYmin, myXmax, myYmax);
+ break;
+ }
+ case View_CurrentAction3d_DynamicPanning:
+ break;
+ case View_CurrentAction3d_DynamicRotation:
+ break;
+ default:
+ {
+ throw Standard_ProgramError("View_Widget::processLeftButtonUp : Incompatible Current Mode");
+ break;
+ }
+ }
+ myDragButtonDownX = 0;
+ myDragButtonDownY = 0;
+ myDragMultiButtonDownX = 0;
+ myDragMultiButtonDownY = 0;
+
+ activateCursor (myCurrentMode);
+ emit selectionChanged();
+}
+
+// =======================================================================
+// function : processMiddleButtonUp
+// purpose :
+// =======================================================================
+void View_Widget::processMiddleButtonUp (const int /*theFlags*/, const QPoint /*thePoint*/)
+{
+ myCurrentMode = View_CurrentAction3d_Nothing;
+ activateCursor (myCurrentMode);
+}
+
+// =======================================================================
+// function : processRightButtonUp
+// purpose :
+// =======================================================================
+void View_Widget::processRightButtonUp (const int /*theFlags*/, const QPoint thePoint)
+{
+ if (myCurrentMode == View_CurrentAction3d_Nothing)
+ {
+ popup (thePoint.x(), thePoint.y());
+ }
+ else
+ myCurrentMode = View_CurrentAction3d_Nothing;
+ activateCursor (myCurrentMode);
+}
+
+// =======================================================================
+// function : processMouseMove
+// purpose :
+// =======================================================================
+void View_Widget::processMouseMove (const int theFlags, const QPoint thePoint)
+{
+ if (theFlags & Qt::LeftButton || theFlags & Qt::RightButton || theFlags & Qt::MidButton)
+ {
+ switch (myCurrentMode)
+ {
+ case View_CurrentAction3d_Nothing:
+ {
+ myXmax = thePoint.x();
+ myYmax = thePoint.y();
+ drawRectangle (myXmin, myYmin, myXmax, myYmax, Standard_False);
+ if (theFlags & MULTISELECTIONKEY)
+ processDragMultiEvent (myXmax, myYmax, View_DragMode_ButtonMove);
+ else
+ processDragEvent (myXmax, myYmax, View_DragMode_ButtonMove);
+ drawRectangle (myXmin, myYmin, myXmax, myYmax, Standard_True);
+ break;
+ }
+ case View_CurrentAction3d_DynamicZooming:
+ {
+ myViewer->GetView()->Zoom (myXmax, myYmax, thePoint.x(), thePoint.y());
+ myXmax = thePoint.x();
+ myYmax = thePoint.y();
+ break;
+ }
+ case View_CurrentAction3d_WindowZooming:
+ {
+ myXmax = thePoint.x();
+ myYmax = thePoint.y();
+ drawRectangle (myXmin, myYmin, myXmax, myYmax, Standard_False);
+ drawRectangle (myXmin, myYmin, myXmax, myYmax, Standard_True);
+ break;
+ }
+ case View_CurrentAction3d_DynamicPanning:
+ {
+ myViewer->GetView()->Pan (thePoint.x() - myXmax, myYmax - thePoint.y());
+ myXmax = thePoint.x();
+ myYmax = thePoint.y();
+ break;
+ }
+ case View_CurrentAction3d_DynamicRotation:
+ {
+ myViewer->GetView()->Rotation (thePoint.x(), thePoint.y());
+ myViewer->GetView()->Redraw();
+ break;
+ }
+ default:
+ {
+ throw Standard_ProgramError("View_Widget::processMouseMove : Incompatible Current Mode");
+ break;
+ }
+ }
+ }
+ else
+ {
+ myXmax = thePoint.x();
+ myYmax = thePoint.y();
+ if (theFlags & MULTISELECTIONKEY)
+ processMoveMultiEvent (thePoint.x(), thePoint.y());
+ else
+ processMoveEvent (thePoint.x(), thePoint.y());
+ }
+}
+
+// =======================================================================
+// function : processDragEvent
+// purpose :
+// =======================================================================
+void View_Widget::processDragEvent (const Standard_Integer theX, const Standard_Integer theY, const View_DragMode& theState)
+{
+ //myDragButtonDownX = 0;
+ //myDragButtonDownY = 0;
+
+ switch (theState)
+ {
+ case View_DragMode_ButtonDown:
+ {
+ myDragButtonDownX = theX;
+ myDragButtonDownY = theY;
+ break;
+ }
+ case View_DragMode_ButtonMove:
+ break;
+ case View_DragMode_ButtonUp:
+ {
+ myViewer->GetContext()->Select (myDragButtonDownX, myDragButtonDownY, theX, theY, myViewer->GetView(), Standard_True);
+ emit selectionChanged();
+ break;
+ }
+ default:
+ break;
+ }
+}
+
+// =======================================================================
+// function : processInputEvent
+// purpose :
+// =======================================================================
+void View_Widget::processInputEvent (const Standard_Integer/* theX*/, const Standard_Integer/* theY*/)
+{
+ myViewer->GetContext()->Select (Standard_True);
+ emit selectionChanged();
+}
+
+// =======================================================================
+// function : processMoveEvent
+// purpose :
+// =======================================================================
+void View_Widget::processMoveEvent (const Standard_Integer theX, const Standard_Integer theY)
+{
+ myViewer->GetContext()->MoveTo (theX, theY, myViewer->GetView(), Standard_True);
+}
+
+// =======================================================================
+// function : processDragMultiEvent
+// purpose :
+// =======================================================================
+void View_Widget::processDragMultiEvent (const Standard_Integer theX, const Standard_Integer theY,
+ const View_DragMode& theState)
+{
+ switch (theState)
+ {
+ case View_DragMode_ButtonDown:
+ {
+ myDragMultiButtonDownX = theX;
+ myDragMultiButtonDownY = theY;
+ break;
+ }
+ case View_DragMode_ButtonMove:
+ {
+ myViewer->GetContext()->ShiftSelect (myDragMultiButtonDownX, myDragMultiButtonDownY, theX, theY,
+ myViewer->GetView(), Standard_True);
+ emit selectionChanged();
+ break;
+ }
+ case View_DragMode_ButtonUp:
+ default:
+ break;
+ }
+}
+
+// =======================================================================
+// function : processInputMultiEvent
+// purpose :
+// =======================================================================
+void View_Widget::processInputMultiEvent (const Standard_Integer /*theX*/, const Standard_Integer /*theY*/)
+{
+ myViewer->GetContext()->ShiftSelect (Standard_True);
+ emit selectionChanged();
+}
+
+// =======================================================================
+// function : drawRectangle
+// purpose :
+// =======================================================================
+void View_Widget::drawRectangle (const Standard_Integer theMinX, const Standard_Integer MinY,
+ const Standard_Integer MaxX, const Standard_Integer MaxY,
+ const Standard_Boolean theToDraw)
+{
+ Standard_Integer StoredMinX, StoredMaxX, StoredMinY, StoredMaxY;
+
+ StoredMinX = (theMinX < MaxX) ? theMinX : MaxX;
+ StoredMinY = (MinY < MaxY) ? MinY : MaxY;
+ StoredMaxX = (theMinX > MaxX) ? theMinX : MaxX;
+ StoredMaxY = (MinY > MaxY) ? MinY : MaxY;
+
+ QRect aRect;
+ aRect.setRect(StoredMinX, StoredMinY, abs (StoredMaxX-StoredMinX), abs (StoredMaxY-StoredMinY));
+
+ if (!myRectBand)
+ {
+ myRectBand = new QRubberBand (QRubberBand::Rectangle, this);
+ myRectBand->setStyle (QStyleFactory::create ("windows"));
+ myRectBand->setGeometry (aRect);
+ myRectBand->show();
+ }
+
+ if (myIsRectVisible && !theToDraw) // move or up : erase at the old position
+ {
+ myRectBand->hide();
+ delete myRectBand;
+ myRectBand = 0;
+ myIsRectVisible = false;
+ }
+
+ if (theToDraw) // move : draw
+ {
+ myIsRectVisible = true;
+ myRectBand->setGeometry (aRect);
+ }
+}
+
+// =======================================================================
+// function : createAction
+// purpose :
+// =======================================================================
+void View_Widget::createAction (const View_ViewActionType theActionId, const QString& theIcon, const QString& theText,
+ const char* theSlot, const bool isCheckable, const QString& theToolBar,
+ const QString& theStatusBar)
+{
+ QAction* anAction = new QAction (QIcon (theIcon), theText, this);
+ anAction->setToolTip (!theToolBar.isEmpty() ? theToolBar : theText);
+ anAction->setStatusTip (!theStatusBar.isEmpty() ? theStatusBar : theText);
+ if (isCheckable)
+ anAction->setCheckable (true);
+ connect(anAction, SIGNAL (triggered()) , this, theSlot);
+ myViewActions[theActionId] = anAction;
+}
+
+// =======================================================================
+// function : setActiveCursor
+// purpose :
+// =======================================================================
+void View_Widget::setActiveCursor (const View_CursorMode& theMode)
+{
+ QCursor aCursor = myCursors[theMode];
+ setCursor (myCursors[theMode]);
+}
--- /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 View_View_H
+#define View_View_H
+
+#include <AIS_InteractiveContext.hxx>
+#include <V3d_View.hxx>
+#include <View_ViewActionType.hxx>
+#include <View_Viewer.hxx>
+
+#ifdef _MSC_VER
+ #pragma warning(disable : 4127 4718) // conditional expression is constant, recursive call has no side effects
+#endif
+#include <QAction>
+#include <QMap>
+#include <QString>
+#include <QWidget>
+
+class View_Viewer;
+
+class QRubberBand;
+
+//! \class View_Widget
+//! \brief It is a Qt control that visualizes content of OCCT 3D view
+//! It creates control and actions of manipulating of this view,
+//! emits signal about selection happenning in the view and signal about display mode change and
+//! changes application cursor depending on an active action.
+class View_Widget : public QWidget
+{
+ Q_OBJECT
+protected:
+
+ //! Enumeration defines manipulating actions of the widget
+ enum View_CurrentAction3d
+ {
+ View_CurrentAction3d_Nothing, //!< Empty action
+ View_CurrentAction3d_DynamicZooming, //!< Zoom action
+ View_CurrentAction3d_WindowZooming, //!< Zoom action using rectangle
+ View_CurrentAction3d_DynamicPanning, //!< Panning action
+ View_CurrentAction3d_DynamicRotation //!< Rotation action
+ };
+
+ //! Enumeration defines cursor kind
+ enum View_CursorMode
+ {
+ View_CursorMode_DefaultCursor, //!< default Qt cursor
+ View_CursorMode_HandCursor, //!< hand cursor
+ View_CursorMode_PanCursor, //!< panning cursor
+ View_CursorMode_ZoomCursor, //!< zoom cursor
+ View_CursorMode_RotationCursor //!< onRotate cursor
+ };
+
+ //! Enumeration defines drag mode
+ enum View_DragMode
+ {
+ View_DragMode_ButtonDown, // theState == -1 button down
+ View_DragMode_ButtonMove, // theState == 0 move
+ View_DragMode_ButtonUp // theState == 1 button up
+ };
+
+public:
+
+ //! Constructor
+ Standard_EXPORT View_Widget (QWidget* theParent);
+
+ //! Destructor
+ virtual ~View_Widget() {}
+
+ //! Returns current viewer
+ View_Viewer* GetViewer() const { return myViewer; }
+
+ //! Sets default size that is used in sizeHint when the widget is firstly show
+ Standard_EXPORT void SetPredefinedSize (int theDefaultWidth, int theDefaultHeight);
+
+ //! Creates V3d view and set Qt control for it
+ Standard_EXPORT void Init();
+
+ //! Returns an action for the given action type
+ //! \param theActionId an action indes
+ QAction* GetViewAction (const View_ViewActionType theActionId) const { return myViewActions[theActionId]; };
+
+ //! \returns 0 - AIS_WireFrame, 1 - AIS_Shaded
+ Standard_EXPORT int GetDisplayMode() const;
+
+ //! Enable/disable view and tool bar actions depending on the parameter
+ //! \param theIsEnabled boolean value
+ Standard_EXPORT void SetEnabledView (const bool theIsEnabled);
+
+ //! Get paint engine for the OpenGL viewer. Avoid default execution of Qt Widget.
+ virtual QPaintEngine* paintEngine() const Standard_OVERRIDE { return 0; }
+
+ //! Recommended size for view. If default size exists, it returns the default size
+ Standard_EXPORT virtual QSize sizeHint() const Standard_OVERRIDE;
+
+signals:
+
+ //! Sends a signal about selection change if the left mouse button is pressed and current action does not process it
+ void selectionChanged();
+
+ //! Sends a signal about display mode change
+ void displayModeClicked();
+
+public slots:
+
+ //! Fits all the V3d view and redraw view
+ void OnFitAll() { myViewer->GetView()->FitAll(); }
+
+ //! Stores state about fitting all to use it by the mouse move
+ void OnFitArea() { myCurrentMode = View_CurrentAction3d_WindowZooming; }
+
+ //! Stores state about zoom to use it by the mouse move
+ void OnZoom() { myCurrentMode = View_CurrentAction3d_DynamicZooming; }
+
+ //! Stores state about pan to use it by the mouse move
+ void OnPan() { myCurrentMode = View_CurrentAction3d_DynamicPanning; }
+
+ //! Stores state about onRotate to use it by the mouse move
+ void OnRotate() { myCurrentMode = View_CurrentAction3d_DynamicRotation; }
+
+ //! Updates states of tool actions:
+ //! - if the action is display mode, it changes an icon for action(wireframe or shading)
+ //! - if the state is checked, uncheck all other actions
+ //! \param isOn boolean value about check
+ Standard_EXPORT void OnUpdateToggled (bool isOn);
+
+protected:
+
+ //! Avoid Qt standard execution of this method, redraw V3d view
+ //! \param an event
+ virtual void paintEvent (QPaintEvent* theEvent) Standard_OVERRIDE;
+
+ //! Avoid Qt standard execution of this method, do mustBeResized for V3d view, Init view if it is the first call
+ //! \param an event
+ virtual void resizeEvent (QResizeEvent* theEvent) Standard_OVERRIDE;
+
+ //! Left, Middle, Right button processing
+ //! \param an event
+ virtual void mousePressEvent (QMouseEvent* theEvent) Standard_OVERRIDE;
+
+ //! Left, Middle, Right button processing
+ //! \param an event
+ virtual void mouseReleaseEvent (QMouseEvent* theEvent) Standard_OVERRIDE;
+
+ //! Left, Middle, Right button processing
+ //! \param an event
+ virtual void mouseMoveEvent (QMouseEvent* theEvent) Standard_OVERRIDE;
+
+protected:
+
+ //! Creates view actions and fills an internal map
+ void initViewActions();
+
+ //! Creates cursors and fills an internal map
+ void initCursors();
+
+ //! Sets widget cursor by the action type
+ //! \param theMode an active action mode
+ void activateCursor (const View_CurrentAction3d theMode);
+
+ //! Activates cursor of the active operation, perform drag, onRotate depending on mode,
+ //! stores the point position in xmin/xmax and ymin/ymax
+ //! \param theFlags an event buttons and modifiers
+ //! \param thePoint a clicked point
+ void processLeftButtonDown (const int theFlags, const QPoint thePoint);
+
+ //! Activates cursor of the active operation and performs dynamic pan if it is active
+ //! \param theFlags an event buttons and modifiers
+ //! \param thePoint a clicked point
+ void processMiddleButtonDown (const int theFlags, const QPoint thePoint);
+
+ //! Activates cursor of the active operation, build popup menu
+ //! \param theFlags an event buttons and modifiers
+ //! \param thePoint a clicked point
+ void processRightButtonDown (const int theFlags, const QPoint thePoint);
+
+ //! Performs the active operation or performs Input/Drag event processing, emits selection changed signal
+ //! \param theFlags an event buttons and modifiers
+ //! \param thePoint a clicked point
+ void processLeftButtonUp (const int theFlags, const QPoint thePoint);
+
+ //! Changes the active operation to None
+ //! \param theFlags an event buttons and modifiers
+ //! \param thePoint a clicked point
+ void processMiddleButtonUp (const int theFlags, const QPoint thePoint);
+
+ //! Calls popup menu build and changes the active operation to None
+ //! \param theFlags an event buttons and modifiers
+ //! \param thePoint a clicked point
+ void processRightButtonUp (const int theFlags, const QPoint thePoint);
+
+ //! Performs active operation or draws rectangle of zoom
+ //! \param theFlags an event buttons and modifiers
+ //! \param thePoint a clicked point
+ void processMouseMove (const int theFlags, const QPoint thePoint);
+
+ //! Performs selection: store clicked point by botton down, call Select by button up
+ //! Emits signal about selection changed
+ //! \param theX a horizontal position of mouse event
+ //! \param theX a vertical position of mouse event
+ //! \param theState a mouse button state: down, move or up
+ void processDragEvent (const Standard_Integer theX, const Standard_Integer theY, const View_DragMode& theState);
+
+ //! Performs selection in context without parameter, it means the selection of picked object
+ //! \param theX a horizontal position of mouse event
+ //! \param theX a vertical position of mouse event
+ void processInputEvent (const Standard_Integer theX, const Standard_Integer theY);
+
+ //! Calls MoveTo of the context for the parameter coordinates
+ //! \param theX a horizontal position of mouse event
+ //! \param theX a vertical position of mouse event
+ void processMoveEvent (const Standard_Integer theX, const Standard_Integer theY);
+
+ //! Empty: template to process mouse move with multi selection key pressed
+ //! \param theX a horizontal position of mouse event
+ //! \param theX a vertical position of mouse event
+ void processMoveMultiEvent (const Standard_Integer theX, const Standard_Integer theY)
+ { (void)theX; (void)theY; }
+
+ //! Performs selection: store clicked point by botton down, call ShiftSelect by button move
+ //! Emits signal about selection changed
+ //! \param theX a horizontal position of mouse event
+ //! \param theX a vertical position of mouse event
+ //! \param theState a mouse button state: down, move or up
+ void processDragMultiEvent (const Standard_Integer theX, const Standard_Integer theY, const View_DragMode& theState);
+
+ //! Performs shift selection in context without parameter, it means the selection of picked object
+ //! \param theX a horizontal position of mouse event
+ //! \param theX a vertical position of mouse event
+ void processInputMultiEvent (const Standard_Integer theX, const Standard_Integer theY);
+
+ //! Empty: template to create popup menu
+ //! \param theX a horizontal position of mouse event
+ //! \param theX a vertical position of mouse event
+ void popup (const Standard_Integer theX, const Standard_Integer theY) { (void)theX; (void)theY; }
+
+ //! Draws Qt rectangle for the given area (e.g. for panning operation)
+ //! \param theMinX a minimal X coordinate
+ //! \param theMinY a minimal Y coordinate
+ //! \param theMinZ a minimal Z coordinate
+ //! \param theMaxX a maximum X coordinate
+ //! \param theMaxY a maximum Y coordinate
+ //! \param theMaxZ a maximum Z coordinate
+ //! \param theToDraw state whether the rectangle should be visualized or hidden
+ void drawRectangle (const Standard_Integer theMinX, const Standard_Integer theMinY, const Standard_Integer theMaxX,
+ const Standard_Integer theMaxY, const Standard_Boolean theToDraw);
+private:
+
+ //! Creates action and stores it in a map of actions
+ //! \param theActionId an identifier of action in internal map
+ //! \param theIcon an icon name and place according to qrc resource file, e.g. ":/icons/view_fitall.png"
+ //! \param theText an action text
+ //! \param theToolBar a tool bar action text
+ //! \param theStatusBar a status bar action text
+ void createAction (const View_ViewActionType theActionId, const QString& theIcon, const QString& theText,
+ const char* theSlot, const bool isCheckable = false,
+ const QString& theToolBar = QString(), const QString& theStatusBar = QString());
+
+ //! Sets active action cursor for application
+ //! \param theMode a cursor mode
+ void setActiveCursor (const View_CursorMode& theMode);
+
+private:
+
+ View_Viewer* myViewer; //!< connector to context, V3d viewer and V3d View
+ QMap<View_ViewActionType, QAction*> myViewActions; //!< tool bar view actions
+ QMap<View_CursorMode, QCursor> myCursors; //!< possible cursors for view actions
+
+ View_CurrentAction3d myCurrentMode; //!< an active action mode for viewer
+ bool myFirst; //!< flag to Init view by the first resize/paint call
+ int myDefaultWidth; //!< default width for the first sizeHint
+ int myDefaultHeight; //!< default height for the first sizeHint
+ bool myViewIsEnabled; //!< flag if the view and tool bar view actions are enabled/disabled
+ Standard_Integer myXmin; //!< cached X minimal position by mouse press event
+ Standard_Integer myYmin; //!< cached Y minimal position by mouse press event
+ Standard_Integer myXmax; //!< cached X maximum position by mouse press event
+ Standard_Integer myYmax; //!< cached Y maximum position by mouse press event
+ Standard_Integer myDragButtonDownX; //!< cached X button down by drag event
+ Standard_Integer myDragButtonDownY; //!< cached Y button down by drag event
+ Standard_Integer myDragMultiButtonDownX; //!< cached X button down by multi drag event
+ Standard_Integer myDragMultiButtonDownY; //!< cached Y button down by multi drag event
+ Standard_Boolean myIsRectVisible; //!< true if rectangle is visible now
+ QRubberBand* myRectBand; //!< selection rectangle rubber band
+};
+
+#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.
+
+#if !defined _WIN32
+#define QT_CLEAN_NAMESPACE /* avoid definition of INT32 and INT8 */
+#endif
+
+#include <View_Window.hxx>
+
+#include <View_Displayer.hxx>
+#include <View_ToolBar.hxx>
+#include <View_Viewer.hxx>
+#include <View_Widget.hxx>
+
+#include <QComboBox>
+#include <QDockWidget>
+#include <QGridLayout>
+#include <QToolBar>
+
+const int DEFAULT_SPACING = 3;
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+View_Window::View_Window (QWidget* theParent)
+: QWidget (theParent)
+{
+ QGridLayout* aViewLayout = new QGridLayout (this);
+ aViewLayout->setContentsMargins (0, 0, 0, 0);
+ aViewLayout->setSpacing (DEFAULT_SPACING);
+
+ myView = new View_Widget (this);
+ myViewToolBar = new View_ToolBar (this);
+ aViewLayout->addWidget (myViewToolBar->GetControl(), 0, 0, 1, 2);
+ connect (myViewToolBar, SIGNAL (contextChanged()), this, SLOT (onViewSelectorActivated()));
+ connect (myViewToolBar, SIGNAL (actionClicked (int)),
+ this, SLOT (onToolBarActionClicked (int)));
+
+ myActionsToolBar = new QToolBar (this);
+ myActionsToolBar->layout()->setContentsMargins (0, 0, 0, 0);
+ myActionsToolBar->setOrientation (Qt::Vertical);
+
+ for (int anActionId = View_ViewActionType_FitAllId; anActionId <= View_ViewActionType_DisplayModeId; anActionId++)
+ myActionsToolBar->addAction (myView->GetViewAction ((View_ViewActionType)anActionId));
+ aViewLayout->addWidget (myActionsToolBar, 1, 0);
+ aViewLayout->addWidget (myView, 1, 1);
+ aViewLayout->setRowStretch (1, 1);
+
+ Handle(AIS_InteractiveContext) aContext = myView->GetViewer()->GetContext();
+ myViewToolBar->SetContext (View_ContextType_Own, aContext);
+
+ myDisplayer = new View_Displayer();
+ connect (myView, SIGNAL (displayModeClicked()), this, SLOT (onDisplayModeChanged()));
+ onViewSelectorActivated();
+}
+
+// =======================================================================
+// function : SetContext
+// purpose :
+// =======================================================================
+void View_Window::SetContext (View_ContextType /*theType*/, const Handle(AIS_InteractiveContext)& theContext)
+{
+ GetViewToolBar()->SetContext (View_ContextType_External, theContext);
+}
+
+// =======================================================================
+// function : onViewSelectorActivated
+// purpose :
+// =======================================================================
+void View_Window::onViewSelectorActivated()
+{
+ View_ContextType aType = myViewToolBar->GetCurrentContextType();
+ bool isViewEnabled = aType == View_ContextType_Own;
+
+ myView->SetEnabledView (isViewEnabled);
+
+ Handle(AIS_InteractiveContext) aContext = myViewToolBar->GetCurrentContext();
+ myDisplayer->EraseAllPresentations (true);
+ myDisplayer->SetContext (aContext);
+}
+
+// =======================================================================
+// function : onToolBarActionClicked
+// purpose :
+// =======================================================================
+void View_Window::onToolBarActionClicked (const int theActionId)
+{
+ switch (theActionId)
+ {
+ case View_ToolActionType_KeepViewId:
+ {
+ myDisplayer->KeepPresentations (myViewToolBar->IsActionChecked (theActionId));
+ break;
+ }
+ case View_ToolActionType_KeepViewOffId:
+ {
+ myDisplayer->KeepPresentations (!myViewToolBar->IsActionChecked (theActionId));
+ break;
+ }
+ case View_ToolActionType_ClearViewId:
+ {
+ myDisplayer->EraseAllPresentations (true);
+ break;
+ }
+ default:
+ break;
+ }
+}
+
+// =======================================================================
+// function : onDisplayModeChanged
+// purpose :
+// =======================================================================
+void View_Window::onDisplayModeChanged()
+{
+ int aDisplayMode = myView->GetDisplayMode();
+ for (NCollection_DataMap<View_PresentationType, NCollection_Shared<AIS_ListOfInteractive> >::Iterator
+ anIterator(myDisplayer->GetDisplayed()); anIterator.More(); anIterator.Next())
+ myDisplayer->SetDisplayMode (aDisplayMode, anIterator.Key(), false);
+ myDisplayer->UpdateViewer();
+}
--- /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 View_Window_H
+#define View_Window_H
+
+#include <AIS_InteractiveContext.hxx>
+#include <View_ContextType.hxx>
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4127) // conditional expression is constant
+#endif
+#include <QWidget>
+
+class View_Displayer;
+class View_ToolBar;
+class View_Widget;
+
+class QToolBar;
+
+//! \class View_Window
+//! \brief It is a widget where in grid layout View widget and tool bars are placed. There are two tool bars.
+//! The first, view actions, tool bar is placed on Vertical, the window tool bar is placed Horizontally.
+//! The second tool bar contains actions of View_ToolBar.
+class View_Window : public QWidget
+{
+ Q_OBJECT
+
+public:
+
+ //! Constructor
+ Standard_EXPORT View_Window (QWidget* theParent);
+
+ //! Destructor
+ virtual ~View_Window() {}
+
+ //! Returns view displayer
+ View_Displayer* GetDisplayer() const { return myDisplayer; }
+
+ //! Returns view widget
+ View_Widget* GetView() const { return myView; }
+
+ //! Returns actions tool bar
+ QToolBar* GetActionsToolBar() const { return myActionsToolBar; }
+
+ //! Returns window tool bar
+ View_ToolBar* GetViewToolBar() const { return myViewToolBar; }
+
+ //! Sets a new context for context type
+ //! \param theType a type of context, will be selected in the tool bar combo box
+ //! \param theContext an AIS context
+ Standard_EXPORT void SetContext (View_ContextType theType, const Handle(AIS_InteractiveContext)& theContext);
+
+protected slots:
+
+ //! Processing context change:
+ //! - set an active context in the displayer,
+ //! - erase all displayed presentations from the previous context,
+ //! - sets the current view enabled only if a current context type is View_ContextType_Own
+ void onViewSelectorActivated();
+
+ //! Processing window tool bar actions
+ void onToolBarActionClicked (const int theActionId);
+
+ //! Sets selected display mode in the current context
+ void onDisplayModeChanged();
+
+private:
+
+ View_Displayer* myDisplayer; //!< displayer
+ View_Widget* myView; //!< view widget
+ QToolBar* myActionsToolBar; //!< actions tool bar
+ View_ToolBar* myViewToolBar; //!< window tool bar
+};
+
+#endif
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ id="svg4136"
+ version="1.1"
+ inkscape:version="0.91 r13725"
+ width="16"
+ height="16"
+ viewBox="0 0 16 16"
+ sodipodi:docname="keep_view_off.svg"
+ shape-rendering="crispEdges"
+ inkscape:export-filename="D:\Projects\OInspector\Dev\DFBrowser_1.5\src\DFView\icons\keep_view_off.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <metadata
+ id="metadata4142">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <defs
+ id="defs4140" />
+ <sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="1310"
+ inkscape:window-height="884"
+ id="namedview4138"
+ showgrid="false"
+ inkscape:zoom="24.625"
+ inkscape:cx="0.32877433"
+ inkscape:cy="7.9357725"
+ inkscape:window-x="1874"
+ inkscape:window-y="21"
+ inkscape:window-maximized="0"
+ inkscape:current-layer="svg4136" />
+ <rect
+ style="fill:none;fill-opacity:1;stroke:#133f49;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.98039216"
+ id="rect4178"
+ width="13.238579"
+ height="11.939087"
+ x="1.3807107"
+ y="2.0710659" />
+</svg>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ id="svg4136"
+ version="1.1"
+ inkscape:version="0.91 r13725"
+ width="16"
+ height="16"
+ viewBox="0 0 16 16"
+ sodipodi:docname="keep_view_on.svg"
+ shape-rendering="crispEdges"
+ inkscape:export-filename="D:\Projects\OInspector\Dev\DFBrowser_1.5\src\DFView\icons\keep_view_on.png"
+ inkscape:export-xdpi="99.009903"
+ inkscape:export-ydpi="99.009903">
+ <metadata
+ id="metadata4142">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <defs
+ id="defs4140" />
+ <sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="1310"
+ inkscape:window-height="884"
+ id="namedview4138"
+ showgrid="false"
+ inkscape:zoom="24.625"
+ inkscape:cx="0.32877433"
+ inkscape:cy="7.9357725"
+ inkscape:window-x="1858"
+ inkscape:window-y="40"
+ inkscape:window-maximized="1"
+ inkscape:current-layer="svg4136" />
+ <rect
+ style="fill:none;fill-opacity:1;stroke:#133f49;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.98039216"
+ id="rect4178"
+ width="6.8223352"
+ height="5.7664976"
+ x="1.1370559"
+ y="2.0710659" />
+ <rect
+ style="fill:none;fill-opacity:1;stroke:#133f49;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.98039216"
+ id="rect4188"
+ width="6.7817259"
+ height="6.6598983"
+ x="4.9543152"
+ y="5.3197966" />
+ <rect
+ style="fill:none;fill-opacity:1;stroke:#133f49;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.98039216"
+ id="rect4190"
+ width="6.0913706"
+ height="5.5228424"
+ x="8.8527918"
+ y="9.5837564" />
+</svg>